; LLVM IR from tangjz/acm-icpc :: 51nod (1290)

; 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.Query = type { i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@a = external dso_local global [50001 x i32], align 16
@tot = external dso_local global i32, align 4
@que = external dso_local global [50001 x i32], align 16
@sz = external dso_local global i32, align 4
@lpos = external dso_local global [50001 x i32], align 16
@qL = external dso_local global [50001 x i32], align 16
@qR = external dso_local global [50001 x i32], align 16
@ans = external dso_local global [50001 x i64], align 16
@query = external dso_local global [50001 x %struct.Query], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

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

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

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

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

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

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i32, ptr @a, i64 %26
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %27)
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = load i32, ptr @tot, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr @tot, align 4, !tbaa !5
  %35 = sext i32 %33 to i64
  %36 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %35
  store i32 %32, ptr %36, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %24
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !9

40:                                               ; preds = %23
  %41 = load i32, ptr @tot, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr @que, i64 %42
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %43)
  %44 = load i32, ptr @tot, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr @que, i64 %45
  %47 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @que, ptr noundef %46)
  %48 = ptrtoint ptr %47 to i64
  %49 = sub i64 %48, ptrtoint (ptr @que to i64)
  %50 = sdiv exact i64 %49, 4
  %51 = trunc i64 %50 to i32
  store i32 %51, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %108, %40
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = load i32, ptr @n, align 4, !tbaa !5
  %55 = icmp sle i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %111

57:                                               ; preds = %52
  %58 = load i32, ptr @tot, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr @que, i64 %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = load i32, ptr @m, align 4, !tbaa !5
  %66 = sub nsw i32 %64, %65
  store i32 %66, ptr %4, align 4, !tbaa !5
  %67 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %60, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %68 = ptrtoint ptr %67 to i64
  %69 = sub i64 %68, ptrtoint (ptr @que to i64)
  %70 = sdiv exact i64 %69, 4
  %71 = trunc i64 %70 to i32
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %73
  store i32 %71, ptr %74, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  %75 = load i32, ptr @tot, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i32, ptr @que, i64 %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = load i32, ptr @m, align 4, !tbaa !5
  %83 = add nsw i32 %81, %82
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %5, align 4, !tbaa !5
  %85 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %77, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %86 = ptrtoint ptr %85 to i64
  %87 = sub i64 %86, ptrtoint (ptr @que to i64)
  %88 = sdiv exact i64 %87, 4
  %89 = trunc i64 %88 to i32
  %90 = load i32, ptr %3, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %91
  store i32 %89, ptr %92, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  %93 = load i32, ptr @tot, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i32, ptr @que, i64 %94
  %96 = load i32, ptr %3, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %97
  %99 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %95, ptr noundef nonnull align 4 dereferenceable(4) %98)
  %100 = ptrtoint ptr %99 to i64
  %101 = sub i64 %100, ptrtoint (ptr @que to i64)
  %102 = sdiv exact i64 %101, 4
  %103 = add nsw i64 %102, 1
  %104 = trunc i64 %103 to i32
  %105 = load i32, ptr %3, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %106
  store i32 %104, ptr %107, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %57
  %109 = load i32, ptr %3, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %3, align 4, !tbaa !5
  br label %52, !llvm.loop !11

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

112:                                              ; preds = %130, %111
  %113 = load i32, ptr %6, align 4, !tbaa !5
  %114 = load i32, ptr @q, align 4, !tbaa !5
  %115 = icmp slt i32 %113, %114
  br i1 %115, label %117, label %116

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

117:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %118 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %7, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #8
  %119 = getelementptr inbounds %struct.Query, ptr %9, i32 0, i32 0
  %120 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %120, ptr %119, align 4, !tbaa !12
  %121 = getelementptr inbounds %struct.Query, ptr %9, i32 0, i32 1
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %7, align 4, !tbaa !5
  store i32 %123, ptr %121, align 4, !tbaa !14
  %124 = getelementptr inbounds %struct.Query, ptr %9, i32 0, i32 2
  %125 = load i32, ptr %8, align 4, !tbaa !5
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %8, align 4, !tbaa !5
  store i32 %126, ptr %124, align 4, !tbaa !15
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [50001 x %struct.Query], ptr @query, i64 0, i64 %128
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %129, ptr align 4 %9, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %130

130:                                              ; preds = %117
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %6, align 4, !tbaa !5
  br label %112, !llvm.loop !17

133:                                              ; preds = %116
  %134 = load i32, ptr @n, align 4, !tbaa !5
  %135 = sitofp i32 %134 to double
  %136 = call double @sqrt(double noundef %135) #8
  %137 = call double @llvm.ceil.f64(double %136)
  %138 = fptosi double %137 to i32
  store i32 %138, ptr @sz, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 1, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 1, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %161, %133
  %140 = load i32, ptr %10, align 4, !tbaa !5
  %141 = load i32, ptr @n, align 4, !tbaa !5
  %142 = icmp sle i32 %140, %141
  br i1 %142, label %144, label %143

143:                                              ; preds = %139
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %163

144:                                              ; preds = %139
  %145 = load i32, ptr %11, align 4, !tbaa !5
  %146 = load i32, ptr %10, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [50001 x i32], ptr @lpos, i64 0, i64 %147
  store i32 %145, ptr %148, align 4, !tbaa !5
  br label %149

149:                                              ; preds = %144
  %150 = load i32, ptr %10, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  store i32 %151, ptr %10, align 4, !tbaa !5
  %152 = load i32, ptr %12, align 4, !tbaa !5
  %153 = load i32, ptr @sz, align 4, !tbaa !5
  %154 = icmp eq i32 %152, %153
  br i1 %154, label %155, label %158

155:                                              ; preds = %149
  %156 = load i32, ptr %11, align 4, !tbaa !5
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %11, align 4, !tbaa !5
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %161

158:                                              ; preds = %149
  %159 = load i32, ptr %12, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %12, align 4, !tbaa !5
  br label %161

161:                                              ; preds = %158, %155
  %162 = phi ptr [ %12, %155 ], [ %12, %158 ]
  br label %139, !llvm.loop !18

163:                                              ; preds = %143
  %164 = load i32, ptr @q, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds %struct.Query, ptr @query, i64 %165
  call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef @query, ptr noundef %166)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  store i64 0, ptr %13, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  store i32 1, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %167

167:                                              ; preds = %311, %163
  %168 = load i32, ptr %14, align 4, !tbaa !5
  %169 = load i32, ptr @q, align 4, !tbaa !5
  %170 = icmp slt i32 %168, %169
  br i1 %170, label %172, label %171

171:                                              ; preds = %167
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %314

172:                                              ; preds = %167
  br label %173

173:                                              ; preds = %203, %172
  %174 = load i32, ptr %16, align 4, !tbaa !5
  %175 = load i32, ptr %14, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [50001 x %struct.Query], ptr @query, i64 0, i64 %176
  %178 = getelementptr inbounds %struct.Query, ptr %177, i32 0, i32 2
  %179 = load i32, ptr %178, align 4, !tbaa !15
  %180 = icmp slt i32 %174, %179
  br i1 %180, label %181, label %206

181:                                              ; preds = %173
  %182 = load i32, ptr %16, align 4, !tbaa !5
  %183 = add nsw i32 %182, 1
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !5
  %187 = call noundef i32 @_Z4calci(i32 noundef %186)
  %188 = load i32, ptr %16, align 4, !tbaa !5
  %189 = add nsw i32 %188, 1
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %190
  %192 = load i32, ptr %191, align 4, !tbaa !5
  %193 = call noundef i32 @_Z4calci(i32 noundef %192)
  %194 = sub nsw i32 %187, %193
  %195 = sext i32 %194 to i64
  %196 = load i64, ptr %13, align 8, !tbaa !19
  %197 = add nsw i64 %196, %195
  store i64 %197, ptr %13, align 8, !tbaa !19
  %198 = load i32, ptr %16, align 4, !tbaa !5
  %199 = add nsw i32 %198, 1
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %200
  %202 = load i32, ptr %201, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %202, i32 noundef 1)
  br label %203

203:                                              ; preds = %181
  %204 = load i32, ptr %16, align 4, !tbaa !5
  %205 = add nsw i32 %204, 1
  store i32 %205, ptr %16, align 4, !tbaa !5
  br label %173, !llvm.loop !21

206:                                              ; preds = %173
  br label %207

207:                                              ; preds = %237, %206
  %208 = load i32, ptr %15, align 4, !tbaa !5
  %209 = load i32, ptr %14, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [50001 x %struct.Query], ptr @query, i64 0, i64 %210
  %212 = getelementptr inbounds %struct.Query, ptr %211, i32 0, i32 1
  %213 = load i32, ptr %212, align 4, !tbaa !14
  %214 = icmp sgt i32 %208, %213
  br i1 %214, label %215, label %240

215:                                              ; preds = %207
  %216 = load i32, ptr %15, align 4, !tbaa !5
  %217 = sub nsw i32 %216, 1
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %218
  %220 = load i32, ptr %219, align 4, !tbaa !5
  %221 = call noundef i32 @_Z4calci(i32 noundef %220)
  %222 = load i32, ptr %15, align 4, !tbaa !5
  %223 = sub nsw i32 %222, 1
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %224
  %226 = load i32, ptr %225, align 4, !tbaa !5
  %227 = call noundef i32 @_Z4calci(i32 noundef %226)
  %228 = sub nsw i32 %221, %227
  %229 = sext i32 %228 to i64
  %230 = load i64, ptr %13, align 8, !tbaa !19
  %231 = add nsw i64 %230, %229
  store i64 %231, ptr %13, align 8, !tbaa !19
  %232 = load i32, ptr %15, align 4, !tbaa !5
  %233 = sub nsw i32 %232, 1
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %234
  %236 = load i32, ptr %235, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %236, i32 noundef 1)
  br label %237

237:                                              ; preds = %215
  %238 = load i32, ptr %15, align 4, !tbaa !5
  %239 = add nsw i32 %238, -1
  store i32 %239, ptr %15, align 4, !tbaa !5
  br label %207, !llvm.loop !22

240:                                              ; preds = %207
  br label %241

241:                                              ; preds = %268, %240
  %242 = load i32, ptr %15, align 4, !tbaa !5
  %243 = load i32, ptr %14, align 4, !tbaa !5
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [50001 x %struct.Query], ptr @query, i64 0, i64 %244
  %246 = getelementptr inbounds %struct.Query, ptr %245, i32 0, i32 1
  %247 = load i32, ptr %246, align 4, !tbaa !14
  %248 = icmp slt i32 %242, %247
  br i1 %248, label %249, label %271

249:                                              ; preds = %241
  %250 = load i32, ptr %15, align 4, !tbaa !5
  %251 = sext i32 %250 to i64
  %252 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %251
  %253 = load i32, ptr %252, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %253, i32 noundef -1)
  %254 = load i32, ptr %15, align 4, !tbaa !5
  %255 = sext i32 %254 to i64
  %256 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %255
  %257 = load i32, ptr %256, align 4, !tbaa !5
  %258 = call noundef i32 @_Z4calci(i32 noundef %257)
  %259 = load i32, ptr %15, align 4, !tbaa !5
  %260 = sext i32 %259 to i64
  %261 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %260
  %262 = load i32, ptr %261, align 4, !tbaa !5
  %263 = call noundef i32 @_Z4calci(i32 noundef %262)
  %264 = sub nsw i32 %258, %263
  %265 = sext i32 %264 to i64
  %266 = load i64, ptr %13, align 8, !tbaa !19
  %267 = sub nsw i64 %266, %265
  store i64 %267, ptr %13, align 8, !tbaa !19
  br label %268

268:                                              ; preds = %249
  %269 = load i32, ptr %15, align 4, !tbaa !5
  %270 = add nsw i32 %269, 1
  store i32 %270, ptr %15, align 4, !tbaa !5
  br label %241, !llvm.loop !23

271:                                              ; preds = %241
  br label %272

272:                                              ; preds = %299, %271
  %273 = load i32, ptr %16, align 4, !tbaa !5
  %274 = load i32, ptr %14, align 4, !tbaa !5
  %275 = sext i32 %274 to i64
  %276 = getelementptr inbounds [50001 x %struct.Query], ptr @query, i64 0, i64 %275
  %277 = getelementptr inbounds %struct.Query, ptr %276, i32 0, i32 2
  %278 = load i32, ptr %277, align 4, !tbaa !15
  %279 = icmp sgt i32 %273, %278
  br i1 %279, label %280, label %302

280:                                              ; preds = %272
  %281 = load i32, ptr %16, align 4, !tbaa !5
  %282 = sext i32 %281 to i64
  %283 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %282
  %284 = load i32, ptr %283, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %284, i32 noundef -1)
  %285 = load i32, ptr %16, align 4, !tbaa !5
  %286 = sext i32 %285 to i64
  %287 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %286
  %288 = load i32, ptr %287, align 4, !tbaa !5
  %289 = call noundef i32 @_Z4calci(i32 noundef %288)
  %290 = load i32, ptr %16, align 4, !tbaa !5
  %291 = sext i32 %290 to i64
  %292 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %291
  %293 = load i32, ptr %292, align 4, !tbaa !5
  %294 = call noundef i32 @_Z4calci(i32 noundef %293)
  %295 = sub nsw i32 %289, %294
  %296 = sext i32 %295 to i64
  %297 = load i64, ptr %13, align 8, !tbaa !19
  %298 = sub nsw i64 %297, %296
  store i64 %298, ptr %13, align 8, !tbaa !19
  br label %299

299:                                              ; preds = %280
  %300 = load i32, ptr %16, align 4, !tbaa !5
  %301 = add nsw i32 %300, -1
  store i32 %301, ptr %16, align 4, !tbaa !5
  br label %272, !llvm.loop !24

302:                                              ; preds = %272
  %303 = load i64, ptr %13, align 8, !tbaa !19
  %304 = load i32, ptr %14, align 4, !tbaa !5
  %305 = sext i32 %304 to i64
  %306 = getelementptr inbounds [50001 x %struct.Query], ptr @query, i64 0, i64 %305
  %307 = getelementptr inbounds %struct.Query, ptr %306, i32 0, i32 0
  %308 = load i32, ptr %307, align 4, !tbaa !12
  %309 = sext i32 %308 to i64
  %310 = getelementptr inbounds [50001 x i64], ptr @ans, i64 0, i64 %309
  store i64 %303, ptr %310, align 8, !tbaa !19
  br label %311

311:                                              ; preds = %302
  %312 = load i32, ptr %14, align 4, !tbaa !5
  %313 = add nsw i32 %312, 1
  store i32 %313, ptr %14, align 4, !tbaa !5
  br label %167, !llvm.loop !25

314:                                              ; preds = %171
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %315

315:                                              ; preds = %326, %314
  %316 = load i32, ptr %17, align 4, !tbaa !5
  %317 = load i32, ptr @q, align 4, !tbaa !5
  %318 = icmp slt i32 %316, %317
  br i1 %318, label %320, label %319

319:                                              ; preds = %315
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %329

320:                                              ; preds = %315
  %321 = load i32, ptr %17, align 4, !tbaa !5
  %322 = sext i32 %321 to i64
  %323 = getelementptr inbounds [50001 x i64], ptr @ans, i64 0, i64 %322
  %324 = load i64, ptr %323, align 8, !tbaa !19
  %325 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %324)
  br label %326

326:                                              ; preds = %320
  %327 = load i32, ptr %17, align 4, !tbaa !5
  %328 = add nsw i32 %327, 1
  store i32 %328, ptr %17, align 4, !tbaa !5
  br label %315, !llvm.loop !26

329:                                              ; preds = %319
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  ret i32 0
}

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

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

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

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

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #6

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #7

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

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

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

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

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@a = external dso_local global [50001 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [50001 x i32], align 16
@sz = external dso_local local_unnamed_addr global i32, align 4
@lpos = external dso_local local_unnamed_addr global [50001 x i32], align 16
@qL = external dso_local local_unnamed_addr global [50001 x i32], align 16
@qR = external dso_local local_unnamed_addr global [50001 x i32], align 16
@ans = external dso_local local_unnamed_addr global [50001 x i64], align 16
@query = external dso_local global [50001 x %struct.Query], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @q)
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %.not83 = icmp slt i32 %6, 1
  br i1 %.not83, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = load i32, ptr @tot, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %7 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %23, %.lr.ph ]
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds i32, ptr @que, i64 %8
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %9)
  %10 = load i32, ptr @tot, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds i32, ptr @que, i64 %11
  %13 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %12)
  %14 = ptrtoint ptr %13 to i64
  %15 = sub i64 %14, ptrtoint (ptr @que to i64)
  %16 = lshr exact i64 %15, 2
  %17 = trunc i64 %16 to i32
  store i32 %17, ptr @tot, align 4, !tbaa !5
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %.not7485 = icmp slt i32 %18, 1
  br i1 %.not7485, label %.preheader80, label %.lr.ph88

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %19 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %20 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %19)
  %21 = load i32, ptr %19, align 4, !tbaa !5
  %22 = load i32, ptr @tot, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr @tot, align 4, !tbaa !5
  %24 = sext i32 %22 to i64
  %25 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %24
  store i32 %21, ptr %25, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %.not.not = icmp slt i64 %indvars.iv, %27
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader80:                                     ; preds = %.lr.ph88, %._crit_edge
  %28 = phi i32 [ %18, %._crit_edge ], [ %66, %.lr.ph88 ]
  %29 = load i32, ptr @q, align 4, !tbaa !5
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %.lr.ph90, label %._crit_edge91

.lr.ph88:                                         ; preds = %._crit_edge, %.lr.ph88
  %indvars.iv137 = phi i64 [ %indvars.iv.next138, %.lr.ph88 ], [ 1, %._crit_edge ]
  %31 = load i32, ptr @tot, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr @que, i64 %32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %34 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %indvars.iv137
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = load i32, ptr @m, align 4, !tbaa !5
  %37 = sub nsw i32 %35, %36
  store i32 %37, ptr %1, align 4, !tbaa !5
  %38 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %33, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %39 = ptrtoint ptr %38 to i64
  %40 = sub i64 %39, ptrtoint (ptr @que to i64)
  %41 = lshr exact i64 %40, 2
  %42 = trunc i64 %41 to i32
  %43 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %indvars.iv137
  store i32 %42, ptr %43, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %44 = load i32, ptr @tot, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr @que, i64 %45
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %47 = load i32, ptr %34, align 4, !tbaa !5
  %48 = load i32, ptr @m, align 4, !tbaa !5
  %49 = add i32 %47, 1
  %50 = add i32 %49, %48
  store i32 %50, ptr %2, align 4, !tbaa !5
  %51 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %46, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %52 = ptrtoint ptr %51 to i64
  %53 = sub i64 %52, ptrtoint (ptr @que to i64)
  %54 = lshr exact i64 %53, 2
  %55 = trunc i64 %54 to i32
  %56 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %indvars.iv137
  store i32 %55, ptr %56, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %57 = load i32, ptr @tot, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i32, ptr @que, i64 %58
  %60 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %59, ptr noundef nonnull align 4 dereferenceable(4) %34)
  %61 = ptrtoint ptr %60 to i64
  %62 = sub i64 %61, ptrtoint (ptr @que to i64)
  %63 = lshr exact i64 %62, 2
  %64 = trunc i64 %63 to i32
  %65 = add i32 %64, 1
  store i32 %65, ptr %34, align 4, !tbaa !5
  %indvars.iv.next138 = add nuw nsw i64 %indvars.iv137, 1
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %.not74.not = icmp slt i64 %indvars.iv137, %67
  br i1 %.not74.not, label %.lr.ph88, label %.preheader80, !llvm.loop !11

._crit_edge91.loopexit:                           ; preds = %.lr.ph90
  %.pre164 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge91

._crit_edge91:                                    ; preds = %._crit_edge91.loopexit, %.preheader80
  %68 = phi i32 [ %.pre164, %._crit_edge91.loopexit ], [ %28, %.preheader80 ]
  %69 = sitofp i32 %68 to double
  %70 = call double @sqrt(double noundef %69) #7
  %71 = call double @llvm.ceil.f64(double %70)
  %72 = fptosi double %71 to i32
  store i32 %72, ptr @sz, align 4, !tbaa !5
  %73 = load i32, ptr @n, align 4, !tbaa !5
  %.not7592 = icmp slt i32 %73, 1
  br i1 %.not7592, label %._crit_edge98, label %.lr.ph97.preheader

.lr.ph97.preheader:                               ; preds = %._crit_edge91
  %74 = zext nneg i32 %73 to i64
  %xtraiter = and i64 %74, 1
  %75 = icmp eq i32 %73, 1
  br i1 %75, label %._crit_edge98.loopexit.unr-lcssa, label %.lr.ph97.preheader.new

.lr.ph97.preheader.new:                           ; preds = %.lr.ph97.preheader
  %unroll_iter = and i64 %74, 2147483646
  br label %.lr.ph97

.lr.ph90:                                         ; preds = %.preheader80, %.lr.ph90
  %indvars.iv140 = phi i64 [ %indvars.iv.next141, %.lr.ph90 ], [ 0, %.preheader80 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %76 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %77 = load i32, ptr %3, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  %81 = getelementptr inbounds [50001 x %struct.Query], ptr @query, i64 0, i64 %indvars.iv140
  %82 = trunc nuw nsw i64 %indvars.iv140 to i32
  store i32 %82, ptr %81, align 4, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %81, i64 4
  store i32 %78, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %81, i64 8
  store i32 %80, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  %indvars.iv.next141 = add nuw nsw i64 %indvars.iv140, 1
  %83 = load i32, ptr @q, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = icmp slt i64 %indvars.iv.next141, %84
  br i1 %85, label %.lr.ph90, label %._crit_edge91.loopexit, !llvm.loop !12

._crit_edge98.loopexit.unr-lcssa:                 ; preds = %.lr.ph97, %.lr.ph97.preheader
  %indvars.iv143.unr = phi i64 [ 1, %.lr.ph97.preheader ], [ %indvars.iv.next144.1, %.lr.ph97 ]
  %.06894.unr = phi i32 [ 1, %.lr.ph97.preheader ], [ %.169.1, %.lr.ph97 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge98, label %.lr.ph97.epil

.lr.ph97.epil:                                    ; preds = %._crit_edge98.loopexit.unr-lcssa
  %86 = getelementptr inbounds [50001 x i32], ptr @lpos, i64 0, i64 %indvars.iv143.unr
  store i32 %.06894.unr, ptr %86, align 4, !tbaa !5
  br label %._crit_edge98

._crit_edge98:                                    ; preds = %.lr.ph97.epil, %._crit_edge98.loopexit.unr-lcssa, %._crit_edge91
  %87 = load i32, ptr @q, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds %struct.Query, ptr @query, i64 %88
  call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef nonnull @query, ptr noundef nonnull %89)
  %90 = load i32, ptr @q, align 4, !tbaa !5
  %91 = icmp sgt i32 %90, 0
  br i1 %91, label %.preheader79, label %._crit_edge128

.lr.ph97:                                         ; preds = %.lr.ph97, %.lr.ph97.preheader.new
  %indvars.iv143 = phi i64 [ 1, %.lr.ph97.preheader.new ], [ %indvars.iv.next144.1, %.lr.ph97 ]
  %.06695 = phi i32 [ 1, %.lr.ph97.preheader.new ], [ %.167.1, %.lr.ph97 ]
  %.06894 = phi i32 [ 1, %.lr.ph97.preheader.new ], [ %.169.1, %.lr.ph97 ]
  %niter = phi i64 [ 0, %.lr.ph97.preheader.new ], [ %niter.next.1, %.lr.ph97 ]
  %92 = getelementptr inbounds [50001 x i32], ptr @lpos, i64 0, i64 %indvars.iv143
  store i32 %.06894, ptr %92, align 4, !tbaa !5
  %indvars.iv.next144 = add nuw nsw i64 %indvars.iv143, 1
  %93 = icmp eq i32 %.06695, %72
  %94 = add nsw i32 %.06695, 1
  %95 = zext i1 %93 to i32
  %.169 = add nuw nsw i32 %.06894, %95
  %.167 = select i1 %93, i32 1, i32 %94
  %96 = getelementptr inbounds [50001 x i32], ptr @lpos, i64 0, i64 %indvars.iv.next144
  store i32 %.169, ptr %96, align 4, !tbaa !5
  %indvars.iv.next144.1 = add nuw nsw i64 %indvars.iv143, 2
  %97 = icmp eq i32 %.167, %72
  %98 = add nsw i32 %.167, 1
  %99 = zext i1 %97 to i32
  %.169.1 = add nuw nsw i32 %.169, %99
  %.167.1 = select i1 %97, i32 1, i32 %98
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge98.loopexit.unr-lcssa, label %.lr.ph97, !llvm.loop !13

.preheader79:                                     ; preds = %._crit_edge98, %._crit_edge119
  %indvars.iv158 = phi i64 [ %indvars.iv.next159, %._crit_edge119 ], [ 0, %._crit_edge98 ]
  %.058125 = phi i32 [ %.2.lcssa, %._crit_edge119 ], [ 0, %._crit_edge98 ]
  %.059124 = phi i32 [ %.261.lcssa, %._crit_edge119 ], [ 1, %._crit_edge98 ]
  %.063122 = phi i64 [ %.4.lcssa, %._crit_edge119 ], [ 0, %._crit_edge98 ]
  %100 = getelementptr inbounds [50001 x %struct.Query], ptr @query, i64 0, i64 %indvars.iv158
  %101 = getelementptr inbounds i8, ptr %100, i64 8
  %102 = load i32, ptr %101, align 4, !tbaa !14
  %103 = icmp slt i32 %.058125, %102
  br i1 %103, label %.lr.ph102.preheader, label %.preheader78

.lr.ph102.preheader:                              ; preds = %.preheader79
  %104 = sext i32 %.058125 to i64
  br label %.lr.ph102

.preheader:                                       ; preds = %._crit_edge119
  %105 = icmp sgt i32 %179, 0
  br i1 %105, label %.lr.ph127, label %._crit_edge128

.preheader78.loopexit:                            ; preds = %.lr.ph102
  %106 = trunc nsw i64 %indvars.iv.next147 to i32
  br label %.preheader78

.preheader78:                                     ; preds = %.preheader78.loopexit, %.preheader79
  %.164.lcssa = phi i64 [ %.063122, %.preheader79 ], [ %119, %.preheader78.loopexit ]
  %.1.lcssa = phi i32 [ %.058125, %.preheader79 ], [ %106, %.preheader78.loopexit ]
  %107 = getelementptr inbounds i8, ptr %100, i64 4
  %108 = load i32, ptr %107, align 4, !tbaa !16
  %109 = icmp sgt i32 %.059124, %108
  br i1 %109, label %.lr.ph108.preheader, label %.preheader77

.lr.ph108.preheader:                              ; preds = %.preheader78
  %110 = sext i32 %.059124 to i64
  br label %.lr.ph108

.lr.ph102:                                        ; preds = %.lr.ph102.preheader, %.lr.ph102
  %indvars.iv146 = phi i64 [ %104, %.lr.ph102.preheader ], [ %indvars.iv.next147, %.lr.ph102 ]
  %.164100 = phi i64 [ %.063122, %.lr.ph102.preheader ], [ %119, %.lr.ph102 ]
  %indvars.iv.next147 = add nsw i64 %indvars.iv146, 1
  %111 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %indvars.iv.next147
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = call noundef i32 @_Z4calci(i32 noundef %112)
  %114 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %indvars.iv.next147
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = call noundef i32 @_Z4calci(i32 noundef %115)
  %117 = sub nsw i32 %113, %116
  %118 = sext i32 %117 to i64
  %119 = add nsw i64 %.164100, %118
  %120 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %indvars.iv.next147
  %121 = load i32, ptr %120, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %121, i32 noundef 1)
  %122 = load i32, ptr %101, align 4, !tbaa !14
  %123 = sext i32 %122 to i64
  %124 = icmp slt i64 %indvars.iv.next147, %123
  br i1 %124, label %.lr.ph102, label %.preheader78.loopexit, !llvm.loop !17

.preheader77.loopexit:                            ; preds = %.lr.ph108
  %125 = trunc nsw i64 %indvars.iv.next150 to i32
  br label %.preheader77

.preheader77:                                     ; preds = %.preheader77.loopexit, %.preheader78
  %126 = phi i32 [ %108, %.preheader78 ], [ %140, %.preheader77.loopexit ]
  %.265.lcssa = phi i64 [ %.164.lcssa, %.preheader78 ], [ %137, %.preheader77.loopexit ]
  %.160.lcssa = phi i32 [ %.059124, %.preheader78 ], [ %125, %.preheader77.loopexit ]
  %127 = icmp slt i32 %.160.lcssa, %126
  br i1 %127, label %.lr.ph113.preheader, label %.preheader76

.lr.ph113.preheader:                              ; preds = %.preheader77
  %128 = sext i32 %.160.lcssa to i64
  br label %.lr.ph113

.lr.ph108:                                        ; preds = %.lr.ph108.preheader, %.lr.ph108
  %indvars.iv149 = phi i64 [ %110, %.lr.ph108.preheader ], [ %indvars.iv.next150, %.lr.ph108 ]
  %.265106 = phi i64 [ %.164.lcssa, %.lr.ph108.preheader ], [ %137, %.lr.ph108 ]
  %indvars.iv.next150 = add nsw i64 %indvars.iv149, -1
  %129 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %indvars.iv.next150
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = call noundef i32 @_Z4calci(i32 noundef %130)
  %132 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %indvars.iv.next150
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = call noundef i32 @_Z4calci(i32 noundef %133)
  %135 = sub nsw i32 %131, %134
  %136 = sext i32 %135 to i64
  %137 = add nsw i64 %.265106, %136
  %138 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %indvars.iv.next150
  %139 = load i32, ptr %138, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %139, i32 noundef 1)
  %140 = load i32, ptr %107, align 4, !tbaa !16
  %141 = sext i32 %140 to i64
  %142 = icmp sgt i64 %indvars.iv.next150, %141
  br i1 %142, label %.lr.ph108, label %.preheader77.loopexit, !llvm.loop !18

.preheader76.loopexit:                            ; preds = %.lr.ph113
  %143 = trunc nsw i64 %indvars.iv.next153 to i32
  br label %.preheader76

.preheader76:                                     ; preds = %.preheader76.loopexit, %.preheader77
  %.3.lcssa = phi i64 [ %.265.lcssa, %.preheader77 ], [ %157, %.preheader76.loopexit ]
  %.261.lcssa = phi i32 [ %.160.lcssa, %.preheader77 ], [ %143, %.preheader76.loopexit ]
  %144 = load i32, ptr %101, align 4, !tbaa !14
  %145 = icmp sgt i32 %.1.lcssa, %144
  br i1 %145, label %.lr.ph118.preheader, label %._crit_edge119

.lr.ph118.preheader:                              ; preds = %.preheader76
  %146 = sext i32 %.1.lcssa to i64
  br label %.lr.ph118

.lr.ph113:                                        ; preds = %.lr.ph113.preheader, %.lr.ph113
  %indvars.iv152 = phi i64 [ %128, %.lr.ph113.preheader ], [ %indvars.iv.next153, %.lr.ph113 ]
  %.3111 = phi i64 [ %.265.lcssa, %.lr.ph113.preheader ], [ %157, %.lr.ph113 ]
  %147 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %indvars.iv152
  %148 = load i32, ptr %147, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %148, i32 noundef -1)
  %149 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %indvars.iv152
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = call noundef i32 @_Z4calci(i32 noundef %150)
  %152 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %indvars.iv152
  %153 = load i32, ptr %152, align 4, !tbaa !5
  %154 = call noundef i32 @_Z4calci(i32 noundef %153)
  %155 = sub nsw i32 %151, %154
  %156 = sext i32 %155 to i64
  %157 = sub nsw i64 %.3111, %156
  %indvars.iv.next153 = add nsw i64 %indvars.iv152, 1
  %158 = load i32, ptr %107, align 4, !tbaa !16
  %159 = sext i32 %158 to i64
  %160 = icmp slt i64 %indvars.iv.next153, %159
  br i1 %160, label %.lr.ph113, label %.preheader76.loopexit, !llvm.loop !19

.lr.ph118:                                        ; preds = %.lr.ph118.preheader, %.lr.ph118
  %indvars.iv155 = phi i64 [ %146, %.lr.ph118.preheader ], [ %indvars.iv.next156, %.lr.ph118 ]
  %.4116 = phi i64 [ %.3.lcssa, %.lr.ph118.preheader ], [ %171, %.lr.ph118 ]
  %161 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %indvars.iv155
  %162 = load i32, ptr %161, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %162, i32 noundef -1)
  %163 = getelementptr inbounds [50001 x i32], ptr @qR, i64 0, i64 %indvars.iv155
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = call noundef i32 @_Z4calci(i32 noundef %164)
  %166 = getelementptr inbounds [50001 x i32], ptr @qL, i64 0, i64 %indvars.iv155
  %167 = load i32, ptr %166, align 4, !tbaa !5
  %168 = call noundef i32 @_Z4calci(i32 noundef %167)
  %169 = sub nsw i32 %165, %168
  %170 = sext i32 %169 to i64
  %171 = sub nsw i64 %.4116, %170
  %indvars.iv.next156 = add nsw i64 %indvars.iv155, -1
  %172 = load i32, ptr %101, align 4, !tbaa !14
  %173 = sext i32 %172 to i64
  %174 = icmp sgt i64 %indvars.iv.next156, %173
  br i1 %174, label %.lr.ph118, label %._crit_edge119.loopexit, !llvm.loop !20

._crit_edge119.loopexit:                          ; preds = %.lr.ph118
  %175 = trunc nsw i64 %indvars.iv.next156 to i32
  br label %._crit_edge119

._crit_edge119:                                   ; preds = %._crit_edge119.loopexit, %.preheader76
  %.4.lcssa = phi i64 [ %.3.lcssa, %.preheader76 ], [ %171, %._crit_edge119.loopexit ]
  %.2.lcssa = phi i32 [ %.1.lcssa, %.preheader76 ], [ %175, %._crit_edge119.loopexit ]
  %176 = load i32, ptr %100, align 4, !tbaa !21
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [50001 x i64], ptr @ans, i64 0, i64 %177
  store i64 %.4.lcssa, ptr %178, align 8, !tbaa !22
  %indvars.iv.next159 = add nuw nsw i64 %indvars.iv158, 1
  %179 = load i32, ptr @q, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = icmp slt i64 %indvars.iv.next159, %180
  br i1 %181, label %.preheader79, label %.preheader, !llvm.loop !24

._crit_edge128:                                   ; preds = %.lr.ph127, %._crit_edge98, %.preheader
  ret i32 0

.lr.ph127:                                        ; preds = %.preheader, %.lr.ph127
  %indvars.iv161 = phi i64 [ %indvars.iv.next162, %.lr.ph127 ], [ 0, %.preheader ]
  %182 = getelementptr inbounds [50001 x i64], ptr @ans, i64 0, i64 %indvars.iv161
  %183 = load i64, ptr %182, align 8, !tbaa !22
  %184 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %183)
  %indvars.iv.next162 = add nuw nsw i64 %indvars.iv161, 1
  %185 = load i32, ptr @q, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = icmp slt i64 %indvars.iv.next162, %186
  br i1 %187, label %.lr.ph127, label %._crit_edge128, !llvm.loop !25
}

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

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #6

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

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

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


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