program ABC132B
    implicit none
    integer::n,i,ans=0
    integer,allocatable::P(:)
    read*,n
    allocate(P(n))
    read*,P
    do i=1,n-2
        if(P(i+1)/=maxval(P(i:i+2)).and.P(i+1)/=minval(P(i:i+2)))ans=ans+1
    end do
    print'(i0)',ans
end program ABC132B
; 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"

@_QFEans = internal unnamed_addr global i32 0
@_QFEp.0 = internal unnamed_addr global ptr null
@_QFEp.8 = internal unnamed_addr global i64 0
@_QQcl.6abca62049b1a971a087f8b5d5d1c7f6 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3861/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_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

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %3 = alloca i32, align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.6abca62049b1a971a087f8b5d5d1c7f6, i32 5)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %7 = load i32, ptr %3, align 4, !tbaa !3
  %8 = call i32 @llvm.smax.i32(i32 %7, i32 0)
  %9 = zext i32 %8 to i64
  %10 = shl nuw nsw i64 %9, 2
  %11 = call ptr @malloc(i64 %10)
  store ptr %11, ptr @_QFEp.0, align 8, !tbaa !7
  store i64 %9, ptr @_QFEp.8, align 8, !tbaa !7
  %12 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.6abca62049b1a971a087f8b5d5d1c7f6, i32 7)
  %.unpack = load ptr, ptr @_QFEp.0, align 8, !tbaa !7
  %.unpack155.unpack.unpack157 = load i64, ptr @_QFEp.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %2, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 1
  store i64 4, 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 %2, 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 %2, 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 %2, i64 0, i32 4
  store i8 9, 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 %2, 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 %2, 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 %2, 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 %2, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack155.unpack.unpack157, 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 %2, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %13 = call i1 @_FortranAioInputDescriptor(ptr %12, ptr nonnull %2)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %12)
  %15 = load i32, ptr %3, align 4, !tbaa !3
  %16 = add i32 %15, -2
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %18 = zext i32 %16 to i64
  %.fca.1.gep123 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  %.fca.2.gep125 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  %.fca.3.gep127 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  %.fca.4.gep129 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  %.fca.5.gep131 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  %.fca.6.gep133 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  %.fca.7.0.0.gep135 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  %.fca.7.0.1.gep137 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  %.fca.7.0.2.gep139 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  br label %19

19:                                               ; preds = %.lr.ph, %52
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %52 ]
  %.unpack160 = load ptr, ptr @_QFEp.0, align 8, !tbaa !7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext = shl i64 %indvars.iv.next, 32
  %20 = ashr exact i64 %sext, 32
  %21 = add nsw i64 %20, -1
  %22 = getelementptr i32, ptr %.unpack160, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !3
  %24 = shl i64 %indvars.iv, 32
  %sext185 = add i64 %24, 8589934592
  %25 = ashr exact i64 %sext185, 32
  %26 = add nsw i64 %indvars.iv, -1
  %27 = sub nsw i64 %25, %indvars.iv
  %28 = call i64 @llvm.smax.i64(i64 %27, i64 -1)
  %29 = add nsw i64 %28, 1
  %30 = getelementptr i32, ptr %.unpack160, i64 %26
  %.not = icmp eq i64 %29, 0
  br i1 %.not, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader

.lr.ph.i.preheader:                               ; preds = %19
  %min.iters.check = icmp ult i64 %29, 8
  br i1 %min.iters.check, label %.lr.ph.i.preheader188, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.i.preheader
  %n.vec = and i64 %29, -8
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %34, %vector.body ]
  %vec.phi186 = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %35, %vector.body ]
  %31 = shl i64 %index, 2
  %32 = getelementptr i8, ptr %30, i64 %31
  %wide.load = load <4 x i32>, ptr %32, align 4, !tbaa !3
  %33 = getelementptr i32, ptr %32, i64 4
  %wide.load187 = load <4 x i32>, ptr %33, align 4, !tbaa !3
  %34 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load, <4 x i32> %vec.phi)
  %35 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load187, <4 x i32> %vec.phi186)
  %index.next = add nuw i64 %index, 8
  %36 = icmp eq i64 %index.next, %n.vec
  br i1 %36, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %rdx.minmax.select = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %34, <4 x i32> %35)
  %37 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax.select)
  %cmp.n = icmp eq i64 %29, %n.vec
  br i1 %cmp.n, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader188

.lr.ph.i.preheader188:                            ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph = phi i32 [ -2147483648, %.lr.ph.i.preheader ], [ %37, %middle.block ]
  %.ph189 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader188, %.lr.ph.i
  %38 = phi i32 [ %43, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader188 ]
  %39 = phi i64 [ %44, %.lr.ph.i ], [ %.ph189, %.lr.ph.i.preheader188 ]
  %40 = shl i64 %39, 2
  %41 = getelementptr i8, ptr %30, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !3
  %43 = call i32 @llvm.smax.i32(i32 %42, i32 %38)
  %44 = add nuw nsw i64 %39, 1
  %exitcond.not.i = icmp eq i64 %39, %28
  br i1 %exitcond.not.i, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !12

_FortranAMaxvalInteger4x1_contract_simplified.exit: ; preds = %.lr.ph.i, %middle.block, %19
  %.lcssa.i = phi i32 [ -2147483648, %19 ], [ %37, %middle.block ], [ %43, %.lr.ph.i ]
  %45 = icmp ne i32 %23, %.lcssa.i
  store ptr %30, ptr %1, align 8, !tbaa !7
  store i64 4, ptr %.fca.1.gep123, align 8, !tbaa !7
  store i32 20180515, ptr %.fca.2.gep125, align 8, !tbaa !7
  store i8 1, ptr %.fca.3.gep127, align 4, !tbaa !7
  store i8 9, ptr %.fca.4.gep129, align 1, !tbaa !7
  store i8 0, ptr %.fca.5.gep131, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep133, align 1, !tbaa !7
  store i64 1, ptr %.fca.7.0.0.gep135, align 8, !tbaa !7
  store i64 %29, ptr %.fca.7.0.1.gep137, align 8, !tbaa !7
  store i64 4, ptr %.fca.7.0.2.gep139, align 8, !tbaa !7
  %46 = call i32 @_FortranAMinvalInteger4(ptr nonnull %1, ptr nonnull @_QQcl.6abca62049b1a971a087f8b5d5d1c7f6, i32 8, i32 0, ptr null)
  %47 = icmp ne i32 %23, %46
  %48 = and i1 %45, %47
  br i1 %48, label %49, label %52

49:                                               ; preds = %_FortranAMaxvalInteger4x1_contract_simplified.exit
  %50 = load i32, ptr @_QFEans, align 4, !tbaa !3
  %51 = add i32 %50, 1
  store i32 %51, ptr @_QFEans, align 4, !tbaa !3
  br label %52

52:                                               ; preds = %49, %_FortranAMaxvalInteger4x1_contract_simplified.exit
  %exitcond.not = icmp eq i64 %indvars.iv, %18
  br i1 %exitcond.not, label %._crit_edge, label %19

._crit_edge:                                      ; preds = %52, %0
  %53 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.6abca62049b1a971a087f8b5d5d1c7f6, i32 11)
  %54 = load i32, ptr @_QFEans, align 4, !tbaa !3
  %55 = call i1 @_FortranAioOutputInteger32(ptr %53, i32 %54)
  %56 = call i32 @_FortranAioEndIoStatement(ptr %53)
  ret void
}

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 i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

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

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32>) #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(none) }

!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}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !11, !10}
