; LLVM IR from lzyrapx/Competitive-Programming :: Xiangtan Invitation Contest 2017 (1269(J)（树状数组+dp）)

; 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.BITree = type { [505 x i32] }

@a = external dso_local global [25 x i32], align 16
@b = external dso_local global [505 x i32], align 16
@dp = external dso_local global [25 x [505 x [505 x i32]]], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tree = external dso_local global [25 x [505 x %struct.BITree]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addRii(ptr noundef nonnull align 4 dereferenceable(4), 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 i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca 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 i32, align 4
  store i32 0, ptr %1, align 4
  br label %17

17:                                               ; preds = %313, %0
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %19 = xor i32 %18, -1
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %316

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

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

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %35

27:                                               ; preds = %22
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [25 x i32], ptr @a, i64 0, i64 %29
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %30)
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !5
  br label %22, !llvm.loop !9

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

36:                                               ; preds = %46, %35
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = load i32, ptr @m, align 4, !tbaa !5
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %49

41:                                               ; preds = %36
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [505 x i32], ptr @b, i64 0, i64 %43
  %45 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %44)
  br label %46

46:                                               ; preds = %41
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %3, align 4, !tbaa !5
  br label %36, !llvm.loop !11

49:                                               ; preds = %40
  call void @llvm.memset.p0.i64(ptr align 16 @dp, i8 0, i64 25502500, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %50

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

54:                                               ; preds = %50
  store i32 10, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %75

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

56:                                               ; preds = %68, %55
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = load i32, ptr @m, align 4, !tbaa !5
  %59 = icmp sle i32 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 13, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %71

61:                                               ; preds = %56
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %63
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [505 x %struct.BITree], ptr %64, i64 0, i64 %66
  call void @_ZN6BITree5clearEv(ptr noundef nonnull align 4 dereferenceable(2020) %67)
  br label %68

68:                                               ; preds = %61
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %6, align 4, !tbaa !5
  br label %56, !llvm.loop !12

71:                                               ; preds = %60
  br label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %4, align 4, !tbaa !5
  br label %50, !llvm.loop !13

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

76:                                               ; preds = %97, %75
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = load i32, ptr @m, align 4, !tbaa !5
  %79 = icmp sle i32 %77, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %76
  store i32 16, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %100

81:                                               ; preds = %76
  %82 = load i32, ptr getelementptr inbounds ([25 x i32], ptr @a, i64 0, i64 1), align 4, !tbaa !5
  %83 = icmp eq i32 %82, 1
  br i1 %83, label %84, label %89

84:                                               ; preds = %81
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds ([25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 1), i64 0, i64 %86
  %88 = getelementptr inbounds [505 x i32], ptr %87, i64 0, i64 1
  store i32 1, ptr %88, align 4, !tbaa !5
  br label %96

89:                                               ; preds = %81
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds ([25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 1), i64 0, i64 %91
  %93 = load i32, ptr @m, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [505 x i32], ptr %92, i64 0, i64 %94
  store i32 1, ptr %95, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %89, %84
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %7, align 4, !tbaa !5
  br label %76, !llvm.loop !14

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

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

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

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

107:                                              ; preds = %276, %106
  %108 = load i32, ptr %9, align 4, !tbaa !5
  %109 = load i32, ptr @m, align 4, !tbaa !5
  %110 = icmp sle i32 %108, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %107
  store i32 22, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %279

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

113:                                              ; preds = %139, %112
  %114 = load i32, ptr %10, align 4, !tbaa !5
  %115 = load i32, ptr @m, align 4, !tbaa !5
  %116 = icmp sle i32 %114, %115
  br i1 %116, label %118, label %117

117:                                              ; preds = %113
  store i32 25, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %142

118:                                              ; preds = %113
  %119 = load i32, ptr %8, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %120
  %122 = load i32, ptr %10, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [505 x %struct.BITree], ptr %121, i64 0, i64 %123
  %125 = load i32, ptr %9, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [505 x i32], ptr @b, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = call noundef i32 @_ZN6BITree5queryEi(ptr noundef nonnull align 4 dereferenceable(2020) %124, i32 noundef %128)
  %130 = load i32, ptr %8, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %131
  %133 = load i32, ptr %9, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [505 x [505 x i32]], ptr %132, i64 0, i64 %134
  %136 = load i32, ptr %10, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [505 x i32], ptr %135, i64 0, i64 %137
  store i32 %129, ptr %138, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %118
  %140 = load i32, ptr %10, align 4, !tbaa !5
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %10, align 4, !tbaa !5
  br label %113, !llvm.loop !15

142:                                              ; preds = %117
  %143 = load i32, ptr %8, align 4, !tbaa !5
  %144 = icmp eq i32 %143, 1
  br i1 %144, label %145, label %146

145:                                              ; preds = %142
  br label %276

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

147:                                              ; preds = %272, %146
  %148 = load i32, ptr %11, align 4, !tbaa !5
  %149 = load i32, ptr @m, align 4, !tbaa !5
  %150 = icmp sle i32 %148, %149
  br i1 %150, label %152, label %151

151:                                              ; preds = %147
  store i32 28, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %275

152:                                              ; preds = %147
  %153 = load i32, ptr %8, align 4, !tbaa !5
  %154 = sub nsw i32 %153, 1
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %155
  %157 = load i32, ptr %9, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [505 x [505 x i32]], ptr %156, i64 0, i64 %158
  %160 = load i32, ptr %11, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [505 x i32], ptr %159, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = icmp eq i32 %163, 0
  br i1 %164, label %165, label %166

165:                                              ; preds = %152
  br label %272

166:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %167 = load i32, ptr %9, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [505 x i32], ptr @b, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  store i32 %170, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %171 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %171, ptr %13, align 4, !tbaa !5
  %172 = load i32, ptr %8, align 4, !tbaa !5
  %173 = sub nsw i32 %172, 1
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [25 x i32], ptr @a, i64 0, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = icmp eq i32 %176, 1
  br i1 %177, label %178, label %179

178:                                              ; preds = %166
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13) #7
  br label %179

179:                                              ; preds = %178, %166
  %180 = load i32, ptr %12, align 4, !tbaa !5
  %181 = load i32, ptr %13, align 4, !tbaa !5
  %182 = icmp sgt i32 %180, %181
  br i1 %182, label %183, label %184

183:                                              ; preds = %179
  store i32 30, ptr %5, align 4
  br label %269

184:                                              ; preds = %179
  %185 = load i32, ptr %8, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [25 x i32], ptr @a, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = icmp eq i32 %188, 0
  br i1 %189, label %190, label %229

190:                                              ; preds = %184
  %191 = load i32, ptr %8, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %192
  %194 = load i32, ptr %13, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [505 x %struct.BITree], ptr %193, i64 0, i64 %195
  %197 = load i32, ptr %13, align 4, !tbaa !5
  %198 = load i32, ptr %8, align 4, !tbaa !5
  %199 = sub nsw i32 %198, 1
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %200
  %202 = load i32, ptr %9, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [505 x [505 x i32]], ptr %201, i64 0, i64 %203
  %205 = load i32, ptr %11, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [505 x i32], ptr %204, i64 0, i64 %206
  %208 = load i32, ptr %207, align 4, !tbaa !5
  call void @_ZN6BITree6updateEii(ptr noundef nonnull align 4 dereferenceable(2020) %196, i32 noundef %197, i32 noundef %208)
  %209 = load i32, ptr %8, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %210
  %212 = load i32, ptr %13, align 4, !tbaa !5
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [505 x %struct.BITree], ptr %211, i64 0, i64 %213
  %215 = load i32, ptr %12, align 4, !tbaa !5
  %216 = sub nsw i32 %215, 1
  %217 = load i32, ptr %8, align 4, !tbaa !5
  %218 = sub nsw i32 %217, 1
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %219
  %221 = load i32, ptr %9, align 4, !tbaa !5
  %222 = sext i32 %221 to i64
  %223 = getelementptr inbounds [505 x [505 x i32]], ptr %220, i64 0, i64 %222
  %224 = load i32, ptr %11, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [505 x i32], ptr %223, i64 0, i64 %225
  %227 = load i32, ptr %226, align 4, !tbaa !5
  %228 = sub nsw i32 0, %227
  call void @_ZN6BITree6updateEii(ptr noundef nonnull align 4 dereferenceable(2020) %214, i32 noundef %216, i32 noundef %228)
  br label %268

229:                                              ; preds = %184
  %230 = load i32, ptr %8, align 4, !tbaa !5
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %231
  %233 = load i32, ptr %12, align 4, !tbaa !5
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [505 x %struct.BITree], ptr %232, i64 0, i64 %234
  %236 = load i32, ptr %13, align 4, !tbaa !5
  %237 = load i32, ptr %8, align 4, !tbaa !5
  %238 = sub nsw i32 %237, 1
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %239
  %241 = load i32, ptr %9, align 4, !tbaa !5
  %242 = sext i32 %241 to i64
  %243 = getelementptr inbounds [505 x [505 x i32]], ptr %240, i64 0, i64 %242
  %244 = load i32, ptr %11, align 4, !tbaa !5
  %245 = sext i32 %244 to i64
  %246 = getelementptr inbounds [505 x i32], ptr %243, i64 0, i64 %245
  %247 = load i32, ptr %246, align 4, !tbaa !5
  call void @_ZN6BITree6updateEii(ptr noundef nonnull align 4 dereferenceable(2020) %235, i32 noundef %236, i32 noundef %247)
  %248 = load i32, ptr %8, align 4, !tbaa !5
  %249 = sext i32 %248 to i64
  %250 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %249
  %251 = load i32, ptr %12, align 4, !tbaa !5
  %252 = sext i32 %251 to i64
  %253 = getelementptr inbounds [505 x %struct.BITree], ptr %250, i64 0, i64 %252
  %254 = load i32, ptr %12, align 4, !tbaa !5
  %255 = sub nsw i32 %254, 1
  %256 = load i32, ptr %8, align 4, !tbaa !5
  %257 = sub nsw i32 %256, 1
  %258 = sext i32 %257 to i64
  %259 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %258
  %260 = load i32, ptr %9, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [505 x [505 x i32]], ptr %259, i64 0, i64 %261
  %263 = load i32, ptr %11, align 4, !tbaa !5
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds [505 x i32], ptr %262, i64 0, i64 %264
  %266 = load i32, ptr %265, align 4, !tbaa !5
  %267 = sub nsw i32 0, %266
  call void @_ZN6BITree6updateEii(ptr noundef nonnull align 4 dereferenceable(2020) %253, i32 noundef %255, i32 noundef %267)
  br label %268

268:                                              ; preds = %229, %190
  store i32 0, ptr %5, align 4
  br label %269

269:                                              ; preds = %268, %183
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  %270 = load i32, ptr %5, align 4
  switch i32 %270, label %317 [
    i32 0, label %271
    i32 30, label %272
  ]

271:                                              ; preds = %269
  br label %272

272:                                              ; preds = %271, %269, %165
  %273 = load i32, ptr %11, align 4, !tbaa !5
  %274 = add nsw i32 %273, 1
  store i32 %274, ptr %11, align 4, !tbaa !5
  br label %147, !llvm.loop !16

275:                                              ; preds = %151
  br label %276

276:                                              ; preds = %275, %145
  %277 = load i32, ptr %9, align 4, !tbaa !5
  %278 = add nsw i32 %277, 1
  store i32 %278, ptr %9, align 4, !tbaa !5
  br label %107, !llvm.loop !17

279:                                              ; preds = %111
  br label %280

280:                                              ; preds = %279
  %281 = load i32, ptr %8, align 4, !tbaa !5
  %282 = add nsw i32 %281, 1
  store i32 %282, ptr %8, align 4, !tbaa !5
  br label %101, !llvm.loop !18

283:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 1, ptr %15, align 4, !tbaa !5
  br label %284

284:                                              ; preds = %310, %283
  %285 = load i32, ptr %15, align 4, !tbaa !5
  %286 = load i32, ptr @m, align 4, !tbaa !5
  %287 = icmp sle i32 %285, %286
  br i1 %287, label %289, label %288

288:                                              ; preds = %284
  store i32 31, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %313

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

290:                                              ; preds = %306, %289
  %291 = load i32, ptr %16, align 4, !tbaa !5
  %292 = load i32, ptr @m, align 4, !tbaa !5
  %293 = icmp sle i32 %291, %292
  br i1 %293, label %295, label %294

294:                                              ; preds = %290
  store i32 34, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %309

295:                                              ; preds = %290
  %296 = load i32, ptr @n, align 4, !tbaa !5
  %297 = sext i32 %296 to i64
  %298 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %297
  %299 = load i32, ptr %15, align 4, !tbaa !5
  %300 = sext i32 %299 to i64
  %301 = getelementptr inbounds [505 x [505 x i32]], ptr %298, i64 0, i64 %300
  %302 = load i32, ptr %16, align 4, !tbaa !5
  %303 = sext i32 %302 to i64
  %304 = getelementptr inbounds [505 x i32], ptr %301, i64 0, i64 %303
  %305 = load i32, ptr %304, align 4, !tbaa !5
  call void @_Z3addRii(ptr noundef nonnull align 4 dereferenceable(4) %14, i32 noundef %305)
  br label %306

306:                                              ; preds = %295
  %307 = load i32, ptr %16, align 4, !tbaa !5
  %308 = add nsw i32 %307, 1
  store i32 %308, ptr %16, align 4, !tbaa !5
  br label %290, !llvm.loop !19

309:                                              ; preds = %294
  br label %310

310:                                              ; preds = %309
  %311 = load i32, ptr %15, align 4, !tbaa !5
  %312 = add nsw i32 %311, 1
  store i32 %312, ptr %15, align 4, !tbaa !5
  br label %284, !llvm.loop !20

313:                                              ; preds = %288
  %314 = load i32, ptr %14, align 4, !tbaa !5
  %315 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %314)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %17, !llvm.loop !21

316:                                              ; preds = %17
  ret i32 0

317:                                              ; preds = %269
  unreachable
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BITree5clearEv(ptr noundef nonnull align 4 dereferenceable(2020)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6BITree5queryEi(ptr noundef nonnull align 4 dereferenceable(2020), i32 noundef) #5 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BITree6updateEii(ptr noundef nonnull align 4 dereferenceable(2020), i32 noundef, i32 noundef) #0 align 2

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

attributes #0 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { 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 #7 = { nounwind }

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

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


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

%struct.BITree = type { [505 x i32] }

@a = external dso_local global [25 x i32], align 16
@b = external dso_local global [505 x i32], align 16
@dp = external dso_local local_unnamed_addr global [25 x [505 x [505 x i32]]], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tree = external dso_local global [25 x [505 x %struct.BITree]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addRii(ptr noundef nonnull align 4 dereferenceable(4), 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 i32, align 4
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %.not126 = icmp eq i32 %4, -1
  br i1 %.not126, label %._crit_edge127, label %.preheader91

.preheader91:                                     ; preds = %0, %._crit_edge125
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not7392 = icmp slt i32 %5, 1
  br i1 %.not7392, label %.preheader90, label %.lr.ph

.preheader90:                                     ; preds = %.lr.ph, %.preheader91
  %6 = phi i32 [ %5, %.preheader91 ], [ %10, %.lr.ph ]
  %7 = load i32, ptr @m, align 4, !tbaa !5
  %.not7494 = icmp slt i32 %7, 1
  br i1 %.not7494, label %._crit_edge, label %.lr.ph96

.lr.ph:                                           ; preds = %.preheader91, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.preheader91 ]
  %8 = getelementptr inbounds [25 x i32], ptr @a, i64 0, i64 %indvars.iv
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %.not73.not = icmp slt i64 %indvars.iv, %11
  br i1 %.not73.not, label %.lr.ph, label %.preheader90, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %.lr.ph96
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader90
  %12 = phi i32 [ %17, %._crit_edge.loopexit ], [ %7, %.preheader90 ]
  %13 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %6, %.preheader90 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(25502500) @dp, i8 0, i64 25502500, i1 false)
  %.not75101 = icmp slt i32 %13, 1
  br i1 %.not75101, label %.preheader89, label %.preheader87.lr.ph

.preheader87.lr.ph:                               ; preds = %._crit_edge
  %14 = icmp slt i32 %12, 1
  br i1 %14, label %.preheader88, label %.preheader87

.lr.ph96:                                         ; preds = %.preheader90, %.lr.ph96
  %indvars.iv131 = phi i64 [ %indvars.iv.next132, %.lr.ph96 ], [ 1, %.preheader90 ]
  %15 = getelementptr inbounds [505 x i32], ptr @b, i64 0, i64 %indvars.iv131
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %15)
  %indvars.iv.next132 = add nuw nsw i64 %indvars.iv131, 1
  %17 = load i32, ptr @m, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %.not74.not = icmp slt i64 %indvars.iv131, %18
  br i1 %.not74.not, label %.lr.ph96, label %._crit_edge.loopexit, !llvm.loop !11

.preheader89:                                     ; preds = %._crit_edge100, %._crit_edge
  %19 = phi i32 [ %13, %._crit_edge ], [ %37, %._crit_edge100 ]
  %20 = phi i32 [ %12, %._crit_edge ], [ %38, %._crit_edge100 ]
  %.not76103 = icmp slt i32 %20, 1
  br i1 %.not76103, label %.preheader88, label %.lr.ph105

.lr.ph105:                                        ; preds = %.preheader89
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  %22 = icmp eq i32 %21, 1
  %23 = zext nneg i32 %20 to i64
  %24 = add nuw i32 %20, 1
  %wide.trip.count146 = zext i32 %24 to i64
  br i1 %22, label %.lr.ph105.split.us.preheader, label %.lr.ph105.split.preheader

.lr.ph105.split.preheader:                        ; preds = %.lr.ph105
  %25 = zext nneg i32 %20 to i64
  %26 = add nsw i64 %wide.trip.count146, -2
  %xtraiter = and i64 %25, 3
  %27 = icmp ult i64 %26, 3
  br i1 %27, label %.preheader88.loopexit201.unr-lcssa, label %.lr.ph105.split.preheader.new

.lr.ph105.split.preheader.new:                    ; preds = %.lr.ph105.split.preheader
  %unroll_iter = and i64 %25, 2147483644
  br label %.lr.ph105.split

.lr.ph105.split.us.preheader:                     ; preds = %.lr.ph105
  %28 = zext nneg i32 %20 to i64
  %29 = add nsw i64 %wide.trip.count146, -2
  %xtraiter212 = and i64 %28, 3
  %30 = icmp ult i64 %29, 3
  br i1 %30, label %.preheader88.loopexit.unr-lcssa, label %.lr.ph105.split.us.preheader.new

.lr.ph105.split.us.preheader.new:                 ; preds = %.lr.ph105.split.us.preheader
  %unroll_iter215 = and i64 %28, 2147483644
  br label %.lr.ph105.split.us

.lr.ph105.split.us:                               ; preds = %.lr.ph105.split.us, %.lr.ph105.split.us.preheader.new
  %indvars.iv143 = phi i64 [ 1, %.lr.ph105.split.us.preheader.new ], [ %indvars.iv.next144.3, %.lr.ph105.split.us ]
  %niter216 = phi i64 [ 0, %.lr.ph105.split.us.preheader.new ], [ %niter216.next.3, %.lr.ph105.split.us ]
  %31 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv143, i64 1
  store i32 1, ptr %31, align 4, !tbaa !5
  %indvars.iv.next144 = add nuw nsw i64 %indvars.iv143, 1
  %32 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv.next144, i64 1
  store i32 1, ptr %32, align 4, !tbaa !5
  %indvars.iv.next144.1 = add nuw nsw i64 %indvars.iv143, 2
  %33 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv.next144.1, i64 1
  store i32 1, ptr %33, align 4, !tbaa !5
  %indvars.iv.next144.2 = add nuw nsw i64 %indvars.iv143, 3
  %34 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv.next144.2, i64 1
  store i32 1, ptr %34, align 4, !tbaa !5
  %indvars.iv.next144.3 = add nuw nsw i64 %indvars.iv143, 4
  %niter216.next.3 = add i64 %niter216, 4
  %niter216.ncmp.3 = icmp eq i64 %niter216.next.3, %unroll_iter215
  br i1 %niter216.ncmp.3, label %.preheader88.loopexit.unr-lcssa, label %.lr.ph105.split.us, !llvm.loop !12

.preheader87:                                     ; preds = %.preheader87.lr.ph, %._crit_edge100
  %35 = phi i32 [ %37, %._crit_edge100 ], [ %13, %.preheader87.lr.ph ]
  %36 = phi i32 [ %38, %._crit_edge100 ], [ %12, %.preheader87.lr.ph ]
  %indvars.iv137 = phi i64 [ %indvars.iv.next138, %._crit_edge100 ], [ 1, %.preheader87.lr.ph ]
  %.not8397 = icmp slt i32 %36, 1
  br i1 %.not8397, label %._crit_edge100, label %.lr.ph99

._crit_edge100.loopexit:                          ; preds = %.lr.ph99
  %.pre166 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge100

._crit_edge100:                                   ; preds = %._crit_edge100.loopexit, %.preheader87
  %37 = phi i32 [ %.pre166, %._crit_edge100.loopexit ], [ %35, %.preheader87 ]
  %38 = phi i32 [ %41, %._crit_edge100.loopexit ], [ %36, %.preheader87 ]
  %indvars.iv.next138 = add nuw nsw i64 %indvars.iv137, 1
  %39 = sext i32 %37 to i64
  %.not75.not = icmp slt i64 %indvars.iv137, %39
  br i1 %.not75.not, label %.preheader87, label %.preheader89, !llvm.loop !13

.lr.ph99:                                         ; preds = %.preheader87, %.lr.ph99
  %indvars.iv134 = phi i64 [ %indvars.iv.next135, %.lr.ph99 ], [ 1, %.preheader87 ]
  %40 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %indvars.iv137, i64 %indvars.iv134
  call void @_ZN6BITree5clearEv(ptr noundef nonnull align 4 dereferenceable(2020) %40)
  %indvars.iv.next135 = add nuw nsw i64 %indvars.iv134, 1
  %41 = load i32, ptr @m, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %.not83.not = icmp slt i64 %indvars.iv134, %42
  br i1 %.not83.not, label %.lr.ph99, label %._crit_edge100.loopexit, !llvm.loop !15

.preheader88.loopexit.unr-lcssa:                  ; preds = %.lr.ph105.split.us, %.lr.ph105.split.us.preheader
  %indvars.iv143.unr = phi i64 [ 1, %.lr.ph105.split.us.preheader ], [ %indvars.iv.next144.3, %.lr.ph105.split.us ]
  %lcmp.mod214.not = icmp eq i64 %xtraiter212, 0
  br i1 %lcmp.mod214.not, label %.preheader88, label %.lr.ph105.split.us.epil

.lr.ph105.split.us.epil:                          ; preds = %.preheader88.loopexit.unr-lcssa, %.lr.ph105.split.us.epil
  %indvars.iv143.epil = phi i64 [ %indvars.iv.next144.epil, %.lr.ph105.split.us.epil ], [ %indvars.iv143.unr, %.preheader88.loopexit.unr-lcssa ]
  %epil.iter213 = phi i64 [ %epil.iter213.next, %.lr.ph105.split.us.epil ], [ 0, %.preheader88.loopexit.unr-lcssa ]
  %43 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv143.epil, i64 1
  store i32 1, ptr %43, align 4, !tbaa !5
  %indvars.iv.next144.epil = add nuw nsw i64 %indvars.iv143.epil, 1
  %epil.iter213.next = add i64 %epil.iter213, 1
  %epil.iter213.cmp.not = icmp eq i64 %epil.iter213.next, %xtraiter212
  br i1 %epil.iter213.cmp.not, label %.preheader88, label %.lr.ph105.split.us.epil, !llvm.loop !16

.preheader88.loopexit201.unr-lcssa:               ; preds = %.lr.ph105.split, %.lr.ph105.split.preheader
  %indvars.iv140.unr = phi i64 [ 1, %.lr.ph105.split.preheader ], [ %indvars.iv.next141.3, %.lr.ph105.split ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader88, label %.lr.ph105.split.epil

.lr.ph105.split.epil:                             ; preds = %.preheader88.loopexit201.unr-lcssa, %.lr.ph105.split.epil
  %indvars.iv140.epil = phi i64 [ %indvars.iv.next141.epil, %.lr.ph105.split.epil ], [ %indvars.iv140.unr, %.preheader88.loopexit201.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph105.split.epil ], [ 0, %.preheader88.loopexit201.unr-lcssa ]
  %44 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv140.epil, i64 %23
  store i32 1, ptr %44, align 4, !tbaa !5
  %indvars.iv.next141.epil = add nuw nsw i64 %indvars.iv140.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader88, label %.lr.ph105.split.epil, !llvm.loop !18

.preheader88:                                     ; preds = %.preheader88.loopexit201.unr-lcssa, %.lr.ph105.split.epil, %.preheader88.loopexit.unr-lcssa, %.lr.ph105.split.us.epil, %.preheader87.lr.ph, %.preheader89
  %45 = phi i32 [ %20, %.preheader89 ], [ %12, %.preheader87.lr.ph ], [ %20, %.lr.ph105.split.us.epil ], [ %20, %.preheader88.loopexit.unr-lcssa ], [ %20, %.lr.ph105.split.epil ], [ %20, %.preheader88.loopexit201.unr-lcssa ]
  %46 = phi i32 [ %19, %.preheader89 ], [ %13, %.preheader87.lr.ph ], [ %19, %.lr.ph105.split.us.epil ], [ %19, %.preheader88.loopexit.unr-lcssa ], [ %19, %.lr.ph105.split.epil ], [ %19, %.preheader88.loopexit201.unr-lcssa ]
  %.not77116 = icmp slt i32 %46, 2
  br i1 %.not77116, label %._crit_edge118, label %.preheader86

.lr.ph105.split:                                  ; preds = %.lr.ph105.split, %.lr.ph105.split.preheader.new
  %indvars.iv140 = phi i64 [ 1, %.lr.ph105.split.preheader.new ], [ %indvars.iv.next141.3, %.lr.ph105.split ]
  %niter = phi i64 [ 0, %.lr.ph105.split.preheader.new ], [ %niter.next.3, %.lr.ph105.split ]
  %47 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv140, i64 %23
  store i32 1, ptr %47, align 4, !tbaa !5
  %indvars.iv.next141 = add nuw nsw i64 %indvars.iv140, 1
  %48 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv.next141, i64 %23
  store i32 1, ptr %48, align 4, !tbaa !5
  %indvars.iv.next141.1 = add nuw nsw i64 %indvars.iv140, 2
  %49 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv.next141.1, i64 %23
  store i32 1, ptr %49, align 4, !tbaa !5
  %indvars.iv.next141.2 = add nuw nsw i64 %indvars.iv140, 3
  %50 = getelementptr inbounds [505 x [505 x i32]], ptr getelementptr inbounds (i8, ptr @dp, i64 1020100), i64 0, i64 %indvars.iv.next141.2, i64 %23
  store i32 1, ptr %50, align 4, !tbaa !5
  %indvars.iv.next141.3 = add nuw nsw i64 %indvars.iv140, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader88.loopexit201.unr-lcssa, label %.lr.ph105.split, !llvm.loop !12

.preheader86:                                     ; preds = %.preheader88, %._crit_edge115
  %51 = phi i32 [ %61, %._crit_edge115 ], [ %46, %.preheader88 ]
  %52 = phi i32 [ %62, %._crit_edge115 ], [ %45, %.preheader88 ]
  %53 = phi i32 [ %63, %._crit_edge115 ], [ %45, %.preheader88 ]
  %indvars.iv157 = phi i64 [ %indvars.iv.next158, %._crit_edge115 ], [ 2, %.preheader88 ]
  %.not80113 = icmp slt i32 %53, 1
  br i1 %.not80113, label %._crit_edge115, label %.preheader84.lr.ph

.preheader84.lr.ph:                               ; preds = %.preheader86
  %54 = add nsw i64 %indvars.iv157, -1
  %55 = getelementptr inbounds [25 x i32], ptr @a, i64 0, i64 %54
  %56 = getelementptr inbounds [25 x i32], ptr @a, i64 0, i64 %indvars.iv157
  br label %.preheader84

._crit_edge118:                                   ; preds = %._crit_edge115, %.preheader88
  %57 = phi i32 [ %45, %.preheader88 ], [ %62, %._crit_edge115 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  %.not78123 = icmp slt i32 %57, 1
  br i1 %.not78123, label %._crit_edge125, label %.preheader85

.preheader84:                                     ; preds = %.preheader84.lr.ph, %._crit_edge112
  %58 = phi i32 [ %52, %.preheader84.lr.ph ], [ %110, %._crit_edge112 ]
  %59 = phi i32 [ %53, %.preheader84.lr.ph ], [ %110, %._crit_edge112 ]
  %indvars.iv154 = phi i64 [ 1, %.preheader84.lr.ph ], [ %indvars.iv.next155, %._crit_edge112 ]
  %.not81106 = icmp slt i32 %59, 1
  br i1 %.not81106, label %._crit_edge112, label %.lr.ph108

.lr.ph108:                                        ; preds = %.preheader84
  %60 = getelementptr inbounds [505 x i32], ptr @b, i64 0, i64 %indvars.iv154
  br label %66

._crit_edge115.loopexit:                          ; preds = %._crit_edge112
  %.pre170 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge115

._crit_edge115:                                   ; preds = %._crit_edge115.loopexit, %.preheader86
  %61 = phi i32 [ %.pre170, %._crit_edge115.loopexit ], [ %51, %.preheader86 ]
  %62 = phi i32 [ %110, %._crit_edge115.loopexit ], [ %52, %.preheader86 ]
  %63 = phi i32 [ %110, %._crit_edge115.loopexit ], [ %53, %.preheader86 ]
  %indvars.iv.next158 = add nuw nsw i64 %indvars.iv157, 1
  %64 = sext i32 %61 to i64
  %.not77.not = icmp slt i64 %indvars.iv157, %64
  br i1 %.not77.not, label %.preheader86, label %._crit_edge118, !llvm.loop !19

.preheader:                                       ; preds = %66
  %.not82109 = icmp slt i32 %71, 1
  br i1 %.not82109, label %._crit_edge112, label %.lr.ph111

.lr.ph111:                                        ; preds = %.preheader
  %65 = getelementptr inbounds [505 x i32], ptr @b, i64 0, i64 %indvars.iv154
  br label %73

66:                                               ; preds = %.lr.ph108, %66
  %indvars.iv148 = phi i64 [ 1, %.lr.ph108 ], [ %indvars.iv.next149, %66 ]
  %67 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %indvars.iv157, i64 %indvars.iv148
  %68 = load i32, ptr %60, align 4, !tbaa !5
  %69 = call noundef i32 @_ZN6BITree5queryEi(ptr noundef nonnull align 4 dereferenceable(2020) %67, i32 noundef %68)
  %70 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %indvars.iv157, i64 %indvars.iv154, i64 %indvars.iv148
  store i32 %69, ptr %70, align 4, !tbaa !5
  %indvars.iv.next149 = add nuw nsw i64 %indvars.iv148, 1
  %71 = load i32, ptr @m, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %.not81.not = icmp slt i64 %indvars.iv148, %72
  br i1 %.not81.not, label %66, label %.preheader, !llvm.loop !20

73:                                               ; preds = %.lr.ph111, %106
  %74 = phi i32 [ %71, %.lr.ph111 ], [ %107, %106 ]
  %75 = phi i32 [ %71, %.lr.ph111 ], [ %108, %106 ]
  %indvars.iv151 = phi i64 [ 1, %.lr.ph111 ], [ %indvars.iv.next152, %106 ]
  %76 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %54, i64 %indvars.iv154, i64 %indvars.iv151
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = icmp eq i32 %77, 0
  br i1 %78, label %106, label %79

79:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %80 = load i32, ptr %65, align 4, !tbaa !5
  store i32 %80, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %81 = trunc nuw nsw i64 %indvars.iv151 to i32
  store i32 %81, ptr %2, align 4, !tbaa !5
  %82 = load i32, ptr %55, align 4, !tbaa !5
  %83 = icmp eq i32 %82, 1
  br i1 %83, label %84, label %85

84:                                               ; preds = %79
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2) #7
  %.pre167 = load i32, ptr %1, align 4, !tbaa !5
  %.pre168 = load i32, ptr %2, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %84, %79
  %86 = phi i32 [ %.pre168, %84 ], [ %81, %79 ]
  %87 = phi i32 [ %.pre167, %84 ], [ %80, %79 ]
  %88 = icmp sgt i32 %87, %86
  br i1 %88, label %105, label %89

89:                                               ; preds = %85
  %90 = load i32, ptr %56, align 4, !tbaa !5
  %91 = icmp eq i32 %90, 0
  %92 = load i32, ptr %76, align 4, !tbaa !5
  br i1 %91, label %93, label %98

93:                                               ; preds = %89
  %94 = sext i32 %86 to i64
  %95 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %indvars.iv157, i64 %94
  call void @_ZN6BITree6updateEii(ptr noundef nonnull align 4 dereferenceable(2020) %95, i32 noundef %86, i32 noundef %92)
  %96 = load i32, ptr %2, align 4, !tbaa !5
  %97 = load i32, ptr %1, align 4, !tbaa !5
  br label %.sink.split

98:                                               ; preds = %89
  %99 = sext i32 %87 to i64
  %100 = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %indvars.iv157, i64 %99
  call void @_ZN6BITree6updateEii(ptr noundef nonnull align 4 dereferenceable(2020) %100, i32 noundef %86, i32 noundef %92)
  %101 = load i32, ptr %1, align 4, !tbaa !5
  br label %.sink.split

.sink.split:                                      ; preds = %98, %93
  %.sink189 = phi i32 [ %97, %93 ], [ %101, %98 ]
  %.pn.in = phi i32 [ %96, %93 ], [ %101, %98 ]
  %.pn = sext i32 %.pn.in to i64
  %.sink = getelementptr inbounds [25 x [505 x %struct.BITree]], ptr @tree, i64 0, i64 %indvars.iv157, i64 %.pn
  %102 = add nsw i32 %.sink189, -1
  %103 = load i32, ptr %76, align 4, !tbaa !5
  %104 = sub nsw i32 0, %103
  call void @_ZN6BITree6updateEii(ptr noundef nonnull align 4 dereferenceable(2020) %.sink, i32 noundef %102, i32 noundef %104)
  br label %105

105:                                              ; preds = %.sink.split, %85
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %.pre169 = load i32, ptr @m, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %105, %73
  %107 = phi i32 [ %.pre169, %105 ], [ %74, %73 ]
  %108 = phi i32 [ %.pre169, %105 ], [ %75, %73 ]
  %indvars.iv.next152 = add nuw nsw i64 %indvars.iv151, 1
  %109 = sext i32 %108 to i64
  %.not82.not = icmp slt i64 %indvars.iv151, %109
  br i1 %.not82.not, label %73, label %._crit_edge112, !llvm.loop !21

._crit_edge112:                                   ; preds = %106, %.preheader84, %.preheader
  %110 = phi i32 [ %71, %.preheader ], [ %58, %.preheader84 ], [ %107, %106 ]
  %indvars.iv.next155 = add nuw nsw i64 %indvars.iv154, 1
  %111 = sext i32 %110 to i64
  %.not80.not = icmp slt i64 %indvars.iv154, %111
  br i1 %.not80.not, label %.preheader84, label %._crit_edge115.loopexit, !llvm.loop !22

.preheader85:                                     ; preds = %._crit_edge118, %._crit_edge122
  %112 = phi i32 [ %116, %._crit_edge122 ], [ %57, %._crit_edge118 ]
  %indvars.iv163 = phi i64 [ %indvars.iv.next164, %._crit_edge122 ], [ 1, %._crit_edge118 ]
  %.not79119 = icmp slt i32 %112, 1
  br i1 %.not79119, label %.preheader85.._crit_edge122_crit_edge, label %.lr.ph121

.preheader85.._crit_edge122_crit_edge:            ; preds = %.preheader85
  %.pre172 = sext i32 %112 to i64
  br label %._crit_edge122

._crit_edge125.loopexit:                          ; preds = %._crit_edge122
  %.pre171 = load i32, ptr %3, align 4, !tbaa !5
  br label %._crit_edge125

._crit_edge125:                                   ; preds = %._crit_edge125.loopexit, %._crit_edge118
  %113 = phi i32 [ %.pre171, %._crit_edge125.loopexit ], [ 0, %._crit_edge118 ]
  %114 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %113)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  %115 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %.not = icmp eq i32 %115, -1
  br i1 %.not, label %._crit_edge127, label %.preheader91, !llvm.loop !23

._crit_edge122:                                   ; preds = %.lr.ph121, %.preheader85.._crit_edge122_crit_edge
  %.pre-phi = phi i64 [ %.pre172, %.preheader85.._crit_edge122_crit_edge ], [ %122, %.lr.ph121 ]
  %116 = phi i32 [ %112, %.preheader85.._crit_edge122_crit_edge ], [ %121, %.lr.ph121 ]
  %indvars.iv.next164 = add nuw nsw i64 %indvars.iv163, 1
  %.not78.not = icmp slt i64 %indvars.iv163, %.pre-phi
  br i1 %.not78.not, label %.preheader85, label %._crit_edge125.loopexit, !llvm.loop !24

.lr.ph121:                                        ; preds = %.preheader85, %.lr.ph121
  %indvars.iv160 = phi i64 [ %indvars.iv.next161, %.lr.ph121 ], [ 1, %.preheader85 ]
  %117 = load i32, ptr @n, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [25 x [505 x [505 x i32]]], ptr @dp, i64 0, i64 %118, i64 %indvars.iv163, i64 %indvars.iv160
  %120 = load i32, ptr %119, align 4, !tbaa !5
  call void @_Z3addRii(ptr noundef nonnull align 4 dereferenceable(4) %3, i32 noundef %120)
  %indvars.iv.next161 = add nuw nsw i64 %indvars.iv160, 1
  %121 = load i32, ptr @m, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %.not79.not = icmp slt i64 %indvars.iv160, %122
  br i1 %.not79.not, label %.lr.ph121, label %._crit_edge122, !llvm.loop !25

._crit_edge127:                                   ; preds = %._crit_edge125, %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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BITree5clearEv(ptr noundef nonnull align 4 dereferenceable(2020)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6BITree5queryEi(ptr noundef nonnull align 4 dereferenceable(2020), i32 noundef) local_unnamed_addr #5 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6BITree6updateEii(ptr noundef nonnull align 4 dereferenceable(2020), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

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

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { 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 #7 = { nounwind }

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

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


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