program modulo_summation
  implicit none
  integer :: n, a(3000) = 0
  read(*,*) n
  read(*,*) a(1:n)
  write(*,'(i0)') sum(a)-n
end program modulo_summation
; 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 = internal global [3000 x i32] zeroinitializer
@_QQcl.1f2de11885d02422835a2f2ba97537a4 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5739/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
.lr.ph.i:
  %0 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %1 = alloca i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.1f2de11885d02422835a2f2ba97537a4, i32 4)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.1f2de11885d02422835a2f2ba97537a4, i32 5)
  %6 = load i32, ptr %1, align 4, !tbaa !3
  %7 = call i32 @llvm.smax.i32(i32 %6, i32 0)
  %8 = zext i32 %7 to i64
  store ptr @_QFEa, ptr %0, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, 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 %0, 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 %0, 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 %0, 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 %0, 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 %0, 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 %0, 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 %0, i64 0, i32 7, i64 0, i64 1
  store i64 %8, 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 %0, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %9 = call i1 @_FortranAioInputDescriptor(ptr %5, ptr nonnull %0)
  %10 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %11 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.1f2de11885d02422835a2f2ba97537a4, i32 6)
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %.lr.ph.i
  %index = phi i64 [ 0, %.lr.ph.i ], [ %index.next.2, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %.lr.ph.i ], [ %25, %vector.body ]
  %vec.phi11 = phi <4 x i32> [ zeroinitializer, %.lr.ph.i ], [ %26, %vector.body ]
  %12 = shl i64 %index, 2
  %13 = getelementptr i8, ptr @_QFEa, i64 %12
  %wide.load = load <4 x i32>, ptr %13, align 16, !tbaa !3
  %14 = getelementptr i32, ptr %13, i64 4
  %wide.load12 = load <4 x i32>, ptr %14, align 16, !tbaa !3
  %15 = add <4 x i32> %wide.load, %vec.phi
  %16 = add <4 x i32> %wide.load12, %vec.phi11
  %index.next = shl i64 %index, 2
  %17 = add i64 %index.next, 32
  %18 = getelementptr i8, ptr @_QFEa, i64 %17
  %wide.load.1 = load <4 x i32>, ptr %18, align 16, !tbaa !3
  %19 = getelementptr i32, ptr %18, i64 4
  %wide.load12.1 = load <4 x i32>, ptr %19, align 16, !tbaa !3
  %20 = add <4 x i32> %wide.load.1, %15
  %21 = add <4 x i32> %wide.load12.1, %16
  %index.next.1 = shl i64 %index, 2
  %22 = add i64 %index.next.1, 64
  %23 = getelementptr i8, ptr @_QFEa, i64 %22
  %wide.load.2 = load <4 x i32>, ptr %23, align 16, !tbaa !3
  %24 = getelementptr i32, ptr %23, i64 4
  %wide.load12.2 = load <4 x i32>, ptr %24, align 16, !tbaa !3
  %25 = add <4 x i32> %wide.load.2, %20
  %26 = add <4 x i32> %wide.load12.2, %21
  %index.next.2 = add nuw nsw i64 %index, 24
  %27 = icmp eq i64 %index.next.2, 3000
  br i1 %27, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %26, %25
  %28 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %29 = load i32, ptr %1, align 4, !tbaa !3
  %30 = sub i32 %28, %29
  %31 = call i1 @_FortranAioOutputInteger32(ptr %11, i32 %30)
  %32 = call i32 @_FortranAioEndIoStatement(ptr %11)
  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 @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, 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 i32 @llvm.smax.i32(i32, i32) #0

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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"}
