program contest_with_drinks_easy
  implicit none
  integer :: n, m, t(100), p, x, i, s
  t = 0
  read(*,*) n
  read(*,*) t(1:n)
  read(*,*) m
  s = sum(t(1:n))
  do i = 1, m
    read(*,*) p, x
    write(*,'(i0)') s-t(p)+x
  end do
  stop
end program contest_with_drinks_easy
; 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 i32] undef
@_QQcl.82b14b5bac21dd8d5cd9d28e2d4f5062 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7633/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) @_QFEt, i8 0, i64 400, i1 false), !tbaa !3
  %6 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.82b14b5bac21dd8d5cd9d28e2d4f5062, i32 5)
  %7 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %3, i32 4)
  %8 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %9 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.82b14b5bac21dd8d5cd9d28e2d4f5062, i32 6)
  %10 = load i32, ptr %3, align 4, !tbaa !3
  %11 = call i32 @llvm.smax.i32(i32 %10, i32 0)
  %12 = zext i32 %11 to i64
  store ptr @_QFEt, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = 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.gep, align 8, !tbaa !7
  %.fca.2.gep = 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.gep, align 8, !tbaa !7
  %.fca.3.gep = 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.gep, align 4, !tbaa !7
  %.fca.4.gep = 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.gep, align 1, !tbaa !7
  %.fca.5.gep = 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.gep, align 2, !tbaa !7
  %.fca.6.gep = 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.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 %1, 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 %1, i64 0, i32 7, i64 0, i64 1
  store i64 %12, 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 %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %13 = call i1 @_FortranAioInputDescriptor(ptr %9, ptr nonnull %1)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %9)
  %15 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.82b14b5bac21dd8d5cd9d28e2d4f5062, i32 7)
  %16 = call i1 @_FortranAioInputInteger(ptr %15, ptr nonnull %2, i32 4)
  %17 = call i32 @_FortranAioEndIoStatement(ptr %15)
  %18 = load i32, ptr %3, align 4, !tbaa !3
  %19 = call i32 @llvm.smax.i32(i32 %18, i32 0)
  %20 = zext i32 %19 to i64
  %.not = icmp slt i32 %18, 1
  br i1 %.not, label %_FortranASumInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader

.lr.ph.i.preheader:                               ; preds = %0
  %min.iters.check = icmp ult i32 %19, 8
  br i1 %min.iters.check, label %.lr.ph.i.preheader25, label %vector.ph

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

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %25, %24
  %27 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %20
  br i1 %cmp.n, label %_FortranASumInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader25

.lr.ph.i.preheader25:                             ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph = phi i32 [ 0, %.lr.ph.i.preheader ], [ %27, %middle.block ]
  %.ph26 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader25, %.lr.ph.i
  %28 = phi i32 [ %33, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader25 ]
  %29 = phi i64 [ %34, %.lr.ph.i ], [ %.ph26, %.lr.ph.i.preheader25 ]
  %30 = shl i64 %29, 2
  %31 = getelementptr i8, ptr @_QFEt, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !3
  %33 = add i32 %32, %28
  %34 = add nuw nsw i64 %29, 1
  %exitcond.not.i = icmp eq i64 %34, %20
  br i1 %exitcond.not.i, label %_FortranASumInteger4x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !12

_FortranASumInteger4x1_contract_simplified.exit:  ; preds = %.lr.ph.i, %middle.block, %0
  %.lcssa.i = phi i32 [ 0, %0 ], [ %27, %middle.block ], [ %33, %.lr.ph.i ]
  %35 = load i32, ptr %2, align 4, !tbaa !3
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %_FortranASumInteger4x1_contract_simplified.exit
  %37 = zext i32 %35 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %38 = phi i64 [ %54, %.lr.ph ], [ %37, %.lr.ph.preheader ]
  %39 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.82b14b5bac21dd8d5cd9d28e2d4f5062, i32 10)
  %40 = call i1 @_FortranAioInputInteger(ptr %39, ptr nonnull %4, i32 4)
  %41 = call i1 @_FortranAioInputInteger(ptr %39, ptr nonnull %5, i32 4)
  %42 = call i32 @_FortranAioEndIoStatement(ptr %39)
  %43 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.82b14b5bac21dd8d5cd9d28e2d4f5062, i32 11)
  %44 = load i32, ptr %4, align 4, !tbaa !3
  %45 = sext i32 %44 to i64
  %46 = add nsw i64 %45, -1
  %47 = getelementptr [100 x i32], ptr @_QFEt, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !3
  %49 = sub i32 %.lcssa.i, %48
  %50 = load i32, ptr %5, align 4, !tbaa !3
  %51 = add i32 %49, %50
  %52 = call i1 @_FortranAioOutputInteger32(ptr %43, i32 %51)
  %53 = call i32 @_FortranAioEndIoStatement(ptr %43)
  %54 = add nsw i64 %38, -1
  %55 = icmp ugt i64 %38, 1
  br i1 %55, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %_FortranASumInteger4x1_contract_simplified.exit
  %56 = 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 @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, 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) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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