; LLVM IR from tangjz/acm-icpc :: codeforces/gym (100540B)

; 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
@a = external dso_local global [1001 x [1001 x i32]], align 16
@s = external dso_local global [1001 x [1001 x i64]], align 16
@f = external dso_local global [1001 x [1001 x i64]], align 16
@g = external dso_local global [1001 x [1001 x i64]], align 16
@h = external dso_local global [1001 x [1001 x i64]], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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 i64, align 8
  store i32 0, ptr %1, align 4
  br label %11

11:                                               ; preds = %224, %0
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %17

14:                                               ; preds = %11
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br label %17

17:                                               ; preds = %14, %11
  %18 = phi i1 [ false, %11 ], [ %16, %14 ]
  br i1 %18, label %19, label %227

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

20:                                               ; preds = %47, %19
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = icmp sle i32 %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 4, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %50

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

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

30:                                               ; preds = %26
  store i32 7, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %46

31:                                               ; preds = %26
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sub nsw i32 %32, %33
  %35 = add nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %36
  %38 = getelementptr inbounds [1001 x i32], ptr %37, i64 0, i64 0
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %38, i64 %40
  %42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %41)
  br label %43

43:                                               ; preds = %31
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %4, align 4, !tbaa !5
  br label %26, !llvm.loop !11

46:                                               ; preds = %30
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %2, align 4, !tbaa !5
  br label %20, !llvm.loop !13

50:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %51 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %51, ptr %6, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %219, %50
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = load i32, ptr @n, align 4, !tbaa !5
  %55 = icmp sle i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  store i32 10, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %224

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

58:                                               ; preds = %136, %57
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = icmp sle i32 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %139

63:                                               ; preds = %58
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %65
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [1001 x i32], ptr %66, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sub nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %74
  %76 = load i32, ptr %7, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1001 x i64], ptr %75, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !9
  %80 = add nsw i64 %71, %79
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %82
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = sub nsw i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1001 x i64], ptr %83, i64 0, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !9
  %89 = add nsw i64 %80, %88
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = sub nsw i32 %90, 1
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %92
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = sub nsw i32 %94, 1
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [1001 x i64], ptr %93, i64 0, i64 %96
  %98 = load i64, ptr %97, align 8, !tbaa !9
  %99 = sub nsw i64 %89, %98
  %100 = load i32, ptr %5, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %101
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [1001 x i64], ptr %102, i64 0, i64 %104
  store i64 %99, ptr %105, align 8, !tbaa !9
  %106 = load i32, ptr %5, align 4, !tbaa !5
  %107 = sub nsw i32 %106, 1
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [1001 x [1001 x i64]], ptr @h, i64 0, i64 %108
  %110 = load i32, ptr %7, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1001 x i64], ptr %109, i64 0, i64 %111
  %113 = load i64, ptr %112, align 8, !tbaa !9
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %115
  %117 = load i32, ptr %7, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [1001 x i64], ptr %116, i64 0, i64 %118
  %120 = load i64, ptr %119, align 8, !tbaa !9
  %121 = add nsw i64 %113, %120
  %122 = load i32, ptr %5, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [1001 x [1001 x i64]], ptr @f, i64 0, i64 %123
  %125 = load i32, ptr %7, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [1001 x i64], ptr %124, i64 0, i64 %126
  store i64 %121, ptr %127, align 8, !tbaa !9
  %128 = load i32, ptr %5, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [1001 x [1001 x i64]], ptr @f, i64 0, i64 %129
  %131 = load i32, ptr %7, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [1001 x i64], ptr %130, i64 0, i64 %132
  %134 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %133)
  %135 = load i64, ptr %134, align 8, !tbaa !9
  store i64 %135, ptr @ans, align 8, !tbaa !9
  br label %136

136:                                              ; preds = %63
  %137 = load i32, ptr %7, align 4, !tbaa !5
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr %7, align 4, !tbaa !5
  br label %58, !llvm.loop !14

139:                                              ; preds = %62
  %140 = load i32, ptr %5, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [1001 x [1001 x i64]], ptr @g, i64 0, i64 %141
  %143 = load i32, ptr %6, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [1001 x i64], ptr %142, i64 0, i64 %145
  store i64 -4557430888798830399, ptr %146, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %147 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %147, ptr %8, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %174, %139
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = icmp sge i32 %149, 1
  br i1 %150, label %152, label %151

151:                                              ; preds = %148
  store i32 16, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %177

152:                                              ; preds = %148
  %153 = load i32, ptr %5, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [1001 x [1001 x i64]], ptr @g, i64 0, i64 %154
  %156 = load i32, ptr %8, align 4, !tbaa !5
  %157 = add nsw i32 %156, 1
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1001 x i64], ptr %155, i64 0, i64 %158
  %160 = load i32, ptr %5, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [1001 x [1001 x i64]], ptr @f, i64 0, i64 %161
  %163 = load i32, ptr %8, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [1001 x i64], ptr %162, i64 0, i64 %164
  %166 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %159, ptr noundef nonnull align 8 dereferenceable(8) %165)
  %167 = load i64, ptr %166, align 8, !tbaa !9
  %168 = load i32, ptr %5, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [1001 x [1001 x i64]], ptr @g, i64 0, i64 %169
  %171 = load i32, ptr %8, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [1001 x i64], ptr %170, i64 0, i64 %172
  store i64 %167, ptr %173, align 8, !tbaa !9
  br label %174

174:                                              ; preds = %152
  %175 = load i32, ptr %8, align 4, !tbaa !5
  %176 = add nsw i32 %175, -1
  store i32 %176, ptr %8, align 4, !tbaa !5
  br label %148, !llvm.loop !15

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

178:                                              ; preds = %215, %177
  %179 = load i32, ptr %9, align 4, !tbaa !5
  %180 = load i32, ptr %6, align 4, !tbaa !5
  %181 = icmp sle i32 %179, %180
  br i1 %181, label %183, label %182

182:                                              ; preds = %178
  store i32 19, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %218

183:                                              ; preds = %178
  %184 = load i32, ptr %5, align 4, !tbaa !5
  %185 = sub nsw i32 %184, 1
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [1001 x [1001 x i64]], ptr @h, i64 0, i64 %186
  %188 = load i32, ptr %9, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [1001 x i64], ptr %187, i64 0, i64 %189
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %191 = load i32, ptr %5, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [1001 x [1001 x i64]], ptr @g, i64 0, i64 %192
  %194 = load i32, ptr %9, align 4, !tbaa !5
  %195 = add nsw i32 %194, 1
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [1001 x i64], ptr %193, i64 0, i64 %196
  %198 = load i64, ptr %197, align 8, !tbaa !9
  %199 = load i32, ptr %5, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %200
  %202 = load i32, ptr %9, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [1001 x i64], ptr %201, i64 0, i64 %203
  %205 = load i64, ptr %204, align 8, !tbaa !9
  %206 = sub nsw i64 %198, %205
  store i64 %206, ptr %10, align 8, !tbaa !9
  %207 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %190, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %208 = load i64, ptr %207, align 8, !tbaa !9
  %209 = load i32, ptr %5, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [1001 x [1001 x i64]], ptr @h, i64 0, i64 %210
  %212 = load i32, ptr %9, align 4, !tbaa !5
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [1001 x i64], ptr %211, i64 0, i64 %213
  store i64 %208, ptr %214, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %215

215:                                              ; preds = %183
  %216 = load i32, ptr %9, align 4, !tbaa !5
  %217 = add nsw i32 %216, 1
  store i32 %217, ptr %9, align 4, !tbaa !5
  br label %178, !llvm.loop !16

218:                                              ; preds = %182
  br label %219

219:                                              ; preds = %218
  %220 = load i32, ptr %5, align 4, !tbaa !5
  %221 = add nsw i32 %220, 1
  store i32 %221, ptr %5, align 4, !tbaa !5
  %222 = load i32, ptr %6, align 4, !tbaa !5
  %223 = add nsw i32 %222, -1
  store i32 %223, ptr %6, align 4, !tbaa !5
  br label %52, !llvm.loop !17

224:                                              ; preds = %56
  %225 = load i64, ptr @ans, align 8, !tbaa !9
  %226 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %225)
  br label %11, !llvm.loop !18

227:                                              ; preds = %17
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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

attributes #0 = { 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 #1 = { "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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !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
@a = external dso_local global [1001 x [1001 x i32]], align 16
@s = external dso_local local_unnamed_addr global [1001 x [1001 x i64]], align 16
@f = external dso_local global [1001 x [1001 x i64]], align 16
@g = external dso_local global [1001 x [1001 x i64]], align 16
@h = external dso_local global [1001 x [1001 x i64]], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %3 = icmp eq i32 %2, 1
  %4 = load i32, ptr @n, align 4
  %5 = icmp ne i32 %4, 0
  %6 = select i1 %3, i1 %5, i1 false
  br i1 %6, label %.lr.ph85, label %._crit_edge86

.lr.ph85:                                         ; preds = %0, %._crit_edge83
  %7 = phi i32 [ %26, %._crit_edge83 ], [ %4, %0 ]
  store i64 0, ptr @ans, align 8, !tbaa !5
  %.not69 = icmp slt i32 %7, 1
  br i1 %.not69, label %._crit_edge83, label %.preheader66

.preheader67:                                     ; preds = %10
  %.not6180 = icmp slt i32 %11, 1
  br i1 %.not6180, label %._crit_edge83, label %.preheader65.preheader

.preheader65.preheader:                           ; preds = %.preheader67
  %8 = add nuw i32 %11, 1
  %9 = zext nneg i32 %11 to i64
  br label %.preheader65

.preheader66:                                     ; preds = %.lr.ph85, %10
  %indvars.iv93 = phi i64 [ %indvars.iv.next94, %10 ], [ 1, %.lr.ph85 ]
  %indvars.iv91 = phi i64 [ %indvars.iv.next92, %10 ], [ 2, %.lr.ph85 ]
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  br label %13

10:                                               ; preds = %13
  %11 = load i32, ptr @n, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %.not.not = icmp slt i64 %indvars.iv93, %12
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  br i1 %.not.not, label %.preheader66, label %.preheader67, !llvm.loop !11

13:                                               ; preds = %.preheader66, %13
  %indvars.iv = phi i64 [ 1, %.preheader66 ], [ %indvars.iv.next, %13 ]
  %14 = sub nsw i64 %indvars.iv.next94, %indvars.iv
  %15 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %14
  %16 = getelementptr inbounds i32, ptr %15, i64 %indvars.iv
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %16)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %indvars.iv91
  br i1 %exitcond.not, label %10, label %13, !llvm.loop !13

.preheader65:                                     ; preds = %.preheader65.preheader, %._crit_edge79
  %indvars.iv114 = phi i64 [ 1, %.preheader65.preheader ], [ %indvars.iv.next115, %._crit_edge79 ]
  %indvars.iv112 = phi i64 [ %9, %.preheader65.preheader ], [ %indvars.iv.next113, %._crit_edge79 ]
  %indvars.iv101 = phi i32 [ %8, %.preheader65.preheader ], [ %indvars.iv.next102, %._crit_edge79 ]
  %18 = and i64 %indvars.iv112, 4294967295
  %.not6271 = icmp slt i64 %indvars.iv112, 1
  br i1 %.not6271, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %.preheader65
  %19 = add nsw i64 %indvars.iv112, 1
  %20 = getelementptr inbounds [1001 x [1001 x i64]], ptr @g, i64 0, i64 %indvars.iv114, i64 %19
  store i64 -4557430888798830399, ptr %20, align 8, !tbaa !5
  br label %._crit_edge79

.lr.ph:                                           ; preds = %.preheader65
  %21 = add nsw i64 %indvars.iv114, -1
  %wide.trip.count = zext i32 %indvars.iv101 to i64
  br label %31

._crit_edge83:                                    ; preds = %._crit_edge79, %.lr.ph85, %.preheader67
  %22 = load i64, ptr @ans, align 8, !tbaa !5
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %22)
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %25 = icmp eq i32 %24, 1
  %26 = load i32, ptr @n, align 4
  %27 = icmp ne i32 %26, 0
  %28 = select i1 %25, i1 %27, i1 false
  br i1 %28, label %.lr.ph85, label %._crit_edge86, !llvm.loop !14

._crit_edge:                                      ; preds = %31
  %29 = add nuw nsw i64 %indvars.iv112, 1
  %30 = getelementptr inbounds [1001 x [1001 x i64]], ptr @g, i64 0, i64 %indvars.iv114, i64 %29
  store i64 -4557430888798830399, ptr %30, align 8, !tbaa !5
  br label %.lr.ph75

31:                                               ; preds = %.lr.ph, %31
  %indvars.iv98 = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next99, %31 ]
  %32 = getelementptr inbounds [1001 x [1001 x i32]], ptr @a, i64 0, i64 %indvars.iv114, i64 %indvars.iv98
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %21, i64 %indvars.iv98
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = add nsw i64 %36, %34
  %38 = add nsw i64 %indvars.iv98, -1
  %39 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %indvars.iv114, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !5
  %41 = add nsw i64 %37, %40
  %42 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %21, i64 %38
  %43 = load i64, ptr %42, align 8, !tbaa !5
  %44 = sub i64 %41, %43
  %45 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %indvars.iv114, i64 %indvars.iv98
  store i64 %44, ptr %45, align 8, !tbaa !5
  %46 = getelementptr inbounds [1001 x [1001 x i64]], ptr @h, i64 0, i64 %21, i64 %indvars.iv98
  %47 = load i64, ptr %46, align 8, !tbaa !5
  %48 = add nsw i64 %47, %44
  %49 = getelementptr inbounds [1001 x [1001 x i64]], ptr @f, i64 0, i64 %indvars.iv114, i64 %indvars.iv98
  store i64 %48, ptr %49, align 8, !tbaa !5
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %49)
  %51 = load i64, ptr %50, align 8, !tbaa !5
  store i64 %51, ptr @ans, align 8, !tbaa !5
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %exitcond103.not = icmp eq i64 %indvars.iv.next99, %wide.trip.count
  br i1 %exitcond103.not, label %._crit_edge, label %31, !llvm.loop !15

.preheader:                                       ; preds = %.lr.ph75
  br i1 %.not6271, label %._crit_edge79, label %.lr.ph78

.lr.ph78:                                         ; preds = %.preheader
  %52 = add nsw i64 %indvars.iv114, -1
  %wide.trip.count110 = zext i32 %indvars.iv101 to i64
  br label %63

.lr.ph75:                                         ; preds = %._crit_edge, %.lr.ph75
  %indvars.iv104 = phi i64 [ %indvars.iv.next105, %.lr.ph75 ], [ %18, %._crit_edge ]
  %53 = add nuw nsw i64 %indvars.iv104, 1
  %54 = getelementptr inbounds [1001 x [1001 x i64]], ptr @g, i64 0, i64 %indvars.iv114, i64 %53
  %55 = getelementptr inbounds [1001 x [1001 x i64]], ptr @f, i64 0, i64 %indvars.iv114, i64 %indvars.iv104
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %54, ptr noundef nonnull align 8 dereferenceable(8) %55)
  %57 = load i64, ptr %56, align 8, !tbaa !5
  %58 = getelementptr inbounds [1001 x [1001 x i64]], ptr @g, i64 0, i64 %indvars.iv114, i64 %indvars.iv104
  store i64 %57, ptr %58, align 8, !tbaa !5
  %indvars.iv.next105 = add nsw i64 %indvars.iv104, -1
  %59 = trunc nuw i64 %indvars.iv104 to i32
  %60 = icmp sgt i32 %59, 1
  br i1 %60, label %.lr.ph75, label %.preheader, !llvm.loop !16

._crit_edge79:                                    ; preds = %63, %._crit_edge.thread, %.preheader
  %indvars.iv.next115 = add nuw nsw i64 %indvars.iv114, 1
  %indvars.iv.next113 = add nsw i64 %indvars.iv112, -1
  %61 = load i32, ptr @n, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %.not61.not = icmp slt i64 %indvars.iv114, %62
  %indvars.iv.next102 = add i32 %indvars.iv101, -1
  br i1 %.not61.not, label %.preheader65, label %._crit_edge83, !llvm.loop !17

63:                                               ; preds = %.lr.ph78, %63
  %indvars.iv107 = phi i64 [ 1, %.lr.ph78 ], [ %indvars.iv.next108, %63 ]
  %64 = getelementptr inbounds [1001 x [1001 x i64]], ptr @h, i64 0, i64 %52, i64 %indvars.iv107
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %65 = getelementptr inbounds [1001 x [1001 x i64]], ptr @g, i64 0, i64 %indvars.iv114, i64 %indvars.iv.next108
  %66 = load i64, ptr %65, align 8, !tbaa !5
  %67 = getelementptr inbounds [1001 x [1001 x i64]], ptr @s, i64 0, i64 %indvars.iv114, i64 %indvars.iv107
  %68 = load i64, ptr %67, align 8, !tbaa !5
  %69 = sub nsw i64 %66, %68
  store i64 %69, ptr %1, align 8, !tbaa !5
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %64, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %71 = load i64, ptr %70, align 8, !tbaa !5
  %72 = getelementptr inbounds [1001 x [1001 x i64]], ptr @h, i64 0, i64 %indvars.iv114, i64 %indvars.iv107
  store i64 %71, ptr %72, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  %exitcond111.not = icmp eq i64 %indvars.iv.next108, %wide.trip.count110
  br i1 %exitcond111.not, label %._crit_edge79, label %63, !llvm.loop !18

._crit_edge86:                                    ; preds = %._crit_edge83, %0
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

attributes #0 = { mustprogress norecurse 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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