program candy
  implicit none
  integer::n, i, c, cmax
  integer,allocatable::a(:,:)

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

  read(*,*) (a(i,1), i = 1, n)
  read(*,*) (a(i,2), i = 1, n)

  cmax = 0
  
  do i = 1, n
     c = sum(a(1:i,1:1))+sum(a(i:n,2:2))
     if ( c > cmax) then
        cmax = c
     end if
  end do
  
  write(*,*) cmax
  
  stop
end program candy

; 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
@_QQcl.2c473ef4f298b80080b8aa4eeab59147 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6339/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 i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.2c473ef4f298b80080b8aa4eeab59147, i32 6)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i32, ptr %1, align 4, !tbaa !3
  %6 = call i32 @llvm.smax.i32(i32 %5, i32 0)
  %7 = zext i32 %6 to i64
  %8 = shl nuw nsw i64 %7, 3
  %9 = call ptr @malloc(i64 %8)
  store ptr %9, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %7, ptr @_QFEa.8, align 8, !tbaa !7
  %10 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.2c473ef4f298b80080b8aa4eeab59147, i32 9)
  %11 = load i32, ptr %1, align 4, !tbaa !3
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %13 = zext i32 %11 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %14 = phi i64 [ %19, %.lr.ph ], [ 1, %.lr.ph.preheader ]
  %.unpack264 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %sext280 = shl i64 %14, 32
  %15 = ashr exact i64 %sext280, 32
  %16 = add nsw i64 %15, -1
  %17 = getelementptr i32, ptr %.unpack264, i64 %16
  %18 = call i1 @_FortranAioInputInteger(ptr %10, ptr %17, i32 4)
  %19 = add nuw nsw i64 %14, 1
  %exitcond.not = icmp eq i64 %14, %13
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %20 = call i32 @_FortranAioEndIoStatement(ptr %10)
  %21 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.2c473ef4f298b80080b8aa4eeab59147, i32 10)
  %22 = load i32, ptr %1, align 4, !tbaa !3
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph305.preheader, label %._crit_edge306

.lr.ph305.preheader:                              ; preds = %._crit_edge
  %24 = zext i32 %22 to i64
  br label %.lr.ph305

.lr.ph305:                                        ; preds = %.lr.ph305.preheader, %.lr.ph305
  %25 = phi i64 [ %31, %.lr.ph305 ], [ 1, %.lr.ph305.preheader ]
  %.unpack248 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack255.unpack.unpack258 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  %sext = shl i64 %25, 32
  %26 = ashr exact i64 %sext, 32
  %27 = add nsw i64 %26, -1
  %28 = add i64 %27, %.unpack255.unpack.unpack258
  %29 = getelementptr i32, ptr %.unpack248, i64 %28
  %30 = call i1 @_FortranAioInputInteger(ptr %21, ptr %29, i32 4)
  %31 = add nuw nsw i64 %25, 1
  %exitcond312.not = icmp eq i64 %25, %24
  br i1 %exitcond312.not, label %._crit_edge306, label %.lr.ph305

._crit_edge306:                                   ; preds = %.lr.ph305, %._crit_edge
  %32 = call i32 @_FortranAioEndIoStatement(ptr %21)
  %33 = load i32, ptr %1, align 4, !tbaa !3
  %34 = sext i32 %33 to i64
  %35 = icmp sgt i32 %33, 0
  br i1 %35, label %.lr.ph309, label %._crit_edge310

.lr.ph309:                                        ; preds = %._crit_edge306
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack223.unpack.unpack226 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  br label %.preheader.us.i.preheader

.preheader.us.i.preheader:                        ; preds = %_FortranASumInteger4x2_contract_simplified.exit288, %.lr.ph309
  %indvar = phi i64 [ %indvar.next, %_FortranASumInteger4x2_contract_simplified.exit288 ], [ 0, %.lr.ph309 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %_FortranASumInteger4x2_contract_simplified.exit288 ], [ 1, %.lr.ph309 ]
  %.0307 = phi i32 [ %spec.select, %_FortranASumInteger4x2_contract_simplified.exit288 ], [ 0, %.lr.ph309 ]
  %36 = xor i64 %indvar, -1
  %37 = add i64 %36, %34
  %smax = call i64 @llvm.smax.i64(i64 %37, i64 -1)
  %38 = add nsw i64 %smax, 1
  %min.iters.check321 = icmp ult i64 %indvars.iv, 8
  br i1 %min.iters.check321, label %scalar.ph320.preheader, label %vector.ph322

vector.ph322:                                     ; preds = %.preheader.us.i.preheader
  %n.vec324 = and i64 %indvars.iv, 9223372036854775800
  br label %vector.body327

vector.body327:                                   ; preds = %vector.body327, %vector.ph322
  %index328 = phi i64 [ 0, %vector.ph322 ], [ %index.next333, %vector.body327 ]
  %vec.phi329 = phi <4 x i32> [ zeroinitializer, %vector.ph322 ], [ %42, %vector.body327 ]
  %vec.phi330 = phi <4 x i32> [ zeroinitializer, %vector.ph322 ], [ %43, %vector.body327 ]
  %39 = shl i64 %index328, 2
  %40 = getelementptr i8, ptr %.unpack, i64 %39
  %wide.load331 = load <4 x i32>, ptr %40, align 4, !tbaa !3
  %41 = getelementptr i32, ptr %40, i64 4
  %wide.load332 = load <4 x i32>, ptr %41, align 4, !tbaa !3
  %42 = add <4 x i32> %wide.load331, %vec.phi329
  %43 = add <4 x i32> %wide.load332, %vec.phi330
  %index.next333 = add nuw i64 %index328, 8
  %44 = icmp eq i64 %index.next333, %n.vec324
  br i1 %44, label %middle.block319, label %vector.body327, !llvm.loop !9

middle.block319:                                  ; preds = %vector.body327
  %bin.rdx334 = add <4 x i32> %43, %42
  %45 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx334)
  %cmp.n326 = icmp eq i64 %indvars.iv, %n.vec324
  br i1 %cmp.n326, label %.preheader.us.i283.preheader, label %scalar.ph320.preheader

scalar.ph320.preheader:                           ; preds = %.preheader.us.i.preheader, %middle.block319
  %.ph337 = phi i32 [ 0, %.preheader.us.i.preheader ], [ %45, %middle.block319 ]
  %.ph338 = phi i64 [ 0, %.preheader.us.i.preheader ], [ %n.vec324, %middle.block319 ]
  br label %scalar.ph320

scalar.ph320:                                     ; preds = %scalar.ph320.preheader, %scalar.ph320
  %46 = phi i32 [ %51, %scalar.ph320 ], [ %.ph337, %scalar.ph320.preheader ]
  %47 = phi i64 [ %52, %scalar.ph320 ], [ %.ph338, %scalar.ph320.preheader ]
  %48 = shl i64 %47, 2
  %49 = getelementptr i8, ptr %.unpack, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !3
  %51 = add i32 %50, %46
  %52 = add nuw nsw i64 %47, 1
  %exitcond.not.i = icmp eq i64 %52, %indvars.iv
  br i1 %exitcond.not.i, label %.preheader.us.i283.preheader, label %scalar.ph320, !llvm.loop !12

.preheader.us.i283.preheader:                     ; preds = %scalar.ph320, %middle.block319
  %.lcssa = phi i32 [ %45, %middle.block319 ], [ %51, %scalar.ph320 ]
  %53 = add nsw i64 %indvars.iv, -1
  %54 = sub nsw i64 %34, %indvars.iv
  %55 = call i64 @llvm.smax.i64(i64 %54, i64 -1)
  %56 = add i64 %53, %.unpack223.unpack.unpack226
  %57 = getelementptr i32, ptr %.unpack, i64 %56
  %min.iters.check = icmp ult i64 %38, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.preheader.us.i283.preheader
  %n.vec = and i64 %38, -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> [ zeroinitializer, %vector.ph ], [ %61, %vector.body ]
  %vec.phi317 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %62, %vector.body ]
  %58 = shl i64 %index, 2
  %59 = getelementptr i8, ptr %57, i64 %58
  %wide.load = load <4 x i32>, ptr %59, align 4, !tbaa !3
  %60 = getelementptr i32, ptr %59, i64 4
  %wide.load318 = load <4 x i32>, ptr %60, align 4, !tbaa !3
  %61 = add <4 x i32> %wide.load, %vec.phi
  %62 = add <4 x i32> %wide.load318, %vec.phi317
  %index.next = add nuw i64 %index, 8
  %63 = icmp eq i64 %index.next, %n.vec
  br i1 %63, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %62, %61
  %64 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %38, %n.vec
  br i1 %cmp.n, label %_FortranASumInteger4x2_contract_simplified.exit288, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.preheader.us.i283.preheader, %middle.block
  %.ph = phi i32 [ 0, %.preheader.us.i283.preheader ], [ %64, %middle.block ]
  %.ph336 = phi i64 [ 0, %.preheader.us.i283.preheader ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %65 = phi i32 [ %70, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %66 = phi i64 [ %71, %scalar.ph ], [ %.ph336, %scalar.ph.preheader ]
  %67 = shl i64 %66, 2
  %68 = getelementptr i8, ptr %57, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !3
  %70 = add i32 %69, %65
  %71 = add nuw nsw i64 %66, 1
  %exitcond.not.i284 = icmp eq i64 %66, %55
  br i1 %exitcond.not.i284, label %_FortranASumInteger4x2_contract_simplified.exit288, label %scalar.ph, !llvm.loop !14

_FortranASumInteger4x2_contract_simplified.exit288: ; preds = %scalar.ph, %middle.block
  %.lcssa316 = phi i32 [ %64, %middle.block ], [ %70, %scalar.ph ]
  %72 = add i32 %.lcssa316, %.lcssa
  %spec.select = call i32 @llvm.smax.i32(i32 %72, i32 %.0307)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond314.not = icmp eq i64 %indvars.iv, %34
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond314.not, label %._crit_edge310, label %.preheader.us.i.preheader

._crit_edge310:                                   ; preds = %_FortranASumInteger4x2_contract_simplified.exit288, %._crit_edge306
  %.0.lcssa = phi i32 [ 0, %._crit_edge306 ], [ %spec.select, %_FortranASumInteger4x2_contract_simplified.exit288 ]
  %73 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.2c473ef4f298b80080b8aa4eeab59147, i32 21)
  %74 = call i1 @_FortranAioOutputInteger32(ptr %73, i32 %.0.lcssa)
  %75 = call i32 @_FortranAioEndIoStatement(ptr %73)
  %76 = 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

; 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 i32 @llvm.smax.i32(i32, i32) #2

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { noreturn }
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}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !11, !10}
