; LLVM IR from tangjz/acm-icpc :: codeforces/complete (815C)

; 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
@m = external dso_local global i32, align 4
@fa = external dso_local global [5001 x i32], align 16
@sz = external dso_local global [5001 x i32], align 16
@c = external dso_local global [5001 x i32], align 16
@d = external dso_local global [5001 x i32], align 16
@f = external dso_local global [5001 x [5001 x i64]], align 16
@g = external dso_local global [5001 x [5001 x i64]], align 16
@h = external dso_local global [5001 x i64], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5MergePxiS_i(ptr noundef, i32 noundef, ptr 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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

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

16:                                               ; preds = %11
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds i32, ptr @c, i64 %18
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr @d, i64 %21
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %19, ptr noundef %22)
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = icmp sgt i32 %24, 1
  br i1 %25, label %26, label %31

26:                                               ; preds = %16
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr @fa, i64 %28
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %29)
  br label %31

31:                                               ; preds = %26, %16
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %33
  store i32 1, ptr %34, align 4, !tbaa !5
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [5001 x [5001 x i64]], ptr @f, i64 0, i64 %36
  %38 = getelementptr inbounds [5001 x i64], ptr %37, i64 0, i64 0
  store i64 4611686018427387903, ptr %38, align 8, !tbaa !9
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [5001 x i32], ptr @c, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [5001 x [5001 x i64]], ptr @f, i64 0, i64 %45
  %47 = getelementptr inbounds [5001 x i64], ptr %46, i64 0, i64 1
  store i64 %43, ptr %47, align 8, !tbaa !9
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [5001 x [5001 x i64]], ptr @g, i64 0, i64 %49
  %51 = getelementptr inbounds [5001 x i64], ptr %50, i64 0, i64 0
  store i64 0, ptr %51, align 8, !tbaa !9
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [5001 x i32], ptr @c, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [5001 x [5001 x i64]], ptr @g, i64 0, i64 %58
  %60 = getelementptr inbounds [5001 x i64], ptr %59, i64 0, i64 1
  store i64 %56, ptr %60, align 8, !tbaa !9
  br label %61

61:                                               ; preds = %31
  %62 = load i32, ptr %2, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !11

64:                                               ; preds = %15
  %65 = load i32, ptr getelementptr inbounds ([5001 x i32], ptr @d, i64 0, i64 1), align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = load i64, ptr getelementptr inbounds ([5001 x i64], ptr getelementptr inbounds ([5001 x [5001 x i64]], ptr @f, i64 0, i64 1), i64 0, i64 1), align 8, !tbaa !9
  %68 = sub nsw i64 %67, %66
  store i64 %68, ptr getelementptr inbounds ([5001 x i64], ptr getelementptr inbounds ([5001 x [5001 x i64]], ptr @f, i64 0, i64 1), i64 0, i64 1), align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %69 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %69, ptr %3, align 4, !tbaa !5
  br label %70

70:                                               ; preds = %165, %64
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = icmp sgt i32 %71, 1
  br i1 %72, label %74, label %73

73:                                               ; preds = %70
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %168

74:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [5001 x i32], ptr @fa, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  store i32 %78, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %124, %74
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = icmp sle i32 %80, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %79
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %127

87:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %88 = load i32, ptr %3, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [5001 x [5001 x i64]], ptr @f, i64 0, i64 %89
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [5001 x i64], ptr %90, i64 0, i64 %92
  %94 = load i64, ptr %93, align 8, !tbaa !9
  %95 = icmp slt i64 %94, 4611686018427387903
  br i1 %95, label %96, label %110

96:                                               ; preds = %87
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [5001 x [5001 x i64]], ptr @f, i64 0, i64 %98
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [5001 x i64], ptr %99, i64 0, i64 %101
  %103 = load i64, ptr %102, align 8, !tbaa !9
  %104 = load i32, ptr %3, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [5001 x i32], ptr @d, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = sub nsw i64 %103, %108
  br label %111

110:                                              ; preds = %87
  br label %111

111:                                              ; preds = %110, %96
  %112 = phi i64 [ %109, %96 ], [ 4611686018427387903, %110 ]
  store i64 %112, ptr %7, align 8, !tbaa !9
  %113 = load i32, ptr %3, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [5001 x [5001 x i64]], ptr @g, i64 0, i64 %114
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [5001 x i64], ptr %115, i64 0, i64 %117
  %119 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %118)
  %120 = load i64, ptr %119, align 8, !tbaa !9
  %121 = load i32, ptr %6, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [5001 x i64], ptr @h, i64 0, i64 %122
  store i64 %120, ptr %123, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %124

124:                                              ; preds = %111
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %6, align 4, !tbaa !5
  br label %79, !llvm.loop !13

127:                                              ; preds = %86
  %128 = load i32, ptr %5, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [5001 x [5001 x i64]], ptr @f, i64 0, i64 %129
  %131 = getelementptr inbounds [5001 x i64], ptr %130, i64 0, i64 0
  %132 = load i32, ptr %5, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = load i32, ptr %3, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  call void @_Z5MergePxiS_i(ptr noundef %131, i32 noundef %135, ptr noundef @h, i32 noundef %139)
  %140 = load i32, ptr %5, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [5001 x [5001 x i64]], ptr @g, i64 0, i64 %141
  %143 = getelementptr inbounds [5001 x i64], ptr %142, i64 0, i64 0
  %144 = load i32, ptr %5, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = load i32, ptr %3, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [5001 x [5001 x i64]], ptr @g, i64 0, i64 %149
  %151 = getelementptr inbounds [5001 x i64], ptr %150, i64 0, i64 0
  %152 = load i32, ptr %3, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  call void @_Z5MergePxiS_i(ptr noundef %143, i32 noundef %147, ptr noundef %151, i32 noundef %155)
  %156 = load i32, ptr %3, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %157
  %159 = load i32, ptr %158, align 4, !tbaa !5
  %160 = load i32, ptr %5, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = add nsw i32 %163, %159
  store i32 %164, ptr %162, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %165

165:                                              ; preds = %127
  %166 = load i32, ptr %3, align 4, !tbaa !5
  %167 = add nsw i32 %166, -1
  store i32 %167, ptr %3, align 4, !tbaa !5
  br label %70, !llvm.loop !14

168:                                              ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %169

169:                                              ; preds = %189, %168
  %170 = load i32, ptr %9, align 4, !tbaa !5
  %171 = load i32, ptr @n, align 4, !tbaa !5
  %172 = icmp sle i32 %170, %171
  br i1 %172, label %174, label %173

173:                                              ; preds = %169
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %192

174:                                              ; preds = %169
  %175 = load i32, ptr %9, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [5001 x i64], ptr getelementptr inbounds ([5001 x [5001 x i64]], ptr @f, i64 0, i64 1), i64 0, i64 %176
  %178 = load i32, ptr %9, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [5001 x i64], ptr getelementptr inbounds ([5001 x [5001 x i64]], ptr @g, i64 0, i64 1), i64 0, i64 %179
  %181 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %177, ptr noundef nonnull align 8 dereferenceable(8) %180)
  %182 = load i64, ptr %181, align 8, !tbaa !9
  %183 = load i32, ptr @m, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = icmp sle i64 %182, %184
  br i1 %185, label %186, label %188

186:                                              ; preds = %174
  %187 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %187, ptr %8, align 4, !tbaa !5
  br label %188

188:                                              ; preds = %186, %174
  br label %189

189:                                              ; preds = %188
  %190 = load i32, ptr %9, align 4, !tbaa !5
  %191 = add nsw i32 %190, 1
  store i32 %191, ptr %9, align 4, !tbaa !5
  br label %169, !llvm.loop !15

192:                                              ; preds = %173
  %193 = load i32, ptr %8, align 4, !tbaa !5
  %194 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %193)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %195 = load i32, ptr %1, align 4
  ret i32 %195
}

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

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

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 = { 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 #3 = { 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 #4 = { "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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


; 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
@m = external dso_local global i32, align 4
@fa = external dso_local global [5001 x i32], align 16
@sz = external dso_local local_unnamed_addr global [5001 x i32], align 16
@c = external dso_local global [5001 x i32], align 16
@d = external dso_local global [5001 x i32], align 16
@f = external dso_local global [5001 x [5001 x i64]], align 16
@g = external dso_local global [5001 x [5001 x i64]], align 16
@h = external dso_local global [5001 x i64], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5MergePxiS_i(ptr noundef, i32 noundef, ptr 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

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

4:                                                ; preds = %0
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @c, i64 4), ptr noundef nonnull getelementptr inbounds (i8, ptr @d, i64 4))
  %.pre84 = load i32, ptr @n, align 4, !tbaa !5
  %.pre = load i32, ptr getelementptr inbounds (i8, ptr @c, i64 4), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @sz, i64 4), align 4, !tbaa !5
  store i64 4611686018427387903, ptr getelementptr inbounds (i8, ptr @f, i64 40008), align 8, !tbaa !9
  %6 = sext i32 %.pre to i64
  store i64 %6, ptr getelementptr inbounds (i8, ptr @f, i64 40016), align 16, !tbaa !9
  store i64 0, ptr getelementptr inbounds (i8, ptr @g, i64 40008), align 8, !tbaa !9
  store i64 %6, ptr getelementptr inbounds (i8, ptr @g, i64 40016), align 16, !tbaa !9
  %.not.not.peel = icmp sgt i32 %.pre84, 1
  br i1 %.not.not.peel, label %.lr.ph.peel.next, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0, %4
  %.lcssa53.ph = phi i32 [ %.pre84, %4 ], [ %3, %0 ]
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @d, i64 4), align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = load i64, ptr getelementptr inbounds (i8, ptr @f, i64 40016), align 16, !tbaa !9
  %10 = sub nsw i64 %9, %8
  store i64 %10, ptr getelementptr inbounds (i8, ptr @f, i64 40016), align 16, !tbaa !9
  br label %.preheader

._crit_edge:                                      ; preds = %.lr.ph.peel.next
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @d, i64 4), align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = load i64, ptr getelementptr inbounds (i8, ptr @f, i64 40016), align 16, !tbaa !9
  %14 = sub nsw i64 %13, %12
  store i64 %14, ptr getelementptr inbounds (i8, ptr @f, i64 40016), align 16, !tbaa !9
  %15 = icmp sgt i32 %29, 1
  br i1 %15, label %.lr.ph64.preheader, label %.preheader

.lr.ph64.preheader:                               ; preds = %._crit_edge
  %16 = zext nneg i32 %29 to i64
  br label %.lr.ph64

.lr.ph.peel.next:                                 ; preds = %4, %.lr.ph.peel.next
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.peel.next ], [ 2, %4 ]
  %17 = getelementptr inbounds i32, ptr @c, i64 %indvars.iv
  %18 = getelementptr inbounds i32, ptr @d, i64 %indvars.iv
  %19 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %17, ptr noundef nonnull %18)
  %20 = getelementptr inbounds i32, ptr @fa, i64 %indvars.iv
  %21 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %20)
  %22 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %indvars.iv
  store i32 1, ptr %22, align 4, !tbaa !5
  %23 = getelementptr inbounds [5001 x [5001 x i64]], ptr @f, i64 0, i64 %indvars.iv
  store i64 4611686018427387903, ptr %23, align 8, !tbaa !9
  %24 = load i32, ptr %17, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 8
  store i64 %25, ptr %26, align 8, !tbaa !9
  %27 = getelementptr inbounds [5001 x [5001 x i64]], ptr @g, i64 0, i64 %indvars.iv
  store i64 0, ptr %27, align 8, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  store i64 %25, ptr %28, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %.not.not = icmp slt i64 %indvars.iv, %30
  br i1 %.not.not, label %.lr.ph.peel.next, label %._crit_edge, !llvm.loop !11

.preheader.loopexit:                              ; preds = %._crit_edge60
  %.pre85 = load i32, ptr @n, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %._crit_edge.thread, %.preheader.loopexit, %._crit_edge
  %31 = phi i32 [ %.pre85, %.preheader.loopexit ], [ %29, %._crit_edge ], [ %.lcssa53.ph, %._crit_edge.thread ]
  %.not4965 = icmp slt i32 %31, 1
  br i1 %.not4965, label %._crit_edge69, label %.lr.ph68

.lr.ph64:                                         ; preds = %.lr.ph64.preheader, %._crit_edge60
  %indvars.iv78 = phi i64 [ %16, %.lr.ph64.preheader ], [ %indvars.iv.next79, %._crit_edge60 ]
  %32 = getelementptr inbounds [5001 x i32], ptr @fa, i64 0, i64 %indvars.iv78
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %indvars.iv78
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %.not5156 = icmp slt i32 %35, 0
  br i1 %.not5156, label %._crit_edge60, label %.lr.ph59

.lr.ph59:                                         ; preds = %.lr.ph64
  %36 = getelementptr inbounds [5001 x i32], ptr @d, i64 0, i64 %indvars.iv78
  br label %49

._crit_edge60:                                    ; preds = %57, %.lr.ph64
  %.lcssa = phi i32 [ %35, %.lr.ph64 ], [ %63, %57 ]
  %37 = sext i32 %33 to i64
  %38 = getelementptr inbounds [5001 x [5001 x i64]], ptr @f, i64 0, i64 %37
  %39 = getelementptr inbounds [5001 x i32], ptr @sz, i64 0, i64 %37
  %40 = load i32, ptr %39, align 4, !tbaa !5
  call void @_Z5MergePxiS_i(ptr noundef nonnull %38, i32 noundef %40, ptr noundef nonnull @h, i32 noundef %.lcssa)
  %41 = getelementptr inbounds [5001 x [5001 x i64]], ptr @g, i64 0, i64 %37
  %42 = load i32, ptr %39, align 4, !tbaa !5
  %43 = getelementptr inbounds [5001 x [5001 x i64]], ptr @g, i64 0, i64 %indvars.iv78
  %44 = load i32, ptr %34, align 4, !tbaa !5
  call void @_Z5MergePxiS_i(ptr noundef nonnull %41, i32 noundef %42, ptr noundef nonnull %43, i32 noundef %44)
  %45 = load i32, ptr %34, align 4, !tbaa !5
  %46 = load i32, ptr %39, align 4, !tbaa !5
  %47 = add nsw i32 %46, %45
  store i32 %47, ptr %39, align 4, !tbaa !5
  %indvars.iv.next79 = add nsw i64 %indvars.iv78, -1
  %48 = icmp sgt i64 %indvars.iv78, 2
  br i1 %48, label %.lr.ph64, label %.preheader.loopexit, !llvm.loop !14

49:                                               ; preds = %.lr.ph59, %57
  %indvars.iv75 = phi i64 [ 0, %.lr.ph59 ], [ %indvars.iv.next76, %57 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %50 = getelementptr inbounds [5001 x [5001 x i64]], ptr @f, i64 0, i64 %indvars.iv78, i64 %indvars.iv75
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = icmp slt i64 %51, 4611686018427387903
  br i1 %52, label %53, label %57

53:                                               ; preds = %49
  %54 = load i32, ptr %36, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = sub nsw i64 %51, %55
  br label %57

57:                                               ; preds = %49, %53
  %58 = phi i64 [ %56, %53 ], [ 4611686018427387903, %49 ]
  store i64 %58, ptr %1, align 8, !tbaa !9
  %59 = getelementptr inbounds [5001 x [5001 x i64]], ptr @g, i64 0, i64 %indvars.iv78, i64 %indvars.iv75
  %60 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %59)
  %61 = load i64, ptr %60, align 8, !tbaa !9
  %62 = getelementptr inbounds [5001 x i64], ptr @h, i64 0, i64 %indvars.iv75
  store i64 %61, ptr %62, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %63 = load i32, ptr %34, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %.not51.not = icmp slt i64 %indvars.iv75, %64
  br i1 %.not51.not, label %49, label %._crit_edge60, !llvm.loop !15

._crit_edge69:                                    ; preds = %.lr.ph68, %.preheader
  %.043.lcssa = phi i32 [ 0, %.preheader ], [ %spec.select, %.lr.ph68 ]
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.043.lcssa)
  ret i32 0

.lr.ph68:                                         ; preds = %.preheader, %.lr.ph68
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %.lr.ph68 ], [ 1, %.preheader ]
  %.04366 = phi i32 [ %spec.select, %.lr.ph68 ], [ 0, %.preheader ]
  %66 = getelementptr inbounds [5001 x i64], ptr getelementptr inbounds (i8, ptr @f, i64 40008), i64 0, i64 %indvars.iv81
  %67 = getelementptr inbounds [5001 x i64], ptr getelementptr inbounds (i8, ptr @g, i64 40008), i64 0, i64 %indvars.iv81
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %66, ptr noundef nonnull align 8 dereferenceable(8) %67)
  %69 = load i64, ptr %68, align 8, !tbaa !9
  %70 = load i32, ptr @m, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %.not50 = icmp sgt i64 %69, %71
  %72 = trunc nuw nsw i64 %indvars.iv81 to i32
  %spec.select = select i1 %.not50, i32 %.04366, i32 %72
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %73 = load i32, ptr @n, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %.not49.not = icmp slt i64 %indvars.iv81, %74
  br i1 %.not49.not, label %.lr.ph68, label %._crit_edge69, !llvm.loop !16
}

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

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

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 = { 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 #3 = { 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 #4 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12, !13}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.peeled.count", i32 1}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


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