program name
    implicit none
    integer(4):: n,cnt(0:100000)
    integer(4),allocatable:: a(:)
    integer(4):: i, mcnt

    read*, n
    allocate(a(n))
    read*, a(:)

    cnt(:) = 0

    do i=1,n
        cnt(a(i)) = cnt(a(i)) + 1
    end do
    mcnt=0
    do i=1,99999
        mcnt=max(mcnt,sum(cnt(i-1:i+1)))
    end do

    print*, mcnt
end program name
; 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"

@_QFEa.0 = internal unnamed_addr global ptr null
@_QFEa.8 = internal unnamed_addr global i64 0
@_QFEcnt = internal unnamed_addr global [100001 x i32] undef
@_QQcl.8cc763be45ec4b3a42a5556ff75d0c26 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6956/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

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.8cc763be45ec4b3a42a5556ff75d0c26, i32 7)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i32, ptr %2, align 4, !tbaa !3
  %7 = call i32 @llvm.smax.i32(i32 %6, i32 0)
  %8 = zext i32 %7 to i64
  %9 = shl nuw nsw i64 %8, 2
  %10 = call ptr @malloc(i64 %9)
  store ptr %10, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %8, ptr @_QFEa.8, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.8cc763be45ec4b3a42a5556ff75d0c26, i32 9)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack111.unpack.unpack113 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  %12 = call i64 @llvm.smax.i64(i64 %.unpack111.unpack.unpack113, i64 0)
  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 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 %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 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 %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 %12, 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 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %13 = call i1 @_FortranAioInputDescriptor(ptr %11, ptr nonnull %1)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %11)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400004) @_QFEcnt, i8 0, i64 400004, i1 false), !tbaa !3
  %15 = load i32, ptr %2, align 4, !tbaa !3
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %vector.body.preheader

.lr.ph:                                           ; preds = %0
  %17 = zext i32 %15 to i64
  %.unpack116 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %xtraiter = and i64 %17, 1
  %18 = icmp eq i32 %15, 1
  br i1 %18, label %vector.body.preheader.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %17, 4294967294
  br label %32

vector.body:                                      ; preds = %vector.body.preheader, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.body.preheader ]
  %vec.phi = phi <4 x i32> [ %29, %vector.body ], [ zeroinitializer, %vector.body.preheader ]
  %vec.phi135 = phi <4 x i32> [ %30, %vector.body ], [ zeroinitializer, %vector.body.preheader ]
  %19 = getelementptr [100001 x i32], ptr @_QFEcnt, i64 0, i64 %index
  %20 = getelementptr i8, ptr %19, i64 8
  %wide.load = load <4 x i32>, ptr %20, align 8, !tbaa !3
  %21 = getelementptr i8, ptr %19, i64 24
  %wide.load136 = load <4 x i32>, ptr %21, align 8, !tbaa !3
  %22 = getelementptr i8, ptr %19, i64 4
  %wide.load137 = load <4 x i32>, ptr %22, align 4, !tbaa !3
  %23 = getelementptr i8, ptr %19, i64 20
  %wide.load138 = load <4 x i32>, ptr %23, align 4, !tbaa !3
  %wide.load139 = load <4 x i32>, ptr %19, align 16, !tbaa !3
  %24 = getelementptr i32, ptr %19, i64 4
  %wide.load140 = load <4 x i32>, ptr %24, align 16, !tbaa !3
  %25 = add <4 x i32> %wide.load137, %wide.load139
  %26 = add <4 x i32> %wide.load138, %wide.load140
  %27 = add <4 x i32> %wide.load, %25
  %28 = add <4 x i32> %wide.load136, %26
  %29 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %vec.phi, <4 x i32> %27)
  %30 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %vec.phi135, <4 x i32> %28)
  %index.next = add nuw i64 %index, 8
  %31 = icmp eq i64 %index.next, 99992
  br i1 %31, label %_FortranASumInteger4x1_contract_simplified.exit, label %vector.body, !llvm.loop !9

32:                                               ; preds = %32, %.lr.ph.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.new ], [ %indvars.iv.next.1, %32 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %32 ]
  %33 = add nsw i64 %indvars.iv, -1
  %34 = getelementptr i32, ptr %.unpack116, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !3
  %36 = sext i32 %35 to i64
  %37 = getelementptr [100001 x i32], ptr @_QFEcnt, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !3
  %39 = add i32 %38, 1
  store i32 %39, ptr %37, align 4, !tbaa !3
  %40 = getelementptr i32, ptr %.unpack116, i64 %indvars.iv
  %41 = load i32, ptr %40, align 4, !tbaa !3
  %42 = sext i32 %41 to i64
  %43 = getelementptr [100001 x i32], ptr @_QFEcnt, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !3
  %45 = add i32 %44, 1
  store i32 %45, ptr %43, align 4, !tbaa !3
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %vector.body.preheader.loopexit.unr-lcssa.loopexit, label %32

vector.body.preheader.loopexit.unr-lcssa.loopexit: ; preds = %32
  %46 = add nuw nsw i64 %indvars.iv, 1
  br label %vector.body.preheader.loopexit.unr-lcssa

vector.body.preheader.loopexit.unr-lcssa:         ; preds = %vector.body.preheader.loopexit.unr-lcssa.loopexit, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %46, %vector.body.preheader.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %vector.body.preheader, label %vector.body.preheader.loopexit.epilog-lcssa

vector.body.preheader.loopexit.epilog-lcssa:      ; preds = %vector.body.preheader.loopexit.unr-lcssa
  %47 = getelementptr i32, ptr %.unpack116, i64 %indvars.iv.unr
  %48 = load i32, ptr %47, align 4, !tbaa !3
  %49 = sext i32 %48 to i64
  %50 = getelementptr [100001 x i32], ptr @_QFEcnt, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !3
  %52 = add i32 %51, 1
  store i32 %52, ptr %50, align 4, !tbaa !3
  br label %vector.body.preheader

vector.body.preheader:                            ; preds = %vector.body.preheader.loopexit.epilog-lcssa, %vector.body.preheader.loopexit.unr-lcssa, %0
  br label %vector.body

_FortranASumInteger4x1_contract_simplified.exit:  ; preds = %vector.body
  %rdx.minmax.select = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %29, <4 x i32> %30)
  %53 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax.select)
  %54 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99994), align 8, !tbaa !3
  %55 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99993), align 4, !tbaa !3
  %56 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99992), align 16, !tbaa !3
  %57 = add i32 %55, %56
  %58 = add i32 %54, %57
  %59 = call i32 @llvm.smax.i32(i32 %53, i32 %58)
  %60 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99995), align 4, !tbaa !3
  %61 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99994), align 8, !tbaa !3
  %62 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99993), align 4, !tbaa !3
  %63 = add i32 %61, %62
  %64 = add i32 %60, %63
  %65 = call i32 @llvm.smax.i32(i32 %59, i32 %64)
  %66 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99996), align 16, !tbaa !3
  %67 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99995), align 4, !tbaa !3
  %68 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99994), align 8, !tbaa !3
  %69 = add i32 %67, %68
  %70 = add i32 %66, %69
  %71 = call i32 @llvm.smax.i32(i32 %65, i32 %70)
  %72 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99997), align 4, !tbaa !3
  %73 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99996), align 16, !tbaa !3
  %74 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99995), align 4, !tbaa !3
  %75 = add i32 %73, %74
  %76 = add i32 %72, %75
  %77 = call i32 @llvm.smax.i32(i32 %71, i32 %76)
  %78 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99998), align 8, !tbaa !3
  %79 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99997), align 4, !tbaa !3
  %80 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99996), align 16, !tbaa !3
  %81 = add i32 %79, %80
  %82 = add i32 %78, %81
  %83 = call i32 @llvm.smax.i32(i32 %77, i32 %82)
  %84 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99999), align 4, !tbaa !3
  %85 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99998), align 8, !tbaa !3
  %86 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99997), align 4, !tbaa !3
  %87 = add i32 %85, %86
  %88 = add i32 %84, %87
  %89 = call i32 @llvm.smax.i32(i32 %83, i32 %88)
  %90 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 100000), align 16, !tbaa !3
  %91 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99999), align 4, !tbaa !3
  %92 = load i32, ptr getelementptr inbounds ([100001 x i32], ptr @_QFEcnt, i64 0, i64 99998), align 8, !tbaa !3
  %93 = add i32 %91, %92
  %94 = add i32 %90, %93
  %95 = call i32 @llvm.smax.i32(i32 %89, i32 %94)
  %96 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.8cc763be45ec4b3a42a5556ff75d0c26, i32 21)
  %97 = call i1 @_FortranAioOutputInteger32(ptr %96, i32 %95)
  %98 = call i32 @_FortranAioEndIoStatement(ptr %96)
  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 ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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"}
