; LLVM IR from tangjz/acm-icpc :: lydsy (3289)

; 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
@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
@sqn = external dso_local global i32, align 4
@L = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@tmp = external dso_local global i32, align 4
@ans = external dso_local global [50001 x i32], align 16
@Q = external dso_local global [50001 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 [4 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sumi(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
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = sitofp i32 %8 to double
  %10 = fadd double %9, 1.000000e-01
  %11 = call double @sqrt(double noundef %10) #6
  %12 = fptosi double %11 to i32
  store i32 %12, ptr @sqn, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %13

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

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %34

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

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

34:                                               ; preds = %17
  %35 = load i32, ptr @tot, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr @que, i64 %36
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %37)
  %38 = load i32, ptr @tot, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr @que, i64 %39
  %41 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @que, ptr noundef %40)
  %42 = ptrtoint ptr %41 to i64
  %43 = sub i64 %42, ptrtoint (ptr @que to i64)
  %44 = sdiv exact i64 %43, 4
  %45 = trunc i64 %44 to i32
  store i32 %45, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %67, %34
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = load i32, ptr @n, align 4, !tbaa !5
  %49 = icmp sle i32 %47, %48
  br i1 %49, label %51, label %50

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

51:                                               ; preds = %46
  %52 = load i32, ptr @tot, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr @que, i64 %53
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %56
  %58 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %54, ptr noundef nonnull align 4 dereferenceable(4) %57)
  %59 = ptrtoint ptr %58 to i64
  %60 = sub i64 %59, ptrtoint (ptr @que to i64)
  %61 = sdiv exact i64 %60, 4
  %62 = add nsw i64 %61, 1
  %63 = trunc i64 %62 to i32
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %65
  store i32 %63, ptr %66, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %51
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %3, align 4, !tbaa !5
  br label %46, !llvm.loop !11

70:                                               ; preds = %50
  %71 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %92, %70
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = load i32, ptr @q, align 4, !tbaa !5
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %95

77:                                               ; preds = %72
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %80
  %82 = getelementptr inbounds %struct.Query, ptr %81, i32 0, i32 0
  store i32 %78, ptr %82, align 4, !tbaa !12
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %84
  %86 = getelementptr inbounds %struct.Query, ptr %85, i32 0, i32 1
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %88
  %90 = getelementptr inbounds %struct.Query, ptr %89, i32 0, i32 2
  %91 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %86, ptr noundef %90)
  br label %92

92:                                               ; preds = %77
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %4, align 4, !tbaa !5
  br label %72, !llvm.loop !14

95:                                               ; preds = %76
  %96 = load i32, ptr @q, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds %struct.Query, ptr @Q, i64 %97
  call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef @Q, ptr noundef %98)
  store i32 1, ptr @L, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %225, %95
  %100 = load i32, ptr %5, align 4, !tbaa !5
  %101 = load i32, ptr @q, align 4, !tbaa !5
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %104, label %103

103:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %228

104:                                              ; preds = %99
  br label %105

105:                                              ; preds = %126, %104
  %106 = load i32, ptr @L, align 4, !tbaa !5
  %107 = load i32, ptr %5, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %108
  %110 = getelementptr inbounds %struct.Query, ptr %109, i32 0, i32 1
  %111 = load i32, ptr %110, align 4, !tbaa !15
  %112 = icmp slt i32 %106, %111
  br i1 %112, label %113, label %129

113:                                              ; preds = %105
  %114 = load i32, ptr @L, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = sub nsw i32 %117, 1
  %119 = call noundef i32 @_Z3sumi(i32 noundef %118)
  %120 = load i32, ptr @tmp, align 4, !tbaa !5
  %121 = sub nsw i32 %120, %119
  store i32 %121, ptr @tmp, align 4, !tbaa !5
  %122 = load i32, ptr @L, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  call void @_Z3addii(i32 noundef %125, i32 noundef -1)
  br label %126

126:                                              ; preds = %113
  %127 = load i32, ptr @L, align 4, !tbaa !5
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr @L, align 4, !tbaa !5
  br label %105, !llvm.loop !16

129:                                              ; preds = %105
  br label %130

130:                                              ; preds = %153, %129
  %131 = load i32, ptr @L, align 4, !tbaa !5
  %132 = load i32, ptr %5, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %133
  %135 = getelementptr inbounds %struct.Query, ptr %134, i32 0, i32 1
  %136 = load i32, ptr %135, align 4, !tbaa !15
  %137 = icmp sgt i32 %131, %136
  br i1 %137, label %138, label %156

138:                                              ; preds = %130
  %139 = load i32, ptr @L, align 4, !tbaa !5
  %140 = sub nsw i32 %139, 1
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = sub nsw i32 %143, 1
  %145 = call noundef i32 @_Z3sumi(i32 noundef %144)
  %146 = load i32, ptr @tmp, align 4, !tbaa !5
  %147 = add nsw i32 %146, %145
  store i32 %147, ptr @tmp, align 4, !tbaa !5
  %148 = load i32, ptr @L, align 4, !tbaa !5
  %149 = sub nsw i32 %148, 1
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %150
  %152 = load i32, ptr %151, align 4, !tbaa !5
  call void @_Z3addii(i32 noundef %152, i32 noundef 1)
  br label %153

153:                                              ; preds = %138
  %154 = load i32, ptr @L, align 4, !tbaa !5
  %155 = add nsw i32 %154, -1
  store i32 %155, ptr @L, align 4, !tbaa !5
  br label %130, !llvm.loop !17

156:                                              ; preds = %130
  br label %157

157:                                              ; preds = %184, %156
  %158 = load i32, ptr @R, align 4, !tbaa !5
  %159 = load i32, ptr %5, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %160
  %162 = getelementptr inbounds %struct.Query, ptr %161, i32 0, i32 2
  %163 = load i32, ptr %162, align 4, !tbaa !18
  %164 = icmp slt i32 %158, %163
  br i1 %164, label %165, label %187

165:                                              ; preds = %157
  %166 = load i32, ptr @R, align 4, !tbaa !5
  %167 = load i32, ptr @L, align 4, !tbaa !5
  %168 = sub nsw i32 %166, %167
  %169 = add nsw i32 %168, 1
  %170 = load i32, ptr @R, align 4, !tbaa !5
  %171 = add nsw i32 %170, 1
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %172
  %174 = load i32, ptr %173, align 4, !tbaa !5
  %175 = call noundef i32 @_Z3sumi(i32 noundef %174)
  %176 = sub nsw i32 %169, %175
  %177 = load i32, ptr @tmp, align 4, !tbaa !5
  %178 = add nsw i32 %177, %176
  store i32 %178, ptr @tmp, align 4, !tbaa !5
  %179 = load i32, ptr @R, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %181
  %183 = load i32, ptr %182, align 4, !tbaa !5
  call void @_Z3addii(i32 noundef %183, i32 noundef 1)
  br label %184

184:                                              ; preds = %165
  %185 = load i32, ptr @R, align 4, !tbaa !5
  %186 = add nsw i32 %185, 1
  store i32 %186, ptr @R, align 4, !tbaa !5
  br label %157, !llvm.loop !19

187:                                              ; preds = %157
  br label %188

188:                                              ; preds = %213, %187
  %189 = load i32, ptr @R, align 4, !tbaa !5
  %190 = load i32, ptr %5, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %191
  %193 = getelementptr inbounds %struct.Query, ptr %192, i32 0, i32 2
  %194 = load i32, ptr %193, align 4, !tbaa !18
  %195 = icmp sgt i32 %189, %194
  br i1 %195, label %196, label %216

196:                                              ; preds = %188
  %197 = load i32, ptr @R, align 4, !tbaa !5
  %198 = load i32, ptr @L, align 4, !tbaa !5
  %199 = sub nsw i32 %197, %198
  %200 = add nsw i32 %199, 1
  %201 = load i32, ptr @R, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %202
  %204 = load i32, ptr %203, align 4, !tbaa !5
  %205 = call noundef i32 @_Z3sumi(i32 noundef %204)
  %206 = sub nsw i32 %200, %205
  %207 = load i32, ptr @tmp, align 4, !tbaa !5
  %208 = sub nsw i32 %207, %206
  store i32 %208, ptr @tmp, align 4, !tbaa !5
  %209 = load i32, ptr @R, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %210
  %212 = load i32, ptr %211, align 4, !tbaa !5
  call void @_Z3addii(i32 noundef %212, i32 noundef -1)
  br label %213

213:                                              ; preds = %196
  %214 = load i32, ptr @R, align 4, !tbaa !5
  %215 = add nsw i32 %214, -1
  store i32 %215, ptr @R, align 4, !tbaa !5
  br label %188, !llvm.loop !20

216:                                              ; preds = %188
  %217 = load i32, ptr @tmp, align 4, !tbaa !5
  %218 = load i32, ptr %5, align 4, !tbaa !5
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %219
  %221 = getelementptr inbounds %struct.Query, ptr %220, i32 0, i32 0
  %222 = load i32, ptr %221, align 4, !tbaa !12
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %223
  store i32 %217, ptr %224, align 4, !tbaa !5
  br label %225

225:                                              ; preds = %216
  %226 = load i32, ptr %5, align 4, !tbaa !5
  %227 = add nsw i32 %226, 1
  store i32 %227, ptr %5, align 4, !tbaa !5
  br label %99, !llvm.loop !21

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

229:                                              ; preds = %240, %228
  %230 = load i32, ptr %6, align 4, !tbaa !5
  %231 = load i32, ptr @q, align 4, !tbaa !5
  %232 = icmp slt i32 %230, %231
  br i1 %232, label %234, label %233

233:                                              ; preds = %229
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %243

234:                                              ; preds = %229
  %235 = load i32, ptr %6, align 4, !tbaa !5
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %236
  %238 = load i32, ptr %237, align 4, !tbaa !5
  %239 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %238)
  br label %240

240:                                              ; preds = %234
  %241 = load i32, ptr %6, align 4, !tbaa !5
  %242 = add nsw i32 %241, 1
  store i32 %242, ptr %6, align 4, !tbaa !5
  br label %229, !llvm.loop !22

243:                                              ; preds = %233
  ret i32 0
}

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

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

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

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

; 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)) #5

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

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 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = { 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 = distinct !{!14, !10}
!15 = !{!13, !6, i64 4}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = !{!13, !6, i64 8}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !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
@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
@sqn = external dso_local local_unnamed_addr global i32, align 4
@L = external dso_local local_unnamed_addr global i32, align 4
@R = external dso_local local_unnamed_addr global i32, align 4
@tmp = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global [50001 x i32], align 16
@Q = external dso_local global [50001 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 [4 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sumi(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)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = sitofp i32 %2 to double
  %4 = fadd double %3, 1.000000e-01
  %5 = tail call double @sqrt(double noundef %4) #5
  %6 = fptosi double %5 to i32
  store i32 %6, ptr @sqn, align 4, !tbaa !5
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not45 = icmp slt i32 %7, 1
  br i1 %.not45, 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
  %8 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %24, %.lr.ph ]
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i32, ptr @que, i64 %9
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %10)
  %11 = load i32, ptr @tot, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds i32, ptr @que, i64 %12
  %14 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %13)
  %15 = ptrtoint ptr %14 to i64
  %16 = sub i64 %15, ptrtoint (ptr @que to i64)
  %17 = lshr exact i64 %16, 2
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr @tot, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %.not3347 = icmp slt i32 %19, 1
  br i1 %.not3347, label %._crit_edge51, label %.lr.ph50

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

._crit_edge51:                                    ; preds = %.lr.ph50, %._crit_edge
  %29 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @q)
  %30 = load i32, ptr @q, align 4, !tbaa !5
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph54, label %._crit_edge51.._crit_edge55_crit_edge

._crit_edge51.._crit_edge55_crit_edge:            ; preds = %._crit_edge51
  %.pre81 = sext i32 %30 to i64
  br label %._crit_edge55

.lr.ph50:                                         ; preds = %._crit_edge, %.lr.ph50
  %indvars.iv69 = phi i64 [ %indvars.iv.next70, %.lr.ph50 ], [ 1, %._crit_edge ]
  %32 = load i32, ptr @tot, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr @que, i64 %33
  %35 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %indvars.iv69
  %36 = tail call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %34, ptr noundef nonnull align 4 dereferenceable(4) %35)
  %37 = ptrtoint ptr %36 to i64
  %38 = sub i64 %37, ptrtoint (ptr @que to i64)
  %39 = lshr exact i64 %38, 2
  %40 = trunc i64 %39 to i32
  %41 = add i32 %40, 1
  store i32 %41, ptr %35, align 4, !tbaa !5
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %.not33.not = icmp slt i64 %indvars.iv69, %43
  br i1 %.not33.not, label %.lr.ph50, label %._crit_edge51, !llvm.loop !11

._crit_edge55:                                    ; preds = %.lr.ph54, %._crit_edge51.._crit_edge55_crit_edge
  %.pre-phi = phi i64 [ %.pre81, %._crit_edge51.._crit_edge55_crit_edge ], [ %53, %.lr.ph54 ]
  %44 = getelementptr inbounds %struct.Query, ptr @Q, i64 %.pre-phi
  tail call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef nonnull @Q, ptr noundef nonnull %44)
  store i32 1, ptr @L, align 4, !tbaa !5
  %45 = load i32, ptr @q, align 4, !tbaa !5
  %46 = icmp sgt i32 %45, 0
  br i1 %46, label %.preheader41, label %._crit_edge67

.lr.ph54:                                         ; preds = %._crit_edge51, %.lr.ph54
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %.lr.ph54 ], [ 0, %._crit_edge51 ]
  %47 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %indvars.iv72
  %48 = trunc nuw nsw i64 %indvars.iv72 to i32
  store i32 %48, ptr %47, align 4, !tbaa !12
  %49 = getelementptr inbounds i8, ptr %47, i64 4
  %50 = getelementptr inbounds i8, ptr %47, i64 8
  %51 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %49, ptr noundef nonnull %50)
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %52 = load i32, ptr @q, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = icmp slt i64 %indvars.iv.next73, %53
  br i1 %54, label %.lr.ph54, label %._crit_edge55, !llvm.loop !14

.preheader41:                                     ; preds = %._crit_edge55, %._crit_edge63
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %._crit_edge63 ], [ 0, %._crit_edge55 ]
  %55 = getelementptr inbounds [50001 x %struct.Query], ptr @Q, i64 0, i64 %indvars.iv75
  %56 = getelementptr inbounds i8, ptr %55, i64 4
  %57 = load i32, ptr @L, align 4, !tbaa !5
  %58 = load i32, ptr %56, align 4, !tbaa !15
  %59 = icmp slt i32 %57, %58
  br i1 %59, label %.lr.ph57, label %.preheader40

.preheader:                                       ; preds = %._crit_edge63
  %60 = icmp sgt i32 %146, 0
  br i1 %60, label %.lr.ph66, label %._crit_edge67

.preheader40:                                     ; preds = %.lr.ph57, %.preheader41
  %61 = phi i32 [ %58, %.preheader41 ], [ %78, %.lr.ph57 ]
  %62 = phi i32 [ %57, %.preheader41 ], [ %77, %.lr.ph57 ]
  %63 = icmp sgt i32 %62, %61
  br i1 %63, label %.lr.ph60, label %.preheader39

.lr.ph57:                                         ; preds = %.preheader41, %.lr.ph57
  %64 = phi i32 [ %77, %.lr.ph57 ], [ %57, %.preheader41 ]
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = add nsw i32 %67, -1
  %69 = tail call noundef i32 @_Z3sumi(i32 noundef %68)
  %70 = load i32, ptr @tmp, align 4, !tbaa !5
  %71 = sub nsw i32 %70, %69
  store i32 %71, ptr @tmp, align 4, !tbaa !5
  %72 = load i32, ptr @L, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  tail call void @_Z3addii(i32 noundef %75, i32 noundef -1)
  %76 = load i32, ptr @L, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr @L, align 4, !tbaa !5
  %78 = load i32, ptr %56, align 4, !tbaa !15
  %79 = icmp slt i32 %77, %78
  br i1 %79, label %.lr.ph57, label %.preheader40, !llvm.loop !16

.preheader39:                                     ; preds = %.lr.ph60, %.preheader40
  %80 = getelementptr inbounds i8, ptr %55, i64 8
  %81 = load i32, ptr @R, align 4, !tbaa !5
  %82 = load i32, ptr %80, align 4, !tbaa !17
  %83 = icmp slt i32 %81, %82
  br i1 %83, label %.lr.ph61, label %.preheader38

.lr.ph60:                                         ; preds = %.preheader40, %.lr.ph60
  %84 = phi i32 [ %99, %.lr.ph60 ], [ %62, %.preheader40 ]
  %85 = add nsw i32 %84, -1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = add nsw i32 %88, -1
  %90 = tail call noundef i32 @_Z3sumi(i32 noundef %89)
  %91 = load i32, ptr @tmp, align 4, !tbaa !5
  %92 = add nsw i32 %91, %90
  store i32 %92, ptr @tmp, align 4, !tbaa !5
  %93 = load i32, ptr @L, align 4, !tbaa !5
  %94 = add nsw i32 %93, -1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  tail call void @_Z3addii(i32 noundef %97, i32 noundef 1)
  %98 = load i32, ptr @L, align 4, !tbaa !5
  %99 = add nsw i32 %98, -1
  store i32 %99, ptr @L, align 4, !tbaa !5
  %100 = load i32, ptr %56, align 4, !tbaa !15
  %101 = icmp sgt i32 %99, %100
  br i1 %101, label %.lr.ph60, label %.preheader39, !llvm.loop !18

.preheader38:                                     ; preds = %.lr.ph61, %.preheader39
  %102 = phi i32 [ %82, %.preheader39 ], [ %123, %.lr.ph61 ]
  %103 = phi i32 [ %81, %.preheader39 ], [ %122, %.lr.ph61 ]
  %104 = icmp sgt i32 %103, %102
  br i1 %104, label %.lr.ph62, label %._crit_edge63

.lr.ph61:                                         ; preds = %.preheader39, %.lr.ph61
  %105 = phi i32 [ %122, %.lr.ph61 ], [ %81, %.preheader39 ]
  %106 = load i32, ptr @L, align 4, !tbaa !5
  %107 = add nsw i32 %105, 1
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = tail call noundef i32 @_Z3sumi(i32 noundef %110)
  %112 = load i32, ptr @tmp, align 4, !tbaa !5
  %113 = add i32 %106, %111
  %114 = sub i32 %107, %113
  %115 = add nsw i32 %114, %112
  store i32 %115, ptr @tmp, align 4, !tbaa !5
  %116 = load i32, ptr @R, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  tail call void @_Z3addii(i32 noundef %120, i32 noundef 1)
  %121 = load i32, ptr @R, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr @R, align 4, !tbaa !5
  %123 = load i32, ptr %80, align 4, !tbaa !17
  %124 = icmp slt i32 %122, %123
  br i1 %124, label %.lr.ph61, label %.preheader38, !llvm.loop !19

.lr.ph62:                                         ; preds = %.preheader38, %.lr.ph62
  %125 = phi i32 [ %139, %.lr.ph62 ], [ %103, %.preheader38 ]
  %126 = load i32, ptr @L, align 4, !tbaa !5
  %127 = sext i32 %125 to i64
  %128 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = tail call noundef i32 @_Z3sumi(i32 noundef %129)
  %.neg34 = xor i32 %125, -1
  %131 = load i32, ptr @tmp, align 4, !tbaa !5
  %132 = add i32 %126, %.neg34
  %.neg = add i32 %132, %130
  %133 = add i32 %.neg, %131
  store i32 %133, ptr @tmp, align 4, !tbaa !5
  %134 = load i32, ptr @R, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  tail call void @_Z3addii(i32 noundef %137, i32 noundef -1)
  %138 = load i32, ptr @R, align 4, !tbaa !5
  %139 = add nsw i32 %138, -1
  store i32 %139, ptr @R, align 4, !tbaa !5
  %140 = load i32, ptr %80, align 4, !tbaa !17
  %141 = icmp sgt i32 %139, %140
  br i1 %141, label %.lr.ph62, label %._crit_edge63, !llvm.loop !20

._crit_edge63:                                    ; preds = %.lr.ph62, %.preheader38
  %142 = load i32, ptr @tmp, align 4, !tbaa !5
  %143 = load i32, ptr %55, align 4, !tbaa !12
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %144
  store i32 %142, ptr %145, align 4, !tbaa !5
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %146 = load i32, ptr @q, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = icmp slt i64 %indvars.iv.next76, %147
  br i1 %148, label %.preheader41, label %.preheader, !llvm.loop !21

._crit_edge67:                                    ; preds = %.lr.ph66, %._crit_edge55, %.preheader
  ret i32 0

.lr.ph66:                                         ; preds = %.preheader, %.lr.ph66
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %.lr.ph66 ], [ 0, %.preheader ]
  %149 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %indvars.iv78
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %150)
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %152 = load i32, ptr @q, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = icmp slt i64 %indvars.iv.next79, %153
  br i1 %154, label %.lr.ph66, label %._crit_edge67, !llvm.loop !22
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) 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: 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 #2

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 #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 = !{!13, !6, i64 0}
!13 = !{!"_ZTS5Query", !6, i64 0, !6, i64 4, !6, i64 8}
!14 = distinct !{!14, !10}
!15 = !{!13, !6, i64 4}
!16 = distinct !{!16, !10}
!17 = !{!13, !6, i64 8}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}


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