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

; 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
@q = 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
@b = external dso_local global [100001 x i32], align 16
@c = external dso_local global [11 x i32], align 16
@p = external dso_local global [100001 x i32], align 16
@ans = external dso_local global [100001 x i32], align 16
@query = external dso_local global [100001 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 [4 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 @_Z3quei(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 i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @q, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %22, %0
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %25

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i32, ptr @a, i64 %19
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %20)
  br label %22

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !9

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

26:                                               ; preds = %43, %25
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = icmp sle i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %46

31:                                               ; preds = %26
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr @b, i64 %33
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %34)
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %41
  store i32 %36, ptr %42, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %31
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %3, align 4, !tbaa !5
  br label %26, !llvm.loop !11

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

47:                                               ; preds = %57, %46
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = load i32, ptr @m, align 4, !tbaa !5
  %50 = icmp sle i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %60

52:                                               ; preds = %47
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr @c, i64 %54
  %56 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %55)
  br label %57

57:                                               ; preds = %52
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %4, align 4, !tbaa !5
  br label %47, !llvm.loop !12

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

61:                                               ; preds = %81, %60
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = load i32, ptr @q, align 4, !tbaa !5
  %64 = icmp sle i32 %62, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %84

66:                                               ; preds = %61
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.Query, ptr %70, i32 0, i32 0
  store i32 %67, ptr %71, align 4, !tbaa !13
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %73
  %75 = getelementptr inbounds %struct.Query, ptr %74, i32 0, i32 1
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.Query, ptr %78, i32 0, i32 2
  %80 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %75, ptr noundef %79)
  br label %81

81:                                               ; preds = %66
  %82 = load i32, ptr %5, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %5, align 4, !tbaa !5
  br label %61, !llvm.loop !15

84:                                               ; preds = %65
  %85 = load i32, ptr @q, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds %struct.Query, ptr @query, i64 %86
  %88 = getelementptr inbounds %struct.Query, ptr %87, i64 1
  call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef getelementptr inbounds (%struct.Query, ptr @query, i64 1), ptr noundef %88)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %250, %84
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = load i32, ptr @n, align 4, !tbaa !5
  %92 = icmp sle i32 %90, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %89
  store i32 14, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %253

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

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

99:                                               ; preds = %95
  store i32 17, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %217

100:                                              ; preds = %95
  %101 = load i32, ptr %6, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = load i32, ptr %9, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = sub nsw i32 %104, %108
  %110 = icmp sgt i32 %109, 0
  br i1 %110, label %111, label %156

111:                                              ; preds = %100
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = load i32, ptr %9, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = sub nsw i32 %115, %119
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = load i32, ptr %6, align 4, !tbaa !5
  %125 = icmp slt i32 %123, %124
  br i1 %125, label %126, label %156

126:                                              ; preds = %111
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = load i32, ptr %9, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = sub nsw i32 %130, %134
  %136 = load i32, ptr %6, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = load i32, ptr %6, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = load i32, ptr %9, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = sub nsw i32 %143, %147
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = add nsw i32 %139, %154
  call void @_Z3updii(i32 noundef %135, i32 noundef %155)
  br label %156

156:                                              ; preds = %126, %111, %100
  %157 = load i32, ptr %6, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = load i32, ptr %9, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = add nsw i32 %160, %164
  %166 = load i32, ptr @n, align 4, !tbaa !5
  %167 = icmp sle i32 %165, %166
  br i1 %167, label %168, label %213

168:                                              ; preds = %156
  %169 = load i32, ptr %6, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %170
  %172 = load i32, ptr %171, align 4, !tbaa !5
  %173 = load i32, ptr %9, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = add nsw i32 %172, %176
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %178
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = load i32, ptr %6, align 4, !tbaa !5
  %182 = icmp slt i32 %180, %181
  br i1 %182, label %183, label %213

183:                                              ; preds = %168
  %184 = load i32, ptr %6, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  %188 = load i32, ptr %9, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !5
  %192 = add nsw i32 %187, %191
  %193 = load i32, ptr %6, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %194
  %196 = load i32, ptr %195, align 4, !tbaa !5
  %197 = load i32, ptr %6, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %198
  %200 = load i32, ptr %199, align 4, !tbaa !5
  %201 = load i32, ptr %9, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %202
  %204 = load i32, ptr %203, align 4, !tbaa !5
  %205 = add nsw i32 %200, %204
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %206
  %208 = load i32, ptr %207, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %209
  %211 = load i32, ptr %210, align 4, !tbaa !5
  %212 = add nsw i32 %196, %211
  call void @_Z3updii(i32 noundef %192, i32 noundef %212)
  br label %213

213:                                              ; preds = %183, %168, %156
  br label %214

214:                                              ; preds = %213
  %215 = load i32, ptr %9, align 4, !tbaa !5
  %216 = add nsw i32 %215, 1
  store i32 %216, ptr %9, align 4, !tbaa !5
  br label %95, !llvm.loop !16

217:                                              ; preds = %99
  br label %218

218:                                              ; preds = %246, %217
  %219 = load i32, ptr %7, align 4, !tbaa !5
  %220 = load i32, ptr @q, align 4, !tbaa !5
  %221 = icmp sle i32 %219, %220
  br i1 %221, label %222, label %230

222:                                              ; preds = %218
  %223 = load i32, ptr %6, align 4, !tbaa !5
  %224 = load i32, ptr %7, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %225
  %227 = getelementptr inbounds %struct.Query, ptr %226, i32 0, i32 2
  %228 = load i32, ptr %227, align 4, !tbaa !17
  %229 = icmp eq i32 %223, %228
  br label %230

230:                                              ; preds = %222, %218
  %231 = phi i1 [ false, %218 ], [ %229, %222 ]
  br i1 %231, label %232, label %249

232:                                              ; preds = %230
  %233 = load i32, ptr %7, align 4, !tbaa !5
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %234
  %236 = getelementptr inbounds %struct.Query, ptr %235, i32 0, i32 1
  %237 = load i32, ptr %236, align 4, !tbaa !18
  %238 = call noundef i32 @_Z3quei(i32 noundef %237)
  %239 = load i32, ptr %7, align 4, !tbaa !5
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %240
  %242 = getelementptr inbounds %struct.Query, ptr %241, i32 0, i32 0
  %243 = load i32, ptr %242, align 4, !tbaa !13
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %244
  store i32 %238, ptr %245, align 4, !tbaa !5
  br label %246

246:                                              ; preds = %232
  %247 = load i32, ptr %7, align 4, !tbaa !5
  %248 = add nsw i32 %247, 1
  store i32 %248, ptr %7, align 4, !tbaa !5
  br label %218, !llvm.loop !19

249:                                              ; preds = %230
  br label %250

250:                                              ; preds = %249
  %251 = load i32, ptr %6, align 4, !tbaa !5
  %252 = add nsw i32 %251, 1
  store i32 %252, ptr %6, align 4, !tbaa !5
  br label %89, !llvm.loop !20

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

254:                                              ; preds = %265, %253
  %255 = load i32, ptr %10, align 4, !tbaa !5
  %256 = load i32, ptr @q, align 4, !tbaa !5
  %257 = icmp sle i32 %255, %256
  br i1 %257, label %259, label %258

258:                                              ; preds = %254
  store i32 23, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %268

259:                                              ; preds = %254
  %260 = load i32, ptr %10, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %261
  %263 = load i32, ptr %262, align 4, !tbaa !5
  %264 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %263)
  br label %265

265:                                              ; preds = %259
  %266 = load i32, ptr %10, align 4, !tbaa !5
  %267 = add nsw i32 %266, 1
  store i32 %267, ptr %10, align 4, !tbaa !5
  br label %254, !llvm.loop !21

268:                                              ; preds = %258
  ret i32 0
}

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

; 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 = { 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 = !{!14, !6, i64 0}
!14 = !{!"_ZTS5Query", !6, i64 0, !6, i64 4, !6, i64 8}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = !{!14, !6, i64 8}
!18 = !{!14, !6, i64 4}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}


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

%struct.Query = type { i32, i32, i32 }

@n = external dso_local global i32, align 4
@q = 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
@b = external dso_local global [100001 x i32], align 16
@c = external dso_local global [11 x i32], align 16
@p = external dso_local local_unnamed_addr global [100001 x i32], align 16
@ans = external dso_local local_unnamed_addr global [100001 x i32], align 16
@query = external dso_local global [100001 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 [4 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 @_Z3quei(i32 noundef) local_unnamed_addr #0

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

.preheader74:                                     ; preds = %.lr.ph
  %3 = icmp slt i32 %6, 1
  br i1 %3, label %.preheader73, label %.lr.ph79

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

.preheader73:                                     ; preds = %.lr.ph79, %0, %.preheader74
  %8 = load i32, ptr @m, align 4, !tbaa !5
  %.not6380 = icmp slt i32 %8, 1
  br i1 %.not6380, label %.preheader72, label %.lr.ph82

.lr.ph79:                                         ; preds = %.preheader74, %.lr.ph79
  %indvars.iv104 = phi i64 [ %indvars.iv.next105, %.lr.ph79 ], [ 1, %.preheader74 ]
  %9 = getelementptr inbounds i32, ptr @b, i64 %indvars.iv104
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %9)
  %11 = load i32, ptr %9, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %12
  %14 = trunc nuw nsw i64 %indvars.iv104 to i32
  store i32 %14, ptr %13, align 4, !tbaa !5
  %indvars.iv.next105 = add nuw nsw i64 %indvars.iv104, 1
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %.not62.not = icmp slt i64 %indvars.iv104, %16
  br i1 %.not62.not, label %.lr.ph79, label %.preheader73, !llvm.loop !11

.preheader72:                                     ; preds = %.lr.ph82, %.preheader73
  %17 = load i32, ptr @q, align 4, !tbaa !5
  %.not6483 = icmp slt i32 %17, 1
  br i1 %.not6483, label %.preheader72.._crit_edge_crit_edge, label %.lr.ph85

.preheader72.._crit_edge_crit_edge:               ; preds = %.preheader72
  %.pre129 = sext i32 %17 to i64
  br label %._crit_edge

.lr.ph82:                                         ; preds = %.preheader73, %.lr.ph82
  %indvars.iv107 = phi i64 [ %indvars.iv.next108, %.lr.ph82 ], [ 1, %.preheader73 ]
  %18 = getelementptr inbounds i32, ptr @c, i64 %indvars.iv107
  %19 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %18)
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %20 = load i32, ptr @m, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %.not63.not = icmp slt i64 %indvars.iv107, %21
  br i1 %.not63.not, label %.lr.ph82, label %.preheader72, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph85, %.preheader72.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre129, %.preheader72.._crit_edge_crit_edge ], [ %31, %.lr.ph85 ]
  %22 = getelementptr inbounds %struct.Query, ptr @query, i64 %.pre-phi
  %23 = getelementptr inbounds i8, ptr %22, i64 12
  tail call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef nonnull getelementptr inbounds (i8, ptr @query, i64 12), ptr noundef nonnull %23)
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %.not6595 = icmp slt i32 %24, 1
  br i1 %.not6595, label %._crit_edge..preheader_crit_edge, label %.preheader71

._crit_edge..preheader_crit_edge:                 ; preds = %._crit_edge
  %.pre128 = load i32, ptr @q, align 4, !tbaa !5
  br label %.preheader

.lr.ph85:                                         ; preds = %.preheader72, %.lr.ph85
  %indvars.iv110 = phi i64 [ %indvars.iv.next111, %.lr.ph85 ], [ 1, %.preheader72 ]
  %25 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %indvars.iv110
  %26 = trunc nuw nsw i64 %indvars.iv110 to i32
  store i32 %26, ptr %25, align 4, !tbaa !13
  %27 = getelementptr inbounds i8, ptr %25, i64 4
  %28 = getelementptr inbounds i8, ptr %25, i64 8
  %29 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %27, ptr noundef nonnull %28)
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %30 = load i32, ptr @q, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %.not64.not = icmp slt i64 %indvars.iv110, %31
  br i1 %.not64.not, label %.lr.ph85, label %._crit_edge, !llvm.loop !15

.preheader71:                                     ; preds = %._crit_edge, %.critedge
  %indvars.iv119 = phi i64 [ %indvars.iv.next120, %.critedge ], [ 1, %._crit_edge ]
  %.05197 = phi i32 [ %.1.lcssa, %.critedge ], [ 1, %._crit_edge ]
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %.not6786 = icmp slt i32 %32, 1
  br i1 %.not6786, label %.preheader70, label %.lr.ph88

.lr.ph88:                                         ; preds = %.preheader71
  %33 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %indvars.iv119
  %34 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv119
  br label %43

.preheader:                                       ; preds = %.critedge, %._crit_edge..preheader_crit_edge
  %35 = phi i32 [ %.pre128, %._crit_edge..preheader_crit_edge ], [ %94, %.critedge ]
  %.not6698 = icmp slt i32 %35, 1
  br i1 %.not6698, label %._crit_edge101, label %.lr.ph100

.preheader70:                                     ; preds = %76, %.preheader71
  %36 = load i32, ptr @q, align 4, !tbaa !5
  %.not6889 = icmp sgt i32 %.05197, %36
  br i1 %.not6889, label %.critedge, label %.lr.ph91.preheader

.lr.ph91.preheader:                               ; preds = %.preheader70
  %37 = sext i32 %.05197 to i64
  %38 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %37
  %39 = getelementptr inbounds i8, ptr %38, i64 8
  %40 = load i32, ptr %39, align 4, !tbaa !16
  %41 = zext i32 %40 to i64
  %42 = icmp eq i64 %indvars.iv119, %41
  br i1 %42, label %.lr.ph136, label %.critedge.loopexit

43:                                               ; preds = %.lr.ph88, %76
  %indvars.iv113 = phi i64 [ 1, %.lr.ph88 ], [ %indvars.iv.next114, %76 ]
  %44 = load i32, ptr %33, align 4, !tbaa !5
  %45 = getelementptr inbounds [11 x i32], ptr @c, i64 0, i64 %indvars.iv113
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = sub nsw i32 %44, %46
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %49, label %60

49:                                               ; preds = %43
  %50 = zext nneg i32 %47 to i64
  %51 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = icmp sgt i64 %indvars.iv119, %53
  br i1 %54, label %55, label %60

55:                                               ; preds = %49
  %56 = load i32, ptr %34, align 4, !tbaa !5
  %57 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %53
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = add nsw i32 %58, %56
  tail call void @_Z3updii(i32 noundef %47, i32 noundef %59)
  %.pre = load i32, ptr %33, align 4, !tbaa !5
  %.pre127 = load i32, ptr %45, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %55, %49, %43
  %61 = phi i32 [ %.pre127, %55 ], [ %46, %49 ], [ %46, %43 ]
  %62 = phi i32 [ %.pre, %55 ], [ %44, %49 ], [ %44, %43 ]
  %63 = add nsw i32 %61, %62
  %64 = load i32, ptr @n, align 4, !tbaa !5
  %.not69 = icmp sgt i32 %63, %64
  br i1 %.not69, label %76, label %65

65:                                               ; preds = %60
  %66 = sext i32 %63 to i64
  %67 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = icmp sgt i64 %indvars.iv119, %69
  br i1 %70, label %71, label %76

71:                                               ; preds = %65
  %72 = load i32, ptr %34, align 4, !tbaa !5
  %73 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %69
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add nsw i32 %74, %72
  tail call void @_Z3updii(i32 noundef %63, i32 noundef %75)
  br label %76

76:                                               ; preds = %60, %65, %71
  %indvars.iv.next114 = add nuw nsw i64 %indvars.iv113, 1
  %77 = load i32, ptr @m, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %.not67.not = icmp slt i64 %indvars.iv113, %78
  br i1 %.not67.not, label %43, label %.preheader70, !llvm.loop !17

.lr.ph91:                                         ; preds = %.lr.ph136
  %79 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %indvars.iv.next117
  %80 = getelementptr inbounds i8, ptr %79, i64 8
  %81 = load i32, ptr %80, align 4, !tbaa !16
  %82 = zext i32 %81 to i64
  %83 = icmp eq i64 %indvars.iv119, %82
  br i1 %83, label %.lr.ph136, label %.critedge.loopexit, !llvm.loop !18

.lr.ph136:                                        ; preds = %.lr.ph91.preheader, %.lr.ph91
  %84 = phi ptr [ %79, %.lr.ph91 ], [ %38, %.lr.ph91.preheader ]
  %indvars.iv116135 = phi i64 [ %indvars.iv.next117, %.lr.ph91 ], [ %37, %.lr.ph91.preheader ]
  %85 = getelementptr inbounds i8, ptr %84, i64 4
  %86 = load i32, ptr %85, align 4, !tbaa !19
  %87 = tail call noundef i32 @_Z3quei(i32 noundef %86)
  %88 = load i32, ptr %84, align 4, !tbaa !13
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %89
  store i32 %87, ptr %90, align 4, !tbaa !5
  %indvars.iv.next117 = add nsw i64 %indvars.iv116135, 1
  %91 = load i32, ptr @q, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %.not68.not = icmp slt i64 %indvars.iv116135, %92
  br i1 %.not68.not, label %.lr.ph91, label %.critedge.loopexit, !llvm.loop !18

.critedge.loopexit:                               ; preds = %.lr.ph136, %.lr.ph91, %.lr.ph91.preheader
  %93 = phi i32 [ %36, %.lr.ph91.preheader ], [ %91, %.lr.ph91 ], [ %91, %.lr.ph136 ]
  %.1.lcssa.ph.in = phi i64 [ %37, %.lr.ph91.preheader ], [ %indvars.iv.next117, %.lr.ph91 ], [ %indvars.iv.next117, %.lr.ph136 ]
  %.1.lcssa.ph = trunc i64 %.1.lcssa.ph.in to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.preheader70
  %94 = phi i32 [ %36, %.preheader70 ], [ %93, %.critedge.loopexit ]
  %.1.lcssa = phi i32 [ %.05197, %.preheader70 ], [ %.1.lcssa.ph, %.critedge.loopexit ]
  %indvars.iv.next120 = add nuw nsw i64 %indvars.iv119, 1
  %95 = load i32, ptr @n, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %.not65.not = icmp slt i64 %indvars.iv119, %96
  br i1 %.not65.not, label %.preheader71, label %.preheader, !llvm.loop !20

._crit_edge101:                                   ; preds = %.lr.ph100, %.preheader
  ret i32 0

.lr.ph100:                                        ; preds = %.preheader, %.lr.ph100
  %indvars.iv123 = phi i64 [ %indvars.iv.next124, %.lr.ph100 ], [ 1, %.preheader ]
  %97 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %indvars.iv123
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %98)
  %indvars.iv.next124 = add nuw nsw i64 %indvars.iv123, 1
  %100 = load i32, ptr @q, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %.not66.not = icmp slt i64 %indvars.iv123, %101
  br i1 %.not66.not, label %.lr.ph100, label %._crit_edge101, !llvm.loop !21
}

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

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

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

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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" }

!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 = !{!14, !6, i64 0}
!14 = !{!"_ZTS5Query", !6, i64 0, !6, i64 4, !6, i64 8}
!15 = distinct !{!15, !10}
!16 = !{!14, !6, i64 8}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = !{!14, !6, i64 4}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}


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