; LLVM IR from tangjz/acm-icpc :: zoj (3797)

; 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 { i8, i32 }

@n = external dso_local global i32, align 4
@L = external dso_local global i32, align 4
@len = external dso_local global i32, align 4
@cur = external dso_local global i32, align 4
@pre = external dso_local global i32, align 4
@a = external dso_local global [37 x %"struct.std::pair"], align 16
@m = external dso_local global i64, align 8
@c = external dso_local global [361 x [361 x i64]], align 16
@d = external dso_local global [361 x [361 x i64]], align 16
@f = external dso_local global [2 x [361 x i64]], align 16
@ans = external dso_local global [361 x i8], align 16
@_ZL3INF = external hidden constant i64, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 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 i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [3 x i8], align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %83, %0
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 361
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %86

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

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

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

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %54

35:                                               ; preds = %32
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %38
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sub nsw i32 %40, 1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [361 x i64], ptr %39, i64 0, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = sub nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %47
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [361 x i64], ptr %48, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = add nsw i64 %44, %52
  br label %55

54:                                               ; preds = %32
  br label %55

55:                                               ; preds = %54, %35
  %56 = phi i64 [ %53, %35 ], [ 1, %54 ]
  store i64 %56, ptr %5, align 8, !tbaa !9
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) @_ZL3INF)
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %60
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [361 x i64], ptr %61, i64 0, i64 %63
  store i64 %58, ptr %64, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %66
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [361 x i64], ptr %67, i64 0, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !9
  %72 = sdiv i64 4557430888798830399, %71
  %73 = load i32, ptr %2, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [361 x [361 x i64]], ptr @d, i64 0, i64 %74
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [361 x i64], ptr %75, i64 0, i64 %77
  store i64 %72, ptr %78, align 8, !tbaa !9
  br label %79

79:                                               ; preds = %55
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %4, align 4, !tbaa !5
  br label %27, !llvm.loop !11

82:                                               ; preds = %31
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %2, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %2, align 4, !tbaa !5
  br label %22, !llvm.loop !13

86:                                               ; preds = %25
  br label %87

87:                                               ; preds = %355, %86
  %88 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m, ptr noundef @L)
  %89 = icmp eq i32 %88, 3
  br i1 %89, label %90, label %364

90:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %116, %90
  %92 = load i32, ptr %7, align 4, !tbaa !5
  %93 = load i32, ptr @n, align 4, !tbaa !5
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %91
  store i32 10, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %119

96:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 3, ptr %8) #6
  %97 = getelementptr inbounds [3 x i8], ptr %8, i64 0, i64 0
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %99
  %101 = getelementptr inbounds %"struct.std::pair", ptr %100, i32 0, i32 1
  %102 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %97, ptr noundef %101)
  %103 = getelementptr inbounds [3 x i8], ptr %8, i64 0, i64 0
  %104 = load i8, ptr %103, align 1, !tbaa !14
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %106
  %108 = getelementptr inbounds %"struct.std::pair", ptr %107, i32 0, i32 0
  store i8 %104, ptr %108, align 8, !tbaa !15
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %110
  %112 = getelementptr inbounds %"struct.std::pair", ptr %111, i32 0, i32 1
  %113 = load i32, ptr %112, align 4, !tbaa !17
  %114 = load i32, ptr %6, align 4, !tbaa !5
  %115 = add nsw i32 %114, %113
  store i32 %115, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 3, ptr %8) #6
  br label %116

116:                                              ; preds = %96
  %117 = load i32, ptr %7, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %7, align 4, !tbaa !5
  br label %91, !llvm.loop !18

119:                                              ; preds = %95
  %120 = load i32, ptr @n, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %121
  call void @_ZSt4sortIPSt4pairIciEEvT_S3_(ptr noundef @a, ptr noundef %122)
  store i32 0, ptr @len, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %352, %119
  %124 = load i32, ptr @len, align 4, !tbaa !5
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = icmp slt i32 %124, %125
  br i1 %126, label %127, label %130

127:                                              ; preds = %123
  %128 = load i64, ptr @m, align 8, !tbaa !9
  %129 = icmp ne i64 %128, 0
  br label %130

130:                                              ; preds = %127, %123
  %131 = phi i1 [ false, %123 ], [ %129, %127 ]
  br i1 %131, label %132, label %355

132:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %133 = load i32, ptr @n, align 4, !tbaa !5
  %134 = sub nsw i32 %133, 1
  store i32 %134, ptr %9, align 4, !tbaa !5
  br label %135

135:                                              ; preds = %337, %132
  %136 = load i32, ptr %9, align 4, !tbaa !5
  %137 = icmp sge i32 %136, 0
  br i1 %137, label %139, label %138

138:                                              ; preds = %135
  store i32 16, ptr %3, align 4
  br label %340

139:                                              ; preds = %135
  %140 = load i32, ptr %9, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %141
  %143 = getelementptr inbounds %"struct.std::pair", ptr %142, i32 0, i32 1
  %144 = load i32, ptr %143, align 4, !tbaa !17
  %145 = icmp ne i32 %144, 0
  br i1 %145, label %147, label %146

146:                                              ; preds = %139
  br label %337

147:                                              ; preds = %139
  %148 = load i32, ptr %9, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %149
  %151 = getelementptr inbounds %"struct.std::pair", ptr %150, i32 0, i32 0
  %152 = load i8, ptr %151, align 8, !tbaa !15
  %153 = load i32, ptr @len, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %154
  store i8 %152, ptr %155, align 1, !tbaa !14
  %156 = load i32, ptr %9, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %157
  %159 = getelementptr inbounds %"struct.std::pair", ptr %158, i32 0, i32 1
  %160 = load i32, ptr %159, align 4, !tbaa !17
  %161 = add nsw i32 %160, -1
  store i32 %161, ptr %159, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !5
  %162 = load i32, ptr @cur, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %163
  %165 = getelementptr inbounds [361 x i64], ptr %164, i64 0, i64 0
  store i64 1, ptr %165, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %166

166:                                              ; preds = %276, %147
  %167 = load i32, ptr %12, align 4, !tbaa !5
  %168 = load i32, ptr @n, align 4, !tbaa !5
  %169 = icmp slt i32 %167, %168
  br i1 %169, label %171, label %170

170:                                              ; preds = %166
  store i32 19, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %279

171:                                              ; preds = %166
  %172 = load i32, ptr %12, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %173
  %175 = getelementptr inbounds %"struct.std::pair", ptr %174, i32 0, i32 1
  %176 = load i32, ptr %175, align 4, !tbaa !17
  %177 = icmp ne i32 %176, 0
  br i1 %177, label %179, label %178

178:                                              ; preds = %171
  br label %276

179:                                              ; preds = %171
  %180 = load i32, ptr @pre, align 4, !tbaa !5
  %181 = xor i32 %180, 1
  store i32 %181, ptr @pre, align 4, !tbaa !5
  %182 = load i32, ptr @cur, align 4, !tbaa !5
  %183 = xor i32 %182, 1
  store i32 %183, ptr @cur, align 4, !tbaa !5
  %184 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %184, ptr %10, align 4, !tbaa !5
  %185 = load i32, ptr %12, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %186
  %188 = getelementptr inbounds %"struct.std::pair", ptr %187, i32 0, i32 1
  %189 = load i32, ptr %188, align 4, !tbaa !17
  %190 = load i32, ptr %11, align 4, !tbaa !5
  %191 = add nsw i32 %190, %189
  store i32 %191, ptr %11, align 4, !tbaa !5
  %192 = load i32, ptr @cur, align 4, !tbaa !5
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %193
  %195 = getelementptr inbounds [361 x i64], ptr %194, i64 0, i64 0
  %196 = load i32, ptr %11, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = mul i64 %197, 8
  call void @llvm.memset.p0.i64(ptr align 8 %195, i8 0, i64 %198, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %199

199:                                              ; preds = %272, %179
  %200 = load i32, ptr %13, align 4, !tbaa !5
  %201 = load i32, ptr %10, align 4, !tbaa !5
  %202 = icmp slt i32 %200, %201
  br i1 %202, label %204, label %203

203:                                              ; preds = %199
  store i32 22, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %275

204:                                              ; preds = %199
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %205 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %205, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %206

206:                                              ; preds = %266, %204
  %207 = load i32, ptr %15, align 4, !tbaa !5
  %208 = load i32, ptr %12, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %209
  %211 = getelementptr inbounds %"struct.std::pair", ptr %210, i32 0, i32 1
  %212 = load i32, ptr %211, align 4, !tbaa !17
  %213 = icmp sle i32 %207, %212
  br i1 %213, label %215, label %214

214:                                              ; preds = %206
  store i32 25, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %271

215:                                              ; preds = %206
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %216 = load i32, ptr @cur, align 4, !tbaa !5
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %217
  %219 = load i32, ptr %14, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [361 x i64], ptr %218, i64 0, i64 %220
  %222 = load i64, ptr %221, align 8, !tbaa !9
  %223 = load i32, ptr @pre, align 4, !tbaa !5
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %224
  %226 = load i32, ptr %13, align 4, !tbaa !5
  %227 = sext i32 %226 to i64
  %228 = getelementptr inbounds [361 x i64], ptr %225, i64 0, i64 %227
  %229 = load i64, ptr %228, align 8, !tbaa !9
  %230 = load i32, ptr %14, align 4, !tbaa !5
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [361 x [361 x i64]], ptr @d, i64 0, i64 %231
  %233 = load i32, ptr %15, align 4, !tbaa !5
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [361 x i64], ptr %232, i64 0, i64 %234
  %236 = load i64, ptr %235, align 8, !tbaa !9
  %237 = icmp sle i64 %229, %236
  br i1 %237, label %238, label %254

238:                                              ; preds = %215
  %239 = load i32, ptr @pre, align 4, !tbaa !5
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %240
  %242 = load i32, ptr %13, align 4, !tbaa !5
  %243 = sext i32 %242 to i64
  %244 = getelementptr inbounds [361 x i64], ptr %241, i64 0, i64 %243
  %245 = load i64, ptr %244, align 8, !tbaa !9
  %246 = load i32, ptr %14, align 4, !tbaa !5
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %247
  %249 = load i32, ptr %15, align 4, !tbaa !5
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds [361 x i64], ptr %248, i64 0, i64 %250
  %252 = load i64, ptr %251, align 8, !tbaa !9
  %253 = mul nsw i64 %245, %252
  br label %255

254:                                              ; preds = %215
  br label %255

255:                                              ; preds = %254, %238
  %256 = phi i64 [ %253, %238 ], [ 4557430888798830399, %254 ]
  %257 = add nsw i64 %222, %256
  store i64 %257, ptr %16, align 8, !tbaa !9
  %258 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull align 8 dereferenceable(8) @_ZL3INF)
  %259 = load i64, ptr %258, align 8, !tbaa !9
  %260 = load i32, ptr @cur, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %261
  %263 = load i32, ptr %14, align 4, !tbaa !5
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds [361 x i64], ptr %262, i64 0, i64 %264
  store i64 %259, ptr %265, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %266

266:                                              ; preds = %255
  %267 = load i32, ptr %14, align 4, !tbaa !5
  %268 = add nsw i32 %267, 1
  store i32 %268, ptr %14, align 4, !tbaa !5
  %269 = load i32, ptr %15, align 4, !tbaa !5
  %270 = add nsw i32 %269, 1
  store i32 %270, ptr %15, align 4, !tbaa !5
  br label %206, !llvm.loop !19

271:                                              ; preds = %214
  br label %272

272:                                              ; preds = %271
  %273 = load i32, ptr %13, align 4, !tbaa !5
  %274 = add nsw i32 %273, 1
  store i32 %274, ptr %13, align 4, !tbaa !5
  br label %199, !llvm.loop !20

275:                                              ; preds = %203
  br label %276

276:                                              ; preds = %275, %178
  %277 = load i32, ptr %12, align 4, !tbaa !5
  %278 = add nsw i32 %277, 1
  store i32 %278, ptr %12, align 4, !tbaa !5
  br label %166, !llvm.loop !21

279:                                              ; preds = %170
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  store i64 0, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %280 = load i32, ptr @L, align 4, !tbaa !5
  %281 = load i32, ptr @len, align 4, !tbaa !5
  %282 = sub nsw i32 %280, %281
  %283 = sub nsw i32 %282, 1
  store i32 %283, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 0, ptr %20, align 4, !tbaa !5
  %284 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %19, ptr noundef nonnull align 4 dereferenceable(4) %20)
  %285 = load i32, ptr %284, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  store i32 %285, ptr %18, align 4, !tbaa !5
  br label %286

286:                                              ; preds = %303, %279
  %287 = load i32, ptr %18, align 4, !tbaa !5
  %288 = load i32, ptr %11, align 4, !tbaa !5
  %289 = icmp slt i32 %287, %288
  br i1 %289, label %291, label %290

290:                                              ; preds = %286
  store i32 28, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %306

291:                                              ; preds = %286
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %292 = load i64, ptr %17, align 8, !tbaa !9
  %293 = load i32, ptr @cur, align 4, !tbaa !5
  %294 = sext i32 %293 to i64
  %295 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %294
  %296 = load i32, ptr %18, align 4, !tbaa !5
  %297 = sext i32 %296 to i64
  %298 = getelementptr inbounds [361 x i64], ptr %295, i64 0, i64 %297
  %299 = load i64, ptr %298, align 8, !tbaa !9
  %300 = add nsw i64 %292, %299
  store i64 %300, ptr %21, align 8, !tbaa !9
  %301 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %21, ptr noundef nonnull align 8 dereferenceable(8) @_ZL3INF)
  %302 = load i64, ptr %301, align 8, !tbaa !9
  store i64 %302, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  br label %303

303:                                              ; preds = %291
  %304 = load i32, ptr %18, align 4, !tbaa !5
  %305 = add nsw i32 %304, 1
  store i32 %305, ptr %18, align 4, !tbaa !5
  br label %286, !llvm.loop !22

306:                                              ; preds = %290
  %307 = load i64, ptr @m, align 8, !tbaa !9
  %308 = load i64, ptr %17, align 8, !tbaa !9
  %309 = icmp sle i64 %307, %308
  br i1 %309, label %310, label %321

310:                                              ; preds = %306
  %311 = load i32, ptr @len, align 4, !tbaa !5
  %312 = load i32, ptr @L, align 4, !tbaa !5
  %313 = sub nsw i32 %312, 1
  %314 = icmp sge i32 %311, %313
  br i1 %314, label %315, label %320

315:                                              ; preds = %310
  %316 = load i64, ptr @m, align 8, !tbaa !9
  %317 = load i64, ptr %17, align 8, !tbaa !9
  %318 = icmp eq i64 %316, %317
  br i1 %318, label %319, label %320

319:                                              ; preds = %315
  store i64 0, ptr @m, align 8, !tbaa !9
  br label %320

320:                                              ; preds = %319, %315, %310
  store i32 16, ptr %3, align 4
  br label %334

321:                                              ; preds = %306
  %322 = load i64, ptr %17, align 8, !tbaa !9
  %323 = load i64, ptr @m, align 8, !tbaa !9
  %324 = sub nsw i64 %323, %322
  store i64 %324, ptr @m, align 8, !tbaa !9
  %325 = load i32, ptr @len, align 4, !tbaa !5
  %326 = sext i32 %325 to i64
  %327 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %326
  store i8 0, ptr %327, align 1, !tbaa !14
  %328 = load i32, ptr %9, align 4, !tbaa !5
  %329 = sext i32 %328 to i64
  %330 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %329
  %331 = getelementptr inbounds %"struct.std::pair", ptr %330, i32 0, i32 1
  %332 = load i32, ptr %331, align 4, !tbaa !17
  %333 = add nsw i32 %332, 1
  store i32 %333, ptr %331, align 4, !tbaa !17
  store i32 0, ptr %3, align 4
  br label %334

334:                                              ; preds = %321, %320
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %335 = load i32, ptr %3, align 4
  switch i32 %335, label %340 [
    i32 0, label %336
  ]

336:                                              ; preds = %334
  br label %337

337:                                              ; preds = %336, %146
  %338 = load i32, ptr %9, align 4, !tbaa !5
  %339 = add nsw i32 %338, -1
  store i32 %339, ptr %9, align 4, !tbaa !5
  br label %135, !llvm.loop !23

340:                                              ; preds = %334, %138
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %341

341:                                              ; preds = %340
  %342 = load i64, ptr @m, align 8, !tbaa !9
  %343 = icmp ne i64 %342, 0
  br i1 %343, label %344, label %351

344:                                              ; preds = %341
  %345 = load i32, ptr @len, align 4, !tbaa !5
  %346 = sext i32 %345 to i64
  %347 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %346
  %348 = load i8, ptr %347, align 1, !tbaa !14
  %349 = icmp ne i8 %348, 0
  br i1 %349, label %351, label %350

350:                                              ; preds = %344
  br label %355

351:                                              ; preds = %344, %341
  br label %352

352:                                              ; preds = %351
  %353 = load i32, ptr @len, align 4, !tbaa !5
  %354 = add nsw i32 %353, 1
  store i32 %354, ptr @len, align 4, !tbaa !5
  br label %123, !llvm.loop !24

355:                                              ; preds = %350, %130
  %356 = load i32, ptr @len, align 4, !tbaa !5
  %357 = sext i32 %356 to i64
  %358 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %357
  store i8 0, ptr %358, align 1, !tbaa !14
  %359 = load i64, ptr @m, align 8, !tbaa !9
  %360 = icmp ne i64 %359, 0
  %361 = zext i1 %360 to i64
  %362 = select i1 %360, ptr @.str.2, ptr @ans
  %363 = call i32 @puts(ptr noundef %362)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %87, !llvm.loop !25

364:                                              ; preds = %87
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIciEEvT_S3_(ptr noundef, ptr noundef) #4

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

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

declare i32 @puts(ptr noundef) #3

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 = { 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 = !{!7, !7, i64 0}
!15 = !{!16, !7, i64 0}
!16 = !{!"_ZTSSt4pairIciE", !7, i64 0, !6, i64 4}
!17 = !{!16, !6, i64 4}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !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"

%"struct.std::pair" = type { i8, i32 }

@n = external dso_local global i32, align 4
@L = external dso_local global i32, align 4
@len = external dso_local local_unnamed_addr global i32, align 4
@cur = external dso_local local_unnamed_addr global i32, align 4
@pre = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local global [37 x %"struct.std::pair"], align 16
@m = external dso_local global i64, align 8
@c = external dso_local local_unnamed_addr global [361 x [361 x i64]], align 16
@d = external dso_local local_unnamed_addr global [361 x [361 x i64]], align 16
@f = external dso_local local_unnamed_addr global [2 x [361 x i64]], align 16
@ans = external dso_local global [361 x i8], align 16
@_ZL3INF = external hidden constant i64, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca [3 x i8], align 1
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  br label %7

7:                                                ; preds = %.loopexit138, %0
  %indvars.iv141 = phi i64 [ 0, %0 ], [ %indvars.iv.next142, %.loopexit138 ]
  %indvars.iv139 = phi i64 [ 1, %0 ], [ %indvars.iv.next140, %.loopexit138 ]
  %8 = add nsw i64 %indvars.iv141, -1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  store i64 1, ptr %1, align 8, !tbaa !5
  %9 = 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) @_ZL3INF)
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %indvars.iv141, i64 0
  store i64 %10, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %12 = sdiv i64 4557430888798830399, %10
  %13 = getelementptr inbounds [361 x [361 x i64]], ptr @d, i64 0, i64 %indvars.iv141, i64 0
  store i64 %12, ptr %13, align 8, !tbaa !5
  %exitcond.peel.not = icmp eq i64 %indvars.iv139, 1
  br i1 %exitcond.peel.not, label %.loopexit138, label %.peel.next

.preheader89:                                     ; preds = %.loopexit138
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @L)
  %15 = icmp eq i32 %14, 3
  br i1 %15, label %.preheader88, label %._crit_edge125

.loopexit138:                                     ; preds = %.peel.next, %7
  %indvars.iv.next142 = add nuw nsw i64 %indvars.iv141, 1
  %indvars.iv.next140 = add nuw nsw i64 %indvars.iv139, 1
  %exitcond146.not = icmp eq i64 %indvars.iv.next142, 361
  br i1 %exitcond146.not, label %.preheader89, label %7, !llvm.loop !9

.peel.next:                                       ; preds = %7, %.peel.next
  %indvars.iv = phi i64 [ %indvars.iv.next, %.peel.next ], [ 1, %7 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %16 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %8, i64 %indvars.iv
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %18 = add nsw i64 %indvars.iv, -1
  %19 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %8, i64 %18
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = add nsw i64 %17, %20
  store i64 %21, ptr %1, align 8, !tbaa !5
  %22 = 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) @_ZL3INF)
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %indvars.iv141, i64 %indvars.iv
  store i64 %23, ptr %24, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %25 = sdiv i64 4557430888798830399, %23
  %26 = getelementptr inbounds [361 x [361 x i64]], ptr @d, i64 0, i64 %indvars.iv141, i64 %indvars.iv
  store i64 %25, ptr %26, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %indvars.iv139
  br i1 %exitcond.not, label %.loopexit138, label %.peel.next, !llvm.loop !11

.preheader88:                                     ; preds = %.preheader89, %174
  %27 = load i32, ptr @n, align 4, !tbaa !13
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %.lr.ph, label %.preheader88.._crit_edge_crit_edge

.preheader88.._crit_edge_crit_edge:               ; preds = %.preheader88
  %.pre181 = sext i32 %27 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader88.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre181, %.preheader88.._crit_edge_crit_edge ], [ %49, %.lr.ph ]
  %.070.lcssa = phi i32 [ 0, %.preheader88.._crit_edge_crit_edge ], [ %47, %.lr.ph ]
  %29 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %.pre-phi
  call void @_ZSt4sortIPSt4pairIciEEvT_S3_(ptr noundef nonnull @a, ptr noundef nonnull %29)
  store i32 0, ptr @len, align 4, !tbaa !13
  %30 = icmp sgt i32 %.070.lcssa, 0
  %31 = load i64, ptr @m, align 8
  %.pr.us.fr = freeze i64 %31
  %32 = icmp ne i64 %.pr.us.fr, 0
  %33 = and i1 %30, %32
  br i1 %33, label %.lr.ph120, label %._crit_edge121

.lr.ph120:                                        ; preds = %._crit_edge
  %34 = load i32, ptr @n, align 4, !tbaa !13
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %.lr.ph120.split, label %.thread.loopexit.us.preheader

.thread.loopexit.us.preheader:                    ; preds = %.lr.ph120
  %36 = zext nneg i32 %.070.lcssa to i64
  br label %.thread.loopexit.us

.thread.loopexit.us:                              ; preds = %.thread.loopexit.us.preheader, %39
  %indvars.iv150 = phi i64 [ 0, %.thread.loopexit.us.preheader ], [ %indvars.iv.next151, %39 ]
  %37 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %indvars.iv150
  %38 = load i8, ptr %37, align 1, !tbaa !15
  %.not80.us = icmp eq i8 %38, 0
  br i1 %.not80.us, label %._crit_edge121.thread, label %39

39:                                               ; preds = %.thread.loopexit.us
  %indvars.iv.next151 = add nuw nsw i64 %indvars.iv150, 1
  %40 = trunc nsw i64 %indvars.iv.next151 to i32
  store i32 %40, ptr @len, align 4, !tbaa !13
  %41 = icmp ult i64 %indvars.iv.next151, %36
  br i1 %41, label %.thread.loopexit.us, label %._crit_edge121.thread, !llvm.loop !16

.lr.ph:                                           ; preds = %.preheader88, %.lr.ph
  %indvars.iv147 = phi i64 [ %indvars.iv.next148, %.lr.ph ], [ 0, %.preheader88 ]
  %.07094 = phi i32 [ %47, %.lr.ph ], [ 0, %.preheader88 ]
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %2) #6
  %42 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv147
  %43 = getelementptr inbounds i8, ptr %42, i64 4
  %44 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %43)
  %45 = load i8, ptr %2, align 1, !tbaa !15
  store i8 %45, ptr %42, align 8, !tbaa !17
  %46 = load i32, ptr %43, align 4, !tbaa !19
  %47 = add nsw i32 %46, %.07094
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %2) #6
  %indvars.iv.next148 = add nuw nsw i64 %indvars.iv147, 1
  %48 = load i32, ptr @n, align 4, !tbaa !13
  %49 = sext i32 %48 to i64
  %50 = icmp slt i64 %indvars.iv.next148, %49
  br i1 %50, label %.lr.ph, label %._crit_edge, !llvm.loop !20

.lr.ph120.splitthread-pre-split:                  ; preds = %160
  %.pr182 = load i32, ptr @n, align 4, !tbaa !13
  br label %.lr.ph120.split

.lr.ph120.split:                                  ; preds = %.lr.ph120, %.lr.ph120.splitthread-pre-split
  %51 = phi i32 [ %.pr182, %.lr.ph120.splitthread-pre-split ], [ %34, %.lr.ph120 ]
  %52 = phi i64 [ %161, %.lr.ph120.splitthread-pre-split ], [ %.pr.us.fr, %.lr.ph120 ]
  %53 = phi i32 [ %163, %.lr.ph120.splitthread-pre-split ], [ 0, %.lr.ph120 ]
  %54 = icmp sgt i32 %51, 0
  br i1 %54, label %.lr.ph118.preheader, label %.thread.thread183

.lr.ph118.preheader:                              ; preds = %.lr.ph120.split
  %55 = zext nneg i32 %51 to i64
  br label %.lr.ph118

.lr.ph118:                                        ; preds = %.lr.ph118.preheader, %149
  %56 = phi i64 [ %52, %.lr.ph118.preheader ], [ %150, %149 ]
  %.pr179 = phi i64 [ %52, %.lr.ph118.preheader ], [ %.pr178, %149 ]
  %57 = phi i32 [ %53, %.lr.ph118.preheader ], [ %151, %149 ]
  %indvars.iv172 = phi i64 [ %55, %.lr.ph118.preheader ], [ %indvars.iv.next173, %149 ]
  %indvars.iv.next173 = add nsw i64 %indvars.iv172, -1
  %58 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv.next173
  %59 = getelementptr inbounds i8, ptr %58, i64 4
  %60 = load i32, ptr %59, align 4, !tbaa !19
  %.not = icmp eq i32 %60, 0
  br i1 %.not, label %149, label %61

61:                                               ; preds = %.lr.ph118
  %62 = load i8, ptr %58, align 8, !tbaa !17
  %63 = sext i32 %57 to i64
  %64 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %63
  store i8 %62, ptr %64, align 1, !tbaa !15
  %65 = add nsw i32 %60, -1
  store i32 %65, ptr %59, align 4, !tbaa !19
  %66 = load i32, ptr @cur, align 4, !tbaa !13
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %67
  store i64 1, ptr %68, align 8, !tbaa !5
  %69 = load i32, ptr @n, align 4, !tbaa !13
  %70 = icmp sgt i32 %69, 0
  br i1 %70, label %.lr.ph106, label %._crit_edge107

._crit_edge107.loopexit:                          ; preds = %.loopexit
  %.pre176 = load i32, ptr @len, align 4, !tbaa !13
  br label %._crit_edge107

._crit_edge107:                                   ; preds = %._crit_edge107.loopexit, %61
  %71 = phi i32 [ %57, %61 ], [ %.pre176, %._crit_edge107.loopexit ]
  %.066.lcssa = phi i32 [ 1, %61 ], [ %.1, %._crit_edge107.loopexit ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %72 = load i32, ptr @L, align 4, !tbaa !13
  %73 = xor i32 %71, -1
  %74 = add i32 %72, %73
  store i32 %74, ptr %4, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  store i32 0, ptr %5, align 4, !tbaa !13
  %75 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %76 = load i32, ptr %75, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  %77 = icmp slt i32 %76, %.066.lcssa
  br i1 %77, label %.lr.ph112.preheader, label %._crit_edge113

.lr.ph112.preheader:                              ; preds = %._crit_edge107
  %78 = sext i32 %76 to i64
  %wide.trip.count170 = sext i32 %.066.lcssa to i64
  br label %.lr.ph112

.lr.ph106:                                        ; preds = %61, %.loopexit
  %79 = phi i32 [ %122, %.loopexit ], [ %69, %61 ]
  %80 = phi i32 [ %123, %.loopexit ], [ %66, %61 ]
  %indvars.iv164 = phi i64 [ %indvars.iv.next165, %.loopexit ], [ 0, %61 ]
  %.066103 = phi i32 [ %.1, %.loopexit ], [ 1, %61 ]
  %81 = getelementptr inbounds [37 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv164, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !19
  %.not82 = icmp eq i32 %82, 0
  br i1 %.not82, label %.loopexit, label %83

83:                                               ; preds = %.lr.ph106
  %84 = load i32, ptr @pre, align 4, !tbaa !13
  %85 = xor i32 %84, 1
  store i32 %85, ptr @pre, align 4, !tbaa !13
  %86 = xor i32 %80, 1
  store i32 %86, ptr @cur, align 4, !tbaa !13
  %87 = add nsw i32 %82, %.066103
  %88 = sext i32 %86 to i64
  %89 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %88
  %90 = sext i32 %87 to i64
  %91 = shl nsw i64 %90, 3
  call void @llvm.memset.p0.i64(ptr nonnull align 8 %89, i8 0, i64 %91, i1 false)
  %92 = icmp slt i32 %.066103, 1
  %93 = icmp slt i32 %82, 0
  %or.cond203 = or i1 %92, %93
  br i1 %or.cond203, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %83
  %wide.trip.count = zext nneg i32 %.066103 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge101
  %94 = phi i32 [ %82, %.preheader.preheader ], [ %96, %._crit_edge101 ]
  %95 = phi i32 [ %86, %.preheader.preheader ], [ %97, %._crit_edge101 ]
  %indvars.iv155 = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next156, %._crit_edge101 ]
  %.not8397 = icmp slt i32 %94, 0
  br i1 %.not8397, label %._crit_edge101, label %.lr.ph100

._crit_edge101:                                   ; preds = %112, %.preheader
  %96 = phi i32 [ %94, %.preheader ], [ %120, %112 ]
  %97 = phi i32 [ %95, %.preheader ], [ %117, %112 ]
  %indvars.iv.next156 = add nuw nsw i64 %indvars.iv155, 1
  %exitcond163.not = icmp eq i64 %indvars.iv.next156, %wide.trip.count
  br i1 %exitcond163.not, label %.loopexit.loopexit127, label %.preheader, !llvm.loop !21

.lr.ph100:                                        ; preds = %.preheader, %112
  %98 = phi i32 [ %117, %112 ], [ %95, %.preheader ]
  %indvars.iv157 = phi i64 [ %indvars.iv.next158, %112 ], [ %indvars.iv155, %.preheader ]
  %indvars.iv153 = phi i64 [ %indvars.iv.next154, %112 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %99, i64 %indvars.iv157
  %101 = load i64, ptr %100, align 8, !tbaa !5
  %102 = load i32, ptr @pre, align 4, !tbaa !13
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %103, i64 %indvars.iv155
  %105 = load i64, ptr %104, align 8, !tbaa !5
  %106 = getelementptr inbounds [361 x [361 x i64]], ptr @d, i64 0, i64 %indvars.iv157, i64 %indvars.iv153
  %107 = load i64, ptr %106, align 8, !tbaa !5
  %.not84 = icmp sgt i64 %105, %107
  br i1 %.not84, label %112, label %108

108:                                              ; preds = %.lr.ph100
  %109 = getelementptr inbounds [361 x [361 x i64]], ptr @c, i64 0, i64 %indvars.iv157, i64 %indvars.iv153
  %110 = load i64, ptr %109, align 8, !tbaa !5
  %111 = mul nsw i64 %110, %105
  br label %112

112:                                              ; preds = %.lr.ph100, %108
  %113 = phi i64 [ %111, %108 ], [ 4557430888798830399, %.lr.ph100 ]
  %114 = add nsw i64 %113, %101
  store i64 %114, ptr %3, align 8, !tbaa !5
  %115 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) @_ZL3INF)
  %116 = load i64, ptr %115, align 8, !tbaa !5
  %117 = load i32, ptr @cur, align 4, !tbaa !13
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %118, i64 %indvars.iv157
  store i64 %116, ptr %119, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %indvars.iv.next158 = add nuw nsw i64 %indvars.iv157, 1
  %indvars.iv.next154 = add nuw nsw i64 %indvars.iv153, 1
  %120 = load i32, ptr %81, align 4, !tbaa !19
  %121 = sext i32 %120 to i64
  %.not83.not = icmp slt i64 %indvars.iv153, %121
  br i1 %.not83.not, label %.lr.ph100, label %._crit_edge101, !llvm.loop !23

.loopexit.loopexit127:                            ; preds = %._crit_edge101
  %.pre = load i32, ptr @n, align 4, !tbaa !13
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit127, %83, %.lr.ph106
  %122 = phi i32 [ %79, %.lr.ph106 ], [ %79, %83 ], [ %.pre, %.loopexit.loopexit127 ]
  %123 = phi i32 [ %80, %.lr.ph106 ], [ %86, %83 ], [ %97, %.loopexit.loopexit127 ]
  %.1 = phi i32 [ %.066103, %.lr.ph106 ], [ %87, %83 ], [ %87, %.loopexit.loopexit127 ]
  %indvars.iv.next165 = add nuw nsw i64 %indvars.iv164, 1
  %124 = sext i32 %122 to i64
  %125 = icmp slt i64 %indvars.iv.next165, %124
  br i1 %125, label %.lr.ph106, label %._crit_edge107.loopexit, !llvm.loop !24

._crit_edge113:                                   ; preds = %.lr.ph112, %._crit_edge107
  %.061.lcssa = phi i64 [ 0, %._crit_edge107 ], [ %133, %.lr.ph112 ]
  %126 = load i64, ptr @m, align 8
  %.not77 = icmp sgt i64 %126, %.061.lcssa
  br i1 %.not77, label %142, label %134

.lr.ph112:                                        ; preds = %.lr.ph112.preheader, %.lr.ph112
  %indvars.iv167 = phi i64 [ %78, %.lr.ph112.preheader ], [ %indvars.iv.next168, %.lr.ph112 ]
  %.061109 = phi i64 [ 0, %.lr.ph112.preheader ], [ %133, %.lr.ph112 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %127 = load i32, ptr @cur, align 4, !tbaa !13
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [2 x [361 x i64]], ptr @f, i64 0, i64 %128, i64 %indvars.iv167
  %130 = load i64, ptr %129, align 8, !tbaa !5
  %131 = add nsw i64 %130, %.061109
  store i64 %131, ptr %6, align 8, !tbaa !5
  %132 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) @_ZL3INF)
  %133 = load i64, ptr %132, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  %indvars.iv.next168 = add nsw i64 %indvars.iv167, 1
  %exitcond171.not = icmp eq i64 %indvars.iv.next168, %wide.trip.count170
  br i1 %exitcond171.not, label %._crit_edge113, label %.lr.ph112, !llvm.loop !25

134:                                              ; preds = %._crit_edge113
  %135 = load i32, ptr @len, align 4, !tbaa !13
  %136 = load i32, ptr @L, align 4, !tbaa !13
  %137 = add nsw i32 %136, -1
  %.not78 = icmp sge i32 %135, %137
  %138 = icmp eq i64 %126, %.061.lcssa
  %or.cond = and i1 %.not78, %138
  br i1 %or.cond, label %._crit_edge121.thread189, label %.thread

._crit_edge121.thread189:                         ; preds = %134
  store i64 0, ptr @m, align 8, !tbaa !5
  %139 = add nsw i32 %135, 1
  store i32 %139, ptr @len, align 4, !tbaa !13
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %140
  store i8 0, ptr %141, align 1, !tbaa !15
  br label %173

142:                                              ; preds = %._crit_edge113
  %143 = sub nsw i64 %126, %.061.lcssa
  store i64 %143, ptr @m, align 8, !tbaa !5
  %144 = load i32, ptr @len, align 4, !tbaa !13
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %145
  store i8 0, ptr %146, align 1, !tbaa !15
  %147 = load i32, ptr %59, align 4, !tbaa !19
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %59, align 4, !tbaa !19
  br label %149

149:                                              ; preds = %142, %.lr.ph118
  %150 = phi i64 [ %143, %142 ], [ %56, %.lr.ph118 ]
  %.pr178 = phi i64 [ %143, %142 ], [ %.pr179, %.lr.ph118 ]
  %151 = phi i32 [ %144, %142 ], [ %57, %.lr.ph118 ]
  %152 = icmp sgt i64 %indvars.iv172, 1
  br i1 %152, label %.lr.ph118, label %.thread, !llvm.loop !26

.thread:                                          ; preds = %149, %134
  %153 = phi i64 [ %126, %134 ], [ %150, %149 ]
  %154 = phi i32 [ %135, %134 ], [ %151, %149 ]
  %.pr = phi i64 [ %126, %134 ], [ %.pr178, %149 ]
  %.not79 = icmp eq i64 %.pr, 0
  br i1 %.not79, label %160, label %.thread.thread183

.thread.thread183:                                ; preds = %.lr.ph120.split, %.thread
  %155 = phi i32 [ %154, %.thread ], [ %53, %.lr.ph120.split ]
  %156 = phi i64 [ %153, %.thread ], [ %52, %.lr.ph120.split ]
  %157 = sext i32 %155 to i64
  %158 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %157
  %159 = load i8, ptr %158, align 1, !tbaa !15
  %.not80 = icmp eq i8 %159, 0
  br i1 %.not80, label %._crit_edge121, label %160

160:                                              ; preds = %.thread, %.thread.thread183
  %161 = phi i64 [ %153, %.thread ], [ %156, %.thread.thread183 ]
  %162 = phi i32 [ %154, %.thread ], [ %155, %.thread.thread183 ]
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr @len, align 4, !tbaa !13
  %164 = icmp slt i32 %163, %.070.lcssa
  %165 = icmp ne i64 %161, 0
  %166 = select i1 %164, i1 %165, i1 false
  br i1 %166, label %.lr.ph120.splitthread-pre-split, label %._crit_edge121, !llvm.loop !27

._crit_edge121.thread:                            ; preds = %.thread.loopexit.us, %39
  %.ph = phi i64 [ %indvars.iv.next151, %39 ], [ %indvars.iv150, %.thread.loopexit.us ]
  %sext = shl i64 %.ph, 32
  %167 = ashr exact i64 %sext, 32
  %168 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %167
  store i8 0, ptr %168, align 1, !tbaa !15
  br label %174

._crit_edge121:                                   ; preds = %160, %.thread.thread183, %._crit_edge
  %169 = phi i64 [ %.pr.us.fr, %._crit_edge ], [ %161, %160 ], [ %156, %.thread.thread183 ]
  %170 = phi i32 [ 0, %._crit_edge ], [ %163, %160 ], [ %155, %.thread.thread183 ]
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [361 x i8], ptr @ans, i64 0, i64 %171
  store i8 0, ptr %172, align 1, !tbaa !15
  %.fr = freeze i64 %169
  %.not81 = icmp eq i64 %.fr, 0
  br i1 %.not81, label %173, label %174

173:                                              ; preds = %._crit_edge121.thread189, %._crit_edge121
  br label %174

174:                                              ; preds = %._crit_edge121.thread, %._crit_edge121, %173
  %175 = phi ptr [ @ans, %173 ], [ @.str.2, %._crit_edge121 ], [ @.str.2, %._crit_edge121.thread ]
  %176 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %175)
  %177 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @L)
  %178 = icmp eq i32 %177, 3
  br i1 %178, label %.preheader88, label %._crit_edge125, !llvm.loop !28

._crit_edge125:                                   ; preds = %174, %.preheader89
  ret i32 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: 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIciEEvT_S3_(ptr noundef, ptr noundef) local_unnamed_addr #4

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

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

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

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 = { 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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12}
!12 = !{!"llvm.loop.peeled.count", i32 1}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !10}
!17 = !{!18, !7, i64 0}
!18 = !{!"_ZTSSt4pairIciE", !7, i64 0, !14, i64 4}
!19 = !{!18, !14, i64 4}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10, !22}
!22 = !{!"llvm.loop.unswitch.partial.disable"}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !10}
!27 = distinct !{!27, !10, !22}
!28 = distinct !{!28, !10}


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