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

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@sz = external dso_local global i32, align 4
@val = external dso_local global [200010 x i32], align 16
@que = external dso_local global [200010 x i32], align 16
@A = external dso_local global [200010 x i32], align 16
@B = external dso_local global [200010 x i32], align 16
@K = external dso_local global [200010 x i32], align 16
@root = external dso_local global [200010 x i32], align 16
@l = external dso_local global [30 x i32], align 16
@r = external dso_local global [30 x i32], align 16
@a = external dso_local global i32, align 4
@b = 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 [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updateiiiiRiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(4), 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 uwtable
declare dso_local noundef i32 @_Z5queryiii(i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) #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 [2 x i8], align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %13

13:                                               ; preds = %303, %0
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %16, label %304

16:                                               ; preds = %13
  store i32 0, ptr @tot, align 4, !tbaa !5
  store i32 0, ptr @sz, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @K, i8 0, i64 800040, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @root, i8 0, i64 800040, i1 false)
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %34, %16
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr @n, 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 %2) #6
  br label %37

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %24
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %25)
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr @tot, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @tot, align 4, !tbaa !5
  %32 = sext i32 %30 to i64
  %33 = getelementptr inbounds [200010 x i32], ptr @que, i64 0, i64 %32
  store i32 %29, ptr %33, align 4, !tbaa !5
  br label %34

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

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

38:                                               ; preds = %70, %37
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = load i32, ptr @m, align 4, !tbaa !5
  %41 = icmp sle i32 %39, %40
  br i1 %41, label %43, label %42

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

43:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #6
  %44 = getelementptr inbounds [2 x i8], ptr %4, i64 0, i64 0
  %45 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %44)
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %47
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %48)
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [200010 x i32], ptr @B, i64 0, i64 %50
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %51)
  %52 = getelementptr inbounds [2 x i8], ptr %4, i64 0, i64 0
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 81
  br i1 %55, label %56, label %60

56:                                               ; preds = %43
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [200010 x i32], ptr @K, i64 0, i64 %58
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %59)
  br label %69

60:                                               ; preds = %43
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [200010 x i32], ptr @B, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = load i32, ptr @tot, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr @tot, align 4, !tbaa !5
  %67 = sext i32 %65 to i64
  %68 = getelementptr inbounds [200010 x i32], ptr @que, i64 0, i64 %67
  store i32 %64, ptr %68, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %60, %56
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #6
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %3, align 4, !tbaa !5
  br label %38, !llvm.loop !12

73:                                               ; preds = %42
  %74 = load i32, ptr @tot, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr @que, i64 %75
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %76)
  %77 = load i32, ptr @tot, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i32, ptr @que, i64 %78
  %80 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @que, ptr noundef %79)
  %81 = ptrtoint ptr %80 to i64
  %82 = sub i64 %81, ptrtoint (ptr @que to i64)
  %83 = sdiv exact i64 %82, 4
  %84 = trunc i64 %83 to i32
  store i32 %84, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %134, %73
  %86 = load i32, ptr %5, align 4, !tbaa !5
  %87 = load i32, ptr @n, align 4, !tbaa !5
  %88 = icmp sle i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  store i32 10, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %137

90:                                               ; preds = %85
  %91 = load i32, ptr @tot, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i32, ptr @que, i64 %92
  %94 = load i32, ptr %5, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %95
  %97 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %93, ptr noundef nonnull align 4 dereferenceable(4) %96)
  %98 = ptrtoint ptr %97 to i64
  %99 = sub i64 %98, ptrtoint (ptr @que to i64)
  %100 = sdiv exact i64 %99, 4
  %101 = add nsw i64 %100, 1
  %102 = trunc i64 %101 to i32
  %103 = load i32, ptr %5, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %104
  store i32 %102, ptr %105, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %106 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %106, ptr %7, align 4, !tbaa !5
  br label %107

107:                                              ; preds = %126, %90
  %108 = load i32, ptr %7, align 4, !tbaa !5
  %109 = load i32, ptr @n, align 4, !tbaa !5
  %110 = icmp sle i32 %108, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %107
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %133

112:                                              ; preds = %107
  %113 = load i32, ptr %7, align 4, !tbaa !5
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = load i32, ptr @tot, align 4, !tbaa !5
  %119 = load i32, ptr %7, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %120
  %122 = load i32, ptr %5, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  call void @_Z6updateiiiiRiii(i32 noundef %113, i32 noundef %117, i32 noundef 1, i32 noundef %118, ptr noundef nonnull align 4 dereferenceable(4) %121, i32 noundef %125, i32 noundef 1)
  br label %126

126:                                              ; preds = %112
  %127 = load i32, ptr %7, align 4, !tbaa !5
  %128 = load i32, ptr %7, align 4, !tbaa !5
  %129 = sub nsw i32 0, %128
  %130 = and i32 %127, %129
  %131 = load i32, ptr %7, align 4, !tbaa !5
  %132 = add nsw i32 %131, %130
  store i32 %132, ptr %7, align 4, !tbaa !5
  br label %107, !llvm.loop !13

133:                                              ; preds = %111
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %5, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %5, align 4, !tbaa !5
  br label %85, !llvm.loop !14

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

138:                                              ; preds = %300, %137
  %139 = load i32, ptr %8, align 4, !tbaa !5
  %140 = load i32, ptr @m, align 4, !tbaa !5
  %141 = icmp sle i32 %139, %140
  br i1 %141, label %143, label %142

142:                                              ; preds = %138
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %303

143:                                              ; preds = %138
  %144 = load i32, ptr %8, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [200010 x i32], ptr @K, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = icmp ne i32 %147, 0
  br i1 %148, label %149, label %212

149:                                              ; preds = %143
  store i32 0, ptr @b, align 4, !tbaa !5
  store i32 0, ptr @a, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %150 = load i32, ptr %8, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %151
  %153 = load i32, ptr %152, align 4, !tbaa !5
  %154 = sub nsw i32 %153, 1
  store i32 %154, ptr %9, align 4, !tbaa !5
  br label %155

155:                                              ; preds = %168, %149
  %156 = load i32, ptr %9, align 4, !tbaa !5
  %157 = icmp sgt i32 %156, 0
  br i1 %157, label %159, label %158

158:                                              ; preds = %155
  store i32 19, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %175

159:                                              ; preds = %155
  %160 = load i32, ptr %9, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = load i32, ptr @a, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr @a, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [30 x i32], ptr @l, i64 0, i64 %166
  store i32 %163, ptr %167, align 4, !tbaa !5
  br label %168

168:                                              ; preds = %159
  %169 = load i32, ptr %9, align 4, !tbaa !5
  %170 = load i32, ptr %9, align 4, !tbaa !5
  %171 = sub nsw i32 0, %170
  %172 = and i32 %169, %171
  %173 = load i32, ptr %9, align 4, !tbaa !5
  %174 = sub nsw i32 %173, %172
  store i32 %174, ptr %9, align 4, !tbaa !5
  br label %155, !llvm.loop !15

175:                                              ; preds = %158
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %176 = load i32, ptr %8, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [200010 x i32], ptr @B, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !5
  store i32 %179, ptr %10, align 4, !tbaa !5
  br label %180

180:                                              ; preds = %193, %175
  %181 = load i32, ptr %10, align 4, !tbaa !5
  %182 = icmp sgt i32 %181, 0
  br i1 %182, label %184, label %183

183:                                              ; preds = %180
  store i32 22, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %200

184:                                              ; preds = %180
  %185 = load i32, ptr %10, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = load i32, ptr @b, align 4, !tbaa !5
  %190 = add nsw i32 %189, 1
  store i32 %190, ptr @b, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [30 x i32], ptr @r, i64 0, i64 %191
  store i32 %188, ptr %192, align 4, !tbaa !5
  br label %193

193:                                              ; preds = %184
  %194 = load i32, ptr %10, align 4, !tbaa !5
  %195 = load i32, ptr %10, align 4, !tbaa !5
  %196 = sub nsw i32 0, %195
  %197 = and i32 %194, %196
  %198 = load i32, ptr %10, align 4, !tbaa !5
  %199 = sub nsw i32 %198, %197
  store i32 %199, ptr %10, align 4, !tbaa !5
  br label %180, !llvm.loop !16

200:                                              ; preds = %183
  %201 = load i32, ptr @tot, align 4, !tbaa !5
  %202 = load i32, ptr %8, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [200010 x i32], ptr @K, i64 0, i64 %203
  %205 = load i32, ptr %204, align 4, !tbaa !5
  %206 = call noundef i32 @_Z5queryiii(i32 noundef 1, i32 noundef %201, i32 noundef %205)
  %207 = sub nsw i32 %206, 1
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [200010 x i32], ptr @que, i64 0, i64 %208
  %210 = load i32, ptr %209, align 4, !tbaa !5
  %211 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %210)
  br label %299

212:                                              ; preds = %143
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %213 = load i32, ptr %8, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %214
  %216 = load i32, ptr %215, align 4, !tbaa !5
  store i32 %216, ptr %11, align 4, !tbaa !5
  br label %217

217:                                              ; preds = %239, %212
  %218 = load i32, ptr %11, align 4, !tbaa !5
  %219 = load i32, ptr @n, align 4, !tbaa !5
  %220 = icmp sle i32 %218, %219
  br i1 %220, label %222, label %221

221:                                              ; preds = %217
  store i32 25, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %246

222:                                              ; preds = %217
  %223 = load i32, ptr %11, align 4, !tbaa !5
  %224 = load i32, ptr %11, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %225
  %227 = load i32, ptr %226, align 4, !tbaa !5
  %228 = load i32, ptr @tot, align 4, !tbaa !5
  %229 = load i32, ptr %11, align 4, !tbaa !5
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %230
  %232 = load i32, ptr %8, align 4, !tbaa !5
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %233
  %235 = load i32, ptr %234, align 4, !tbaa !5
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %236
  %238 = load i32, ptr %237, align 4, !tbaa !5
  call void @_Z6updateiiiiRiii(i32 noundef %223, i32 noundef %227, i32 noundef 1, i32 noundef %228, ptr noundef nonnull align 4 dereferenceable(4) %231, i32 noundef %238, i32 noundef -1)
  br label %239

239:                                              ; preds = %222
  %240 = load i32, ptr %11, align 4, !tbaa !5
  %241 = load i32, ptr %11, align 4, !tbaa !5
  %242 = sub nsw i32 0, %241
  %243 = and i32 %240, %242
  %244 = load i32, ptr %11, align 4, !tbaa !5
  %245 = add nsw i32 %244, %243
  store i32 %245, ptr %11, align 4, !tbaa !5
  br label %217, !llvm.loop !17

246:                                              ; preds = %221
  %247 = load i32, ptr @tot, align 4, !tbaa !5
  %248 = sext i32 %247 to i64
  %249 = getelementptr inbounds i32, ptr @que, i64 %248
  %250 = load i32, ptr %8, align 4, !tbaa !5
  %251 = sext i32 %250 to i64
  %252 = getelementptr inbounds [200010 x i32], ptr @B, i64 0, i64 %251
  %253 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %249, ptr noundef nonnull align 4 dereferenceable(4) %252)
  %254 = ptrtoint ptr %253 to i64
  %255 = sub i64 %254, ptrtoint (ptr @que to i64)
  %256 = sdiv exact i64 %255, 4
  %257 = add nsw i64 %256, 1
  %258 = trunc i64 %257 to i32
  %259 = load i32, ptr %8, align 4, !tbaa !5
  %260 = sext i32 %259 to i64
  %261 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %260
  %262 = load i32, ptr %261, align 4, !tbaa !5
  %263 = sext i32 %262 to i64
  %264 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %263
  store i32 %258, ptr %264, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %265 = load i32, ptr %8, align 4, !tbaa !5
  %266 = sext i32 %265 to i64
  %267 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %266
  %268 = load i32, ptr %267, align 4, !tbaa !5
  store i32 %268, ptr %12, align 4, !tbaa !5
  br label %269

269:                                              ; preds = %291, %246
  %270 = load i32, ptr %12, align 4, !tbaa !5
  %271 = load i32, ptr @n, align 4, !tbaa !5
  %272 = icmp sle i32 %270, %271
  br i1 %272, label %274, label %273

273:                                              ; preds = %269
  store i32 28, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %298

274:                                              ; preds = %269
  %275 = load i32, ptr %12, align 4, !tbaa !5
  %276 = load i32, ptr %12, align 4, !tbaa !5
  %277 = sext i32 %276 to i64
  %278 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %277
  %279 = load i32, ptr %278, align 4, !tbaa !5
  %280 = load i32, ptr @tot, align 4, !tbaa !5
  %281 = load i32, ptr %12, align 4, !tbaa !5
  %282 = sext i32 %281 to i64
  %283 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %282
  %284 = load i32, ptr %8, align 4, !tbaa !5
  %285 = sext i32 %284 to i64
  %286 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %285
  %287 = load i32, ptr %286, align 4, !tbaa !5
  %288 = sext i32 %287 to i64
  %289 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %288
  %290 = load i32, ptr %289, align 4, !tbaa !5
  call void @_Z6updateiiiiRiii(i32 noundef %275, i32 noundef %279, i32 noundef 1, i32 noundef %280, ptr noundef nonnull align 4 dereferenceable(4) %283, i32 noundef %290, i32 noundef 1)
  br label %291

291:                                              ; preds = %274
  %292 = load i32, ptr %12, align 4, !tbaa !5
  %293 = load i32, ptr %12, align 4, !tbaa !5
  %294 = sub nsw i32 0, %293
  %295 = and i32 %292, %294
  %296 = load i32, ptr %12, align 4, !tbaa !5
  %297 = add nsw i32 %296, %295
  store i32 %297, ptr %12, align 4, !tbaa !5
  br label %269, !llvm.loop !18

298:                                              ; preds = %273
  br label %299

299:                                              ; preds = %298, %200
  br label %300

300:                                              ; preds = %299
  %301 = load i32, ptr %8, align 4, !tbaa !5
  %302 = add nsw i32 %301, 1
  store i32 %302, ptr %8, align 4, !tbaa !5
  br label %138, !llvm.loop !19

303:                                              ; preds = %142
  br label %13, !llvm.loop !20

304:                                              ; preds = %13
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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

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

attributes #0 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@sz = external dso_local local_unnamed_addr global i32, align 4
@val = external dso_local global [200010 x i32], align 16
@que = external dso_local global [200010 x i32], align 16
@A = external dso_local global [200010 x i32], align 16
@B = external dso_local global [200010 x i32], align 16
@K = external dso_local global [200010 x i32], align 16
@root = external dso_local global [200010 x i32], align 16
@l = external dso_local local_unnamed_addr global [30 x i32], align 16
@r = external dso_local local_unnamed_addr global [30 x i32], align 16
@a = external dso_local local_unnamed_addr global i32, align 4
@b = 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 [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updateiiiiRiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(4), 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 uwtable
declare dso_local noundef i32 @_Z5queryiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca [2 x i8], align 1
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %3 = icmp eq i32 %2, 1
  br i1 %3, label %.lr.ph114, label %._crit_edge115

.loopexit76:                                      ; preds = %.loopexit, %.preheader
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %.lr.ph114, label %._crit_edge115, !llvm.loop !5

.lr.ph114:                                        ; preds = %0, %.loopexit76
  store i32 0, ptr @tot, align 4, !tbaa !7
  store i32 0, ptr @sz, align 4, !tbaa !7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(800040) @K, i8 0, i64 800040, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(800040) @root, i8 0, i64 800040, i1 false)
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @m)
  %6 = load i32, ptr @n, align 4, !tbaa !7
  %.not78 = icmp slt i32 %6, 1
  br i1 %.not78, label %.preheader77, label %.lr.ph

.preheader77:                                     ; preds = %.lr.ph, %.lr.ph114
  %7 = load i32, ptr @m, align 4, !tbaa !7
  %.not6780 = icmp slt i32 %7, 1
  br i1 %.not6780, label %._crit_edge, label %.lr.ph82

.lr.ph:                                           ; preds = %.lr.ph114, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph114 ]
  %8 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %indvars.iv
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %8)
  %9 = load i32, ptr %8, align 4, !tbaa !7
  %10 = load i32, ptr @tot, align 4, !tbaa !7
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr @tot, align 4, !tbaa !7
  %12 = sext i32 %10 to i64
  %13 = getelementptr inbounds [200010 x i32], ptr @que, i64 0, i64 %12
  store i32 %9, ptr %13, align 4, !tbaa !7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr @n, align 4, !tbaa !7
  %15 = sext i32 %14 to i64
  %.not.not = icmp slt i64 %indvars.iv, %15
  br i1 %.not.not, label %.lr.ph, label %.preheader77, !llvm.loop !11

._crit_edge:                                      ; preds = %41, %.preheader77
  %16 = load i32, ptr @tot, align 4, !tbaa !7
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i32, ptr @que, i64 %17
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %18)
  %19 = load i32, ptr @tot, align 4, !tbaa !7
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr @que, i64 %20
  %22 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %21)
  %23 = ptrtoint ptr %22 to i64
  %24 = sub i64 %23, ptrtoint (ptr @que to i64)
  %25 = lshr exact i64 %24, 2
  %26 = trunc i64 %25 to i32
  store i32 %26, ptr @tot, align 4, !tbaa !7
  %27 = load i32, ptr @n, align 4, !tbaa !7
  %.not6888 = icmp slt i32 %27, 1
  br i1 %.not6888, label %.preheader, label %.lr.ph91

.lr.ph82:                                         ; preds = %.preheader77, %41
  %indvars.iv118 = phi i64 [ %indvars.iv.next119, %41 ], [ 1, %.preheader77 ]
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %1) #6
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %29 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %indvars.iv118
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %29)
  %30 = getelementptr inbounds [200010 x i32], ptr @B, i64 0, i64 %indvars.iv118
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %30)
  %31 = load i8, ptr %1, align 1, !tbaa !12
  %32 = icmp eq i8 %31, 81
  br i1 %32, label %33, label %35

33:                                               ; preds = %.lr.ph82
  %34 = getelementptr inbounds [200010 x i32], ptr @K, i64 0, i64 %indvars.iv118
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %34)
  br label %41

35:                                               ; preds = %.lr.ph82
  %36 = load i32, ptr %30, align 4, !tbaa !7
  %37 = load i32, ptr @tot, align 4, !tbaa !7
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr @tot, align 4, !tbaa !7
  %39 = sext i32 %37 to i64
  %40 = getelementptr inbounds [200010 x i32], ptr @que, i64 0, i64 %39
  store i32 %36, ptr %40, align 4, !tbaa !7
  br label %41

41:                                               ; preds = %35, %33
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %1) #6
  %indvars.iv.next119 = add nuw nsw i64 %indvars.iv118, 1
  %42 = load i32, ptr @m, align 4, !tbaa !7
  %43 = sext i32 %42 to i64
  %.not67.not = icmp slt i64 %indvars.iv118, %43
  br i1 %.not67.not, label %.lr.ph82, label %._crit_edge, !llvm.loop !13

.preheader:                                       ; preds = %._crit_edge87, %._crit_edge
  %44 = load i32, ptr @m, align 4, !tbaa !7
  %.not69110 = icmp slt i32 %44, 1
  br i1 %.not69110, label %.loopexit76, label %.lr.ph112

.lr.ph91:                                         ; preds = %._crit_edge, %._crit_edge87
  %indvars.iv121 = phi i64 [ %indvars.iv.next122, %._crit_edge87 ], [ 1, %._crit_edge ]
  %45 = load i32, ptr @tot, align 4, !tbaa !7
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i32, ptr @que, i64 %46
  %48 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %indvars.iv121
  %49 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %47, ptr noundef nonnull align 4 dereferenceable(4) %48)
  %50 = ptrtoint ptr %49 to i64
  %51 = sub i64 %50, ptrtoint (ptr @que to i64)
  %52 = lshr exact i64 %51, 2
  %53 = trunc i64 %52 to i32
  %54 = add i32 %53, 1
  store i32 %54, ptr %48, align 4, !tbaa !7
  %55 = load i32, ptr @n, align 4, !tbaa !7
  %56 = sext i32 %55 to i64
  %.not7583 = icmp sgt i64 %indvars.iv121, %56
  br i1 %.not7583, label %._crit_edge87, label %.lr.ph86.preheader

.lr.ph86.preheader:                               ; preds = %.lr.ph91
  %57 = trunc nuw nsw i64 %indvars.iv121 to i32
  br label %.lr.ph86

._crit_edge87.loopexit:                           ; preds = %.lr.ph86
  %.pre = sext i32 %66 to i64
  br label %._crit_edge87

._crit_edge87:                                    ; preds = %._crit_edge87.loopexit, %.lr.ph91
  %.pre-phi = phi i64 [ %.pre, %._crit_edge87.loopexit ], [ %56, %.lr.ph91 ]
  %indvars.iv.next122 = add nuw nsw i64 %indvars.iv121, 1
  %.not68.not = icmp slt i64 %indvars.iv121, %.pre-phi
  br i1 %.not68.not, label %.lr.ph91, label %.preheader, !llvm.loop !14

.lr.ph86:                                         ; preds = %.lr.ph86.preheader, %.lr.ph86
  %.06384 = phi i32 [ %65, %.lr.ph86 ], [ %57, %.lr.ph86.preheader ]
  %58 = sext i32 %.06384 to i64
  %59 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !7
  %61 = load i32, ptr @tot, align 4, !tbaa !7
  %62 = load i32, ptr %48, align 4, !tbaa !7
  call void @_Z6updateiiiiRiii(i32 noundef %.06384, i32 noundef %60, i32 noundef 1, i32 noundef %61, ptr noundef nonnull align 4 dereferenceable(4) %59, i32 noundef %62, i32 noundef 1)
  %63 = sub nsw i32 0, %.06384
  %64 = and i32 %.06384, %63
  %65 = add nsw i32 %64, %.06384
  %66 = load i32, ptr @n, align 4, !tbaa !7
  %.not75 = icmp sgt i32 %65, %66
  br i1 %.not75, label %._crit_edge87.loopexit, label %.lr.ph86, !llvm.loop !15

.lr.ph112:                                        ; preds = %.preheader, %.loopexit
  %indvars.iv130 = phi i64 [ %indvars.iv.next131, %.loopexit ], [ 1, %.preheader ]
  %67 = getelementptr inbounds [200010 x i32], ptr @K, i64 0, i64 %indvars.iv130
  %68 = load i32, ptr %67, align 4, !tbaa !7
  %.not70 = icmp eq i32 %68, 0
  br i1 %.not70, label %98, label %69

69:                                               ; preds = %.lr.ph112
  store i32 0, ptr @b, align 4, !tbaa !7
  store i32 0, ptr @a, align 4, !tbaa !7
  %70 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %indvars.iv130
  %71 = load i32, ptr %70, align 4, !tbaa !7
  %72 = icmp sgt i32 %71, 1
  br i1 %72, label %.lr.ph94.preheader, label %75

.lr.ph94.preheader:                               ; preds = %69
  %73 = add nsw i32 %71, -1
  br label %.lr.ph94

._crit_edge95:                                    ; preds = %.lr.ph94
  %74 = trunc nuw nsw i64 %indvars.iv.next125 to i32
  store i32 %74, ptr @a, align 4, !tbaa !7
  br label %75

75:                                               ; preds = %._crit_edge95, %69
  %76 = getelementptr inbounds [200010 x i32], ptr @B, i64 0, i64 %indvars.iv130
  %77 = load i32, ptr %76, align 4, !tbaa !7
  %78 = icmp sgt i32 %77, 0
  br i1 %78, label %.lr.ph98, label %85

.lr.ph94:                                         ; preds = %.lr.ph94.preheader, %.lr.ph94
  %indvars.iv124 = phi i64 [ 0, %.lr.ph94.preheader ], [ %indvars.iv.next125, %.lr.ph94 ]
  %.06192 = phi i32 [ %73, %.lr.ph94.preheader ], [ %83, %.lr.ph94 ]
  %79 = zext nneg i32 %.06192 to i64
  %80 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !7
  %indvars.iv.next125 = add nuw nsw i64 %indvars.iv124, 1
  %82 = getelementptr inbounds [30 x i32], ptr @l, i64 0, i64 %indvars.iv.next125
  store i32 %81, ptr %82, align 4, !tbaa !7
  %.not74 = add nsw i32 %.06192, -1
  %83 = and i32 %.not74, %.06192
  %.not = icmp eq i32 %83, 0
  br i1 %.not, label %._crit_edge95, label %.lr.ph94, !llvm.loop !16

._crit_edge99:                                    ; preds = %.lr.ph98
  %84 = trunc nsw i64 %indvars.iv.next128 to i32
  store i32 %84, ptr @b, align 4, !tbaa !7
  br label %85

85:                                               ; preds = %._crit_edge99, %75
  %86 = load i32, ptr @tot, align 4, !tbaa !7
  %87 = call noundef i32 @_Z5queryiii(i32 noundef 1, i32 noundef %86, i32 noundef %68)
  %88 = add nsw i32 %87, -1
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [200010 x i32], ptr @que, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !7
  %92 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %91)
  br label %.loopexit

.lr.ph98:                                         ; preds = %75, %.lr.ph98
  %indvars.iv127 = phi i64 [ %indvars.iv.next128, %.lr.ph98 ], [ 0, %75 ]
  %.06096 = phi i32 [ %97, %.lr.ph98 ], [ %77, %75 ]
  %93 = zext nneg i32 %.06096 to i64
  %94 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !7
  %indvars.iv.next128 = add nuw nsw i64 %indvars.iv127, 1
  %96 = getelementptr inbounds [30 x i32], ptr @r, i64 0, i64 %indvars.iv.next128
  store i32 %95, ptr %96, align 4, !tbaa !7
  %.not73 = add nsw i32 %.06096, -1
  %97 = and i32 %.not73, %.06096
  %.not133 = icmp eq i32 %97, 0
  br i1 %.not133, label %._crit_edge99, label %.lr.ph98, !llvm.loop !17

98:                                               ; preds = %.lr.ph112
  %99 = getelementptr inbounds [200010 x i32], ptr @A, i64 0, i64 %indvars.iv130
  %100 = load i32, ptr %99, align 4, !tbaa !7
  %101 = load i32, ptr @n, align 4, !tbaa !7
  %.not71101 = icmp sgt i32 %100, %101
  br i1 %.not71101, label %._crit_edge105, label %.lr.ph104

._crit_edge105:                                   ; preds = %.lr.ph104, %98
  %102 = load i32, ptr @tot, align 4, !tbaa !7
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds i32, ptr @que, i64 %103
  %105 = getelementptr inbounds [200010 x i32], ptr @B, i64 0, i64 %indvars.iv130
  %106 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %104, ptr noundef nonnull align 4 dereferenceable(4) %105)
  %107 = ptrtoint ptr %106 to i64
  %108 = sub i64 %107, ptrtoint (ptr @que to i64)
  %109 = lshr exact i64 %108, 2
  %110 = trunc i64 %109 to i32
  %111 = add i32 %110, 1
  %112 = load i32, ptr %99, align 4, !tbaa !7
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %113
  store i32 %111, ptr %114, align 4, !tbaa !7
  %115 = load i32, ptr @n, align 4, !tbaa !7
  %.not72106 = icmp sgt i32 %112, %115
  br i1 %.not72106, label %.loopexit, label %.lr.ph109

.lr.ph104:                                        ; preds = %98, %.lr.ph104
  %.059102 = phi i32 [ %126, %.lr.ph104 ], [ %100, %98 ]
  %116 = sext i32 %.059102 to i64
  %117 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !7
  %119 = load i32, ptr @tot, align 4, !tbaa !7
  %120 = load i32, ptr %99, align 4, !tbaa !7
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !7
  call void @_Z6updateiiiiRiii(i32 noundef %.059102, i32 noundef %118, i32 noundef 1, i32 noundef %119, ptr noundef nonnull align 4 dereferenceable(4) %117, i32 noundef %123, i32 noundef -1)
  %124 = sub nsw i32 0, %.059102
  %125 = and i32 %.059102, %124
  %126 = add nsw i32 %125, %.059102
  %127 = load i32, ptr @n, align 4, !tbaa !7
  %.not71 = icmp sgt i32 %126, %127
  br i1 %.not71, label %._crit_edge105, label %.lr.ph104, !llvm.loop !18

.lr.ph109:                                        ; preds = %._crit_edge105, %.lr.ph109
  %.0107 = phi i32 [ %138, %.lr.ph109 ], [ %112, %._crit_edge105 ]
  %128 = sext i32 %.0107 to i64
  %129 = getelementptr inbounds [200010 x i32], ptr @root, i64 0, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !7
  %131 = load i32, ptr @tot, align 4, !tbaa !7
  %132 = load i32, ptr %99, align 4, !tbaa !7
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [200010 x i32], ptr @val, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !7
  call void @_Z6updateiiiiRiii(i32 noundef %.0107, i32 noundef %130, i32 noundef 1, i32 noundef %131, ptr noundef nonnull align 4 dereferenceable(4) %129, i32 noundef %135, i32 noundef 1)
  %136 = sub nsw i32 0, %.0107
  %137 = and i32 %.0107, %136
  %138 = add nsw i32 %137, %.0107
  %139 = load i32, ptr @n, align 4, !tbaa !7
  %.not72 = icmp sgt i32 %138, %139
  br i1 %.not72, label %.loopexit, label %.lr.ph109, !llvm.loop !19

.loopexit:                                        ; preds = %.lr.ph109, %._crit_edge105, %85
  %indvars.iv.next131 = add nuw nsw i64 %indvars.iv130, 1
  %140 = load i32, ptr @m, align 4, !tbaa !7
  %141 = sext i32 %140 to i64
  %.not69.not = icmp slt i64 %indvars.iv130, %141
  br i1 %.not69.not, label %.lr.ph112, label %.loopexit76, !llvm.loop !20

._crit_edge115:                                   ; preds = %.loopexit76, %0
  ret i32 0
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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: 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = 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 = distinct !{!11, !6}
!12 = !{!9, !9, i64 0}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}
!15 = distinct !{!15, !6}
!16 = distinct !{!16, !6}
!17 = distinct !{!17, !6}
!18 = distinct !{!18, !6}
!19 = distinct !{!19, !6}
!20 = distinct !{!20, !6}


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