program prob4
    implicit none
    integer :: n, i, m, tmp
    integer, allocatable :: a(:), aa(:)
    read(*,*) n
    allocate(a(n))
    allocate(aa(n))
    read(*,*) a
    read(*,*) aa

    tmp = a(1)
    do i = 1, n
        tmp = tmp + aa(i)
    end do
    m = tmp

    do i = 2, n
        tmp = tmp + a(i)
        tmp = tmp - aa(i-1)
        m = max(m, tmp)
    end do

    write(*,*) m
    deallocate(a)
    deallocate(aa)

    stop
contains
end program prob4
; 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
@_QFEaa.0 = internal unnamed_addr global ptr null
@_QFEaa.8 = internal unnamed_addr global i64 0
@_QQcl.f40c9341e3f98afe6e4b4606bdeef8c7 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6345/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: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #2 {
  %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.f40c9341e3f98afe6e4b4606bdeef8c7, 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 @_QFEa.0, align 8, !tbaa !7
  store i64 %9, ptr @_QFEa.8, align 8, !tbaa !7
  %12 = call ptr @malloc(i64 %10)
  store ptr %12, ptr @_QFEaa.0, align 8, !tbaa !7
  store i64 %9, ptr @_QFEaa.8, align 8, !tbaa !7
  %13 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.f40c9341e3f98afe6e4b4606bdeef8c7, i32 8)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack420.unpack.unpack422 = load i64, ptr @_QFEa.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 %.unpack420.unpack.unpack422, 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
  %14 = call i1 @_FortranAioInputDescriptor(ptr %13, ptr nonnull %2)
  %15 = call i32 @_FortranAioEndIoStatement(ptr %13)
  %16 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.f40c9341e3f98afe6e4b4606bdeef8c7, i32 9)
  %.unpack425 = load ptr, ptr @_QFEaa.0, align 8, !tbaa !7
  %.unpack432.unpack.unpack434 = load i64, ptr @_QFEaa.8, align 8, !tbaa !7
  store ptr %.unpack425, ptr %1, align 8, !tbaa !7
  %.fca.1.gep122 = 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.gep122, align 8, !tbaa !7
  %.fca.2.gep124 = 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.gep124, align 8, !tbaa !7
  %.fca.3.gep126 = 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.gep126, align 4, !tbaa !7
  %.fca.4.gep128 = 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.gep128, align 1, !tbaa !7
  %.fca.5.gep130 = 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.gep130, align 2, !tbaa !7
  %.fca.6.gep132 = 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.gep132, align 1, !tbaa !7
  %.fca.7.0.0.gep134 = 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.gep134, align 8, !tbaa !7
  %.fca.7.0.1.gep136 = 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 %.unpack432.unpack.unpack434, ptr %.fca.7.0.1.gep136, align 8, !tbaa !7
  %.fca.7.0.2.gep138 = 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.gep138, align 8, !tbaa !7
  %17 = call i1 @_FortranAioInputDescriptor(ptr %16, ptr nonnull %1)
  %18 = call i32 @_FortranAioEndIoStatement(ptr %16)
  %.unpack437 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %19 = load i32, ptr %.unpack437, align 4, !tbaa !3
  %20 = load i32, ptr %3, align 4, !tbaa !3
  %21 = sext i32 %20 to i64
  %22 = icmp sgt i32 %20, 0
  br i1 %22, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %.unpack497 = load ptr, ptr @_QFEaa.0, align 8, !tbaa !7
  %min.iters.check = icmp ult i32 %20, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %21, -8
  %ind.end = or i64 %n.vec, 1
  %23 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %19, i64 0
  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> [ %23, %vector.ph ], [ %26, %vector.body ]
  %vec.phi523 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %27, %vector.body ]
  %24 = getelementptr i32, ptr %.unpack497, i64 %index
  %wide.load = load <4 x i32>, ptr %24, align 4, !tbaa !3
  %25 = getelementptr i32, ptr %24, i64 4
  %wide.load524 = load <4 x i32>, ptr %25, align 4, !tbaa !3
  %26 = add <4 x i32> %wide.load, %vec.phi
  %27 = add <4 x i32> %wide.load524, %vec.phi523
  %index.next = add nuw i64 %index, 8
  %28 = icmp eq i64 %index.next, %n.vec
  br i1 %28, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %27, %26
  %29 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %21
  br i1 %cmp.n, label %.preheader, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.lr.ph, %middle.block
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  %.0509.ph = phi i32 [ %19, %.lr.ph ], [ %29, %middle.block ]
  br label %scalar.ph

.preheader:                                       ; preds = %scalar.ph, %middle.block
  %.lcssa522 = phi i32 [ %29, %middle.block ], [ %36, %scalar.ph ]
  %30 = icmp sgt i32 %20, 1
  br i1 %30, label %.lr.ph512, label %._crit_edge

.lr.ph512:                                        ; preds = %.preheader
  %.unpack485 = load ptr, ptr @_QFEaa.0, align 8, !tbaa !7
  %31 = add nsw i64 %21, -1
  %xtraiter = and i64 %31, 1
  %32 = icmp eq i32 %20, 2
  br i1 %32, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph512.new

.lr.ph512.new:                                    ; preds = %.lr.ph512
  %unroll_iter = and i64 %31, -2
  br label %37

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %.0509 = phi i32 [ %36, %scalar.ph ], [ %.0509.ph, %scalar.ph.preheader ]
  %33 = add i64 %indvars.iv, -1
  %34 = getelementptr i32, ptr %.unpack497, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !3
  %36 = add i32 %35, %.0509
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %21
  br i1 %exitcond.not, label %.preheader, label %scalar.ph, !llvm.loop !12

37:                                               ; preds = %37, %.lr.ph512.new
  %indvars.iv516 = phi i64 [ 2, %.lr.ph512.new ], [ %indvars.iv.next517.1, %37 ]
  %.1511 = phi i32 [ %.lcssa522, %.lr.ph512.new ], [ %53, %37 ]
  %.0393510 = phi i32 [ %.lcssa522, %.lr.ph512.new ], [ %54, %37 ]
  %niter = phi i64 [ 0, %.lr.ph512.new ], [ %niter.next.1, %37 ]
  %38 = add nsw i64 %indvars.iv516, -1
  %39 = getelementptr i32, ptr %.unpack437, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !3
  %41 = add i32 %40, %.1511
  %42 = add nsw i64 %indvars.iv516, -2
  %43 = getelementptr i32, ptr %.unpack485, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !3
  %45 = sub i32 %41, %44
  %46 = call i32 @llvm.smax.i32(i32 %.0393510, i32 %45)
  %47 = getelementptr i32, ptr %.unpack437, i64 %indvars.iv516
  %48 = load i32, ptr %47, align 4, !tbaa !3
  %49 = add i32 %48, %45
  %50 = add nsw i64 %indvars.iv516, -1
  %51 = getelementptr i32, ptr %.unpack485, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !3
  %53 = sub i32 %49, %52
  %54 = call i32 @llvm.smax.i32(i32 %46, i32 %53)
  %indvars.iv.next517.1 = add nuw nsw i64 %indvars.iv516, 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 %._crit_edge.loopexit.unr-lcssa, label %37

._crit_edge.loopexit.unr-lcssa:                   ; preds = %37, %.lr.ph512
  %.lcssa.ph = phi i32 [ undef, %.lr.ph512 ], [ %54, %37 ]
  %indvars.iv516.unr = phi i64 [ 2, %.lr.ph512 ], [ %indvars.iv.next517.1, %37 ]
  %.1511.unr = phi i32 [ %.lcssa522, %.lr.ph512 ], [ %53, %37 ]
  %.0393510.unr = phi i32 [ %.lcssa522, %.lr.ph512 ], [ %54, %37 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %55 = add nsw i64 %indvars.iv516.unr, -1
  %56 = getelementptr i32, ptr %.unpack437, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !3
  %58 = add i32 %57, %.1511.unr
  %59 = add nsw i64 %indvars.iv516.unr, -2
  %60 = getelementptr i32, ptr %.unpack485, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !3
  %62 = sub i32 %58, %61
  %63 = call i32 @llvm.smax.i32(i32 %.0393510.unr, i32 %62)
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %0, %.preheader
  %.0393.lcssa = phi i32 [ %.lcssa522, %.preheader ], [ %19, %0 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %63, %._crit_edge.loopexit.epilog-lcssa ]
  %64 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.f40c9341e3f98afe6e4b4606bdeef8c7, i32 23)
  %65 = call i1 @_FortranAioOutputInteger32(ptr %64, i32 %.0393.lcssa)
  %66 = call i32 @_FortranAioEndIoStatement(ptr %64)
  %.unpack449 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  call void @free(ptr %.unpack449)
  store ptr null, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 0, ptr @_QFEa.8, align 8, !tbaa !7
  %.unpack461 = load ptr, ptr @_QFEaa.0, align 8, !tbaa !7
  call void @free(ptr %.unpack461)
  store ptr null, ptr @_QFEaa.0, align 8, !tbaa !7
  store i64 0, ptr @_QFEaa.8, align 8, !tbaa !7
  %67 = 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 i1 @_FortranAioInputDescriptor(ptr, 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

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

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #2 = { noreturn }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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}
