; LLVM IR from tangjz/acm-icpc :: hdu (5192)

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

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

@n = external dso_local global i32, align 4
@bit1 = external dso_local global [50010 x i32], align 16
@d = external dso_local global [150030 x i32], align 16
@pos = external dso_local global i32, align 4
@w = external dso_local global i64, align 8
@h = external dso_local global i64, align 8
@bit2 = external dso_local global [50010 x i64], align 16
@sum = external dso_local global [150030 x i64], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addiix(i32 noundef, i32 noundef, i64 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local { i32, i64 } @_Z5queryi(i32 noundef) #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca %"struct.std::pair", align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca %"struct.std::pair", align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  br label %17

17:                                               ; preds = %292, %80, %0
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @w, ptr noundef @h)
  %19 = icmp eq i32 %18, 3
  br i1 %19, label %20, label %296

20:                                               ; preds = %17
  store i64 1000000000000, ptr @ans, align 8, !tbaa !5
  %21 = load i64, ptr @h, align 8, !tbaa !5
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr @pos, align 4, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 16 @d, i8 0, i64 600120, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @bit1, i8 0, i64 200040, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @bit2, i8 0, i64 400080, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %34, %20
  %24 = load i32, ptr %2, align 4, !tbaa !9
  %25 = load i32, ptr @n, align 4, !tbaa !9
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %23
  %29 = load i64, ptr @w, align 8, !tbaa !5
  %30 = load i32, ptr %2, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = add nsw i64 %29, %31
  %33 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %32
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %33)
  br label %34

34:                                               ; preds = %28
  %35 = load i32, ptr %2, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !9
  br label %23, !llvm.loop !11

37:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %64, %37
  %39 = load i32, ptr %3, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = load i64, ptr @w, align 8, !tbaa !5
  %42 = load i64, ptr @w, align 8, !tbaa !5
  %43 = add nsw i64 %41, %42
  %44 = load i32, ptr @n, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = add nsw i64 %43, %45
  %47 = icmp slt i64 %40, %46
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %38
  %50 = load i32, ptr %3, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !5
  %54 = load i32, ptr %3, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = add nsw i64 %53, %58
  %60 = load i32, ptr %3, align 4, !tbaa !9
  %61 = add nsw i32 %60, 1
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %62
  store i64 %59, ptr %63, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %49
  %65 = load i32, ptr %3, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %3, align 4, !tbaa !9
  br label %38, !llvm.loop !13

67:                                               ; preds = %48
  %68 = load i64, ptr @w, align 8, !tbaa !5
  %69 = load i64, ptr @w, align 8, !tbaa !5
  %70 = add nsw i64 %68, %69
  %71 = load i32, ptr @n, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = add nsw i64 %70, %72
  %74 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %73
  %75 = load i64, ptr %74, align 8, !tbaa !5
  %76 = load i64, ptr @w, align 8, !tbaa !5
  %77 = load i64, ptr @h, align 8, !tbaa !5
  %78 = mul nsw i64 %76, %77
  %79 = icmp slt i64 %75, %78
  br i1 %79, label %80, label %82

80:                                               ; preds = %67
  %81 = call i32 @puts(ptr noundef @.str.1)
  br label %17, !llvm.loop !14

82:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %289, %82
  %84 = load i32, ptr %4, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = load i64, ptr @w, align 8, !tbaa !5
  %87 = load i32, ptr @n, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = add nsw i64 %86, %88
  %90 = icmp slt i64 %85, %89
  br i1 %90, label %92, label %91

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

92:                                               ; preds = %83
  br label %93

93:                                               ; preds = %101, %92
  %94 = load i32, ptr %5, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = load i64, ptr @w, align 8, !tbaa !5
  %97 = load i32, ptr %4, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = add nsw i64 %96, %98
  %100 = icmp slt i64 %95, %99
  br i1 %100, label %101, label %114

101:                                              ; preds = %93
  %102 = load i32, ptr %5, align 4, !tbaa !9
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  %107 = load i32, ptr %5, align 4, !tbaa !9
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !9
  %111 = sext i32 %110 to i64
  call void @_Z3addiix(i32 noundef %106, i32 noundef 1, i64 noundef %111)
  %112 = load i32, ptr %5, align 4, !tbaa !9
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %5, align 4, !tbaa !9
  br label %93, !llvm.loop !15

114:                                              ; preds = %93
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %115 = load i32, ptr %5, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %116
  %118 = load i64, ptr %117, align 8, !tbaa !5
  %119 = load i32, ptr %4, align 4, !tbaa !9
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %120
  %122 = load i64, ptr %121, align 8, !tbaa !5
  %123 = sub nsw i64 %118, %122
  %124 = load i64, ptr @w, align 8, !tbaa !5
  %125 = sdiv i64 %123, %124
  store i64 %125, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %126 = load i64, ptr %7, align 8, !tbaa !5
  store i64 %126, ptr %8, align 8, !tbaa !5
  br label %127

127:                                              ; preds = %213, %114
  %128 = load i64, ptr %8, align 8, !tbaa !5
  %129 = load i64, ptr %7, align 8, !tbaa !5
  %130 = add nsw i64 %129, 1
  %131 = icmp sle i64 %128, %130
  br i1 %131, label %133, label %132

132:                                              ; preds = %127
  store i32 15, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %216

133:                                              ; preds = %127
  %134 = load i64, ptr %8, align 8, !tbaa !5
  %135 = load i64, ptr @h, align 8, !tbaa !5
  %136 = icmp sge i64 %134, %135
  br i1 %136, label %137, label %212

137:                                              ; preds = %133
  %138 = load i64, ptr @w, align 8, !tbaa !5
  %139 = load i64, ptr @w, align 8, !tbaa !5
  %140 = add nsw i64 %138, %139
  %141 = load i32, ptr @n, align 4, !tbaa !9
  %142 = sext i32 %141 to i64
  %143 = add nsw i64 %140, %142
  %144 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %143
  %145 = load i64, ptr %144, align 8, !tbaa !5
  %146 = load i64, ptr @w, align 8, !tbaa !5
  %147 = load i64, ptr %8, align 8, !tbaa !5
  %148 = mul nsw i64 %146, %147
  %149 = icmp sge i64 %145, %148
  br i1 %149, label %150, label %212

150:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #7
  %151 = load i64, ptr %8, align 8, !tbaa !5
  %152 = add nsw i64 %151, 1
  %153 = trunc i64 %152 to i32
  %154 = call { i32, i64 } @_Z5queryi(i32 noundef %153)
  %155 = getelementptr inbounds { i32, i64 }, ptr %9, i32 0, i32 0
  %156 = extractvalue { i32, i64 } %154, 0
  store i32 %156, ptr %155, align 8
  %157 = getelementptr inbounds { i32, i64 }, ptr %9, i32 0, i32 1
  %158 = extractvalue { i32, i64 } %154, 1
  store i64 %158, ptr %157, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %159 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %160 = load i32, ptr %159, align 8, !tbaa !16
  %161 = sext i32 %160 to i64
  %162 = load i64, ptr %8, align 8, !tbaa !5
  %163 = mul nsw i64 %161, %162
  %164 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 1
  %165 = load i64, ptr %164, align 8, !tbaa !18
  %166 = sub nsw i64 %163, %165
  store i64 %166, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %167 = load i32, ptr %4, align 4, !tbaa !9
  %168 = sext i32 %167 to i64
  %169 = load i64, ptr @w, align 8, !tbaa !5
  %170 = add nsw i64 %168, %169
  %171 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %170
  %172 = load i64, ptr %171, align 8, !tbaa !5
  %173 = load i32, ptr %4, align 4, !tbaa !9
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %174
  %176 = load i64, ptr %175, align 8, !tbaa !5
  %177 = sub nsw i64 %172, %176
  %178 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 1
  %179 = load i64, ptr %178, align 8, !tbaa !18
  %180 = sub nsw i64 %177, %179
  %181 = load i64, ptr @w, align 8, !tbaa !5
  %182 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %183 = load i32, ptr %182, align 8, !tbaa !16
  %184 = sext i32 %183 to i64
  %185 = sub nsw i64 %181, %184
  %186 = load i64, ptr %8, align 8, !tbaa !5
  %187 = mul nsw i64 %185, %186
  %188 = sub nsw i64 %180, %187
  store i64 %188, ptr %12, align 8, !tbaa !5
  %189 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %190 = load i64, ptr %189, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  store i64 %190, ptr %10, align 8, !tbaa !5
  %191 = load i64, ptr @ans, align 8, !tbaa !5
  %192 = load i64, ptr %10, align 8, !tbaa !5
  %193 = icmp sgt i64 %191, %192
  br i1 %193, label %194, label %198

194:                                              ; preds = %150
  %195 = load i64, ptr %10, align 8, !tbaa !5
  store i64 %195, ptr @ans, align 8, !tbaa !5
  %196 = load i64, ptr %8, align 8, !tbaa !5
  %197 = trunc i64 %196 to i32
  store i32 %197, ptr @pos, align 4, !tbaa !9
  br label %211

198:                                              ; preds = %150
  %199 = load i64, ptr @ans, align 8, !tbaa !5
  %200 = load i64, ptr %10, align 8, !tbaa !5
  %201 = icmp eq i64 %199, %200
  br i1 %201, label %202, label %210

202:                                              ; preds = %198
  %203 = load i32, ptr @pos, align 4, !tbaa !9
  %204 = sext i32 %203 to i64
  %205 = load i64, ptr %8, align 8, !tbaa !5
  %206 = icmp slt i64 %204, %205
  br i1 %206, label %207, label %210

207:                                              ; preds = %202
  %208 = load i64, ptr %8, align 8, !tbaa !5
  %209 = trunc i64 %208 to i32
  store i32 %209, ptr @pos, align 4, !tbaa !9
  br label %210

210:                                              ; preds = %207, %202, %198
  br label %211

211:                                              ; preds = %210, %194
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #7
  br label %212

212:                                              ; preds = %211, %137, %133
  br label %213

213:                                              ; preds = %212
  %214 = load i64, ptr %8, align 8, !tbaa !5
  %215 = add nsw i64 %214, 1
  store i64 %215, ptr %8, align 8, !tbaa !5
  br label %127, !llvm.loop !19

216:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #7
  %217 = load i64, ptr @h, align 8, !tbaa !5
  %218 = add nsw i64 %217, 1
  %219 = trunc i64 %218 to i32
  %220 = call { i32, i64 } @_Z5queryi(i32 noundef %219)
  %221 = getelementptr inbounds { i32, i64 }, ptr %13, i32 0, i32 0
  %222 = extractvalue { i32, i64 } %220, 0
  store i32 %222, ptr %221, align 8
  %223 = getelementptr inbounds { i32, i64 }, ptr %13, i32 0, i32 1
  %224 = extractvalue { i32, i64 } %220, 1
  store i64 %224, ptr %223, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %225 = getelementptr inbounds %"struct.std::pair", ptr %13, i32 0, i32 0
  %226 = load i32, ptr %225, align 8, !tbaa !16
  %227 = sext i32 %226 to i64
  %228 = load i64, ptr @h, align 8, !tbaa !5
  %229 = mul nsw i64 %227, %228
  %230 = getelementptr inbounds %"struct.std::pair", ptr %13, i32 0, i32 1
  %231 = load i64, ptr %230, align 8, !tbaa !18
  %232 = sub nsw i64 %229, %231
  store i64 %232, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %233 = load i32, ptr %4, align 4, !tbaa !9
  %234 = sext i32 %233 to i64
  %235 = load i64, ptr @w, align 8, !tbaa !5
  %236 = add nsw i64 %234, %235
  %237 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %236
  %238 = load i64, ptr %237, align 8, !tbaa !5
  %239 = load i32, ptr %4, align 4, !tbaa !9
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %240
  %242 = load i64, ptr %241, align 8, !tbaa !5
  %243 = sub nsw i64 %238, %242
  %244 = getelementptr inbounds %"struct.std::pair", ptr %13, i32 0, i32 1
  %245 = load i64, ptr %244, align 8, !tbaa !18
  %246 = sub nsw i64 %243, %245
  %247 = load i64, ptr @w, align 8, !tbaa !5
  %248 = getelementptr inbounds %"struct.std::pair", ptr %13, i32 0, i32 0
  %249 = load i32, ptr %248, align 8, !tbaa !16
  %250 = sext i32 %249 to i64
  %251 = sub nsw i64 %247, %250
  %252 = load i64, ptr @h, align 8, !tbaa !5
  %253 = mul nsw i64 %251, %252
  %254 = sub nsw i64 %246, %253
  store i64 %254, ptr %16, align 8, !tbaa !5
  %255 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull align 8 dereferenceable(8) %16)
  %256 = load i64, ptr %255, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  store i64 %256, ptr %14, align 8, !tbaa !5
  %257 = load i64, ptr @ans, align 8, !tbaa !5
  %258 = load i64, ptr %14, align 8, !tbaa !5
  %259 = icmp sgt i64 %257, %258
  br i1 %259, label %260, label %264

260:                                              ; preds = %216
  %261 = load i64, ptr %14, align 8, !tbaa !5
  store i64 %261, ptr @ans, align 8, !tbaa !5
  %262 = load i64, ptr @h, align 8, !tbaa !5
  %263 = trunc i64 %262 to i32
  store i32 %263, ptr @pos, align 4, !tbaa !9
  br label %277

264:                                              ; preds = %216
  %265 = load i64, ptr @ans, align 8, !tbaa !5
  %266 = load i64, ptr %14, align 8, !tbaa !5
  %267 = icmp eq i64 %265, %266
  br i1 %267, label %268, label %276

268:                                              ; preds = %264
  %269 = load i32, ptr @pos, align 4, !tbaa !9
  %270 = sext i32 %269 to i64
  %271 = load i64, ptr @h, align 8, !tbaa !5
  %272 = icmp slt i64 %270, %271
  br i1 %272, label %273, label %276

273:                                              ; preds = %268
  %274 = load i64, ptr @h, align 8, !tbaa !5
  %275 = trunc i64 %274 to i32
  store i32 %275, ptr @pos, align 4, !tbaa !9
  br label %276

276:                                              ; preds = %273, %268, %264
  br label %277

277:                                              ; preds = %276, %260
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #7
  %278 = load i32, ptr %4, align 4, !tbaa !9
  %279 = sext i32 %278 to i64
  %280 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %279
  %281 = load i32, ptr %280, align 4, !tbaa !9
  %282 = add nsw i32 %281, 1
  %283 = load i32, ptr %4, align 4, !tbaa !9
  %284 = sext i32 %283 to i64
  %285 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %284
  %286 = load i32, ptr %285, align 4, !tbaa !9
  %287 = sub nsw i32 0, %286
  %288 = sext i32 %287 to i64
  call void @_Z3addiix(i32 noundef %282, i32 noundef -1, i64 noundef %288)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %289

289:                                              ; preds = %277
  %290 = load i32, ptr %4, align 4, !tbaa !9
  %291 = add nsw i32 %290, 1
  store i32 %291, ptr %4, align 4, !tbaa !9
  br label %83, !llvm.loop !20

292:                                              ; preds = %91
  %293 = load i32, ptr @pos, align 4, !tbaa !9
  %294 = load i64, ptr @ans, align 8, !tbaa !5
  %295 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %293, i64 noundef %294)
  br label %17, !llvm.loop !14

296:                                              ; preds = %17
  ret i32 0
}

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

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

declare i32 @puts(ptr noundef) #4

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

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

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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = !{!17, !10, i64 0}
!17 = !{!"_ZTSSt4pairIixE", !10, i64 0, !6, i64 8}
!18 = !{!17, !6, i64 8}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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

@n = external dso_local global i32, align 4
@bit1 = external dso_local local_unnamed_addr global [50010 x i32], align 16
@d = external dso_local global [150030 x i32], align 16
@pos = external dso_local local_unnamed_addr global i32, align 4
@w = external dso_local global i64, align 8
@h = external dso_local global i64, align 8
@bit2 = external dso_local local_unnamed_addr global [50010 x i64], align 16
@sum = external dso_local local_unnamed_addr global [150030 x i64], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addiix(i32 noundef, i32 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local { i32, i64 } @_Z5queryi(i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @w, ptr noundef nonnull @h)
  %6 = icmp eq i32 %5, 3
  br i1 %6, label %.lr.ph99, label %._crit_edge100

.lr.ph99:                                         ; preds = %0, %.backedge
  store i64 1000000000000, ptr @ans, align 8, !tbaa !5
  %7 = load i64, ptr @h, align 8, !tbaa !5
  %8 = trunc i64 %7 to i32
  store i32 %8, ptr @pos, align 4, !tbaa !9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(600120) @d, i8 0, i64 600120, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(200040) @bit1, i8 0, i64 200040, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400080) @bit2, i8 0, i64 400080, i1 false)
  %9 = load i32, ptr @n, align 4, !tbaa !9
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %.lr.ph99..preheader78_crit_edge

.lr.ph99..preheader78_crit_edge:                  ; preds = %.lr.ph99
  %.pre115 = sext i32 %9 to i64
  br label %.preheader78

.preheader78:                                     ; preds = %.lr.ph, %.lr.ph99..preheader78_crit_edge
  %.pre-phi = phi i64 [ %.pre115, %.lr.ph99..preheader78_crit_edge ], [ %22, %.lr.ph ]
  %11 = load i64, ptr @w, align 8, !tbaa !5
  %12 = shl nsw i64 %11, 1
  %13 = add nsw i64 %12, %.pre-phi
  %14 = icmp sgt i64 %13, 0
  br i1 %14, label %.lr.ph85.preheader, label %._crit_edge

.lr.ph85.preheader:                               ; preds = %.preheader78
  %.pre = load i64, ptr @sum, align 16, !tbaa !5
  %15 = add nsw i64 %.pre-phi, -1
  %16 = add i64 %15, %12
  %xtraiter = and i64 %13, 3
  %17 = icmp ult i64 %16, 3
  br i1 %17, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph85.preheader.new

.lr.ph85.preheader.new:                           ; preds = %.lr.ph85.preheader
  %unroll_iter = and i64 %13, 9223372036854775804
  br label %.lr.ph85

.lr.ph:                                           ; preds = %.lr.ph99, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph99 ]
  %18 = load i64, ptr @w, align 8, !tbaa !5
  %19 = add nsw i64 %18, %indvars.iv
  %20 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %19
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %20)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = load i32, ptr @n, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next, %22
  br i1 %23, label %.lr.ph, label %.preheader78, !llvm.loop !11

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph85, %.lr.ph85.preheader
  %.unr = phi i64 [ %.pre, %.lr.ph85.preheader ], [ %56, %.lr.ph85 ]
  %indvars.iv106.unr = phi i64 [ 0, %.lr.ph85.preheader ], [ %indvars.iv.next107.3, %.lr.ph85 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph85.epil

.lr.ph85.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph85.epil
  %24 = phi i64 [ %28, %.lr.ph85.epil ], [ %.unr, %._crit_edge.loopexit.unr-lcssa ]
  %indvars.iv106.epil = phi i64 [ %indvars.iv.next107.epil, %.lr.ph85.epil ], [ %indvars.iv106.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph85.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %25 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv106.epil
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = add nsw i64 %24, %27
  %indvars.iv.next107.epil = add nuw nsw i64 %indvars.iv106.epil, 1
  %29 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %indvars.iv.next107.epil
  store i64 %28, ptr %29, align 8, !tbaa !5
  %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 %._crit_edge, label %.lr.ph85.epil, !llvm.loop !13

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph85.epil, %.preheader78
  %30 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %13
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = load i64, ptr @h, align 8, !tbaa !5
  %33 = mul nsw i64 %32, %11
  %34 = icmp slt i64 %31, %33
  br i1 %34, label %58, label %.preheader77

.preheader77:                                     ; preds = %._crit_edge
  %35 = add nsw i64 %11, %.pre-phi
  %36 = icmp sgt i64 %35, 0
  br i1 %36, label %.preheader, label %._crit_edge97

.lr.ph85:                                         ; preds = %.lr.ph85, %.lr.ph85.preheader.new
  %37 = phi i64 [ %.pre, %.lr.ph85.preheader.new ], [ %56, %.lr.ph85 ]
  %indvars.iv106 = phi i64 [ 0, %.lr.ph85.preheader.new ], [ %indvars.iv.next107.3, %.lr.ph85 ]
  %niter = phi i64 [ 0, %.lr.ph85.preheader.new ], [ %niter.next.3, %.lr.ph85 ]
  %38 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv106
  %39 = load i32, ptr %38, align 16, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = add nsw i64 %37, %40
  %indvars.iv.next107 = or disjoint i64 %indvars.iv106, 1
  %42 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %indvars.iv.next107
  store i64 %41, ptr %42, align 8, !tbaa !5
  %43 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv.next107
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = add nsw i64 %41, %45
  %indvars.iv.next107.1 = or disjoint i64 %indvars.iv106, 2
  %47 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %indvars.iv.next107.1
  store i64 %46, ptr %47, align 16, !tbaa !5
  %48 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv.next107.1
  %49 = load i32, ptr %48, align 8, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = add nsw i64 %46, %50
  %indvars.iv.next107.2 = or disjoint i64 %indvars.iv106, 3
  %52 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %indvars.iv.next107.2
  store i64 %51, ptr %52, align 8, !tbaa !5
  %53 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv.next107.2
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = add nsw i64 %51, %55
  %indvars.iv.next107.3 = add nuw nsw i64 %indvars.iv106, 4
  %57 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %indvars.iv.next107.3
  store i64 %56, ptr %57, align 16, !tbaa !5
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph85, !llvm.loop !15

58:                                               ; preds = %._crit_edge
  %59 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %.backedge

.backedge:                                        ; preds = %58, %._crit_edge97
  %60 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @w, ptr noundef nonnull @h)
  %61 = icmp eq i32 %60, 3
  br i1 %61, label %.lr.ph99, label %._crit_edge100, !llvm.loop !16

.preheader:                                       ; preds = %.preheader77, %192
  %62 = phi i64 [ %198, %192 ], [ %11, %.preheader77 ]
  %indvars.iv112 = phi i64 [ %indvars.iv.next113, %192 ], [ 0, %.preheader77 ]
  %.05195 = phi i32 [ %.1.lcssa, %192 ], [ 0, %.preheader77 ]
  %63 = sext i32 %.05195 to i64
  %64 = add nsw i64 %62, %indvars.iv112
  %65 = icmp sgt i64 %64, %63
  br i1 %65, label %.lr.ph89, label %._crit_edge90

._crit_edge97:                                    ; preds = %192, %.preheader77
  %66 = load i32, ptr @pos, align 4, !tbaa !9
  %67 = load i64, ptr @ans, align 8, !tbaa !5
  %68 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %66, i64 noundef %67)
  br label %.backedge

.lr.ph89:                                         ; preds = %.preheader, %.lr.ph89
  %indvars.iv109 = phi i64 [ %indvars.iv.next110, %.lr.ph89 ], [ %63, %.preheader ]
  %69 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv109
  %70 = load i32, ptr %69, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  %72 = sext i32 %70 to i64
  call void @_Z3addiix(i32 noundef %71, i32 noundef 1, i64 noundef %72)
  %indvars.iv.next110 = add nsw i64 %indvars.iv109, 1
  %73 = load i64, ptr @w, align 8, !tbaa !5
  %74 = add nsw i64 %73, %indvars.iv112
  %75 = icmp sgt i64 %74, %indvars.iv.next110
  br i1 %75, label %.lr.ph89, label %._crit_edge90.loopexit, !llvm.loop !17

._crit_edge90.loopexit:                           ; preds = %.lr.ph89
  %76 = trunc nsw i64 %indvars.iv.next110 to i32
  br label %._crit_edge90

._crit_edge90:                                    ; preds = %._crit_edge90.loopexit, %.preheader
  %.1.lcssa = phi i32 [ %.05195, %.preheader ], [ %76, %._crit_edge90.loopexit ]
  %.lcssa82 = phi i64 [ %63, %.preheader ], [ %indvars.iv.next110, %._crit_edge90.loopexit ]
  %77 = phi i64 [ %62, %.preheader ], [ %73, %._crit_edge90.loopexit ]
  %78 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %.lcssa82
  %79 = load i64, ptr %78, align 8, !tbaa !5
  %80 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %indvars.iv112
  %81 = load i64, ptr %80, align 8, !tbaa !5
  %82 = sub nsw i64 %79, %81
  %83 = sdiv i64 %82, %77
  %84 = load i64, ptr @h, align 8, !tbaa !5
  %.not65 = icmp slt i64 %83, %84
  br i1 %.not65, label %120, label %85

85:                                               ; preds = %._crit_edge90
  %86 = shl nsw i64 %77, 1
  %87 = load i32, ptr @n, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = add nsw i64 %86, %88
  %90 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %89
  %91 = load i64, ptr %90, align 8, !tbaa !5
  %92 = mul nsw i64 %77, %83
  %.not66 = icmp slt i64 %91, %92
  br i1 %.not66, label %120, label %93

93:                                               ; preds = %85
  %94 = trunc i64 %83 to i32
  %95 = add i32 %94, 1
  %96 = call { i32, i64 } @_Z5queryi(i32 noundef %95)
  %97 = extractvalue { i32, i64 } %96, 0
  %98 = extractvalue { i32, i64 } %96, 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %99 = sext i32 %97 to i64
  %100 = mul nsw i64 %83, %99
  %101 = sub nsw i64 %100, %98
  store i64 %101, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %102 = load i64, ptr @w, align 8, !tbaa !5
  %103 = add nsw i64 %102, %indvars.iv112
  %104 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %103
  %105 = load i64, ptr %104, align 8, !tbaa !5
  %106 = load i64, ptr %80, align 8, !tbaa !5
  %.neg67 = sub i64 %99, %102
  %.neg68 = mul i64 %.neg67, %83
  %107 = add i64 %98, %106
  %108 = sub i64 %105, %107
  %109 = add i64 %108, %.neg68
  store i64 %109, ptr %2, align 8, !tbaa !5
  %110 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %111 = load i64, ptr %110, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %112 = load i64, ptr @ans, align 8, !tbaa !5
  %113 = icmp sgt i64 %112, %111
  br i1 %113, label %114, label %115

114:                                              ; preds = %93
  store i64 %111, ptr @ans, align 8, !tbaa !5
  br label %.sink.split

115:                                              ; preds = %93
  %116 = icmp eq i64 %112, %111
  %117 = load i32, ptr @pos, align 4
  %118 = sext i32 %117 to i64
  %119 = icmp sgt i64 %83, %118
  %or.cond = select i1 %116, i1 %119, i1 false
  br i1 %or.cond, label %.sink.split, label %120

.sink.split:                                      ; preds = %115, %114
  store i32 %94, ptr @pos, align 4, !tbaa !9
  br label %120

120:                                              ; preds = %.sink.split, %115, %._crit_edge90, %85
  %121 = add nsw i64 %83, 1
  %122 = load i64, ptr @h, align 8, !tbaa !5
  %.not65.1 = icmp slt i64 %121, %122
  br i1 %.not65.1, label %159, label %123

123:                                              ; preds = %120
  %124 = load i64, ptr @w, align 8, !tbaa !5
  %125 = shl nsw i64 %124, 1
  %126 = load i32, ptr @n, align 4, !tbaa !9
  %127 = sext i32 %126 to i64
  %128 = add nsw i64 %125, %127
  %129 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %128
  %130 = load i64, ptr %129, align 8, !tbaa !5
  %131 = mul nsw i64 %124, %121
  %.not66.1 = icmp slt i64 %130, %131
  br i1 %.not66.1, label %159, label %132

132:                                              ; preds = %123
  %133 = trunc i64 %121 to i32
  %134 = add i32 %133, 1
  %135 = call { i32, i64 } @_Z5queryi(i32 noundef %134)
  %136 = extractvalue { i32, i64 } %135, 0
  %137 = extractvalue { i32, i64 } %135, 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %138 = sext i32 %136 to i64
  %139 = mul nsw i64 %121, %138
  %140 = sub nsw i64 %139, %137
  store i64 %140, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %141 = load i64, ptr @w, align 8, !tbaa !5
  %142 = add nsw i64 %141, %indvars.iv112
  %143 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %142
  %144 = load i64, ptr %143, align 8, !tbaa !5
  %145 = load i64, ptr %80, align 8, !tbaa !5
  %.neg67.1 = sub i64 %138, %141
  %.neg68.1 = mul i64 %.neg67.1, %121
  %146 = add i64 %137, %145
  %147 = sub i64 %144, %146
  %148 = add i64 %147, %.neg68.1
  store i64 %148, ptr %2, align 8, !tbaa !5
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %150 = load i64, ptr %149, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %151 = load i64, ptr @ans, align 8, !tbaa !5
  %152 = icmp sgt i64 %151, %150
  br i1 %152, label %158, label %153

153:                                              ; preds = %132
  %154 = icmp eq i64 %151, %150
  %155 = load i32, ptr @pos, align 4
  %156 = sext i32 %155 to i64
  %157 = icmp sge i64 %83, %156
  %or.cond.1 = select i1 %154, i1 %157, i1 false
  br i1 %or.cond.1, label %.sink.split117, label %159

158:                                              ; preds = %132
  store i64 %150, ptr @ans, align 8, !tbaa !5
  br label %.sink.split117

.sink.split117:                                   ; preds = %153, %158
  store i32 %133, ptr @pos, align 4, !tbaa !9
  br label %159

159:                                              ; preds = %.sink.split117, %153, %123, %120
  %160 = load i64, ptr @h, align 8, !tbaa !5
  %161 = trunc i64 %160 to i32
  %162 = add i32 %161, 1
  %163 = call { i32, i64 } @_Z5queryi(i32 noundef %162)
  %164 = extractvalue { i32, i64 } %163, 0
  %165 = extractvalue { i32, i64 } %163, 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %166 = sext i32 %164 to i64
  %167 = load i64, ptr @h, align 8, !tbaa !5
  %168 = mul nsw i64 %167, %166
  %169 = sub nsw i64 %168, %165
  store i64 %169, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %170 = load i64, ptr @w, align 8, !tbaa !5
  %171 = add nsw i64 %170, %indvars.iv112
  %172 = getelementptr inbounds [150030 x i64], ptr @sum, i64 0, i64 %171
  %173 = load i64, ptr %172, align 8, !tbaa !5
  %174 = load i64, ptr %80, align 8, !tbaa !5
  %.neg = sub i64 %166, %170
  %.neg64 = mul i64 %.neg, %167
  %175 = add i64 %165, %174
  %176 = sub i64 %173, %175
  %177 = add i64 %176, %.neg64
  store i64 %177, ptr %4, align 8, !tbaa !5
  %178 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %179 = load i64, ptr %178, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  %180 = load i64, ptr @ans, align 8, !tbaa !5
  %181 = icmp sgt i64 %180, %179
  br i1 %181, label %182, label %184

182:                                              ; preds = %159
  store i64 %179, ptr @ans, align 8, !tbaa !5
  %183 = load i64, ptr @h, align 8, !tbaa !5
  br label %.sink.split118

184:                                              ; preds = %159
  %185 = icmp eq i64 %180, %179
  br i1 %185, label %186, label %192

186:                                              ; preds = %184
  %187 = load i32, ptr @pos, align 4, !tbaa !9
  %188 = sext i32 %187 to i64
  %189 = load i64, ptr @h, align 8, !tbaa !5
  %190 = icmp sgt i64 %189, %188
  br i1 %190, label %.sink.split118, label %192

.sink.split118:                                   ; preds = %186, %182
  %.sink119 = phi i64 [ %183, %182 ], [ %189, %186 ]
  %191 = trunc i64 %.sink119 to i32
  store i32 %191, ptr @pos, align 4, !tbaa !9
  br label %192

192:                                              ; preds = %.sink.split118, %184, %186
  %193 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv112
  %194 = load i32, ptr %193, align 4, !tbaa !9
  %195 = add nsw i32 %194, 1
  %196 = sub nsw i32 0, %194
  %197 = sext i32 %196 to i64
  call void @_Z3addiix(i32 noundef %195, i32 noundef -1, i64 noundef %197)
  %indvars.iv.next113 = add nuw nsw i64 %indvars.iv112, 1
  %198 = load i64, ptr @w, align 8, !tbaa !5
  %199 = load i32, ptr @n, align 4, !tbaa !9
  %200 = sext i32 %199 to i64
  %201 = add nsw i64 %198, %200
  %202 = icmp sgt i64 %201, %indvars.iv.next113
  br i1 %202, label %.preheader, label %._crit_edge97, !llvm.loop !18

._crit_edge100:                                   ; preds = %.backedge, %0
  ret i32 0
}

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

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

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

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

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

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


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