; LLVM IR from lzyrapx/Competitive-Programming :: ACdream (1055（离散化+树状数组）)

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

@d = external dso_local global [123456 x %struct.data], align 16
@tree = external dso_local global [200010 x [2 x i32]], align 16
@has = external dso_local global [200010 x i32], align 16
@all = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 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 @_Z6updateiii(i32 noundef, i32 noundef, 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 nounwind uwtable
declare dso_local noundef i32 @_Z5solveii(i32 noundef, i32 noundef) #0

; 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
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  br label %12

12:                                               ; preds = %234, %0
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  %14 = xor i32 %13, -1
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %235

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

17:                                               ; preds = %80, %16
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = icmp sle i32 %18, %19
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %17
  %23 = call i32 @getchar()
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %25
  %27 = getelementptr inbounds %struct.data, ptr %26, i32 0, i32 2
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %27)
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.data, ptr %31, i32 0, i32 2
  %33 = load i8, ptr %32, align 4, !tbaa !9
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %34, 67
  br i1 %35, label %36, label %51

36:                                               ; preds = %22
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %38
  %40 = getelementptr inbounds %struct.data, ptr %39, i32 0, i32 0
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %40)
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.data, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 4, !tbaa !11
  %47 = load i32, ptr @all, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr @all, align 4, !tbaa !5
  %49 = sext i32 %47 to i64
  %50 = getelementptr inbounds [200010 x i32], ptr @has, i64 0, i64 %49
  store i32 %46, ptr %50, align 4, !tbaa !5
  br label %79

51:                                               ; preds = %22
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.data, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %57
  %59 = getelementptr inbounds %struct.data, ptr %58, i32 0, i32 1
  %60 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %55, ptr noundef %59)
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.data, ptr %63, i32 0, i32 0
  %65 = load i32, ptr %64, align 4, !tbaa !11
  %66 = load i32, ptr @all, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr @all, align 4, !tbaa !5
  %68 = sext i32 %66 to i64
  %69 = getelementptr inbounds [200010 x i32], ptr @has, i64 0, i64 %68
  store i32 %65, ptr %69, align 4, !tbaa !5
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %71
  %73 = getelementptr inbounds %struct.data, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %73, align 4, !tbaa !12
  %75 = load i32, ptr @all, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr @all, align 4, !tbaa !5
  %77 = sext i32 %75 to i64
  %78 = getelementptr inbounds [200010 x i32], ptr @has, i64 0, i64 %77
  store i32 %74, ptr %78, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %51, %36
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %3, align 4, !tbaa !5
  br label %17, !llvm.loop !13

83:                                               ; preds = %21
  %84 = load i32, ptr @all, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr @has, i64 %85
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @has, ptr noundef %86)
  %87 = load i32, ptr @all, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds i32, ptr @has, i64 %88
  %90 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @has, ptr noundef %89)
  %91 = ptrtoint ptr %90 to i64
  %92 = sub i64 %91, ptrtoint (ptr @has to i64)
  %93 = sdiv exact i64 %92, 4
  %94 = trunc i64 %93 to i32
  store i32 %94, ptr @all, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @tree, i8 0, i64 1600080, i1 false)
  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
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %231, %83
  %96 = load i32, ptr %5, align 4, !tbaa !5
  %97 = load i32, ptr %2, align 4, !tbaa !5
  %98 = icmp sle i32 %96, %97
  br i1 %98, label %100, label %99

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

100:                                              ; preds = %95
  %101 = load i32, ptr %5, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %102
  %104 = getelementptr inbounds %struct.data, ptr %103, i32 0, i32 2
  %105 = load i8, ptr %104, align 4, !tbaa !9
  %106 = sext i8 %105 to i32
  %107 = icmp eq i32 %106, 68
  br i1 %107, label %108, label %144

108:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %109 = load i32, ptr @all, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds i32, ptr @has, i64 %110
  %112 = load i32, ptr %5, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %113
  %115 = getelementptr inbounds %struct.data, ptr %114, i32 0, i32 0
  %116 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @has, ptr noundef %111, ptr noundef nonnull align 4 dereferenceable(4) %115)
  %117 = ptrtoint ptr %116 to i64
  %118 = sub i64 %117, ptrtoint (ptr @has to i64)
  %119 = sdiv exact i64 %118, 4
  %120 = trunc i64 %119 to i32
  store i32 %120, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %121 = load i32, ptr @all, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds i32, ptr @has, i64 %122
  %124 = load i32, ptr %5, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %125
  %127 = getelementptr inbounds %struct.data, ptr %126, i32 0, i32 1
  %128 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @has, ptr noundef %123, ptr noundef nonnull align 4 dereferenceable(4) %127)
  %129 = ptrtoint ptr %128 to i64
  %130 = sub i64 %129, ptrtoint (ptr @has to i64)
  %131 = sdiv exact i64 %130, 4
  %132 = trunc i64 %131 to i32
  store i32 %132, ptr %7, align 4, !tbaa !5
  %133 = load i32, ptr %6, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  call void @_Z6updateiii(i32 noundef %134, i32 noundef 1, i32 noundef 0)
  %135 = load i32, ptr %7, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  call void @_Z6updateiii(i32 noundef %136, i32 noundef 1, i32 noundef 1)
  %137 = load i32, ptr %5, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %138
  %140 = load i32, ptr %4, align 4, !tbaa !5
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %4, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %142
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %143, ptr align 4 %139, i64 12, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %230

144:                                              ; preds = %100
  %145 = load i32, ptr %5, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %146
  %148 = getelementptr inbounds %struct.data, ptr %147, i32 0, i32 2
  %149 = load i8, ptr %148, align 4, !tbaa !9
  %150 = sext i8 %149 to i32
  %151 = icmp eq i32 %150, 81
  br i1 %151, label %152, label %183

152:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %153 = load i32, ptr @all, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds i32, ptr @has, i64 %154
  %156 = load i32, ptr %5, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %157
  %159 = getelementptr inbounds %struct.data, ptr %158, i32 0, i32 0
  %160 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @has, ptr noundef %155, ptr noundef nonnull align 4 dereferenceable(4) %159)
  %161 = ptrtoint ptr %160 to i64
  %162 = sub i64 %161, ptrtoint (ptr @has to i64)
  %163 = sdiv exact i64 %162, 4
  %164 = trunc i64 %163 to i32
  store i32 %164, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %165 = load i32, ptr @all, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds i32, ptr @has, i64 %166
  %168 = load i32, ptr %5, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %169
  %171 = getelementptr inbounds %struct.data, ptr %170, i32 0, i32 1
  %172 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @has, ptr noundef %167, ptr noundef nonnull align 4 dereferenceable(4) %171)
  %173 = ptrtoint ptr %172 to i64
  %174 = sub i64 %173, ptrtoint (ptr @has to i64)
  %175 = sdiv exact i64 %174, 4
  %176 = trunc i64 %175 to i32
  store i32 %176, ptr %9, align 4, !tbaa !5
  %177 = load i32, ptr %8, align 4, !tbaa !5
  %178 = add nsw i32 %177, 1
  %179 = load i32, ptr %9, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  %181 = call noundef i32 @_Z5solveii(i32 noundef %178, i32 noundef %180)
  %182 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %181)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %229

183:                                              ; preds = %144
  %184 = load i32, ptr %5, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %185
  %187 = getelementptr inbounds %struct.data, ptr %186, i32 0, i32 2
  %188 = load i8, ptr %187, align 4, !tbaa !9
  %189 = sext i8 %188 to i32
  %190 = icmp eq i32 %189, 67
  br i1 %190, label %191, label %228

191:                                              ; preds = %183
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %192 = load i32, ptr @all, align 4, !tbaa !5
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds i32, ptr @has, i64 %193
  %195 = load i32, ptr %5, align 4, !tbaa !5
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %196
  %198 = getelementptr inbounds %struct.data, ptr %197, i32 0, i32 0
  %199 = load i32, ptr %198, align 4, !tbaa !11
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %200
  %202 = getelementptr inbounds %struct.data, ptr %201, i32 0, i32 0
  %203 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @has, ptr noundef %194, ptr noundef nonnull align 4 dereferenceable(4) %202)
  %204 = ptrtoint ptr %203 to i64
  %205 = sub i64 %204, ptrtoint (ptr @has to i64)
  %206 = sdiv exact i64 %205, 4
  %207 = trunc i64 %206 to i32
  store i32 %207, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %208 = load i32, ptr @all, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds i32, ptr @has, i64 %209
  %211 = load i32, ptr %5, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %212
  %214 = getelementptr inbounds %struct.data, ptr %213, i32 0, i32 0
  %215 = load i32, ptr %214, align 4, !tbaa !11
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %216
  %218 = getelementptr inbounds %struct.data, ptr %217, i32 0, i32 1
  %219 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @has, ptr noundef %210, ptr noundef nonnull align 4 dereferenceable(4) %218)
  %220 = ptrtoint ptr %219 to i64
  %221 = sub i64 %220, ptrtoint (ptr @has to i64)
  %222 = sdiv exact i64 %221, 4
  %223 = trunc i64 %222 to i32
  store i32 %223, ptr %11, align 4, !tbaa !5
  %224 = load i32, ptr %10, align 4, !tbaa !5
  %225 = add nsw i32 %224, 1
  call void @_Z6updateiii(i32 noundef %225, i32 noundef -1, i32 noundef 0)
  %226 = load i32, ptr %11, align 4, !tbaa !5
  %227 = add nsw i32 %226, 1
  call void @_Z6updateiii(i32 noundef %227, i32 noundef -1, i32 noundef 1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %228

228:                                              ; preds = %191, %183
  br label %229

229:                                              ; preds = %228, %152
  br label %230

230:                                              ; preds = %229, %108
  br label %231

231:                                              ; preds = %230
  %232 = load i32, ptr %5, align 4, !tbaa !5
  %233 = add nsw i32 %232, 1
  store i32 %233, ptr %5, align 4, !tbaa !5
  br label %95, !llvm.loop !17

234:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %12, !llvm.loop !18

235:                                              ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @getchar() #4

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

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

; Function Attrs: 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 noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #4

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

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

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !7, i64 8}
!10 = !{!"_ZTS4data", !6, i64 0, !6, i64 4, !7, i64 8}
!11 = !{!10, !6, i64 0}
!12 = !{!10, !6, i64 4}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 1, !16}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


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

@d = external dso_local global [123456 x %struct.data], align 16
@tree = external dso_local local_unnamed_addr global [200010 x [2 x i32]], align 16
@has = external dso_local global [200010 x i32], align 16
@all = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 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 @_Z6updateiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %.not41 = icmp eq i32 %2, -1
  br i1 %.not41, label %._crit_edge44, label %.lr.ph43

.loopexit:                                        ; preds = %114, %._crit_edge
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %.not = icmp eq i32 %3, -1
  br i1 %.not, label %._crit_edge44, label %.lr.ph43, !llvm.loop !5

.lr.ph43:                                         ; preds = %0, %.loopexit
  store i32 0, ptr @all, align 4, !tbaa !7
  %4 = load i32, ptr %1, align 4, !tbaa !7
  %.not3234 = icmp slt i32 %4, 1
  br i1 %.not3234, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %36, %.lr.ph43
  %5 = phi i32 [ 0, %.lr.ph43 ], [ %.sink, %36 ]
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds i32, ptr @has, i64 %6
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @has, ptr noundef nonnull %7)
  %8 = load i32, ptr @all, align 4, !tbaa !7
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i32, ptr @has, i64 %9
  %11 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @has, ptr noundef nonnull %10)
  %12 = ptrtoint ptr %11 to i64
  %13 = sub i64 %12, ptrtoint (ptr @has to i64)
  %14 = lshr exact i64 %13, 2
  %15 = trunc i64 %14 to i32
  store i32 %15, ptr @all, align 4, !tbaa !7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1600080) @tree, i8 0, i64 1600080, i1 false)
  %16 = load i32, ptr %1, align 4, !tbaa !7
  %.not3336 = icmp slt i32 %16, 1
  br i1 %.not3336, label %.loopexit, label %.lr.ph40

.lr.ph:                                           ; preds = %.lr.ph43, %36
  %indvars.iv = phi i64 [ %indvars.iv.next, %36 ], [ 1, %.lr.ph43 ]
  %17 = call i32 @getchar()
  %18 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %indvars.iv
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %19)
  %21 = load i8, ptr %19, align 4, !tbaa !11
  %22 = icmp eq i8 %21, 67
  br i1 %22, label %23, label %27

23:                                               ; preds = %.lr.ph
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %18)
  %25 = load i32, ptr @all, align 4, !tbaa !7
  %26 = add nsw i32 %25, 1
  br label %36

27:                                               ; preds = %.lr.ph
  %28 = getelementptr inbounds i8, ptr %18, i64 4
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %18, ptr noundef nonnull %28)
  %30 = load i32, ptr %18, align 4, !tbaa !13
  %31 = load i32, ptr @all, align 4, !tbaa !7
  %32 = add nsw i32 %31, 1
  %33 = sext i32 %31 to i64
  %34 = getelementptr inbounds [200010 x i32], ptr @has, i64 0, i64 %33
  store i32 %30, ptr %34, align 4, !tbaa !7
  %35 = add nsw i32 %31, 2
  br label %36

36:                                               ; preds = %23, %27
  %.sink52 = phi i32 [ %25, %23 ], [ %32, %27 ]
  %.sink49.in = phi ptr [ %18, %23 ], [ %28, %27 ]
  %.sink = phi i32 [ %26, %23 ], [ %35, %27 ]
  %.sink49 = load i32, ptr %.sink49.in, align 4, !tbaa !7
  %37 = sext i32 %.sink52 to i64
  %38 = getelementptr inbounds [200010 x i32], ptr @has, i64 0, i64 %37
  store i32 %.sink49, ptr %38, align 4, !tbaa !7
  store i32 %.sink, ptr @all, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %39 = load i32, ptr %1, align 4, !tbaa !7
  %40 = sext i32 %39 to i64
  %.not32.not = icmp slt i64 %indvars.iv, %40
  br i1 %.not32.not, label %.lr.ph, label %._crit_edge, !llvm.loop !14

.lr.ph40:                                         ; preds = %._crit_edge, %114
  %indvars.iv46 = phi i64 [ %indvars.iv.next47, %114 ], [ 1, %._crit_edge ]
  %.02938 = phi i32 [ %.1, %114 ], [ 0, %._crit_edge ]
  %41 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %indvars.iv46
  %42 = getelementptr inbounds i8, ptr %41, i64 8
  %43 = load i8, ptr %42, align 4, !tbaa !11
  switch i8 %43, label %114 [
    i8 68, label %44
    i8 81, label %67
    i8 67, label %89
  ]

44:                                               ; preds = %.lr.ph40
  %45 = load i32, ptr @all, align 4, !tbaa !7
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i32, ptr @has, i64 %46
  %48 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @has, ptr noundef nonnull %47, ptr noundef nonnull align 4 dereferenceable(4) %41)
  %49 = ptrtoint ptr %48 to i64
  %50 = sub i64 %49, ptrtoint (ptr @has to i64)
  %51 = lshr exact i64 %50, 2
  %52 = trunc i64 %51 to i32
  %53 = load i32, ptr @all, align 4, !tbaa !7
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr @has, i64 %54
  %56 = getelementptr inbounds i8, ptr %41, i64 4
  %57 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @has, ptr noundef nonnull %55, ptr noundef nonnull align 4 dereferenceable(4) %56)
  %58 = ptrtoint ptr %57 to i64
  %59 = sub i64 %58, ptrtoint (ptr @has to i64)
  %60 = lshr exact i64 %59, 2
  %61 = trunc i64 %60 to i32
  %62 = add nsw i32 %52, 1
  call void @_Z6updateiii(i32 noundef %62, i32 noundef 1, i32 noundef 0)
  %63 = add nsw i32 %61, 1
  call void @_Z6updateiii(i32 noundef %63, i32 noundef 1, i32 noundef 1)
  %64 = add nsw i32 %.02938, 1
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %65
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %66, ptr noundef nonnull align 4 dereferenceable(12) %41, i64 12, i1 false), !tbaa.struct !15
  br label %114

67:                                               ; preds = %.lr.ph40
  %68 = load i32, ptr @all, align 4, !tbaa !7
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i32, ptr @has, i64 %69
  %71 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @has, ptr noundef nonnull %70, ptr noundef nonnull align 4 dereferenceable(4) %41)
  %72 = ptrtoint ptr %71 to i64
  %73 = sub i64 %72, ptrtoint (ptr @has to i64)
  %74 = lshr exact i64 %73, 2
  %75 = trunc i64 %74 to i32
  %76 = load i32, ptr @all, align 4, !tbaa !7
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i32, ptr @has, i64 %77
  %79 = getelementptr inbounds i8, ptr %41, i64 4
  %80 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @has, ptr noundef nonnull %78, ptr noundef nonnull align 4 dereferenceable(4) %79)
  %81 = ptrtoint ptr %80 to i64
  %82 = sub i64 %81, ptrtoint (ptr @has to i64)
  %83 = lshr exact i64 %82, 2
  %84 = trunc i64 %83 to i32
  %85 = add nsw i32 %75, 1
  %86 = add nsw i32 %84, 1
  %87 = call noundef i32 @_Z5solveii(i32 noundef %85, i32 noundef %86)
  %88 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %87)
  br label %114

89:                                               ; preds = %.lr.ph40
  %90 = load i32, ptr @all, align 4, !tbaa !7
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i32, ptr @has, i64 %91
  %93 = load i32, ptr %41, align 4, !tbaa !13
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %94
  %96 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @has, ptr noundef nonnull %92, ptr noundef nonnull align 4 dereferenceable(4) %95)
  %97 = ptrtoint ptr %96 to i64
  %98 = sub i64 %97, ptrtoint (ptr @has to i64)
  %99 = lshr exact i64 %98, 2
  %100 = trunc i64 %99 to i32
  %101 = load i32, ptr @all, align 4, !tbaa !7
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i32, ptr @has, i64 %102
  %104 = load i32, ptr %41, align 4, !tbaa !13
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [123456 x %struct.data], ptr @d, i64 0, i64 %105, i32 1
  %107 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @has, ptr noundef nonnull %103, ptr noundef nonnull align 4 dereferenceable(4) %106)
  %108 = ptrtoint ptr %107 to i64
  %109 = sub i64 %108, ptrtoint (ptr @has to i64)
  %110 = lshr exact i64 %109, 2
  %111 = trunc i64 %110 to i32
  %112 = add nsw i32 %100, 1
  call void @_Z6updateiii(i32 noundef %112, i32 noundef -1, i32 noundef 0)
  %113 = add nsw i32 %111, 1
  call void @_Z6updateiii(i32 noundef %113, i32 noundef -1, i32 noundef 1)
  br label %114

114:                                              ; preds = %.lr.ph40, %44, %89, %67
  %.1 = phi i32 [ %64, %44 ], [ %.02938, %67 ], [ %.02938, %89 ], [ %.02938, %.lr.ph40 ]
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %115 = load i32, ptr %1, align 4, !tbaa !7
  %116 = sext i32 %115 to i64
  %.not33.not = icmp slt i64 %indvars.iv46, %116
  br i1 %.not33.not, label %.lr.ph40, label %.loopexit, !llvm.loop !17

._crit_edge44:                                    ; preds = %.loopexit, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @getchar() local_unnamed_addr #4

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

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

; Function Attrs: mustprogress 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 noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

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

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

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

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

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


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