; LLVM IR from tangjz/acm-icpc :: poj (2912)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@fa = external dso_local global [1503 x i32], align 16
@query = external dso_local global [2001 x [3 x i32]], align 16
@id = external dso_local global i32, align 4
@pos = external dso_local global i32, align 4
@cnt = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [18 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %20

20:                                               ; preds = %302, %0
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %22 = icmp eq i32 %21, 2
  br i1 %22, label %23, label %303

23:                                               ; preds = %20
  store i32 0, ptr @cnt, align 4, !tbaa !5
  store i32 0, ptr @pos, align 4, !tbaa !5
  store i32 0, ptr @id, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %91, %23
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = load i32, ptr @m, align 4, !tbaa !5
  %27 = icmp sle i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %94

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %5, ptr noundef %4)
  %31 = load i8, ptr %5, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 61
  br i1 %33, label %34, label %51

34:                                               ; preds = %29
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %36
  %38 = getelementptr inbounds [3 x i32], ptr %37, i64 0, i64 0
  store i32 1, ptr %38, align 4, !tbaa !5
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %42
  %44 = getelementptr inbounds [3 x i32], ptr %43, i64 0, i64 1
  store i32 %40, ptr %44, align 4, !tbaa !5
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %48
  %50 = getelementptr inbounds [3 x i32], ptr %49, i64 0, i64 2
  store i32 %46, ptr %50, align 4, !tbaa !5
  br label %90

51:                                               ; preds = %29
  %52 = load i8, ptr %5, align 1, !tbaa !9
  %53 = sext i8 %52 to i32
  %54 = icmp eq i32 %53, 60
  br i1 %54, label %55, label %72

55:                                               ; preds = %51
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %57
  %59 = getelementptr inbounds [3 x i32], ptr %58, i64 0, i64 0
  store i32 2, ptr %59, align 4, !tbaa !5
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  %62 = load i32, ptr %2, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %63
  %65 = getelementptr inbounds [3 x i32], ptr %64, i64 0, i64 1
  store i32 %61, ptr %65, align 4, !tbaa !5
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %69
  %71 = getelementptr inbounds [3 x i32], ptr %70, i64 0, i64 2
  store i32 %67, ptr %71, align 4, !tbaa !5
  br label %89

72:                                               ; preds = %51
  %73 = load i32, ptr %2, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %74
  %76 = getelementptr inbounds [3 x i32], ptr %75, i64 0, i64 0
  store i32 2, ptr %76, align 4, !tbaa !5
  %77 = load i32, ptr %3, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %80
  %82 = getelementptr inbounds [3 x i32], ptr %81, i64 0, i64 1
  store i32 %78, ptr %82, align 4, !tbaa !5
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %86
  %88 = getelementptr inbounds [3 x i32], ptr %87, i64 0, i64 2
  store i32 %84, ptr %88, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %72, %55
  br label %90

90:                                               ; preds = %89, %34
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %2, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %2, align 4, !tbaa !5
  br label %24, !llvm.loop !10

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

95:                                               ; preds = %282, %94
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = load i32, ptr @n, align 4, !tbaa !5
  %98 = icmp sle i32 %96, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %95
  store i32 7, ptr %7, align 4
  br label %285

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

101:                                              ; preds = %112, %100
  %102 = load i32, ptr %8, align 4, !tbaa !5
  %103 = load i32, ptr @n, align 4, !tbaa !5
  %104 = mul nsw i32 %103, 3
  %105 = icmp sle i32 %102, %104
  br i1 %105, label %107, label %106

106:                                              ; preds = %101
  store i32 10, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %115

107:                                              ; preds = %101
  %108 = load i32, ptr %8, align 4, !tbaa !5
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %110
  store i32 %108, ptr %111, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %107
  %113 = load i32, ptr %8, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %8, align 4, !tbaa !5
  br label %101, !llvm.loop !12

115:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  store i8 0, ptr %9, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %263, %115
  %117 = load i32, ptr %10, align 4, !tbaa !5
  %118 = load i32, ptr @m, align 4, !tbaa !5
  %119 = icmp sle i32 %117, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %116
  store i32 13, ptr %7, align 4
  br label %266

121:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %122 = load i32, ptr %10, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %123
  %125 = getelementptr inbounds [3 x i32], ptr %124, i64 0, i64 0
  store ptr %125, ptr %11, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %126 = load i32, ptr %10, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %127
  %129 = getelementptr inbounds [3 x i32], ptr %128, i64 0, i64 1
  store ptr %129, ptr %12, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %130 = load i32, ptr %10, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %131
  %133 = getelementptr inbounds [3 x i32], ptr %132, i64 0, i64 2
  store ptr %133, ptr %13, align 8, !tbaa !15
  %134 = load ptr, ptr %12, align 8, !tbaa !15
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = load i32, ptr %6, align 4, !tbaa !5
  %137 = icmp eq i32 %135, %136
  br i1 %137, label %143, label %138

138:                                              ; preds = %121
  %139 = load ptr, ptr %13, align 8, !tbaa !15
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = load i32, ptr %6, align 4, !tbaa !5
  %142 = icmp eq i32 %140, %141
  br i1 %142, label %143, label %144

143:                                              ; preds = %138, %121
  store i32 15, ptr %7, align 4
  br label %260

144:                                              ; preds = %138
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %145 = load ptr, ptr %12, align 8, !tbaa !15
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = call noundef i32 @_Z4findi(i32 noundef %146)
  store i32 %147, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %148 = load ptr, ptr %12, align 8, !tbaa !15
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = load i32, ptr @n, align 4, !tbaa !5
  %151 = add nsw i32 %149, %150
  %152 = call noundef i32 @_Z4findi(i32 noundef %151)
  store i32 %152, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %153 = load ptr, ptr %12, align 8, !tbaa !15
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = load i32, ptr @n, align 4, !tbaa !5
  %156 = add nsw i32 %154, %155
  %157 = load i32, ptr @n, align 4, !tbaa !5
  %158 = add nsw i32 %156, %157
  %159 = call noundef i32 @_Z4findi(i32 noundef %158)
  store i32 %159, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %160 = load ptr, ptr %13, align 8, !tbaa !15
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = call noundef i32 @_Z4findi(i32 noundef %161)
  store i32 %162, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %163 = load ptr, ptr %13, align 8, !tbaa !15
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = load i32, ptr @n, align 4, !tbaa !5
  %166 = add nsw i32 %164, %165
  %167 = call noundef i32 @_Z4findi(i32 noundef %166)
  store i32 %167, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %168 = load ptr, ptr %13, align 8, !tbaa !15
  %169 = load i32, ptr %168, align 4, !tbaa !5
  %170 = load i32, ptr @n, align 4, !tbaa !5
  %171 = add nsw i32 %169, %170
  %172 = load i32, ptr @n, align 4, !tbaa !5
  %173 = add nsw i32 %171, %172
  %174 = call noundef i32 @_Z4findi(i32 noundef %173)
  store i32 %174, ptr %19, align 4, !tbaa !5
  %175 = load ptr, ptr %11, align 8, !tbaa !15
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = icmp eq i32 %176, 1
  br i1 %177, label %178, label %220

178:                                              ; preds = %144
  %179 = load i32, ptr %14, align 4, !tbaa !5
  %180 = load i32, ptr %18, align 4, !tbaa !5
  %181 = icmp eq i32 %179, %180
  br i1 %181, label %194, label %182

182:                                              ; preds = %178
  %183 = load i32, ptr %14, align 4, !tbaa !5
  %184 = load i32, ptr %19, align 4, !tbaa !5
  %185 = icmp eq i32 %183, %184
  br i1 %185, label %194, label %186

186:                                              ; preds = %182
  %187 = load i32, ptr %17, align 4, !tbaa !5
  %188 = load i32, ptr %15, align 4, !tbaa !5
  %189 = icmp eq i32 %187, %188
  br i1 %189, label %194, label %190

190:                                              ; preds = %186
  %191 = load i32, ptr %17, align 4, !tbaa !5
  %192 = load i32, ptr %16, align 4, !tbaa !5
  %193 = icmp eq i32 %191, %192
  br i1 %193, label %194, label %201

194:                                              ; preds = %190, %186, %182, %178
  store i8 1, ptr %9, align 1, !tbaa !13
  %195 = load i32, ptr @pos, align 4, !tbaa !5
  %196 = load i32, ptr %10, align 4, !tbaa !5
  %197 = icmp slt i32 %195, %196
  br i1 %197, label %198, label %200

198:                                              ; preds = %194
  %199 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %199, ptr @pos, align 4, !tbaa !5
  br label %200

200:                                              ; preds = %198, %194
  store i32 13, ptr %7, align 4
  br label %259

201:                                              ; preds = %190
  %202 = load i32, ptr %17, align 4, !tbaa !5
  %203 = call noundef i32 @_Z4findi(i32 noundef %202)
  %204 = load i32, ptr %14, align 4, !tbaa !5
  %205 = call noundef i32 @_Z4findi(i32 noundef %204)
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %206
  store i32 %203, ptr %207, align 4, !tbaa !5
  %208 = load i32, ptr %18, align 4, !tbaa !5
  %209 = call noundef i32 @_Z4findi(i32 noundef %208)
  %210 = load i32, ptr %15, align 4, !tbaa !5
  %211 = call noundef i32 @_Z4findi(i32 noundef %210)
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %212
  store i32 %209, ptr %213, align 4, !tbaa !5
  %214 = load i32, ptr %19, align 4, !tbaa !5
  %215 = call noundef i32 @_Z4findi(i32 noundef %214)
  %216 = load i32, ptr %16, align 4, !tbaa !5
  %217 = call noundef i32 @_Z4findi(i32 noundef %216)
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %218
  store i32 %215, ptr %219, align 4, !tbaa !5
  br label %258

220:                                              ; preds = %144
  %221 = load i32, ptr %14, align 4, !tbaa !5
  %222 = load i32, ptr %17, align 4, !tbaa !5
  %223 = icmp eq i32 %221, %222
  br i1 %223, label %232, label %224

224:                                              ; preds = %220
  %225 = load i32, ptr %14, align 4, !tbaa !5
  %226 = load i32, ptr %19, align 4, !tbaa !5
  %227 = icmp eq i32 %225, %226
  br i1 %227, label %232, label %228

228:                                              ; preds = %224
  %229 = load i32, ptr %15, align 4, !tbaa !5
  %230 = load i32, ptr %17, align 4, !tbaa !5
  %231 = icmp eq i32 %229, %230
  br i1 %231, label %232, label %239

232:                                              ; preds = %228, %224, %220
  store i8 1, ptr %9, align 1, !tbaa !13
  %233 = load i32, ptr @pos, align 4, !tbaa !5
  %234 = load i32, ptr %10, align 4, !tbaa !5
  %235 = icmp slt i32 %233, %234
  br i1 %235, label %236, label %238

236:                                              ; preds = %232
  %237 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %237, ptr @pos, align 4, !tbaa !5
  br label %238

238:                                              ; preds = %236, %232
  store i32 13, ptr %7, align 4
  br label %259

239:                                              ; preds = %228
  %240 = load i32, ptr %18, align 4, !tbaa !5
  %241 = call noundef i32 @_Z4findi(i32 noundef %240)
  %242 = load i32, ptr %14, align 4, !tbaa !5
  %243 = call noundef i32 @_Z4findi(i32 noundef %242)
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %244
  store i32 %241, ptr %245, align 4, !tbaa !5
  %246 = load i32, ptr %19, align 4, !tbaa !5
  %247 = call noundef i32 @_Z4findi(i32 noundef %246)
  %248 = load i32, ptr %15, align 4, !tbaa !5
  %249 = call noundef i32 @_Z4findi(i32 noundef %248)
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %250
  store i32 %247, ptr %251, align 4, !tbaa !5
  %252 = load i32, ptr %17, align 4, !tbaa !5
  %253 = call noundef i32 @_Z4findi(i32 noundef %252)
  %254 = load i32, ptr %16, align 4, !tbaa !5
  %255 = call noundef i32 @_Z4findi(i32 noundef %254)
  %256 = sext i32 %255 to i64
  %257 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %256
  store i32 %253, ptr %257, align 4, !tbaa !5
  br label %258

258:                                              ; preds = %239, %201
  store i32 0, ptr %7, align 4
  br label %259

259:                                              ; preds = %258, %238, %200
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %260

260:                                              ; preds = %259, %143
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %261 = load i32, ptr %7, align 4
  switch i32 %261, label %266 [
    i32 0, label %262
    i32 15, label %263
  ]

262:                                              ; preds = %260
  br label %263

263:                                              ; preds = %262, %260
  %264 = load i32, ptr %10, align 4, !tbaa !5
  %265 = add nsw i32 %264, 1
  store i32 %265, ptr %10, align 4, !tbaa !5
  br label %116, !llvm.loop !17

266:                                              ; preds = %260, %120
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %267

267:                                              ; preds = %266
  %268 = load i8, ptr %9, align 1, !tbaa !13, !range !18, !noundef !19
  %269 = trunc i8 %268 to i1
  br i1 %269, label %278, label %270

270:                                              ; preds = %267
  %271 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %271, ptr @id, align 4, !tbaa !5
  %272 = load i32, ptr @cnt, align 4, !tbaa !5
  %273 = add nsw i32 %272, 1
  store i32 %273, ptr @cnt, align 4, !tbaa !5
  %274 = load i32, ptr @cnt, align 4, !tbaa !5
  %275 = icmp sgt i32 %274, 1
  br i1 %275, label %276, label %277

276:                                              ; preds = %270
  store i32 7, ptr %7, align 4
  br label %279

277:                                              ; preds = %270
  br label %278

278:                                              ; preds = %277, %267
  store i32 0, ptr %7, align 4
  br label %279

279:                                              ; preds = %278, %276
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  %280 = load i32, ptr %7, align 4
  switch i32 %280, label %285 [
    i32 0, label %281
  ]

281:                                              ; preds = %279
  br label %282

282:                                              ; preds = %281
  %283 = load i32, ptr %6, align 4, !tbaa !5
  %284 = add nsw i32 %283, 1
  store i32 %284, ptr %6, align 4, !tbaa !5
  br label %95, !llvm.loop !20

285:                                              ; preds = %279, %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %286

286:                                              ; preds = %285
  %287 = load i32, ptr @cnt, align 4, !tbaa !5
  %288 = icmp ne i32 %287, 0
  br i1 %288, label %291, label %289

289:                                              ; preds = %286
  %290 = call i32 @puts(ptr noundef @.str.2)
  br label %302

291:                                              ; preds = %286
  %292 = load i32, ptr @cnt, align 4, !tbaa !5
  %293 = icmp eq i32 %292, 1
  br i1 %293, label %294, label %299

294:                                              ; preds = %291
  %295 = load i32, ptr @id, align 4, !tbaa !5
  %296 = sub nsw i32 %295, 1
  %297 = load i32, ptr @pos, align 4, !tbaa !5
  %298 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %296, i32 noundef %297)
  br label %301

299:                                              ; preds = %291
  %300 = call i32 @puts(ptr noundef @.str.4)
  br label %301

301:                                              ; preds = %299, %294
  br label %302

302:                                              ; preds = %301, %289
  br label %20, !llvm.loop !21

303:                                              ; preds = %20
  ret i32 0
}

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

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

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

declare i32 @puts(ptr noundef) #2

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

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 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 #2 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind }

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

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


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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@fa = external dso_local local_unnamed_addr global [1503 x i32], align 16
@query = external dso_local local_unnamed_addr global [2001 x [3 x i32]], align 16
@id = external dso_local local_unnamed_addr global i32, align 4
@pos = external dso_local local_unnamed_addr global i32, align 4
@cnt = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [18 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %5 = icmp eq i32 %4, 2
  br i1 %5, label %.lr.ph115, label %._crit_edge116

.lr.ph115:                                        ; preds = %0, %110
  store i32 0, ptr @cnt, align 4, !tbaa !5
  store i32 0, ptr @pos, align 4, !tbaa !5
  store i32 0, ptr @id, align 4, !tbaa !5
  %6 = load i32, ptr @m, align 4, !tbaa !5
  %.not103 = icmp slt i32 %6, 1
  br i1 %.not103, label %.preheader100, label %.lr.ph

.preheader100:                                    ; preds = %16, %.lr.ph115
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not86111 = icmp slt i32 %7, 1
  br i1 %.not86111, label %thread-pre-split, label %.preheader99

.lr.ph:                                           ; preds = %.lr.ph115, %16
  %indvars.iv = phi i64 [ %indvars.iv.next, %16 ], [ 1, %.lr.ph115 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %3, ptr noundef nonnull %2)
  %9 = load i8, ptr %3, align 1, !tbaa !9
  %10 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %indvars.iv
  %11 = getelementptr inbounds i8, ptr %10, i64 4
  %12 = getelementptr inbounds i8, ptr %10, i64 8
  switch i8 %9, label %15 [
    i8 61, label %13
    i8 60, label %14
  ]

13:                                               ; preds = %.lr.ph
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %16

14:                                               ; preds = %.lr.ph
  store i32 2, ptr %10, align 4, !tbaa !5
  br label %16

15:                                               ; preds = %.lr.ph
  store i32 2, ptr %10, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %14, %15, %13
  %.sink145.in = phi ptr [ %2, %14 ], [ %1, %15 ], [ %1, %13 ]
  %.sink128.in = phi ptr [ %1, %14 ], [ %2, %15 ], [ %2, %13 ]
  %.sink145 = load i32, ptr %.sink145.in, align 4, !tbaa !5
  %17 = add nsw i32 %.sink145, 1
  store i32 %17, ptr %11, align 4, !tbaa !5
  %.sink128 = load i32, ptr %.sink128.in, align 4, !tbaa !5
  %18 = add nsw i32 %.sink128, 1
  store i32 %18, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %.not.not = icmp slt i64 %indvars.iv, %20
  br i1 %.not.not, label %.lr.ph, label %.preheader100, !llvm.loop !10

.preheader99:                                     ; preds = %.preheader100, %.critedge
  %21 = phi i32 [ %99, %.critedge ], [ %7, %.preheader100 ]
  %.066112 = phi i32 [ %98, %.critedge ], [ 1, %.preheader100 ]
  %.not87105 = icmp slt i32 %21, 1
  br i1 %.not87105, label %.preheader, label %.lr.ph107.preheader

.lr.ph107.preheader:                              ; preds = %.preheader99
  %22 = mul i32 %21, 3
  %smax = call i32 @llvm.smax.i32(i32 %22, i32 1)
  %23 = add nuw i32 %smax, 1
  %wide.trip.count = zext i32 %23 to i64
  %24 = zext nneg i32 %smax to i64
  %min.iters.check = icmp slt i32 %22, 8
  br i1 %min.iters.check, label %.lr.ph107.preheader146, label %vector.ph

.lr.ph107.preheader146:                           ; preds = %middle.block, %.lr.ph107.preheader
  %indvars.iv120.ph = phi i64 [ 1, %.lr.ph107.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph107

vector.ph:                                        ; preds = %.lr.ph107.preheader
  %n.vec = and i64 %24, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %offset.idx = or disjoint i64 %index, 1
  %25 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %offset.idx
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  store <4 x i32> %vec.ind, ptr %25, align 4, !tbaa !5
  store <4 x i32> %step.add, ptr %26, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, label %middle.block, label %vector.body, !llvm.loop !12

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %24
  br i1 %cmp.n, label %.preheader, label %.lr.ph107.preheader146

.preheader:                                       ; preds = %.lr.ph107, %middle.block, %.preheader99
  %28 = load i32, ptr @m, align 4, !tbaa !5
  %.not88108 = icmp slt i32 %28, 1
  br i1 %.not88108, label %._crit_edge, label %.lr.ph110

.lr.ph107:                                        ; preds = %.lr.ph107.preheader146, %.lr.ph107
  %indvars.iv120 = phi i64 [ %indvars.iv.next121, %.lr.ph107 ], [ %indvars.iv120.ph, %.lr.ph107.preheader146 ]
  %29 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %indvars.iv120
  %30 = trunc nuw nsw i64 %indvars.iv120 to i32
  store i32 %30, ptr %29, align 4, !tbaa !5
  %indvars.iv.next121 = add nuw nsw i64 %indvars.iv120, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next121, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph107, !llvm.loop !15

.lr.ph110:                                        ; preds = %.preheader, %92
  %indvars.iv123 = phi i64 [ %indvars.iv.next124, %92 ], [ 1, %.preheader ]
  %31 = getelementptr inbounds [2001 x [3 x i32]], ptr @query, i64 0, i64 %indvars.iv123
  %32 = getelementptr inbounds i8, ptr %31, i64 4
  %33 = getelementptr inbounds i8, ptr %31, i64 8
  %34 = load i32, ptr %32, align 4, !tbaa !5
  %35 = icmp eq i32 %34, %.066112
  br i1 %35, label %92, label %36

36:                                               ; preds = %.lr.ph110
  %37 = load i32, ptr %33, align 4, !tbaa !5
  %38 = icmp eq i32 %37, %.066112
  br i1 %38, label %92, label %39

39:                                               ; preds = %36
  %40 = call noundef i32 @_Z4findi(i32 noundef %34)
  %41 = load i32, ptr %32, align 4, !tbaa !5
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = add nsw i32 %42, %41
  %44 = call noundef i32 @_Z4findi(i32 noundef %43)
  %45 = load i32, ptr %32, align 4, !tbaa !5
  %46 = load i32, ptr @n, align 4, !tbaa !5
  %reass.add = shl i32 %46, 1
  %47 = add i32 %reass.add, %45
  %48 = call noundef i32 @_Z4findi(i32 noundef %47)
  %49 = load i32, ptr %33, align 4, !tbaa !5
  %50 = call noundef i32 @_Z4findi(i32 noundef %49)
  %51 = load i32, ptr %33, align 4, !tbaa !5
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %53 = add nsw i32 %52, %51
  %54 = call noundef i32 @_Z4findi(i32 noundef %53)
  %55 = load i32, ptr %33, align 4, !tbaa !5
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %reass.add89 = shl i32 %56, 1
  %57 = add i32 %reass.add89, %55
  %58 = call noundef i32 @_Z4findi(i32 noundef %57)
  %59 = load i32, ptr %31, align 4, !tbaa !5
  %60 = icmp eq i32 %59, 1
  %61 = icmp eq i32 %40, %58
  br i1 %60, label %62, label %72

62:                                               ; preds = %39
  %63 = icmp eq i32 %40, %54
  %64 = icmp eq i32 %50, %44
  %65 = or i1 %63, %64
  %66 = icmp eq i32 %50, %48
  %67 = or i1 %65, %66
  %or.cond92 = or i1 %67, %61
  br i1 %or.cond92, label %68, label %.sink.split

68:                                               ; preds = %62
  %69 = trunc nuw nsw i64 %indvars.iv123 to i32
  %70 = load i32, ptr @pos, align 4, !tbaa !5
  %71 = icmp slt i32 %70, %69
  br i1 %71, label %.critedge.sink.split, label %.critedge

72:                                               ; preds = %39
  %73 = icmp eq i32 %40, %50
  %74 = icmp eq i32 %44, %50
  %75 = or i1 %73, %74
  %or.cond94 = or i1 %75, %61
  br i1 %or.cond94, label %76, label %.sink.split

76:                                               ; preds = %72
  %77 = trunc nuw nsw i64 %indvars.iv123 to i32
  %78 = load i32, ptr @pos, align 4, !tbaa !5
  %79 = icmp slt i32 %78, %77
  br i1 %79, label %.critedge.sink.split, label %.critedge

.sink.split:                                      ; preds = %72, %62
  %.sink140 = phi i32 [ %50, %62 ], [ %54, %72 ]
  %.sink136 = phi i32 [ %54, %62 ], [ %58, %72 ]
  %.sink132 = phi i32 [ %58, %62 ], [ %50, %72 ]
  %80 = call noundef i32 @_Z4findi(i32 noundef %.sink140)
  %81 = call noundef i32 @_Z4findi(i32 noundef %40)
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %82
  store i32 %80, ptr %83, align 4, !tbaa !5
  %84 = call noundef i32 @_Z4findi(i32 noundef %.sink136)
  %85 = call noundef i32 @_Z4findi(i32 noundef %44)
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %86
  store i32 %84, ptr %87, align 4, !tbaa !5
  %88 = call noundef i32 @_Z4findi(i32 noundef %.sink132)
  %89 = call noundef i32 @_Z4findi(i32 noundef %48)
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [1503 x i32], ptr @fa, i64 0, i64 %90
  store i32 %88, ptr %91, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %.sink.split, %36, %.lr.ph110
  %indvars.iv.next124 = add nuw nsw i64 %indvars.iv123, 1
  %93 = load i32, ptr @m, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %.not88.not = icmp slt i64 %indvars.iv123, %94
  br i1 %.not88.not, label %.lr.ph110, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %92, %.preheader
  store i32 %.066112, ptr @id, align 4, !tbaa !5
  %95 = load i32, ptr @cnt, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr @cnt, align 4, !tbaa !5
  %97 = icmp sgt i32 %95, 0
  br i1 %97, label %.loopexit, label %.critedge

.critedge.sink.split:                             ; preds = %76, %68
  %.sink = phi i32 [ %69, %68 ], [ %77, %76 ]
  store i32 %.sink, ptr @pos, align 4, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %.critedge.sink.split, %68, %76, %._crit_edge
  %98 = add nuw nsw i32 %.066112, 1
  %99 = load i32, ptr @n, align 4, !tbaa !5
  %.not86.not = icmp slt i32 %.066112, %99
  br i1 %.not86.not, label %.preheader99, label %thread-pre-split, !llvm.loop !17

thread-pre-split:                                 ; preds = %.critedge, %.preheader100
  %.pr = load i32, ptr @cnt, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge, %thread-pre-split
  %100 = phi i32 [ %.pr, %thread-pre-split ], [ %96, %._crit_edge ]
  switch i32 %100, label %108 [
    i32 0, label %101
    i32 1, label %103
  ]

101:                                              ; preds = %.loopexit
  %102 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %110

103:                                              ; preds = %.loopexit
  %104 = load i32, ptr @id, align 4, !tbaa !5
  %105 = add nsw i32 %104, -1
  %106 = load i32, ptr @pos, align 4, !tbaa !5
  %107 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %105, i32 noundef %106)
  br label %110

108:                                              ; preds = %.loopexit
  %109 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %110

110:                                              ; preds = %103, %108, %101
  %111 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %112 = icmp eq i32 %111, 2
  br i1 %112, label %.lr.ph115, label %._crit_edge116, !llvm.loop !18

._crit_edge116:                                   ; preds = %110, %0
  ret i32 0
}

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

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

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

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


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