program sample
    implicit none
  
    integer(8) :: i,j,m,n,a0,a1,b,c,d
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    if(n<3)then
        write(*,*)1
        stop
    end if
    allocate(x(n))
    read(*,*)x
    if (x(1)<x(2))then
        a0=1
    elseif (x(1)==x(2))then
        a0=0
    else
        a0=-1
    end if
    m=1
    b=0
    do i=2,n-1
        
        if (x(i)<x(i+1))then
            a1=1
        elseif (x(i)==x(i+1))then
           
            cycle
        else
            a1=-1
        end if
        if(b==0)then
            if(a0*a1<0)then
                m=m+1
                b=1
            end if
        else
            b=0
        end if
        a0=a1
        
        
    enddo
    write(*,*) m
  
    stop
end program sample
  


; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEx.0 = internal unnamed_addr global ptr null
@_QFEx.8 = internal unnamed_addr global i64 0
@_QQcl.1283c1a1b21469c1ccd8c9cf1f7be5b3 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7373/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #1 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i64, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.1283c1a1b21469c1ccd8c9cf1f7be5b3, i32 7)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 8)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i64, ptr %2, align 8, !tbaa !3
  %7 = icmp slt i64 %6, 3
  br i1 %7, label %8, label %13

8:                                                ; preds = %0
  %9 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.1283c1a1b21469c1ccd8c9cf1f7be5b3, i32 9)
  %10 = call i1 @_FortranAioOutputInteger32(ptr %9, i32 1)
  %11 = call i32 @_FortranAioEndIoStatement(ptr %9)
  %12 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

13:                                               ; preds = %0
  %14 = shl i64 %6, 3
  %15 = call ptr @malloc(i64 %14)
  store ptr %15, ptr @_QFEx.0, align 8, !tbaa !7
  store i64 %6, ptr @_QFEx.8, align 8, !tbaa !7
  %16 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.1283c1a1b21469c1ccd8c9cf1f7be5b3, i32 13)
  %.unpack = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack197.unpack.unpack199 = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 8, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 10, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack197.unpack.unpack199, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 8, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %17 = call i1 @_FortranAioInputDescriptor(ptr %16, ptr nonnull %1)
  %18 = call i32 @_FortranAioEndIoStatement(ptr %16)
  %.unpack202 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %19 = load i64, ptr %2, align 8, !tbaa !3
  %20 = add i64 %19, -2
  %21 = icmp sgt i64 %20, 0
  br i1 %21, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %13
  %22 = load i64, ptr %.unpack202, align 8, !tbaa !3
  %23 = getelementptr i64, ptr %.unpack202, i64 1
  %24 = load i64, ptr %23, align 8, !tbaa !3
  %25 = icmp slt i64 %22, %24
  %26 = icmp ne i64 %22, %24
  %. = sext i1 %26 to i64
  %.0173 = select i1 %25, i64 1, i64 %.
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %40
  %.0232 = phi i64 [ %.2, %40 ], [ 1, %.lr.ph.preheader ]
  %.0168231 = phi i64 [ %30, %40 ], [ 2, %.lr.ph.preheader ]
  %.0169230 = phi i64 [ %.2171, %40 ], [ 0, %.lr.ph.preheader ]
  %.1174229 = phi i64 [ %.2175, %40 ], [ %.0173, %.lr.ph.preheader ]
  %27 = add i64 %.0168231, -1
  %28 = getelementptr i64, ptr %.unpack202, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !3
  %30 = add nuw i64 %.0168231, 1
  %31 = getelementptr i64, ptr %.unpack202, i64 %.0168231
  %32 = load i64, ptr %31, align 8, !tbaa !3
  %33 = icmp slt i64 %29, %32
  br i1 %33, label %36, label %34

34:                                               ; preds = %.lr.ph
  %35 = icmp eq i64 %29, %32
  br i1 %35, label %40, label %36

36:                                               ; preds = %34, %.lr.ph
  %.0172 = phi i64 [ 1, %.lr.ph ], [ -1, %34 ]
  %37 = icmp eq i64 %.0169230, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %36
  %39 = mul i64 %.0172, %.1174229
  %.lobit = lshr i64 %39, 63
  %spec.select226 = add i64 %.lobit, %.0232
  br label %40

40:                                               ; preds = %38, %36, %34
  %.2175 = phi i64 [ %.1174229, %34 ], [ %.0172, %36 ], [ %.0172, %38 ]
  %.2171 = phi i64 [ %.0169230, %34 ], [ 0, %36 ], [ %.lobit, %38 ]
  %.2 = phi i64 [ %.0232, %34 ], [ %.0232, %36 ], [ %spec.select226, %38 ]
  %exitcond.not = icmp eq i64 %30, %19
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %40, %13
  %.0.lcssa = phi i64 [ 1, %13 ], [ %.2, %40 ]
  %41 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.1283c1a1b21469c1ccd8c9cf1f7be5b3, i32 45)
  %42 = call i1 @_FortranAioOutputInteger64(ptr %41, i64 %.0.lcssa)
  %43 = call i32 @_FortranAioEndIoStatement(ptr %41)
  %44 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { noreturn }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
