program ABC050B
    implicit none
    integer(8)::N,P,X,i,M,result
    integer(8),dimension(100)::T
    read(5,*)N,(T(i),i=1,N),M
    result=sum(T(1:N))

    do i=1,M
        read(5,*)P,X
        print'(i0)',result+X-T(P)
    end do
end program ABC050B
; 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"

@_QFEt = internal global [100 x i64] undef
@_QQcl.896c4338a3025dd1ec8febc83e4c2ca7 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7631/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 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.896c4338a3025dd1ec8febc83e4c2ca7, i32 5)
  %6 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %2, i32 8)
  %7 = load i64, ptr %2, align 8, !tbaa !3
  %8 = icmp sgt i64 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %9 = phi i64 [ %13, %.lr.ph ], [ 1, %0 ]
  %10 = add nsw i64 %9, -1
  %11 = getelementptr [100 x i64], ptr @_QFEt, i64 0, i64 %10
  %12 = call i1 @_FortranAioInputInteger(ptr %5, ptr %11, i32 8)
  %13 = add nuw i64 %9, 1
  %exitcond.not = icmp eq i64 %9, %7
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %14 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %1, i32 8)
  %15 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %16 = load i64, ptr %2, align 8, !tbaa !3
  %17 = call i64 @llvm.smax.i64(i64 %16, i64 0)
  %.not = icmp slt i64 %16, 1
  br i1 %.not, label %_FortranASumInteger8x1_contract_simplified.exit, label %.lr.ph.i.preheader

.lr.ph.i.preheader:                               ; preds = %._crit_edge
  %min.iters.check = icmp ult i64 %17, 4
  br i1 %min.iters.check, label %.lr.ph.i.preheader8, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.i.preheader
  %n.vec = and i64 %17, 9223372036854775804
  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> [ zeroinitializer, %vector.ph ], [ %21, %vector.body ]
  %vec.phi6 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %22, %vector.body ]
  %18 = shl i64 %index, 3
  %19 = getelementptr i8, ptr @_QFEt, i64 %18
  %wide.load = load <2 x i64>, ptr %19, align 16, !tbaa !3
  %20 = getelementptr i64, ptr %19, i64 2
  %wide.load7 = load <2 x i64>, ptr %20, align 16, !tbaa !3
  %21 = add <2 x i64> %wide.load, %vec.phi
  %22 = add <2 x i64> %wide.load7, %vec.phi6
  %index.next = add nuw i64 %index, 4
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !7

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %22, %21
  %24 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %17, %n.vec
  br i1 %cmp.n, label %_FortranASumInteger8x1_contract_simplified.exit, label %.lr.ph.i.preheader8

.lr.ph.i.preheader8:                              ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph = phi i64 [ 0, %.lr.ph.i.preheader ], [ %24, %middle.block ]
  %.ph9 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader8, %.lr.ph.i
  %25 = phi i64 [ %30, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader8 ]
  %26 = phi i64 [ %31, %.lr.ph.i ], [ %.ph9, %.lr.ph.i.preheader8 ]
  %27 = shl i64 %26, 3
  %28 = getelementptr i8, ptr @_QFEt, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !3
  %30 = add i64 %29, %25
  %31 = add nuw nsw i64 %26, 1
  %exitcond.not.i = icmp eq i64 %31, %17
  br i1 %exitcond.not.i, label %_FortranASumInteger8x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !10

_FortranASumInteger8x1_contract_simplified.exit:  ; preds = %.lr.ph.i, %middle.block, %._crit_edge
  %.lcssa.i = phi i64 [ 0, %._crit_edge ], [ %24, %middle.block ], [ %30, %.lr.ph.i ]
  %32 = load i64, ptr %1, align 8, !tbaa !3
  %33 = icmp sgt i64 %32, 0
  br i1 %33, label %.lr.ph4, label %._crit_edge5

.lr.ph4:                                          ; preds = %_FortranASumInteger8x1_contract_simplified.exit, %.lr.ph4
  %34 = phi i64 [ %49, %.lr.ph4 ], [ %32, %_FortranASumInteger8x1_contract_simplified.exit ]
  %35 = call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.896c4338a3025dd1ec8febc83e4c2ca7, i32 9)
  %36 = call i1 @_FortranAioInputInteger(ptr %35, ptr nonnull %3, i32 8)
  %37 = call i1 @_FortranAioInputInteger(ptr %35, ptr nonnull %4, i32 8)
  %38 = call i32 @_FortranAioEndIoStatement(ptr %35)
  %39 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.896c4338a3025dd1ec8febc83e4c2ca7, i32 10)
  %40 = load i64, ptr %4, align 8, !tbaa !3
  %41 = add i64 %40, %.lcssa.i
  %42 = load i64, ptr %3, align 8, !tbaa !3
  %43 = add i64 %42, -1
  %44 = getelementptr [100 x i64], ptr @_QFEt, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !3
  %46 = sub i64 %41, %45
  %47 = call i1 @_FortranAioOutputInteger64(ptr %39, i64 %46)
  %48 = call i32 @_FortranAioEndIoStatement(ptr %39)
  %49 = add nsw i64 %34, -1
  %50 = icmp ugt i64 %34, 1
  br i1 %50, label %.lr.ph4, label %._crit_edge5

._crit_edge5:                                     ; preds = %.lr.ph4, %_FortranASumInteger8x1_contract_simplified.exit
  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) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #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 = distinct !{!7, !8, !9}
!8 = !{!"llvm.loop.isvectorized", i32 1}
!9 = !{!"llvm.loop.unroll.runtime.disable"}
!10 = distinct !{!10, !9, !8}
