program ABC103C
    implicit none
    integer(8)::i,N
    integer(8)::result=0
    integer(8),allocatable,dimension(:)::A
    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    do i=1,N
        result=result+A(i)-1
    end do

    print'(i0)',result
    
end program ABC103C
; 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
@_QFEresult = internal unnamed_addr global i64 0
@_QQcl.24d02bbbfdedc001e7009288ebb7e768 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5747/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 i64, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.24d02bbbfdedc001e7009288ebb7e768, i32 6)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 8)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i64, ptr %1, align 8, !tbaa !3
  %6 = call i64 @llvm.smax.i64(i64 %5, i64 0)
  %7 = shl i64 %6, 3
  %8 = call ptr @malloc(i64 %7)
  store ptr %8, ptr @_QFEa.0, align 8, !tbaa !7
  %9 = call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.24d02bbbfdedc001e7009288ebb7e768, i32 8)
  %10 = load i64, ptr %1, align 8, !tbaa !3
  %11 = icmp sgt i64 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %12 = phi i64 [ %16, %.lr.ph ], [ 1, %0 ]
  %.unpack71 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %13 = add i64 %12, -1
  %14 = getelementptr i64, ptr %.unpack71, i64 %13
  %15 = call i1 @_FortranAioInputInteger(ptr %9, ptr %14, i32 8)
  %16 = add nuw i64 %12, 1
  %exitcond.not = icmp eq i64 %12, %10
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %17 = call i32 @_FortranAioEndIoStatement(ptr %9)
  %18 = load i64, ptr %1, align 8, !tbaa !3
  %19 = icmp sgt i64 %18, 0
  br i1 %19, label %.lr.ph84, label %37

.lr.ph84:                                         ; preds = %._crit_edge
  %_QFEresult.promoted = load i64, ptr @_QFEresult, align 8, !tbaa !3
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %min.iters.check = icmp ult i64 %18, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

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

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %26, %25
  %28 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %18, %n.vec
  br i1 %cmp.n, label %._crit_edge85, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.lr.ph84, %middle.block
  %.ph = phi i64 [ 1, %.lr.ph84 ], [ %ind.end, %middle.block ]
  %.ph89 = phi i64 [ %_QFEresult.promoted, %.lr.ph84 ], [ %28, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %29 = phi i64 [ %36, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %30 = phi i64 [ %35, %scalar.ph ], [ %.ph89, %scalar.ph.preheader ]
  %31 = add i64 %29, -1
  %32 = getelementptr i64, ptr %.unpack, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !3
  %34 = add i64 %30, -1
  %35 = add i64 %34, %33
  %36 = add nuw i64 %29, 1
  %exitcond86.not = icmp eq i64 %29, %18
  br i1 %exitcond86.not, label %._crit_edge85, label %scalar.ph, !llvm.loop !12

._crit_edge85:                                    ; preds = %scalar.ph, %middle.block
  %.lcssa = phi i64 [ %28, %middle.block ], [ %35, %scalar.ph ]
  store i64 %.lcssa, ptr @_QFEresult, align 8, !tbaa !3
  br label %37

37:                                               ; preds = %._crit_edge85, %._crit_edge
  %38 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.24d02bbbfdedc001e7009288ebb7e768, i32 14)
  %39 = load i64, ptr @_QFEresult, align 8, !tbaa !3
  %40 = call i1 @_FortranAioOutputInteger64(ptr %38, i64 %39)
  %41 = call i32 @_FortranAioEndIoStatement(ptr %38)
  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 ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) 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 willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #2

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 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}
