; LLVM IR from tangjz/acm-icpc :: codeforces/complete (536D)

; 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"

%"struct.std::pair" = type <{ i64, i32, [4 x i8] }>

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@S = external dso_local global i32, align 4
@T = external dso_local global i32, align 4
@a = external dso_local global [2001 x i32], align 16
@e = external dso_local global [2001 x [2001 x i32]], align 16
@p = external dso_local global [2 x [2001 x i32]], align 16
@c = external dso_local global [2001 x [2001 x i32]], align 16
@s = external dso_local global [2001 x [2001 x i64]], align 16
@f = external dso_local global [2001 x [2001 x i64]], align 16
@g = external dso_local global [2001 x [2001 x i64]], align 16
@mf = external dso_local global [2001 x %"struct.std::pair"], align 16
@mg = external dso_local global [2001 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@_ZL4INF2 = external hidden constant i64, align 8
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %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 %"struct.std::pair", align 8
  %11 = alloca { i64, i32 }, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"struct.std::pair", align 8
  %14 = alloca { i64, i32 }, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m, ptr noundef @S, ptr noundef @T)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %21

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

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

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr @a, i64 %28
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %29)
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [2001 x [2001 x i32]], ptr @e, i64 0, i64 %32
  %34 = getelementptr inbounds [2001 x i32], ptr %33, i64 0, i64 0
  %35 = getelementptr inbounds i32, ptr %34, i64 1
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = mul i64 %37, 4
  call void @llvm.memset.p0.i64(ptr align 4 %35, i8 63, i64 %38, i1 false)
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [2001 x [2001 x i32]], ptr @e, i64 0, i64 %40
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [2001 x i32], ptr %41, i64 0, i64 %43
  store i32 0, ptr %44, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %26
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %2, align 4, !tbaa !5
  br label %21, !llvm.loop !9

48:                                               ; preds = %25
  br label %49

49:                                               ; preds = %78, %48
  %50 = load i32, ptr @m, align 4, !tbaa !5
  %51 = add nsw i32 %50, -1
  store i32 %51, ptr @m, align 4, !tbaa !5
  %52 = icmp ne i32 %50, 0
  br i1 %52, label %53, label %79

53:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  %54 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [2001 x [2001 x i32]], ptr @e, i64 0, i64 %56
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [2001 x i32], ptr %57, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = icmp sgt i32 %61, %62
  br i1 %63, label %64, label %78

64:                                               ; preds = %53
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [2001 x [2001 x i32]], ptr @e, i64 0, i64 %67
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [2001 x i32], ptr %68, i64 0, i64 %70
  store i32 %65, ptr %71, align 4, !tbaa !5
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [2001 x [2001 x i32]], ptr @e, i64 0, i64 %73
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [2001 x i32], ptr %74, i64 0, i64 %76
  store i32 %65, ptr %77, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %64, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %49, !llvm.loop !11

79:                                               ; preds = %49
  %80 = load i32, ptr @S, align 4, !tbaa !5
  %81 = call noundef i32 @_Z7getDistiPi(i32 noundef %80, ptr noundef @p)
  store i32 %81, ptr @S, align 4, !tbaa !5
  %82 = load i32, ptr @T, align 4, !tbaa !5
  %83 = call noundef i32 @_Z7getDistiPi(i32 noundef %82, ptr noundef getelementptr inbounds ([2 x [2001 x i32]], ptr @p, i64 0, i64 1))
  store i32 %83, ptr @T, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %119, %79
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = icmp sle i32 %85, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  br label %122

89:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [2001 x i32], ptr @p, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  store i32 %93, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %94 = load i32, ptr %6, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds ([2 x [2001 x i32]], ptr @p, i64 0, i64 1), i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  store i32 %97, ptr %8, align 4, !tbaa !5
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %99
  %101 = load i32, ptr %8, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2001 x i32], ptr %100, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %103, align 4, !tbaa !5
  %106 = load i32, ptr %6, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [2001 x i32], ptr @a, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %112
  %114 = load i32, ptr %8, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [2001 x i64], ptr %113, i64 0, i64 %115
  %117 = load i64, ptr %116, align 8, !tbaa !12
  %118 = add nsw i64 %117, %110
  store i64 %118, ptr %116, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %119

119:                                              ; preds = %89
  %120 = load i32, ptr %6, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %6, align 4, !tbaa !5
  br label %84, !llvm.loop !14

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

123:                                              ; preds = %134, %122
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = load i32, ptr @S, align 4, !tbaa !5
  %126 = icmp slt i32 %124, %125
  br i1 %126, label %128, label %127

127:                                              ; preds = %123
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %137

128:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #8
  %129 = call { i64, i32 } @_ZSt9make_pairIRKxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS4_INS5_IT0_E4typeEE6__typeEEOS6_OSB_(ptr noundef nonnull align 8 dereferenceable(8) @_ZL4INF2, ptr noundef nonnull align 4 dereferenceable(4) @T)
  store { i64, i32 } %129, ptr %11, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %11, i64 12, i1 false)
  %130 = load i32, ptr %9, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mf, i64 0, i64 %131
  %133 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt4pairIxiEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(12) %132, ptr noundef nonnull align 8 dereferenceable(12) %10) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #8
  br label %134

134:                                              ; preds = %128
  %135 = load i32, ptr %9, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %9, align 4, !tbaa !5
  br label %123, !llvm.loop !15

137:                                              ; preds = %127
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %138

138:                                              ; preds = %149, %137
  %139 = load i32, ptr %12, align 4, !tbaa !5
  %140 = load i32, ptr @T, align 4, !tbaa !5
  %141 = icmp slt i32 %139, %140
  br i1 %141, label %143, label %142

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

143:                                              ; preds = %138
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #8
  %144 = call { i64, i32 } @_ZSt9make_pairIRKxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS4_INS5_IT0_E4typeEE6__typeEEOS6_OSB_(ptr noundef nonnull align 8 dereferenceable(8) @_ZL4INF2, ptr noundef nonnull align 4 dereferenceable(4) @S)
  store { i64, i32 } %144, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %14, i64 12, i1 false)
  %145 = load i32, ptr %12, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mg, i64 0, i64 %146
  %148 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt4pairIxiEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(12) %147, ptr noundef nonnull align 8 dereferenceable(12) %13) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #8
  br label %149

149:                                              ; preds = %143
  %150 = load i32, ptr %12, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  store i32 %151, ptr %12, align 4, !tbaa !5
  br label %138, !llvm.loop !16

152:                                              ; preds = %142
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %153 = load i32, ptr @S, align 4, !tbaa !5
  %154 = sub nsw i32 %153, 1
  store i32 %154, ptr %15, align 4, !tbaa !5
  br label %155

155:                                              ; preds = %399, %152
  %156 = load i32, ptr %15, align 4, !tbaa !5
  %157 = icmp sge i32 %156, 0
  br i1 %157, label %159, label %158

158:                                              ; preds = %155
  store i32 16, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %402

159:                                              ; preds = %155
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  %160 = load i32, ptr @T, align 4, !tbaa !5
  %161 = sub nsw i32 %160, 1
  store i32 %161, ptr %17, align 4, !tbaa !5
  br label %162

162:                                              ; preds = %395, %159
  %163 = load i32, ptr %17, align 4, !tbaa !5
  %164 = icmp sge i32 %163, 0
  br i1 %164, label %166, label %165

165:                                              ; preds = %162
  store i32 19, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %398

166:                                              ; preds = %162
  %167 = load i32, ptr %15, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %168
  %170 = load i32, ptr %17, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [2001 x i32], ptr %169, i64 0, i64 %171
  %173 = load i32, ptr %172, align 4, !tbaa !5
  %174 = load i32, ptr %15, align 4, !tbaa !5
  %175 = add nsw i32 %174, 1
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %176
  %178 = load i32, ptr %17, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [2001 x i32], ptr %177, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = add nsw i32 %173, %181
  %183 = load i32, ptr %15, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %184
  %186 = load i32, ptr %17, align 4, !tbaa !5
  %187 = add nsw i32 %186, 1
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [2001 x i32], ptr %185, i64 0, i64 %188
  %190 = load i32, ptr %189, align 4, !tbaa !5
  %191 = add nsw i32 %182, %190
  %192 = load i32, ptr %15, align 4, !tbaa !5
  %193 = add nsw i32 %192, 1
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %194
  %196 = load i32, ptr %17, align 4, !tbaa !5
  %197 = add nsw i32 %196, 1
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds [2001 x i32], ptr %195, i64 0, i64 %198
  %200 = load i32, ptr %199, align 4, !tbaa !5
  %201 = sub nsw i32 %191, %200
  %202 = load i32, ptr %15, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %203
  %205 = load i32, ptr %17, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [2001 x i32], ptr %204, i64 0, i64 %206
  store i32 %201, ptr %207, align 4, !tbaa !5
  %208 = load i32, ptr %15, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %209
  %211 = load i32, ptr %17, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [2001 x i64], ptr %210, i64 0, i64 %212
  %214 = load i64, ptr %213, align 8, !tbaa !12
  %215 = load i32, ptr %15, align 4, !tbaa !5
  %216 = add nsw i32 %215, 1
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %217
  %219 = load i32, ptr %17, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [2001 x i64], ptr %218, i64 0, i64 %220
  %222 = load i64, ptr %221, align 8, !tbaa !12
  %223 = add nsw i64 %214, %222
  %224 = load i32, ptr %15, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %225
  %227 = load i32, ptr %17, align 4, !tbaa !5
  %228 = add nsw i32 %227, 1
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [2001 x i64], ptr %226, i64 0, i64 %229
  %231 = load i64, ptr %230, align 8, !tbaa !12
  %232 = add nsw i64 %223, %231
  %233 = load i32, ptr %15, align 4, !tbaa !5
  %234 = add nsw i32 %233, 1
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %235
  %237 = load i32, ptr %17, align 4, !tbaa !5
  %238 = add nsw i32 %237, 1
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [2001 x i64], ptr %236, i64 0, i64 %239
  %241 = load i64, ptr %240, align 8, !tbaa !12
  %242 = sub nsw i64 %232, %241
  %243 = load i32, ptr %15, align 4, !tbaa !5
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %244
  %246 = load i32, ptr %17, align 4, !tbaa !5
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds [2001 x i64], ptr %245, i64 0, i64 %247
  store i64 %242, ptr %248, align 8, !tbaa !12
  %249 = load i32, ptr %15, align 4, !tbaa !5
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %250
  %252 = load i32, ptr %17, align 4, !tbaa !5
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [2001 x i32], ptr %251, i64 0, i64 %253
  %255 = load i32, ptr %254, align 4, !tbaa !5
  %256 = icmp ne i32 %255, 0
  br i1 %256, label %258, label %257

257:                                              ; preds = %166
  br label %395

258:                                              ; preds = %166
  br label %259

259:                                              ; preds = %300, %258
  %260 = load i32, ptr %17, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mg, i64 0, i64 %261
  %263 = getelementptr inbounds %"struct.std::pair", ptr %262, i32 0, i32 1
  %264 = load i32, ptr %263, align 8, !tbaa !17
  %265 = sext i32 %264 to i64
  %266 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %265
  %267 = load i32, ptr %17, align 4, !tbaa !5
  %268 = sext i32 %267 to i64
  %269 = getelementptr inbounds [2001 x i32], ptr %266, i64 0, i64 %268
  %270 = load i32, ptr %269, align 4, !tbaa !5
  %271 = load i32, ptr %15, align 4, !tbaa !5
  %272 = sext i32 %271 to i64
  %273 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %272
  %274 = load i32, ptr %17, align 4, !tbaa !5
  %275 = sext i32 %274 to i64
  %276 = getelementptr inbounds [2001 x i32], ptr %273, i64 0, i64 %275
  %277 = load i32, ptr %276, align 4, !tbaa !5
  %278 = icmp slt i32 %270, %277
  br i1 %278, label %279, label %307

279:                                              ; preds = %259
  %280 = load i32, ptr %17, align 4, !tbaa !5
  %281 = sext i32 %280 to i64
  %282 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mg, i64 0, i64 %281
  %283 = getelementptr inbounds %"struct.std::pair", ptr %282, i32 0, i32 0
  %284 = load i32, ptr %17, align 4, !tbaa !5
  %285 = sext i32 %284 to i64
  %286 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mg, i64 0, i64 %285
  %287 = getelementptr inbounds %"struct.std::pair", ptr %286, i32 0, i32 1
  %288 = load i32, ptr %287, align 8, !tbaa !17
  %289 = sext i32 %288 to i64
  %290 = getelementptr inbounds [2001 x [2001 x i64]], ptr @g, i64 0, i64 %289
  %291 = load i32, ptr %17, align 4, !tbaa !5
  %292 = sext i32 %291 to i64
  %293 = getelementptr inbounds [2001 x i64], ptr %290, i64 0, i64 %292
  %294 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %283, ptr noundef nonnull align 8 dereferenceable(8) %293)
  %295 = load i64, ptr %294, align 8, !tbaa !12
  %296 = load i32, ptr %17, align 4, !tbaa !5
  %297 = sext i32 %296 to i64
  %298 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mg, i64 0, i64 %297
  %299 = getelementptr inbounds %"struct.std::pair", ptr %298, i32 0, i32 0
  store i64 %295, ptr %299, align 16, !tbaa !19
  br label %300

300:                                              ; preds = %279
  %301 = load i32, ptr %17, align 4, !tbaa !5
  %302 = sext i32 %301 to i64
  %303 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mg, i64 0, i64 %302
  %304 = getelementptr inbounds %"struct.std::pair", ptr %303, i32 0, i32 1
  %305 = load i32, ptr %304, align 8, !tbaa !17
  %306 = add nsw i32 %305, -1
  store i32 %306, ptr %304, align 8, !tbaa !17
  br label %259, !llvm.loop !20

307:                                              ; preds = %259
  %308 = load i32, ptr %15, align 4, !tbaa !5
  %309 = sext i32 %308 to i64
  %310 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %309
  %311 = load i32, ptr %17, align 4, !tbaa !5
  %312 = sext i32 %311 to i64
  %313 = getelementptr inbounds [2001 x i64], ptr %310, i64 0, i64 %312
  %314 = load i64, ptr %313, align 8, !tbaa !12
  %315 = load i32, ptr %17, align 4, !tbaa !5
  %316 = sext i32 %315 to i64
  %317 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mg, i64 0, i64 %316
  %318 = getelementptr inbounds %"struct.std::pair", ptr %317, i32 0, i32 0
  %319 = load i64, ptr %318, align 16, !tbaa !19
  %320 = sub nsw i64 %314, %319
  %321 = load i32, ptr %15, align 4, !tbaa !5
  %322 = sext i32 %321 to i64
  %323 = getelementptr inbounds [2001 x [2001 x i64]], ptr @f, i64 0, i64 %322
  %324 = load i32, ptr %17, align 4, !tbaa !5
  %325 = sext i32 %324 to i64
  %326 = getelementptr inbounds [2001 x i64], ptr %323, i64 0, i64 %325
  store i64 %320, ptr %326, align 8, !tbaa !12
  br label %327

327:                                              ; preds = %368, %307
  %328 = load i32, ptr %15, align 4, !tbaa !5
  %329 = sext i32 %328 to i64
  %330 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %329
  %331 = load i32, ptr %15, align 4, !tbaa !5
  %332 = sext i32 %331 to i64
  %333 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mf, i64 0, i64 %332
  %334 = getelementptr inbounds %"struct.std::pair", ptr %333, i32 0, i32 1
  %335 = load i32, ptr %334, align 8, !tbaa !17
  %336 = sext i32 %335 to i64
  %337 = getelementptr inbounds [2001 x i32], ptr %330, i64 0, i64 %336
  %338 = load i32, ptr %337, align 4, !tbaa !5
  %339 = load i32, ptr %15, align 4, !tbaa !5
  %340 = sext i32 %339 to i64
  %341 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %340
  %342 = load i32, ptr %17, align 4, !tbaa !5
  %343 = sext i32 %342 to i64
  %344 = getelementptr inbounds [2001 x i32], ptr %341, i64 0, i64 %343
  %345 = load i32, ptr %344, align 4, !tbaa !5
  %346 = icmp slt i32 %338, %345
  br i1 %346, label %347, label %375

347:                                              ; preds = %327
  %348 = load i32, ptr %15, align 4, !tbaa !5
  %349 = sext i32 %348 to i64
  %350 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mf, i64 0, i64 %349
  %351 = getelementptr inbounds %"struct.std::pair", ptr %350, i32 0, i32 0
  %352 = load i32, ptr %15, align 4, !tbaa !5
  %353 = sext i32 %352 to i64
  %354 = getelementptr inbounds [2001 x [2001 x i64]], ptr @f, i64 0, i64 %353
  %355 = load i32, ptr %15, align 4, !tbaa !5
  %356 = sext i32 %355 to i64
  %357 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mf, i64 0, i64 %356
  %358 = getelementptr inbounds %"struct.std::pair", ptr %357, i32 0, i32 1
  %359 = load i32, ptr %358, align 8, !tbaa !17
  %360 = sext i32 %359 to i64
  %361 = getelementptr inbounds [2001 x i64], ptr %354, i64 0, i64 %360
  %362 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %351, ptr noundef nonnull align 8 dereferenceable(8) %361)
  %363 = load i64, ptr %362, align 8, !tbaa !12
  %364 = load i32, ptr %15, align 4, !tbaa !5
  %365 = sext i32 %364 to i64
  %366 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mf, i64 0, i64 %365
  %367 = getelementptr inbounds %"struct.std::pair", ptr %366, i32 0, i32 0
  store i64 %363, ptr %367, align 16, !tbaa !19
  br label %368

368:                                              ; preds = %347
  %369 = load i32, ptr %15, align 4, !tbaa !5
  %370 = sext i32 %369 to i64
  %371 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mf, i64 0, i64 %370
  %372 = getelementptr inbounds %"struct.std::pair", ptr %371, i32 0, i32 1
  %373 = load i32, ptr %372, align 8, !tbaa !17
  %374 = add nsw i32 %373, -1
  store i32 %374, ptr %372, align 8, !tbaa !17
  br label %327, !llvm.loop !21

375:                                              ; preds = %327
  %376 = load i32, ptr %15, align 4, !tbaa !5
  %377 = sext i32 %376 to i64
  %378 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %377
  %379 = load i32, ptr %17, align 4, !tbaa !5
  %380 = sext i32 %379 to i64
  %381 = getelementptr inbounds [2001 x i64], ptr %378, i64 0, i64 %380
  %382 = load i64, ptr %381, align 8, !tbaa !12
  %383 = load i32, ptr %15, align 4, !tbaa !5
  %384 = sext i32 %383 to i64
  %385 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mf, i64 0, i64 %384
  %386 = getelementptr inbounds %"struct.std::pair", ptr %385, i32 0, i32 0
  %387 = load i64, ptr %386, align 16, !tbaa !19
  %388 = sub nsw i64 %382, %387
  %389 = load i32, ptr %15, align 4, !tbaa !5
  %390 = sext i32 %389 to i64
  %391 = getelementptr inbounds [2001 x [2001 x i64]], ptr @g, i64 0, i64 %390
  %392 = load i32, ptr %17, align 4, !tbaa !5
  %393 = sext i32 %392 to i64
  %394 = getelementptr inbounds [2001 x i64], ptr %391, i64 0, i64 %393
  store i64 %388, ptr %394, align 8, !tbaa !12
  br label %395

395:                                              ; preds = %375, %257
  %396 = load i32, ptr %17, align 4, !tbaa !5
  %397 = add nsw i32 %396, -1
  store i32 %397, ptr %17, align 4, !tbaa !5
  br label %162, !llvm.loop !22

398:                                              ; preds = %165
  br label %399

399:                                              ; preds = %398
  %400 = load i32, ptr %15, align 4, !tbaa !5
  %401 = add nsw i32 %400, -1
  store i32 %401, ptr %15, align 4, !tbaa !5
  br label %155, !llvm.loop !23

402:                                              ; preds = %158
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %403 = load i64, ptr @f, align 16, !tbaa !12
  store i64 %403, ptr %18, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #8
  %404 = load i64, ptr @s, align 16, !tbaa !12
  %405 = load i64, ptr @f, align 16, !tbaa !12
  %406 = sub nsw i64 %404, %405
  store i64 %406, ptr %19, align 8, !tbaa !12
  %407 = load i64, ptr %18, align 8, !tbaa !12
  %408 = load i64, ptr %19, align 8, !tbaa !12
  %409 = icmp sgt i64 %407, %408
  br i1 %409, label %410, label %411

410:                                              ; preds = %402
  br label %417

411:                                              ; preds = %402
  %412 = load i64, ptr %18, align 8, !tbaa !12
  %413 = load i64, ptr %19, align 8, !tbaa !12
  %414 = icmp slt i64 %412, %413
  %415 = zext i1 %414 to i64
  %416 = select i1 %414, ptr @.str.4, ptr @.str.5
  br label %417

417:                                              ; preds = %411, %410
  %418 = phi ptr [ @.str.3, %410 ], [ %416, %411 ]
  %419 = call i32 @puts(ptr noundef %418)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  %420 = load i32, ptr %1, align 4
  ret i32 %420
}

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZSt9make_pairIRKxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS4_INS5_IT0_E4typeEE6__typeEEOS6_OSB_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt4pairIxiEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) #7 align 2

declare i32 @puts(ptr noundef) #5

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 nounwind willreturn memory(argmem: write) }
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 = { 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 #5 = { "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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 #8 = { 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 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = !{!18, !6, i64 8}
!18 = !{!"_ZTSSt4pairIxiE", !13, i64 0, !6, i64 8}
!19 = !{!18, !13, i64 0}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !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"

%"struct.std::pair" = type <{ i64, i32, [4 x i8] }>

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@S = external dso_local global i32, align 4
@T = external dso_local global i32, align 4
@a = external dso_local global [2001 x i32], align 16
@e = external dso_local local_unnamed_addr global [2001 x [2001 x i32]], align 16
@p = external dso_local global [2 x [2001 x i32]], align 16
@c = external dso_local local_unnamed_addr global [2001 x [2001 x i32]], align 16
@s = external dso_local local_unnamed_addr global [2001 x [2001 x i64]], align 16
@f = external dso_local global [2001 x [2001 x i64]], align 16
@g = external dso_local global [2001 x [2001 x i64]], align 16
@mf = external dso_local global [2001 x %"struct.std::pair"], align 16
@mg = external dso_local global [2001 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@_ZL4INF2 = external hidden constant i64, align 8
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca %"struct.std::pair", align 8
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @S, ptr noundef nonnull @T)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not99 = icmp slt i32 %7, 1
  br i1 %.not99, label %.preheader97, label %.lr.ph

.preheader97:                                     ; preds = %.lr.ph, %0
  %8 = load i32, ptr @m, align 4, !tbaa !5
  %9 = add nsw i32 %8, -1
  store i32 %9, ptr @m, align 4, !tbaa !5
  %.not92101 = icmp eq i32 %8, 0
  br i1 %.not92101, label %._crit_edge, label %.lr.ph102

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %10 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %10)
  %12 = getelementptr inbounds [2001 x [2001 x i32]], ptr @e, i64 0, i64 %indvars.iv, i64 1
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = shl nsw i64 %14, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 %12, i8 63, i64 %15, i1 false)
  %16 = getelementptr inbounds [2001 x [2001 x i32]], ptr @e, i64 0, i64 %indvars.iv, i64 %indvars.iv
  store i32 0, ptr %16, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not.not = icmp slt i64 %indvars.iv, %14
  br i1 %.not.not, label %.lr.ph, label %.preheader97, !llvm.loop !9

.lr.ph102:                                        ; preds = %.preheader97, %28
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [2001 x [2001 x i32]], ptr @e, i64 0, i64 %19, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = icmp sgt i32 %23, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %.lr.ph102
  %27 = getelementptr inbounds [2001 x [2001 x i32]], ptr @e, i64 0, i64 %21, i64 %19
  store i32 %24, ptr %27, align 4, !tbaa !5
  store i32 %24, ptr %22, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %26, %.lr.ph102
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %29 = load i32, ptr @m, align 4, !tbaa !5
  %30 = add nsw i32 %29, -1
  store i32 %30, ptr @m, align 4, !tbaa !5
  %.not92 = icmp eq i32 %29, 0
  br i1 %.not92, label %._crit_edge, label %.lr.ph102, !llvm.loop !11

._crit_edge:                                      ; preds = %28, %.preheader97
  %31 = load i32, ptr @S, align 4, !tbaa !5
  %32 = call noundef i32 @_Z7getDistiPi(i32 noundef %31, ptr noundef nonnull @p)
  store i32 %32, ptr @S, align 4, !tbaa !5
  %33 = load i32, ptr @T, align 4, !tbaa !5
  %34 = call noundef i32 @_Z7getDistiPi(i32 noundef %33, ptr noundef nonnull getelementptr inbounds (i8, ptr @p, i64 8004))
  store i32 %34, ptr @T, align 4, !tbaa !5
  %35 = load i32, ptr @n, align 4, !tbaa !5
  %.not93103 = icmp slt i32 %35, 1
  br i1 %.not93103, label %.preheader96, label %.lr.ph106.preheader

.lr.ph106.preheader:                              ; preds = %._crit_edge
  %36 = add nuw i32 %35, 1
  %wide.trip.count = zext i32 %36 to i64
  br label %.lr.ph106

.preheader96:                                     ; preds = %.lr.ph106, %._crit_edge
  %37 = load i32, ptr @S, align 4, !tbaa !5
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %.lr.ph108, label %.preheader95

.lr.ph108:                                        ; preds = %.preheader96
  %.sroa.264.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  br label %56

.lr.ph106:                                        ; preds = %.lr.ph106.preheader, %.lr.ph106
  %indvars.iv131 = phi i64 [ 1, %.lr.ph106.preheader ], [ %indvars.iv.next132, %.lr.ph106 ]
  %39 = getelementptr inbounds [2001 x i32], ptr @p, i64 0, i64 %indvars.iv131
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = getelementptr inbounds [2001 x i32], ptr getelementptr inbounds (i8, ptr @p, i64 8004), i64 0, i64 %indvars.iv131
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = sext i32 %40 to i64
  %44 = sext i32 %42 to i64
  %45 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %43, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %45, align 4, !tbaa !5
  %48 = getelementptr inbounds [2001 x i32], ptr @a, i64 0, i64 %indvars.iv131
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %43, i64 %44
  %52 = load i64, ptr %51, align 8, !tbaa !12
  %53 = add nsw i64 %52, %50
  store i64 %53, ptr %51, align 8, !tbaa !12
  %indvars.iv.next132 = add nuw nsw i64 %indvars.iv131, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next132, %wide.trip.count
  br i1 %exitcond.not, label %.preheader96, label %.lr.ph106, !llvm.loop !14

.preheader95.loopexit:                            ; preds = %56
  %.pre = load i32, ptr @T, align 4, !tbaa !5
  br label %.preheader95

.preheader95:                                     ; preds = %.preheader95.loopexit, %.preheader96
  %54 = phi i32 [ %.pre, %.preheader95.loopexit ], [ %34, %.preheader96 ]
  %55 = icmp sgt i32 %54, 0
  br i1 %55, label %.lr.ph110, label %._crit_edge128

.lr.ph110:                                        ; preds = %.preheader95
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  br label %67

56:                                               ; preds = %.lr.ph108, %56
  %indvars.iv134 = phi i64 [ 0, %.lr.ph108 ], [ %indvars.iv.next135, %56 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #7
  %57 = call { i64, i32 } @_ZSt9make_pairIRKxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS4_INS5_IT0_E4typeEE6__typeEEOS6_OSB_(ptr noundef nonnull align 8 dereferenceable(8) @_ZL4INF2, ptr noundef nonnull align 4 dereferenceable(4) @T)
  %.fca.0.extract61 = extractvalue { i64, i32 } %57, 0
  %.fca.1.extract62 = extractvalue { i64, i32 } %57, 1
  store i64 %.fca.0.extract61, ptr %4, align 8
  store i32 %.fca.1.extract62, ptr %.sroa.264.0..sroa_idx, align 8
  %58 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mf, i64 0, i64 %indvars.iv134
  %59 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt4pairIxiEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(12) %58, ptr noundef nonnull align 8 dereferenceable(12) %4) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  %indvars.iv.next135 = add nuw nsw i64 %indvars.iv134, 1
  %60 = load i32, ptr @S, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = icmp slt i64 %indvars.iv.next135, %61
  br i1 %62, label %56, label %.preheader95.loopexit, !llvm.loop !15

._crit_edge111:                                   ; preds = %67
  %.pre150 = load i32, ptr @S, align 4, !tbaa !5
  %63 = icmp slt i32 %71, 1
  %64 = icmp slt i32 %.pre150, 1
  %brmerge = or i1 %64, %63
  br i1 %brmerge, label %._crit_edge128, label %.lr.ph127.split.preheader

.lr.ph127.split.preheader:                        ; preds = %._crit_edge111
  %.085123 = add nsw i32 %.pre150, -1
  %65 = zext nneg i32 %.085123 to i64
  %66 = zext nneg i32 %.pre150 to i64
  br label %.lr.ph127.split

67:                                               ; preds = %.lr.ph110, %67
  %indvars.iv137 = phi i64 [ 0, %.lr.ph110 ], [ %indvars.iv.next138, %67 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #7
  %68 = call { i64, i32 } @_ZSt9make_pairIRKxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS4_INS5_IT0_E4typeEE6__typeEEOS6_OSB_(ptr noundef nonnull align 8 dereferenceable(8) @_ZL4INF2, ptr noundef nonnull align 4 dereferenceable(4) @S)
  %.fca.0.extract = extractvalue { i64, i32 } %68, 0
  %.fca.1.extract = extractvalue { i64, i32 } %68, 1
  store i64 %.fca.0.extract, ptr %5, align 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  %69 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mg, i64 0, i64 %indvars.iv137
  %70 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt4pairIxiEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(12) %69, ptr noundef nonnull align 8 dereferenceable(12) %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #7
  %indvars.iv.next138 = add nuw nsw i64 %indvars.iv137, 1
  %71 = load i32, ptr @T, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = icmp slt i64 %indvars.iv.next138, %72
  br i1 %73, label %67, label %._crit_edge111, !llvm.loop !16

.loopexit:                                        ; preds = %153, %.lr.ph127.split
  %indvars.iv.next144 = add nsw i64 %indvars.iv143, -1
  %74 = icmp sgt i64 %indvars.iv143, 0
  %indvars.iv.next146 = add nsw i64 %indvars.iv145, -1
  br i1 %74, label %.lr.ph127.split, label %._crit_edge128, !llvm.loop !17

._crit_edge128:                                   ; preds = %.loopexit, %._crit_edge111, %.preheader95
  %75 = load i64, ptr @f, align 16, !tbaa !12
  %76 = load i64, ptr @s, align 16, !tbaa !12
  %77 = sub nsw i64 %76, %75
  %78 = icmp sgt i64 %75, %77
  %79 = icmp slt i64 %75, %77
  %80 = select i1 %79, ptr @.str.4, ptr @.str.5
  %81 = select i1 %78, ptr @.str.3, ptr %80
  %82 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %81)
  ret i32 0

.lr.ph127.split:                                  ; preds = %.lr.ph127.split.preheader, %.loopexit
  %indvars.iv145 = phi i64 [ %66, %.lr.ph127.split.preheader ], [ %indvars.iv.next146, %.loopexit ]
  %indvars.iv143 = phi i64 [ %65, %.lr.ph127.split.preheader ], [ %indvars.iv.next144, %.loopexit ]
  %83 = load i32, ptr @T, align 4, !tbaa !5
  %84 = icmp sgt i32 %83, 0
  br i1 %84, label %.lr.ph122, label %.loopexit

.lr.ph122:                                        ; preds = %.lr.ph127.split
  %85 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mf, i64 0, i64 %indvars.iv143
  %86 = getelementptr inbounds i8, ptr %85, i64 8
  %87 = zext nneg i32 %83 to i64
  %.phi.trans.insert = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %indvars.iv143, i64 %87
  %.pre151 = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  %.phi.trans.insert152 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %indvars.iv143, i64 %87
  %.pre153 = load i64, ptr %.phi.trans.insert152, align 8, !tbaa !12
  br label %88

88:                                               ; preds = %.lr.ph122, %153
  %89 = phi i64 [ %.pre153, %.lr.ph122 ], [ %154, %153 ]
  %90 = phi i32 [ %.pre151, %.lr.ph122 ], [ %155, %153 ]
  %indvars.iv140 = phi i64 [ %87, %.lr.ph122 ], [ %indvars.iv.next141, %153 ]
  %indvars.iv.next141 = add nsw i64 %indvars.iv140, -1
  %91 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %indvars.iv143, i64 %indvars.iv.next141
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %indvars.iv145, i64 %indvars.iv.next141
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = add nsw i32 %94, %92
  %96 = add nsw i32 %95, %90
  %97 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %indvars.iv145, i64 %indvars.iv140
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = sub nsw i32 %96, %98
  store i32 %99, ptr %91, align 4, !tbaa !5
  %100 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %indvars.iv143, i64 %indvars.iv.next141
  %101 = load i64, ptr %100, align 8, !tbaa !12
  %102 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %indvars.iv145, i64 %indvars.iv.next141
  %103 = load i64, ptr %102, align 8, !tbaa !12
  %104 = add nsw i64 %103, %101
  %105 = add nsw i64 %104, %89
  %106 = getelementptr inbounds [2001 x [2001 x i64]], ptr @s, i64 0, i64 %indvars.iv145, i64 %indvars.iv140
  %107 = load i64, ptr %106, align 8, !tbaa !12
  %108 = sub i64 %105, %107
  store i64 %108, ptr %100, align 8, !tbaa !12
  %.not94 = icmp eq i32 %96, %98
  br i1 %.not94, label %153, label %.preheader

.preheader:                                       ; preds = %88
  %109 = getelementptr inbounds [2001 x %"struct.std::pair"], ptr @mg, i64 0, i64 %indvars.iv.next141
  %110 = getelementptr inbounds i8, ptr %109, i64 8
  %111 = load i32, ptr %110, align 8, !tbaa !19
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %112, i64 %indvars.iv.next141
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = icmp slt i32 %114, %99
  br i1 %115, label %.lr.ph112, label %.preheader.._crit_edge113_crit_edge

.preheader.._crit_edge113_crit_edge:              ; preds = %.preheader
  %.pre155 = load i64, ptr %109, align 16, !tbaa !21
  br label %._crit_edge113

.lr.ph112:                                        ; preds = %.preheader, %.lr.ph112
  %116 = phi i64 [ %122, %.lr.ph112 ], [ %112, %.preheader ]
  %117 = getelementptr inbounds [2001 x [2001 x i64]], ptr @g, i64 0, i64 %116, i64 %indvars.iv.next141
  %118 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %109, ptr noundef nonnull align 8 dereferenceable(8) %117)
  %119 = load i64, ptr %118, align 8, !tbaa !12
  store i64 %119, ptr %109, align 16, !tbaa !21
  %120 = load i32, ptr %110, align 8, !tbaa !19
  %121 = add nsw i32 %120, -1
  store i32 %121, ptr %110, align 8, !tbaa !19
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %122, i64 %indvars.iv.next141
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = load i32, ptr %91, align 4, !tbaa !5
  %126 = icmp slt i32 %124, %125
  br i1 %126, label %.lr.ph112, label %._crit_edge113.loopexit, !llvm.loop !22

._crit_edge113.loopexit:                          ; preds = %.lr.ph112
  %.pre154 = load i64, ptr %100, align 8, !tbaa !12
  br label %._crit_edge113

._crit_edge113:                                   ; preds = %.preheader.._crit_edge113_crit_edge, %._crit_edge113.loopexit
  %127 = phi i32 [ %125, %._crit_edge113.loopexit ], [ %99, %.preheader.._crit_edge113_crit_edge ]
  %128 = phi i64 [ %119, %._crit_edge113.loopexit ], [ %.pre155, %.preheader.._crit_edge113_crit_edge ]
  %129 = phi i64 [ %.pre154, %._crit_edge113.loopexit ], [ %108, %.preheader.._crit_edge113_crit_edge ]
  %130 = sub nsw i64 %129, %128
  %131 = getelementptr inbounds [2001 x [2001 x i64]], ptr @f, i64 0, i64 %indvars.iv143, i64 %indvars.iv.next141
  store i64 %130, ptr %131, align 8, !tbaa !12
  %132 = load i32, ptr %86, align 8, !tbaa !19
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %indvars.iv143, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = icmp slt i32 %135, %127
  br i1 %136, label %.lr.ph115, label %._crit_edge113.._crit_edge116_crit_edge

._crit_edge113.._crit_edge116_crit_edge:          ; preds = %._crit_edge113
  %.pre157 = load i64, ptr %85, align 16, !tbaa !21
  br label %._crit_edge116

.lr.ph115:                                        ; preds = %._crit_edge113, %.lr.ph115
  %137 = phi i64 [ %143, %.lr.ph115 ], [ %133, %._crit_edge113 ]
  %138 = getelementptr inbounds [2001 x [2001 x i64]], ptr @f, i64 0, i64 %indvars.iv143, i64 %137
  %139 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %85, ptr noundef nonnull align 8 dereferenceable(8) %138)
  %140 = load i64, ptr %139, align 8, !tbaa !12
  store i64 %140, ptr %85, align 16, !tbaa !21
  %141 = load i32, ptr %86, align 8, !tbaa !19
  %142 = add nsw i32 %141, -1
  store i32 %142, ptr %86, align 8, !tbaa !19
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [2001 x [2001 x i32]], ptr @c, i64 0, i64 %indvars.iv143, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = load i32, ptr %91, align 4, !tbaa !5
  %147 = icmp slt i32 %145, %146
  br i1 %147, label %.lr.ph115, label %._crit_edge116.loopexit, !llvm.loop !23

._crit_edge116.loopexit:                          ; preds = %.lr.ph115
  %.pre156 = load i64, ptr %100, align 8, !tbaa !12
  br label %._crit_edge116

._crit_edge116:                                   ; preds = %._crit_edge113.._crit_edge116_crit_edge, %._crit_edge116.loopexit
  %148 = phi i64 [ %140, %._crit_edge116.loopexit ], [ %.pre157, %._crit_edge113.._crit_edge116_crit_edge ]
  %149 = phi i64 [ %.pre156, %._crit_edge116.loopexit ], [ %129, %._crit_edge113.._crit_edge116_crit_edge ]
  %150 = phi i32 [ %146, %._crit_edge116.loopexit ], [ %127, %._crit_edge113.._crit_edge116_crit_edge ]
  %151 = sub nsw i64 %149, %148
  %152 = getelementptr inbounds [2001 x [2001 x i64]], ptr @g, i64 0, i64 %indvars.iv143, i64 %indvars.iv.next141
  store i64 %151, ptr %152, align 8, !tbaa !12
  br label %153

153:                                              ; preds = %88, %._crit_edge116
  %154 = phi i64 [ %108, %88 ], [ %149, %._crit_edge116 ]
  %155 = phi i32 [ %99, %88 ], [ %150, %._crit_edge116 ]
  %156 = icmp sgt i64 %indvars.iv140, 1
  br i1 %156, label %88, label %.loopexit, !llvm.loop !24
}

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZSt9make_pairIRKxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS4_INS5_IT0_E4typeEE6__typeEEOS6_OSB_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(12) ptr @_ZNSt4pairIxiEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #6 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5

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 nounwind willreturn memory(argmem: write) }
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 = { 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 #5 = { 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 #6 = { 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 #7 = { 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 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = !{!20, !6, i64 8}
!20 = !{!"_ZTSSt4pairIxiE", !13, i64 0, !6, i64 8}
!21 = !{!20, !13, i64 0}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}


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