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

; 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 }

@pr = external dso_local global [100001 x i32], align 16
@d = external dso_local global [100001 x i32], align 16
@st = external dso_local global i32, align 4
@etot = external dso_local global i32, align 4
@e = external dso_local global [7 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@ord = external dso_local global [100001 x i32], align 16
@pos = external dso_local global [100001 x i32], align 16
@tot = external dso_local global i32, align 4
@mx = external dso_local global i32, align 4
@que = external dso_local global [100001 x i32], align 16
@bit = external dso_local global [100001 x i64], align 16
@ans = external dso_local global [100001 x i64], align 16
@query = external dso_local global [100001 x %struct.Query], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z7bit_sumi(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 uwtable
declare dso_local noundef i64 @_Z3dfsii(i32 noundef, i32 noundef) #2

; 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 i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %71, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 100001
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %74

22:                                               ; preds = %18
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %37, label %28

28:                                               ; preds = %22
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %31
  store i32 %29, ptr %32, 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 [100001 x i32], ptr @pr, i64 0, i64 %35
  store i32 %29, ptr %36, align 4, !tbaa !5
  br label %37

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

38:                                               ; preds = %66, %37
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = mul nsw i32 %39, %43
  store i32 %44, ptr %5, align 4, !tbaa !5
  %45 = icmp slt i32 %44, 100001
  br i1 %45, label %47, label %46

46:                                               ; preds = %38
  store i32 5, ptr %3, align 4
  br label %69

47:                                               ; preds = %38
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %53
  store i32 %51, ptr %54, align 4, !tbaa !5
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = icmp eq i32 %58, %62
  br i1 %63, label %64, label %65

64:                                               ; preds = %47
  store i32 5, ptr %3, align 4
  br label %69

65:                                               ; preds = %47
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %4, align 4, !tbaa !5
  br label %38, !llvm.loop !9

69:                                               ; preds = %64, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %70

70:                                               ; preds = %69
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !11

74:                                               ; preds = %21
  %75 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %76

76:                                               ; preds = %306, %74
  %77 = load i32, ptr @t, align 4, !tbaa !5
  %78 = add nsw i32 %77, -1
  store i32 %78, ptr @t, align 4, !tbaa !5
  %79 = icmp ne i32 %77, 0
  br i1 %79, label %80, label %307

80:                                               ; preds = %76
  %81 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %92, %80
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = load i32, ptr @n, align 4, !tbaa !5
  %85 = icmp sle i32 %83, %84
  br i1 %85, label %87, label %86

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

87:                                               ; preds = %82
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i32, ptr @a, i64 %89
  %91 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %90)
  br label %92

92:                                               ; preds = %87
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %6, align 4, !tbaa !5
  br label %82, !llvm.loop !12

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

96:                                               ; preds = %115, %95
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = load i32, ptr @m, align 4, !tbaa !5
  %99 = icmp sle i32 %97, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %96
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %118

101:                                              ; preds = %96
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %103
  %105 = getelementptr inbounds %struct.Query, ptr %104, i32 0, i32 0
  %106 = load i32, ptr %7, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %107
  %109 = getelementptr inbounds %struct.Query, ptr %108, i32 0, i32 1
  %110 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %105, ptr noundef %109)
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = load i32, ptr %7, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %113
  store i32 %111, ptr %114, align 4, !tbaa !5
  br label %115

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

118:                                              ; preds = %100
  %119 = load i32, ptr @m, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds i32, ptr @ord, i64 %120
  %122 = getelementptr inbounds i32, ptr %121, i64 1
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef getelementptr inbounds (i32, ptr @ord, i64 1), ptr noundef %122, ptr noundef @_Z3cmpRKiS0_)
  %123 = load i32, ptr @n, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = mul i64 %124, 8
  call void @llvm.memset.p0.i64(ptr align 8 getelementptr inbounds (i64, ptr @bit, i64 1), i8 0, i64 %125, i1 false)
  %126 = load i32, ptr @n, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = mul i64 %127, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @pos, i64 1), i8 63, i64 %128, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %129

129:                                              ; preds = %288, %118
  %130 = load i32, ptr %8, align 4, !tbaa !5
  %131 = load i32, ptr @n, align 4, !tbaa !5
  %132 = icmp sle i32 %130, %131
  br i1 %132, label %134, label %133

133:                                              ; preds = %129
  store i32 16, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %291

134:                                              ; preds = %129
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %135 = load i32, ptr %8, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %136
  %138 = load i32, ptr %137, align 4, !tbaa !5
  store i32 %138, ptr %10, align 4, !tbaa !5
  store i32 0, ptr @mx, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %139 = load i32, ptr %10, align 4, !tbaa !5
  %140 = shl i32 %139, 1
  store i32 %140, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 2, ptr %12, align 4, !tbaa !5
  br label %141

141:                                              ; preds = %164, %134
  %142 = load i32, ptr %11, align 4, !tbaa !5
  %143 = load i32, ptr @n, align 4, !tbaa !5
  %144 = icmp sle i32 %142, %143
  br i1 %144, label %146, label %145

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

146:                                              ; preds = %141
  %147 = load i32, ptr %11, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100001 x i32], ptr @pos, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = load i32, ptr %8, align 4, !tbaa !5
  %152 = icmp slt i32 %150, %151
  br i1 %152, label %153, label %163

153:                                              ; preds = %146
  %154 = load i32, ptr %11, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [100001 x i32], ptr @pos, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = load i32, ptr @tot, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr @tot, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %160
  store i32 %157, ptr %161, align 4, !tbaa !5
  %162 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %162, ptr @mx, align 4, !tbaa !5
  br label %163

163:                                              ; preds = %153, %146
  br label %164

164:                                              ; preds = %163
  %165 = load i32, ptr %10, align 4, !tbaa !5
  %166 = load i32, ptr %11, align 4, !tbaa !5
  %167 = add nsw i32 %166, %165
  store i32 %167, ptr %11, align 4, !tbaa !5
  %168 = load i32, ptr %12, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %12, align 4, !tbaa !5
  br label %141, !llvm.loop !14

170:                                              ; preds = %145
  %171 = load i32, ptr @tot, align 4, !tbaa !5
  %172 = icmp ne i32 %171, 0
  br i1 %172, label %173, label %243

173:                                              ; preds = %170
  %174 = load i32, ptr @tot, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds i32, ptr @que, i64 %175
  %177 = getelementptr inbounds i32, ptr %176, i64 1
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %177)
  %178 = load i32, ptr @st, align 4, !tbaa !5
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr @st, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %180 = load i32, ptr @tot, align 4, !tbaa !5
  store i32 %180, ptr %13, align 4, !tbaa !5
  br label %181

181:                                              ; preds = %239, %173
  %182 = load i32, ptr %13, align 4, !tbaa !5
  %183 = icmp sge i32 %182, 1
  br i1 %183, label %185, label %184

184:                                              ; preds = %181
  store i32 22, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %242

185:                                              ; preds = %181
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %186 = load i32, ptr %13, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %187
  %189 = load i32, ptr %188, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %190
  %192 = load i32, ptr %191, align 4, !tbaa !5
  %193 = load i32, ptr %10, align 4, !tbaa !5
  %194 = sdiv i32 %192, %193
  store i32 %194, ptr %14, align 4, !tbaa !5
  store i32 0, ptr @etot, align 4, !tbaa !5
  br label %195

195:                                              ; preds = %222, %185
  %196 = load i32, ptr %14, align 4, !tbaa !5
  %197 = icmp sgt i32 %196, 1
  br i1 %197, label %198, label %225

198:                                              ; preds = %195
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %199 = load i32, ptr %14, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %200
  %202 = load i32, ptr %201, align 4, !tbaa !5
  %203 = load i32, ptr @etot, align 4, !tbaa !5
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [7 x i32], ptr @e, i64 0, i64 %204
  store i32 %202, ptr %205, align 4, !tbaa !5
  store i32 %202, ptr %15, align 4, !tbaa !5
  %206 = load i32, ptr %15, align 4, !tbaa !5
  %207 = load i32, ptr %14, align 4, !tbaa !5
  %208 = sdiv i32 %207, %206
  store i32 %208, ptr %14, align 4, !tbaa !5
  br label %209

209:                                              ; preds = %217, %198
  %210 = load i32, ptr %14, align 4, !tbaa !5
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %211
  %213 = load i32, ptr %212, align 4, !tbaa !5
  %214 = load i32, ptr %15, align 4, !tbaa !5
  %215 = icmp eq i32 %213, %214
  br i1 %215, label %216, label %221

216:                                              ; preds = %209
  br label %217

217:                                              ; preds = %216
  %218 = load i32, ptr %15, align 4, !tbaa !5
  %219 = load i32, ptr %14, align 4, !tbaa !5
  %220 = sdiv i32 %219, %218
  store i32 %220, ptr %14, align 4, !tbaa !5
  br label %209, !llvm.loop !15

221:                                              ; preds = %209
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %222

222:                                              ; preds = %221
  %223 = load i32, ptr @etot, align 4, !tbaa !5
  %224 = add nsw i32 %223, 1
  store i32 %224, ptr @etot, align 4, !tbaa !5
  br label %195, !llvm.loop !16

225:                                              ; preds = %195
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %226 = call noundef i64 @_Z3dfsii(i32 noundef 0, i32 noundef 1)
  store i64 %226, ptr %16, align 8, !tbaa !17
  %227 = load i64, ptr %16, align 8, !tbaa !17
  %228 = icmp ne i64 %227, 0
  br i1 %228, label %229, label %238

229:                                              ; preds = %225
  %230 = load i32, ptr %13, align 4, !tbaa !5
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %231
  %233 = load i32, ptr %232, align 4, !tbaa !5
  %234 = load i64, ptr %16, align 8, !tbaa !17
  %235 = load i32, ptr %10, align 4, !tbaa !5
  %236 = sext i32 %235 to i64
  %237 = mul nsw i64 %234, %236
  call void @_Z7bit_addix(i32 noundef %233, i64 noundef %237)
  br label %238

238:                                              ; preds = %229, %225
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %239

239:                                              ; preds = %238
  %240 = load i32, ptr %13, align 4, !tbaa !5
  %241 = add nsw i32 %240, -1
  store i32 %241, ptr %13, align 4, !tbaa !5
  br label %181, !llvm.loop !19

242:                                              ; preds = %184
  br label %243

243:                                              ; preds = %242, %170
  %244 = load i32, ptr %8, align 4, !tbaa !5
  %245 = load i32, ptr %8, align 4, !tbaa !5
  %246 = sext i32 %245 to i64
  %247 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %246
  %248 = load i32, ptr %247, align 4, !tbaa !5
  %249 = sext i32 %248 to i64
  %250 = getelementptr inbounds [100001 x i32], ptr @pos, i64 0, i64 %249
  store i32 %244, ptr %250, align 4, !tbaa !5
  br label %251

251:                                              ; preds = %284, %243
  %252 = load i32, ptr %9, align 4, !tbaa !5
  %253 = load i32, ptr @m, align 4, !tbaa !5
  %254 = icmp sle i32 %252, %253
  br i1 %254, label %255, label %266

255:                                              ; preds = %251
  %256 = load i32, ptr %9, align 4, !tbaa !5
  %257 = sext i32 %256 to i64
  %258 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %257
  %259 = load i32, ptr %258, align 4, !tbaa !5
  %260 = sext i32 %259 to i64
  %261 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %260
  %262 = getelementptr inbounds %struct.Query, ptr %261, i32 0, i32 1
  %263 = load i32, ptr %262, align 4, !tbaa !20
  %264 = load i32, ptr %8, align 4, !tbaa !5
  %265 = icmp eq i32 %263, %264
  br label %266

266:                                              ; preds = %255, %251
  %267 = phi i1 [ false, %251 ], [ %265, %255 ]
  br i1 %267, label %268, label %287

268:                                              ; preds = %266
  %269 = load i32, ptr %9, align 4, !tbaa !5
  %270 = sext i32 %269 to i64
  %271 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %270
  %272 = load i32, ptr %271, align 4, !tbaa !5
  %273 = sext i32 %272 to i64
  %274 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %273
  %275 = getelementptr inbounds %struct.Query, ptr %274, i32 0, i32 0
  %276 = load i32, ptr %275, align 8, !tbaa !22
  %277 = call noundef i64 @_Z7bit_sumi(i32 noundef %276)
  %278 = load i32, ptr %9, align 4, !tbaa !5
  %279 = sext i32 %278 to i64
  %280 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %279
  %281 = load i32, ptr %280, align 4, !tbaa !5
  %282 = sext i32 %281 to i64
  %283 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %282
  store i64 %277, ptr %283, align 8, !tbaa !17
  br label %284

284:                                              ; preds = %268
  %285 = load i32, ptr %9, align 4, !tbaa !5
  %286 = add nsw i32 %285, 1
  store i32 %286, ptr %9, align 4, !tbaa !5
  br label %251, !llvm.loop !23

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

288:                                              ; preds = %287
  %289 = load i32, ptr %8, align 4, !tbaa !5
  %290 = add nsw i32 %289, 1
  store i32 %290, ptr %8, align 4, !tbaa !5
  br label %129, !llvm.loop !24

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

292:                                              ; preds = %303, %291
  %293 = load i32, ptr %17, align 4, !tbaa !5
  %294 = load i32, ptr @m, align 4, !tbaa !5
  %295 = icmp sle i32 %293, %294
  br i1 %295, label %297, label %296

296:                                              ; preds = %292
  store i32 34, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %306

297:                                              ; preds = %292
  %298 = load i32, ptr %17, align 4, !tbaa !5
  %299 = sext i32 %298 to i64
  %300 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %299
  %301 = load i64, ptr %300, align 8, !tbaa !17
  %302 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %301)
  br label %303

303:                                              ; preds = %297
  %304 = load i32, ptr %17, align 4, !tbaa !5
  %305 = add nsw i32 %304, 1
  store i32 %305, ptr %17, align 4, !tbaa !5
  br label %292, !llvm.loop !25

306:                                              ; preds = %296
  br label %76, !llvm.loop !26

307:                                              ; preds = %76
  ret i32 0
}

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

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

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

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

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

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

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

@pr = external dso_local local_unnamed_addr global [100001 x i32], align 16
@d = external dso_local local_unnamed_addr global [100001 x i32], align 16
@st = external dso_local local_unnamed_addr global i32, align 4
@etot = external dso_local local_unnamed_addr global i32, align 4
@e = external dso_local local_unnamed_addr global [7 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@ord = external dso_local global [100001 x i32], align 16
@pos = external dso_local local_unnamed_addr global [100001 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@mx = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [100001 x i32], align 16
@bit = external dso_local local_unnamed_addr global [100001 x i64], align 16
@ans = external dso_local local_unnamed_addr global [100001 x i64], align 16
@query = external dso_local global [100001 x %struct.Query], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  br label %5

1:                                                ; preds = %._crit_edge
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %3 = load i32, ptr @t, align 4, !tbaa !5
  %4 = add nsw i32 %3, -1
  store i32 %4, ptr @t, align 4, !tbaa !5
  %.not131 = icmp eq i32 %3, 0
  br i1 %.not131, label %._crit_edge134, label %.lr.ph133

5:                                                ; preds = %0, %._crit_edge
  %indvars.iv138 = phi i64 [ 2, %0 ], [ %indvars.iv.next139, %._crit_edge ]
  %6 = phi i32 [ %tot.promoted, %0 ], [ %14, %._crit_edge ]
  %7 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %indvars.iv138
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %.not85 = icmp eq i32 %8, 0
  %9 = trunc nuw nsw i64 %indvars.iv138 to i32
  br i1 %.not85, label %10, label %._crit_edge167

10:                                               ; preds = %5
  store i32 %9, ptr %7, align 4, !tbaa !5
  %11 = add nsw i32 %6, 1
  store i32 %11, ptr @tot, align 4, !tbaa !5
  %12 = sext i32 %6 to i64
  %13 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %12
  store i32 %9, ptr %13, align 4, !tbaa !5
  br label %._crit_edge167

._crit_edge167:                                   ; preds = %5, %10
  %14 = phi i32 [ %11, %10 ], [ %6, %5 ]
  %15 = load i32, ptr @pr, align 16, !tbaa !5
  %16 = mul nsw i32 %15, %9
  %17 = icmp slt i32 %16, 100001
  br i1 %17, label %.lr.ph, label %._crit_edge

18:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = getelementptr inbounds [100001 x i32], ptr @pr, i64 0, i64 %indvars.iv.next
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = mul nsw i32 %20, %9
  %22 = icmp slt i32 %21, 100001
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph:                                           ; preds = %._crit_edge167, %18
  %indvars.iv = phi i64 [ %indvars.iv.next, %18 ], [ 0, %._crit_edge167 ]
  %23 = phi i32 [ %21, %18 ], [ %16, %._crit_edge167 ]
  %24 = phi i32 [ %20, %18 ], [ %15, %._crit_edge167 ]
  %25 = sext i32 %23 to i64
  %26 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %25
  store i32 %24, ptr %26, align 4, !tbaa !5
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = icmp eq i32 %27, %24
  br i1 %28, label %._crit_edge, label %18

._crit_edge:                                      ; preds = %18, %.lr.ph, %._crit_edge167
  %indvars.iv.next139 = add nuw nsw i64 %indvars.iv138, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next139, 100001
  br i1 %exitcond.not, label %1, label %5, !llvm.loop !11

.loopexit86:                                      ; preds = %.lr.ph129, %.preheader
  %29 = load i32, ptr @t, align 4, !tbaa !5
  %30 = add nsw i32 %29, -1
  store i32 %30, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %29, 0
  br i1 %.not, label %._crit_edge134, label %.lr.ph133, !llvm.loop !12

.lr.ph133:                                        ; preds = %1, %.loopexit86
  %31 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %.not7791 = icmp slt i32 %32, 1
  br i1 %.not7791, label %.preheader87, label %.lr.ph94

.preheader87:                                     ; preds = %.lr.ph94, %.lr.ph133
  %33 = load i32, ptr @m, align 4, !tbaa !5
  %.not7895 = icmp slt i32 %33, 1
  br i1 %.not7895, label %.preheader87.._crit_edge98_crit_edge, label %.lr.ph97

.preheader87.._crit_edge98_crit_edge:             ; preds = %.preheader87
  %.pre169 = sext i32 %33 to i64
  br label %._crit_edge98

.lr.ph94:                                         ; preds = %.lr.ph133, %.lr.ph94
  %indvars.iv141 = phi i64 [ %indvars.iv.next142, %.lr.ph94 ], [ 1, %.lr.ph133 ]
  %34 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv141
  %35 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %34)
  %indvars.iv.next142 = add nuw nsw i64 %indvars.iv141, 1
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %.not77.not = icmp slt i64 %indvars.iv141, %37
  br i1 %.not77.not, label %.lr.ph94, label %.preheader87, !llvm.loop !13

._crit_edge98:                                    ; preds = %.lr.ph97, %.preheader87.._crit_edge98_crit_edge
  %.pre-phi170 = phi i64 [ %.pre169, %.preheader87.._crit_edge98_crit_edge ], [ %48, %.lr.ph97 ]
  %gep130 = getelementptr i32, ptr getelementptr inbounds (i8, ptr @ord, i64 4), i64 %.pre-phi170
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @ord, i64 4), ptr noundef nonnull %gep130, ptr noundef nonnull @_Z3cmpRKiS0_)
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = shl nsw i64 %39, 3
  tail call void @llvm.memset.p0.i64(ptr nonnull align 8 getelementptr inbounds (i8, ptr @bit, i64 8), i8 0, i64 %40, i1 false)
  %41 = shl nsw i64 %39, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @pos, i64 4), i8 63, i64 %41, i1 false)
  %.not79122 = icmp slt i32 %38, 1
  br i1 %.not79122, label %._crit_edge98..preheader_crit_edge, label %.lr.ph126

._crit_edge98..preheader_crit_edge:               ; preds = %._crit_edge98
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %.preheader

.lr.ph97:                                         ; preds = %.preheader87, %.lr.ph97
  %indvars.iv144 = phi i64 [ %indvars.iv.next145, %.lr.ph97 ], [ 1, %.preheader87 ]
  %42 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %indvars.iv144
  %43 = getelementptr inbounds i8, ptr %42, i64 4
  %44 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %42, ptr noundef nonnull %43)
  %45 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv144
  %46 = trunc nuw nsw i64 %indvars.iv144 to i32
  store i32 %46, ptr %45, align 4, !tbaa !5
  %indvars.iv.next145 = add nuw nsw i64 %indvars.iv144, 1
  %47 = load i32, ptr @m, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %.not78.not = icmp slt i64 %indvars.iv144, %48
  br i1 %.not78.not, label %.lr.ph97, label %._crit_edge98, !llvm.loop !14

.preheader:                                       ; preds = %.critedge, %._crit_edge98..preheader_crit_edge
  %49 = phi i32 [ %.pre, %._crit_edge98..preheader_crit_edge ], [ %135, %.critedge ]
  %.not80127 = icmp slt i32 %49, 1
  br i1 %.not80127, label %.loopexit86, label %.lr.ph129

.lr.ph126:                                        ; preds = %._crit_edge98, %.critedge
  %indvars.iv159 = phi i64 [ %indvars.iv.next160, %.critedge ], [ 1, %._crit_edge98 ]
  %50 = phi i32 [ %136, %.critedge ], [ %38, %._crit_edge98 ]
  %.066124 = phi i32 [ %.167.lcssa, %.critedge ], [ 1, %._crit_edge98 ]
  %51 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv159
  %52 = load i32, ptr %51, align 4, !tbaa !5
  store i32 0, ptr @mx, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  %53 = shl i32 %52, 1
  %.not81100 = icmp sgt i32 %53, %50
  br i1 %.not81100, label %.loopexit, label %.lr.ph104.preheader

.lr.ph104.preheader:                              ; preds = %.lr.ph126
  %54 = sext i32 %53 to i64
  %55 = sext i32 %52 to i64
  %56 = sext i32 %50 to i64
  br label %.lr.ph104

._crit_edge105:                                   ; preds = %66
  %.not82 = icmp eq i32 %67, 0
  br i1 %.not82, label %.loopexit, label %69

.lr.ph104:                                        ; preds = %.lr.ph104.preheader, %66
  %indvars.iv147 = phi i64 [ %54, %.lr.ph104.preheader ], [ %indvars.iv.next148, %66 ]
  %.063102 = phi i32 [ 2, %.lr.ph104.preheader ], [ %68, %66 ]
  %57 = phi i32 [ 0, %.lr.ph104.preheader ], [ %67, %66 ]
  %58 = getelementptr inbounds [100001 x i32], ptr @pos, i64 0, i64 %indvars.iv147
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = icmp sgt i64 %indvars.iv159, %60
  br i1 %61, label %62, label %66

62:                                               ; preds = %.lr.ph104
  %63 = add nsw i32 %57, 1
  store i32 %63, ptr @tot, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %64
  store i32 %59, ptr %65, align 4, !tbaa !5
  store i32 %.063102, ptr @mx, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %.lr.ph104, %62
  %67 = phi i32 [ %57, %.lr.ph104 ], [ %63, %62 ]
  %indvars.iv.next148 = add nsw i64 %indvars.iv147, %55
  %68 = add nuw nsw i32 %.063102, 1
  %.not81 = icmp sgt i64 %indvars.iv.next148, %56
  br i1 %.not81, label %._crit_edge105, label %.lr.ph104, !llvm.loop !15

69:                                               ; preds = %._crit_edge105
  %70 = sext i32 %67 to i64
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @que, i64 4), i64 %70
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %gep)
  %71 = load i32, ptr @st, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr @st, align 4, !tbaa !5
  %73 = load i32, ptr @tot, align 4, !tbaa !5
  %74 = icmp sgt i32 %73, 0
  br i1 %74, label %.lr.ph114, label %.loopexit

.lr.ph114:                                        ; preds = %69
  %75 = sext i32 %52 to i64
  %76 = zext nneg i32 %73 to i64
  br label %77

77:                                               ; preds = %.lr.ph114, %101
  %indvars.iv153 = phi i64 [ %76, %.lr.ph114 ], [ %indvars.iv.next154, %101 ]
  %78 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %indvars.iv153
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = sdiv i32 %82, %52
  %84 = icmp sgt i32 %83, 1
  br i1 %84, label %.lr.ph109, label %._crit_edge110

.lr.ph109:                                        ; preds = %77, %94
  %indvars.iv150 = phi i64 [ %indvars.iv.next151, %94 ], [ 0, %77 ]
  %.061107 = phi i32 [ %.1, %94 ], [ %83, %77 ]
  %85 = zext nneg i32 %.061107 to i64
  %86 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = getelementptr inbounds [7 x i32], ptr @e, i64 0, i64 %indvars.iv150
  store i32 %87, ptr %88, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %89, %.lr.ph109
  %.061.pn = phi i32 [ %.061107, %.lr.ph109 ], [ %.1, %89 ]
  %.1 = sdiv i32 %.061.pn, %87
  %90 = sext i32 %.1 to i64
  %91 = getelementptr inbounds [100001 x i32], ptr @d, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = icmp eq i32 %92, %87
  br i1 %93, label %89, label %94, !llvm.loop !16

94:                                               ; preds = %89
  %indvars.iv.next151 = add nuw nsw i64 %indvars.iv150, 1
  %95 = icmp sgt i32 %.1, 1
  br i1 %95, label %.lr.ph109, label %._crit_edge110.loopexit, !llvm.loop !17

._crit_edge110.loopexit:                          ; preds = %94
  %96 = trunc nuw i64 %indvars.iv.next151 to i32
  br label %._crit_edge110

._crit_edge110:                                   ; preds = %._crit_edge110.loopexit, %77
  %storemerge.lcssa = phi i32 [ 0, %77 ], [ %96, %._crit_edge110.loopexit ]
  store i32 %storemerge.lcssa, ptr @etot, align 4, !tbaa !5
  %97 = tail call noundef i64 @_Z3dfsii(i32 noundef 0, i32 noundef 1)
  %.not84 = icmp eq i64 %97, 0
  br i1 %.not84, label %101, label %98

98:                                               ; preds = %._crit_edge110
  %99 = load i32, ptr %78, align 4, !tbaa !5
  %100 = mul nsw i64 %97, %75
  tail call void @_Z7bit_addix(i32 noundef %99, i64 noundef %100)
  br label %101

101:                                              ; preds = %98, %._crit_edge110
  %indvars.iv.next154 = add nsw i64 %indvars.iv153, -1
  %102 = icmp sgt i64 %indvars.iv153, 1
  br i1 %102, label %77, label %.loopexit, !llvm.loop !18

.loopexit:                                        ; preds = %101, %.lr.ph126, %69, %._crit_edge105
  %103 = load i32, ptr %51, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [100001 x i32], ptr @pos, i64 0, i64 %104
  %106 = trunc nuw nsw i64 %indvars.iv159 to i32
  store i32 %106, ptr %105, align 4, !tbaa !5
  %107 = load i32, ptr @m, align 4, !tbaa !5
  %.not83115 = icmp sgt i32 %.066124, %107
  br i1 %.not83115, label %.critedge, label %.lr.ph118.preheader

.lr.ph118.preheader:                              ; preds = %.loopexit
  %108 = sext i32 %.066124 to i64
  %109 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %111
  %113 = getelementptr inbounds i8, ptr %112, i64 4
  %114 = load i32, ptr %113, align 4, !tbaa !19
  %115 = zext i32 %114 to i64
  %116 = icmp eq i64 %indvars.iv159, %115
  br i1 %116, label %.lr.ph177, label %.critedge.loopexit

.lr.ph118:                                        ; preds = %.lr.ph177
  %117 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv.next157
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %119
  %121 = getelementptr inbounds i8, ptr %120, i64 4
  %122 = load i32, ptr %121, align 4, !tbaa !19
  %123 = zext i32 %122 to i64
  %124 = icmp eq i64 %indvars.iv159, %123
  br i1 %124, label %.lr.ph177, label %.critedge.loopexit, !llvm.loop !21

.lr.ph177:                                        ; preds = %.lr.ph118.preheader, %.lr.ph118
  %125 = phi ptr [ %120, %.lr.ph118 ], [ %112, %.lr.ph118.preheader ]
  %126 = phi ptr [ %117, %.lr.ph118 ], [ %109, %.lr.ph118.preheader ]
  %indvars.iv156176 = phi i64 [ %indvars.iv.next157, %.lr.ph118 ], [ %108, %.lr.ph118.preheader ]
  %127 = load i32, ptr %125, align 8, !tbaa !22
  %128 = tail call noundef i64 @_Z7bit_sumi(i32 noundef %127)
  %129 = load i32, ptr %126, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %130
  store i64 %128, ptr %131, align 8, !tbaa !23
  %indvars.iv.next157 = add nsw i64 %indvars.iv156176, 1
  %132 = load i32, ptr @m, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %.not83.not = icmp slt i64 %indvars.iv156176, %133
  br i1 %.not83.not, label %.lr.ph118, label %.critedge.loopexit, !llvm.loop !21

.critedge.loopexit:                               ; preds = %.lr.ph118, %.lr.ph177, %.lr.ph118.preheader
  %134 = phi i32 [ %107, %.lr.ph118.preheader ], [ %132, %.lr.ph177 ], [ %132, %.lr.ph118 ]
  %.167.lcssa.ph.in = phi i64 [ %108, %.lr.ph118.preheader ], [ %indvars.iv.next157, %.lr.ph177 ], [ %indvars.iv.next157, %.lr.ph118 ]
  %.167.lcssa.ph = trunc i64 %.167.lcssa.ph.in to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.loopexit
  %135 = phi i32 [ %107, %.loopexit ], [ %134, %.critedge.loopexit ]
  %.167.lcssa = phi i32 [ %.066124, %.loopexit ], [ %.167.lcssa.ph, %.critedge.loopexit ]
  %indvars.iv.next160 = add nuw nsw i64 %indvars.iv159, 1
  %136 = load i32, ptr @n, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %.not79.not = icmp slt i64 %indvars.iv159, %137
  br i1 %.not79.not, label %.lr.ph126, label %.preheader, !llvm.loop !25

.lr.ph129:                                        ; preds = %.preheader, %.lr.ph129
  %indvars.iv163 = phi i64 [ %indvars.iv.next164, %.lr.ph129 ], [ 1, %.preheader ]
  %138 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %indvars.iv163
  %139 = load i64, ptr %138, align 8, !tbaa !23
  %140 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %139)
  %indvars.iv.next164 = add nuw nsw i64 %indvars.iv163, 1
  %141 = load i32, ptr @m, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %.not80.not = icmp slt i64 %indvars.iv163, %142
  br i1 %.not80.not, label %.lr.ph129, label %.loopexit86, !llvm.loop !26

._crit_edge134:                                   ; preds = %.loopexit86, %1
  ret i32 0
}

; 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 @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(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 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 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 nocallback nofree nounwind willreturn memory(argmem: write) }

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

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


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