; LLVM IR from tangjz/acm-icpc :: codeforces/complete (584E)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@n = external dso_local global i32, align 4
@f = external dso_local global [2010 x i32], align 16
@g = external dso_local global [2010 x i32], align 16
@sum = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@ans = external dso_local global [2000001 x [2 x i32]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4initii(i32 noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3updiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3queiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %22, %0
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %25

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i32, ptr @f, i64 %19
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %20)
  br label %22

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !9

25:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %37, %25
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = icmp sle i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %40

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %4)
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %35
  store i32 %33, ptr %36, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %37

37:                                               ; preds = %31
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %3, align 4, !tbaa !5
  br label %26, !llvm.loop !11

40:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %57, %40
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr @n, align 4, !tbaa !5
  %44 = icmp sle i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %60

46:                                               ; preds = %41
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %55
  store i32 %53, ptr %56, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %46
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %5, align 4, !tbaa !5
  br label %41, !llvm.loop !12

60:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %74, %60
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = icmp sle i32 %62, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %77

66:                                               ; preds = %61
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %72
  store i32 %67, ptr %73, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %66
  %75 = load i32, ptr %6, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %6, align 4, !tbaa !5
  br label %61, !llvm.loop !13

77:                                               ; preds = %65
  %78 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z4initii(i32 noundef 1, i32 noundef %78)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %79 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %79, ptr %7, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %153, %77
  %81 = load i32, ptr %7, align 4, !tbaa !5
  %82 = icmp sge i32 %81, 1
  br i1 %82, label %84, label %83

83:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %156

84:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  store i32 %88, ptr %8, align 4, !tbaa !5
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = sub nsw i32 %89, %93
  %95 = load i32, ptr @sum, align 4, !tbaa !5
  %96 = add nsw i32 %95, %94
  store i32 %96, ptr @sum, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %101, %84
  %98 = load i32, ptr %8, align 4, !tbaa !5
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = icmp ne i32 %98, %99
  br i1 %100, label %101, label %152

101:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %102 = load i32, ptr @n, align 4, !tbaa !5
  %103 = load i32, ptr %8, align 4, !tbaa !5
  %104 = add nsw i32 %103, 1
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = call noundef i32 @_Z3queiiii(i32 noundef 1, i32 noundef %102, i32 noundef %104, i32 noundef %105)
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  store i32 %109, ptr %9, align 4, !tbaa !5
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %111
  %113 = load i32, ptr %9, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %114
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %112, ptr noundef nonnull align 4 dereferenceable(4) %115) #5
  %116 = load i32, ptr %8, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %120
  %122 = load i32, ptr %9, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %126
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %121, ptr noundef nonnull align 4 dereferenceable(4) %127) #5
  %128 = load i32, ptr @n, align 4, !tbaa !5
  %129 = load i32, ptr %8, align 4, !tbaa !5
  %130 = load i32, ptr %8, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  call void @_Z3updiiii(i32 noundef 1, i32 noundef %128, i32 noundef %129, i32 noundef %133)
  %134 = load i32, ptr @n, align 4, !tbaa !5
  %135 = load i32, ptr %9, align 4, !tbaa !5
  %136 = load i32, ptr %9, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  call void @_Z3updiiii(i32 noundef 1, i32 noundef %134, i32 noundef %135, i32 noundef %139)
  %140 = load i32, ptr %8, align 4, !tbaa !5
  %141 = load i32, ptr @tot, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [2000001 x [2 x i32]], ptr @ans, i64 0, i64 %142
  %144 = getelementptr inbounds [2 x i32], ptr %143, i64 0, i64 0
  store i32 %140, ptr %144, align 8, !tbaa !5
  %145 = load i32, ptr %9, align 4, !tbaa !5
  %146 = load i32, ptr @tot, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr @tot, align 4, !tbaa !5
  %148 = sext i32 %146 to i64
  %149 = getelementptr inbounds [2000001 x [2 x i32]], ptr @ans, i64 0, i64 %148
  %150 = getelementptr inbounds [2 x i32], ptr %149, i64 0, i64 1
  store i32 %145, ptr %150, align 4, !tbaa !5
  %151 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %151, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %97, !llvm.loop !14

152:                                              ; preds = %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %7, align 4, !tbaa !5
  %155 = add nsw i32 %154, -1
  store i32 %155, ptr %7, align 4, !tbaa !5
  br label %80, !llvm.loop !15

156:                                              ; preds = %83
  %157 = load i32, ptr @sum, align 4, !tbaa !5
  %158 = load i32, ptr @tot, align 4, !tbaa !5
  %159 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %157, i32 noundef %158)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %177, %156
  %161 = load i32, ptr %10, align 4, !tbaa !5
  %162 = load i32, ptr @tot, align 4, !tbaa !5
  %163 = icmp slt i32 %161, %162
  br i1 %163, label %165, label %164

164:                                              ; preds = %160
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %180

165:                                              ; preds = %160
  %166 = load i32, ptr %10, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [2000001 x [2 x i32]], ptr @ans, i64 0, i64 %167
  %169 = getelementptr inbounds [2 x i32], ptr %168, i64 0, i64 0
  %170 = load i32, ptr %169, align 8, !tbaa !5
  %171 = load i32, ptr %10, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [2000001 x [2 x i32]], ptr @ans, i64 0, i64 %172
  %174 = getelementptr inbounds [2 x i32], ptr %173, i64 0, i64 1
  %175 = load i32, ptr %174, align 4, !tbaa !5
  %176 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %170, i32 noundef %175)
  br label %177

177:                                              ; preds = %165
  %178 = load i32, ptr %10, align 4, !tbaa !5
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %10, align 4, !tbaa !5
  br label %160, !llvm.loop !16

180:                                              ; preds = %164
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

declare i32 @printf(ptr noundef, ...) #3

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@n = external dso_local global i32, align 4
@f = external dso_local global [2010 x i32], align 16
@g = external dso_local global [2010 x i32], align 16
@sum = external dso_local local_unnamed_addr global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global [2000001 x [2 x i32]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4initii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3updiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3queiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not51 = icmp slt i32 %3, 1
  br i1 %.not51, label %._crit_edge, label %.lr.ph

.preheader50:                                     ; preds = %.lr.ph
  %.not4553 = icmp slt i32 %6, 1
  br i1 %.not4553, label %._crit_edge, label %.lr.ph55

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %4 = getelementptr inbounds i32, ptr @f, i64 %indvars.iv
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %4)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %.not.not = icmp slt i64 %indvars.iv, %7
  br i1 %.not.not, label %.lr.ph, label %.preheader50, !llvm.loop !9

.preheader49:                                     ; preds = %.lr.ph55
  %.not4656 = icmp slt i32 %15, 1
  br i1 %.not4656, label %._crit_edge, label %.lr.ph58.preheader

.lr.ph58.preheader:                               ; preds = %.preheader49
  %8 = zext nneg i32 %15 to i64
  %xtraiter = and i64 %8, 3
  %9 = icmp ult i32 %15, 4
  br i1 %9, label %.preheader.unr-lcssa, label %.lr.ph58.preheader.new

.lr.ph58.preheader.new:                           ; preds = %.lr.ph58.preheader
  %unroll_iter = and i64 %8, 2147483644
  br label %.lr.ph58

.lr.ph55:                                         ; preds = %.preheader50, %.lr.ph55
  %.04354 = phi i32 [ %14, %.lr.ph55 ], [ 1, %.preheader50 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %12
  store i32 %.04354, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %14 = add nuw nsw i32 %.04354, 1
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %.not45.not = icmp slt i32 %.04354, %15
  br i1 %.not45.not, label %.lr.ph55, label %.preheader49, !llvm.loop !11

.preheader.unr-lcssa:                             ; preds = %.lr.ph58, %.lr.ph58.preheader
  %indvars.iv77.unr = phi i64 [ 1, %.lr.ph58.preheader ], [ %indvars.iv.next78.3, %.lr.ph58 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.lr.ph58.epil

.lr.ph58.epil:                                    ; preds = %.preheader.unr-lcssa, %.lr.ph58.epil
  %indvars.iv77.epil = phi i64 [ %indvars.iv.next78.epil, %.lr.ph58.epil ], [ %indvars.iv77.unr, %.preheader.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph58.epil ], [ 0, %.preheader.unr-lcssa ]
  %16 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv77.epil
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %20, ptr %16, align 4, !tbaa !5
  %indvars.iv.next78.epil = add nuw nsw i64 %indvars.iv77.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader, label %.lr.ph58.epil, !llvm.loop !12

.preheader:                                       ; preds = %.lr.ph58.epil, %.preheader.unr-lcssa
  br i1 %.not4656, label %._crit_edge, label %.lr.ph61.preheader

.lr.ph61.preheader:                               ; preds = %.preheader
  %xtraiter103 = and i64 %8, 3
  %21 = icmp ult i32 %15, 4
  br i1 %21, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph61.preheader.new

.lr.ph61.preheader.new:                           ; preds = %.lr.ph61.preheader
  %unroll_iter106 = and i64 %8, 2147483644
  br label %.lr.ph61

.lr.ph58:                                         ; preds = %.lr.ph58, %.lr.ph58.preheader.new
  %indvars.iv77 = phi i64 [ 1, %.lr.ph58.preheader.new ], [ %indvars.iv.next78.3, %.lr.ph58 ]
  %niter = phi i64 [ 0, %.lr.ph58.preheader.new ], [ %niter.next.3, %.lr.ph58 ]
  %22 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv77
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  store i32 %26, ptr %22, align 4, !tbaa !5
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %27 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv.next78
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  store i32 %31, ptr %27, align 4, !tbaa !5
  %indvars.iv.next78.1 = add nuw nsw i64 %indvars.iv77, 2
  %32 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv.next78.1
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  store i32 %36, ptr %32, align 4, !tbaa !5
  %indvars.iv.next78.2 = add nuw nsw i64 %indvars.iv77, 3
  %37 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv.next78.2
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  store i32 %41, ptr %37, align 4, !tbaa !5
  %indvars.iv.next78.3 = add nuw nsw i64 %indvars.iv77, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader.unr-lcssa, label %.lr.ph58, !llvm.loop !14

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph61, %.lr.ph61.preheader
  %indvars.iv80.unr = phi i64 [ 1, %.lr.ph61.preheader ], [ %indvars.iv.next81.3, %.lr.ph61 ]
  %lcmp.mod105.not = icmp eq i64 %xtraiter103, 0
  br i1 %lcmp.mod105.not, label %._crit_edge, label %.lr.ph61.epil

.lr.ph61.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph61.epil
  %indvars.iv80.epil = phi i64 [ %indvars.iv.next81.epil, %.lr.ph61.epil ], [ %indvars.iv80.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter104 = phi i64 [ %epil.iter104.next, %.lr.ph61.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %42 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv80.epil
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %44
  %46 = trunc nuw nsw i64 %indvars.iv80.epil to i32
  store i32 %46, ptr %45, align 4, !tbaa !5
  %indvars.iv.next81.epil = add nuw nsw i64 %indvars.iv80.epil, 1
  %epil.iter104.next = add i64 %epil.iter104, 1
  %epil.iter104.cmp.not = icmp eq i64 %epil.iter104.next, %xtraiter103
  br i1 %epil.iter104.cmp.not, label %._crit_edge, label %.lr.ph61.epil, !llvm.loop !15

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph61.epil, %.preheader49, %0, %.preheader50, %.preheader
  %.lcssa9498 = phi i32 [ %15, %.preheader ], [ %6, %.preheader50 ], [ %3, %0 ], [ %15, %.preheader49 ], [ %15, %.lr.ph61.epil ], [ %15, %._crit_edge.loopexit.unr-lcssa ]
  call void @_Z4initii(i32 noundef 1, i32 noundef %.lcssa9498)
  %47 = load i32, ptr @n, align 4, !tbaa !5
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.lr.ph69.preheader, label %._crit_edge70

.lr.ph69.preheader:                               ; preds = %._crit_edge
  %49 = zext nneg i32 %47 to i64
  br label %.lr.ph69

.lr.ph61:                                         ; preds = %.lr.ph61, %.lr.ph61.preheader.new
  %indvars.iv80 = phi i64 [ 1, %.lr.ph61.preheader.new ], [ %indvars.iv.next81.3, %.lr.ph61 ]
  %niter107 = phi i64 [ 0, %.lr.ph61.preheader.new ], [ %niter107.next.3, %.lr.ph61 ]
  %50 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv80
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %52
  %54 = trunc nuw nsw i64 %indvars.iv80 to i32
  store i32 %54, ptr %53, align 4, !tbaa !5
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %55 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv.next81
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %57
  %59 = trunc nuw nsw i64 %indvars.iv.next81 to i32
  store i32 %59, ptr %58, align 4, !tbaa !5
  %indvars.iv.next81.1 = add nuw nsw i64 %indvars.iv80, 2
  %60 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv.next81.1
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %62
  %64 = trunc nuw nsw i64 %indvars.iv.next81.1 to i32
  store i32 %64, ptr %63, align 4, !tbaa !5
  %indvars.iv.next81.2 = add nuw nsw i64 %indvars.iv80, 3
  %65 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv.next81.2
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %67
  %69 = trunc nuw nsw i64 %indvars.iv.next81.2 to i32
  store i32 %69, ptr %68, align 4, !tbaa !5
  %indvars.iv.next81.3 = add nuw nsw i64 %indvars.iv80, 4
  %niter107.next.3 = add i64 %niter107, 4
  %niter107.ncmp.3 = icmp eq i64 %niter107.next.3, %unroll_iter106
  br i1 %niter107.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph61, !llvm.loop !16

._crit_edge70:                                    ; preds = %._crit_edge66, %._crit_edge
  %70 = load i32, ptr @sum, align 4, !tbaa !5
  %71 = load i32, ptr @tot, align 4, !tbaa !5
  %72 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %70, i32 noundef %71)
  %73 = load i32, ptr @tot, align 4, !tbaa !5
  %74 = icmp sgt i32 %73, 0
  br i1 %74, label %.lr.ph73, label %._crit_edge74

.lr.ph69:                                         ; preds = %.lr.ph69.preheader, %._crit_edge66
  %indvars.iv85 = phi i64 [ %49, %.lr.ph69.preheader ], [ %indvars.iv.next86, %._crit_edge66 ]
  %75 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %indvars.iv85
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = trunc nuw nsw i64 %indvars.iv85 to i32
  %78 = sub i32 %77, %76
  %79 = load i32, ptr @sum, align 4, !tbaa !5
  %80 = add nsw i32 %78, %79
  store i32 %80, ptr @sum, align 4, !tbaa !5
  %81 = zext i32 %76 to i64
  %.not4862 = icmp eq i64 %indvars.iv85, %81
  br i1 %.not4862, label %._crit_edge66, label %.lr.ph65

.lr.ph65:                                         ; preds = %.lr.ph69, %.lr.ph65
  %.03963 = phi i32 [ %87, %.lr.ph65 ], [ %76, %.lr.ph69 ]
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = add nsw i32 %.03963, 1
  %84 = call noundef i32 @_Z3queiiii(i32 noundef 1, i32 noundef %82, i32 noundef %83, i32 noundef %77)
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = sext i32 %.03963 to i64
  %89 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %88
  %90 = sext i32 %87 to i64
  %91 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %90
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %89, ptr noundef nonnull align 4 dereferenceable(4) %91) #5
  %92 = load i32, ptr %89, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %93
  %95 = load i32, ptr %91, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [2010 x i32], ptr @g, i64 0, i64 %96
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %94, ptr noundef nonnull align 4 dereferenceable(4) %97) #5
  %98 = load i32, ptr @n, align 4, !tbaa !5
  %99 = load i32, ptr %89, align 4, !tbaa !5
  call void @_Z3updiiii(i32 noundef 1, i32 noundef %98, i32 noundef %.03963, i32 noundef %99)
  %100 = load i32, ptr @n, align 4, !tbaa !5
  %101 = load i32, ptr %91, align 4, !tbaa !5
  call void @_Z3updiiii(i32 noundef 1, i32 noundef %100, i32 noundef %87, i32 noundef %101)
  %102 = load i32, ptr @tot, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [2000001 x [2 x i32]], ptr @ans, i64 0, i64 %103
  store i32 %.03963, ptr %104, align 8, !tbaa !5
  %105 = add nsw i32 %102, 1
  store i32 %105, ptr @tot, align 4, !tbaa !5
  %106 = getelementptr inbounds [2000001 x [2 x i32]], ptr @ans, i64 0, i64 %103, i64 1
  store i32 %87, ptr %106, align 4, !tbaa !5
  %107 = zext i32 %87 to i64
  %.not48 = icmp eq i64 %indvars.iv85, %107
  br i1 %.not48, label %._crit_edge66, label %.lr.ph65, !llvm.loop !17

._crit_edge66:                                    ; preds = %.lr.ph65, %.lr.ph69
  %indvars.iv.next86 = add nsw i64 %indvars.iv85, -1
  %108 = icmp ugt i64 %indvars.iv85, 1
  br i1 %108, label %.lr.ph69, label %._crit_edge70, !llvm.loop !18

._crit_edge74:                                    ; preds = %.lr.ph73, %._crit_edge70
  ret i32 0

.lr.ph73:                                         ; preds = %._crit_edge70, %.lr.ph73
  %indvars.iv88 = phi i64 [ %indvars.iv.next89, %.lr.ph73 ], [ 0, %._crit_edge70 ]
  %109 = getelementptr inbounds [2000001 x [2 x i32]], ptr @ans, i64 0, i64 %indvars.iv88
  %110 = load i32, ptr %109, align 8, !tbaa !5
  %111 = getelementptr inbounds i8, ptr %109, i64 4
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %110, i32 noundef %112)
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %114 = load i32, ptr @tot, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = icmp slt i64 %indvars.iv.next89, %115
  br i1 %116, label %.lr.ph73, label %._crit_edge74, !llvm.loop !19
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass