; LLVM IR from tangjz/acm-icpc :: self_training/2015-09-22 (G)

; 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
@h = external dso_local global [100001 x [17 x i32]], align 16
@Log = external dso_local global [100001 x i32], align 16
@que = external dso_local global [100001 x i32], align 16
@top = external dso_local global i32, align 4
@vis = external dso_local global [100001 x i8], align 16
@first = external dso_local global i8, align 1
@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3rmqii(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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; 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() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %24, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 100001
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %10
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = ashr i32 %15, 1
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %22
  store i32 %20, ptr %23, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %14
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !9

27:                                               ; preds = %13
  br label %28

28:                                               ; preds = %248, %27
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %250

31:                                               ; preds = %28
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 100001, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %43, %31
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = icmp sle i32 %33, %34
  br i1 %35, label %37, label %36

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

37:                                               ; preds = %32
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %39
  %41 = getelementptr inbounds [17 x i32], ptr %40, i64 0, i64 0
  %42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %41)
  br label %43

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

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

47:                                               ; preds = %96, %46
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = icmp sle i32 %48, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %47
  store i32 10, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %99

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

56:                                               ; preds = %92, %55
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sub nsw i32 %58, 1
  %60 = shl i32 1, %59
  %61 = add nsw i32 %57, %60
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = icmp sle i32 %61, %62
  br i1 %63, label %65, label %64

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

65:                                               ; preds = %56
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %67
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = sub nsw i32 %69, 1
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [17 x i32], ptr %68, i64 0, i64 %71
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = sub nsw i32 %74, 1
  %76 = shl i32 1, %75
  %77 = add nsw i32 %73, %76
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %78
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = sub nsw i32 %80, 1
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [17 x i32], ptr %79, i64 0, i64 %82
  %84 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %72, ptr noundef nonnull align 4 dereferenceable(4) %83)
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %87
  %89 = load i32, ptr %4, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [17 x i32], ptr %88, i64 0, i64 %90
  store i32 %85, ptr %91, align 4, !tbaa !5
  br label %92

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

95:                                               ; preds = %64
  br label %96

96:                                               ; preds = %95
  %97 = load i32, ptr %4, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %4, align 4, !tbaa !5
  br label %47, !llvm.loop !13

99:                                               ; preds = %54
  store i32 0, ptr @top, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %158, %99
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = load i32, ptr @n, align 4, !tbaa !5
  %103 = icmp sle i32 %101, %102
  br i1 %103, label %105, label %104

104:                                              ; preds = %100
  store i32 16, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %161

105:                                              ; preds = %100
  br label %106

106:                                              ; preds = %127, %105
  %107 = load i32, ptr @top, align 4, !tbaa !5
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %125

109:                                              ; preds = %106
  %110 = load i32, ptr @top, align 4, !tbaa !5
  %111 = sub nsw i32 %110, 1
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %115
  %117 = getelementptr inbounds [17 x i32], ptr %116, i64 0, i64 0
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = load i32, ptr %7, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %120
  %122 = getelementptr inbounds [17 x i32], ptr %121, i64 0, i64 0
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = icmp sle i32 %118, %123
  br label %125

125:                                              ; preds = %109, %106
  %126 = phi i1 [ false, %106 ], [ %124, %109 ]
  br i1 %126, label %127, label %130

127:                                              ; preds = %125
  %128 = load i32, ptr @top, align 4, !tbaa !5
  %129 = add nsw i32 %128, -1
  store i32 %129, ptr @top, align 4, !tbaa !5
  br label %106, !llvm.loop !14

130:                                              ; preds = %125
  %131 = load i32, ptr @top, align 4, !tbaa !5
  %132 = icmp ne i32 %131, 0
  br i1 %132, label %133, label %152

133:                                              ; preds = %130
  %134 = load i32, ptr @top, align 4, !tbaa !5
  %135 = sub nsw i32 %134, 1
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %136
  %138 = load i32, ptr %137, align 4, !tbaa !5
  %139 = load i32, ptr %7, align 4, !tbaa !5
  %140 = call noundef i32 @_Z3rmqii(i32 noundef %138, i32 noundef %139)
  %141 = load i32, ptr %7, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %142
  %144 = getelementptr inbounds [17 x i32], ptr %143, i64 0, i64 0
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = sub nsw i32 %145, 150000
  %147 = icmp sgt i32 %140, %146
  br i1 %147, label %148, label %152

148:                                              ; preds = %133
  %149 = load i32, ptr %7, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %150
  store i8 1, ptr %151, align 1, !tbaa !15
  br label %152

152:                                              ; preds = %148, %133, %130
  %153 = load i32, ptr %7, align 4, !tbaa !5
  %154 = load i32, ptr @top, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr @top, align 4, !tbaa !5
  %156 = sext i32 %154 to i64
  %157 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %156
  store i32 %153, ptr %157, align 4, !tbaa !5
  br label %158

158:                                              ; preds = %152
  %159 = load i32, ptr %7, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %7, align 4, !tbaa !5
  br label %100, !llvm.loop !17

161:                                              ; preds = %104
  store i32 0, ptr @top, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %162 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %162, ptr %8, align 4, !tbaa !5
  br label %163

163:                                              ; preds = %220, %161
  %164 = load i32, ptr %8, align 4, !tbaa !5
  %165 = icmp ne i32 %164, 0
  br i1 %165, label %167, label %166

166:                                              ; preds = %163
  store i32 21, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %223

167:                                              ; preds = %163
  br label %168

168:                                              ; preds = %189, %167
  %169 = load i32, ptr @top, align 4, !tbaa !5
  %170 = icmp ne i32 %169, 0
  br i1 %170, label %171, label %187

171:                                              ; preds = %168
  %172 = load i32, ptr @top, align 4, !tbaa !5
  %173 = sub nsw i32 %172, 1
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %177
  %179 = getelementptr inbounds [17 x i32], ptr %178, i64 0, i64 0
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = load i32, ptr %8, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %182
  %184 = getelementptr inbounds [17 x i32], ptr %183, i64 0, i64 0
  %185 = load i32, ptr %184, align 4, !tbaa !5
  %186 = icmp sle i32 %180, %185
  br label %187

187:                                              ; preds = %171, %168
  %188 = phi i1 [ false, %168 ], [ %186, %171 ]
  br i1 %188, label %189, label %192

189:                                              ; preds = %187
  %190 = load i32, ptr @top, align 4, !tbaa !5
  %191 = add nsw i32 %190, -1
  store i32 %191, ptr @top, align 4, !tbaa !5
  br label %168, !llvm.loop !18

192:                                              ; preds = %187
  %193 = load i32, ptr @top, align 4, !tbaa !5
  %194 = icmp ne i32 %193, 0
  br i1 %194, label %195, label %214

195:                                              ; preds = %192
  %196 = load i32, ptr %8, align 4, !tbaa !5
  %197 = load i32, ptr @top, align 4, !tbaa !5
  %198 = sub nsw i32 %197, 1
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %199
  %201 = load i32, ptr %200, align 4, !tbaa !5
  %202 = call noundef i32 @_Z3rmqii(i32 noundef %196, i32 noundef %201)
  %203 = load i32, ptr %8, align 4, !tbaa !5
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %204
  %206 = getelementptr inbounds [17 x i32], ptr %205, i64 0, i64 0
  %207 = load i32, ptr %206, align 4, !tbaa !5
  %208 = sub nsw i32 %207, 150000
  %209 = icmp sgt i32 %202, %208
  br i1 %209, label %210, label %214

210:                                              ; preds = %195
  %211 = load i32, ptr %8, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %212
  store i8 1, ptr %213, align 1, !tbaa !15
  br label %214

214:                                              ; preds = %210, %195, %192
  %215 = load i32, ptr %8, align 4, !tbaa !5
  %216 = load i32, ptr @top, align 4, !tbaa !5
  %217 = add nsw i32 %216, 1
  store i32 %217, ptr @top, align 4, !tbaa !5
  %218 = sext i32 %216 to i64
  %219 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %218
  store i32 %215, ptr %219, align 4, !tbaa !5
  br label %220

220:                                              ; preds = %214
  %221 = load i32, ptr %8, align 4, !tbaa !5
  %222 = add nsw i32 %221, -1
  store i32 %222, ptr %8, align 4, !tbaa !5
  br label %163, !llvm.loop !19

223:                                              ; preds = %166
  store i8 0, ptr @first, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %224

224:                                              ; preds = %245, %223
  %225 = load i32, ptr %9, align 4, !tbaa !5
  %226 = load i32, ptr @n, align 4, !tbaa !5
  %227 = icmp sle i32 %225, %226
  br i1 %227, label %229, label %228

228:                                              ; preds = %224
  store i32 26, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %248

229:                                              ; preds = %224
  %230 = load i32, ptr %9, align 4, !tbaa !5
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %231
  %233 = load i8, ptr %232, align 1, !tbaa !15, !range !20, !noundef !21
  %234 = trunc i8 %233 to i1
  br i1 %234, label %244, label %235

235:                                              ; preds = %229
  %236 = load i8, ptr @first, align 1, !tbaa !15, !range !20, !noundef !21
  %237 = trunc i8 %236 to i1
  br i1 %237, label %238, label %240

238:                                              ; preds = %235
  %239 = call i32 @putchar(i32 noundef 32)
  br label %241

240:                                              ; preds = %235
  store i8 1, ptr @first, align 1, !tbaa !15
  br label %241

241:                                              ; preds = %240, %238
  %242 = load i32, ptr %9, align 4, !tbaa !5
  %243 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %242)
  br label %244

244:                                              ; preds = %241, %229
  br label %245

245:                                              ; preds = %244
  %246 = load i32, ptr %9, align 4, !tbaa !5
  %247 = add nsw i32 %246, 1
  store i32 %247, ptr %9, align 4, !tbaa !5
  br label %224, !llvm.loop !22

248:                                              ; preds = %228
  %249 = call i32 @putchar(i32 noundef 10)
  br label %28, !llvm.loop !23

250:                                              ; preds = %28
  ret i32 0
}

declare i32 @__isoc99_scanf(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 i32 @putchar(i32 noundef) #6

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !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
@h = external dso_local global [100001 x [17 x i32]], align 16
@Log = external dso_local local_unnamed_addr global [100001 x i32], align 16
@que = external dso_local local_unnamed_addr global [100001 x i32], align 16
@top = external dso_local local_unnamed_addr global i32, align 4
@vis = external dso_local local_unnamed_addr global [100001 x i8], align 16
@first = external dso_local local_unnamed_addr global i8, align 1
@.str = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  br label %3

.preheader64:                                     ; preds = %3
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %.lr.ph93, label %._crit_edge94

3:                                                ; preds = %3, %0
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next.2, %3 ]
  %4 = lshr i64 %indvars.iv, 1
  %5 = and i64 %4, 2147483647
  %6 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = add nsw i32 %7, 1
  %9 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %indvars.iv
  store i32 %8, ptr %9, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = lshr i64 %indvars.iv.next, 1
  %11 = and i64 %10, 2147483647
  %12 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = add nsw i32 %13, 1
  %15 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %indvars.iv.next
  store i32 %14, ptr %15, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %16 = lshr i64 %indvars.iv.next.1, 1
  %17 = and i64 %16, 2147483647
  %18 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  %21 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %indvars.iv.next.1
  store i32 %20, ptr %21, align 4, !tbaa !5
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %exitcond.not.2 = icmp eq i64 %indvars.iv.next.2, 100001
  br i1 %exitcond.not.2, label %.preheader64, label %3, !llvm.loop !9

.lr.ph93:                                         ; preds = %.preheader64, %._crit_edge92
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(100001) @vis, i8 0, i64 100001, i1 false)
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %.not69 = icmp slt i32 %22, 1
  br i1 %.not69, label %.lr.ph93..preheader63_crit_edge, label %.lr.ph

.lr.ph93..preheader63_crit_edge:                  ; preds = %.lr.ph93
  %.pre128 = sext i32 %22 to i64
  br label %.preheader63

.preheader63:                                     ; preds = %.lr.ph, %.lr.ph93..preheader63_crit_edge
  %.pre-phi = phi i64 [ %.pre128, %.lr.ph93..preheader63_crit_edge ], [ %29, %.lr.ph ]
  %23 = phi i32 [ %22, %.lr.ph93..preheader63_crit_edge ], [ %28, %.lr.ph ]
  %24 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %.pre-phi
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %.not5074 = icmp slt i32 %25, 1
  br i1 %.not5074, label %._crit_edge76, label %.preheader

.lr.ph:                                           ; preds = %.lr.ph93, %.lr.ph
  %indvars.iv101 = phi i64 [ %indvars.iv.next102, %.lr.ph ], [ 1, %.lr.ph93 ]
  %26 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %indvars.iv101
  %27 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %26)
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %.not.not = icmp slt i64 %indvars.iv101, %29
  br i1 %.not.not, label %.lr.ph, label %.preheader63, !llvm.loop !11

.preheader:                                       ; preds = %.preheader63, %._crit_edge
  %30 = phi i32 [ %37, %._crit_edge ], [ %23, %.preheader63 ]
  %indvars.iv107 = phi i64 [ %indvars.iv.next108, %._crit_edge ], [ 1, %.preheader63 ]
  %31 = add nsw i64 %indvars.iv107, -1
  %32 = trunc nuw nsw i64 %31 to i32
  %33 = shl nuw i32 1, %32
  %.not6071.not = icmp slt i32 %33, %30
  br i1 %.not6071.not, label %.lr.ph73, label %.preheader.._crit_edge_crit_edge

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre129 = sext i32 %30 to i64
  br label %._crit_edge

.lr.ph73:                                         ; preds = %.preheader
  %34 = add nuw nsw i32 %33, 1
  %35 = sext i32 %33 to i64
  br label %41

._crit_edge76:                                    ; preds = %._crit_edge, %.preheader63
  %36 = phi i32 [ %23, %.preheader63 ], [ %37, %._crit_edge ]
  store i32 0, ptr @top, align 4, !tbaa !5
  %.not5179 = icmp slt i32 %36, 1
  br i1 %.not5179, label %._crit_edge82, label %thread-pre-split

._crit_edge:                                      ; preds = %41, %.preheader.._crit_edge_crit_edge
  %.pre-phi130 = phi i64 [ %.pre129, %.preheader.._crit_edge_crit_edge ], [ %51, %41 ]
  %37 = phi i32 [ %30, %.preheader.._crit_edge_crit_edge ], [ %50, %41 ]
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %38 = getelementptr inbounds [100001 x i32], ptr @Log, i64 0, i64 %.pre-phi130
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %.not50.not = icmp slt i64 %indvars.iv107, %40
  br i1 %.not50.not, label %.preheader, label %._crit_edge76, !llvm.loop !12

41:                                               ; preds = %.lr.ph73, %41
  %indvars.iv104 = phi i64 [ 1, %.lr.ph73 ], [ %indvars.iv.next105, %41 ]
  %42 = phi i32 [ %34, %.lr.ph73 ], [ %52, %41 ]
  %43 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %indvars.iv104, i64 %31
  %44 = sext i32 %42 to i64
  %45 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %44, i64 %31
  %46 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %43, ptr noundef nonnull align 4 dereferenceable(4) %45)
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %indvars.iv104, i64 %indvars.iv107
  store i32 %47, ptr %48, align 4, !tbaa !5
  %indvars.iv.next105 = add nuw nsw i64 %indvars.iv104, 1
  %49 = add nuw nsw i64 %indvars.iv.next105, %35
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %.not60 = icmp sgt i64 %49, %51
  %52 = trunc nsw i64 %49 to i32
  br i1 %.not60, label %._crit_edge, label %41, !llvm.loop !13

._crit_edge82:                                    ; preds = %.critedge.thread, %._crit_edge76
  %.lcssa = phi i32 [ %36, %._crit_edge76 ], [ %81, %.critedge.thread ]
  store i32 0, ptr @top, align 4, !tbaa !5
  %.not5285 = icmp eq i32 %.lcssa, 0
  br i1 %.not5285, label %._crit_edge87.thread, label %thread-pre-split61.preheader

._crit_edge87.thread:                             ; preds = %._crit_edge82
  store i8 0, ptr @first, align 1, !tbaa !14
  br label %._crit_edge92

thread-pre-split61.preheader:                     ; preds = %._crit_edge82
  %53 = sext i32 %.lcssa to i64
  br label %thread-pre-split61

thread-pre-split:                                 ; preds = %._crit_edge76, %.critedge.thread
  %.pr = phi i32 [ %77, %.critedge.thread ], [ 0, %._crit_edge76 ]
  %indvars.iv113 = phi i64 [ %indvars.iv.next114, %.critedge.thread ], [ 1, %._crit_edge76 ]
  %.not5777 = icmp eq i32 %.pr, 0
  br i1 %.not5777, label %.critedge.thread, label %.lr.ph78

.lr.ph78:                                         ; preds = %thread-pre-split
  %54 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %indvars.iv113
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %.pr to i64
  br label %57

57:                                               ; preds = %.lr.ph78, %63
  %indvars.iv110 = phi i64 [ %56, %.lr.ph78 ], [ %indvars.iv.next111, %63 ]
  %indvars.iv.next111 = add nsw i64 %indvars.iv110, -1
  %58 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %indvars.iv.next111
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %.not58 = icmp sgt i32 %62, %55
  br i1 %.not58, label %.critedge, label %63

63:                                               ; preds = %57
  %64 = trunc nsw i64 %indvars.iv.next111 to i32
  store i32 %64, ptr @top, align 4, !tbaa !5
  %.not57 = icmp eq i64 %indvars.iv.next111, 0
  br i1 %.not57, label %.critedge.thread, label %57, !llvm.loop !16

.critedge:                                        ; preds = %57
  %65 = shl i64 %indvars.iv110, 32
  %sext = add i64 %65, -4294967296
  %66 = ashr exact i64 %sext, 32
  %67 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = trunc nuw nsw i64 %indvars.iv113 to i32
  %70 = tail call noundef i32 @_Z3rmqii(i32 noundef %68, i32 noundef %69)
  %71 = load i32, ptr %54, align 4, !tbaa !5
  %72 = add nsw i32 %71, -150000
  %73 = icmp sgt i32 %70, %72
  br i1 %73, label %74, label %.critedge.thread

74:                                               ; preds = %.critedge
  %75 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %indvars.iv113
  store i8 1, ptr %75, align 1, !tbaa !14
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %63, %thread-pre-split, %74, %.critedge
  %76 = load i32, ptr @top, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr @top, align 4, !tbaa !5
  %78 = sext i32 %76 to i64
  %79 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %78
  %80 = trunc nuw nsw i64 %indvars.iv113 to i32
  store i32 %80, ptr %79, align 4, !tbaa !5
  %indvars.iv.next114 = add nuw nsw i64 %indvars.iv113, 1
  %81 = load i32, ptr @n, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %.not51.not = icmp slt i64 %indvars.iv113, %82
  br i1 %.not51.not, label %thread-pre-split, label %._crit_edge82, !llvm.loop !17

._crit_edge87:                                    ; preds = %.critedge2.thread
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  store i8 0, ptr @first, align 1, !tbaa !14
  %.not5388 = icmp slt i32 %.pre, 1
  br i1 %.not5388, label %._crit_edge92, label %.lr.ph91

thread-pre-split61:                               ; preds = %thread-pre-split61.preheader, %.critedge2.thread
  %.pr62 = phi i32 [ 0, %thread-pre-split61.preheader ], [ %106, %.critedge2.thread ]
  %indvars.iv119 = phi i64 [ %53, %thread-pre-split61.preheader ], [ %indvars.iv.next120, %.critedge2.thread ]
  %.not5483 = icmp eq i32 %.pr62, 0
  br i1 %.not5483, label %.critedge2.thread, label %.lr.ph84

.lr.ph84:                                         ; preds = %thread-pre-split61
  %83 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %indvars.iv119
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = sext i32 %.pr62 to i64
  br label %86

86:                                               ; preds = %.lr.ph84, %92
  %indvars.iv116 = phi i64 [ %85, %.lr.ph84 ], [ %indvars.iv.next117, %92 ]
  %indvars.iv.next117 = add nsw i64 %indvars.iv116, -1
  %87 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %indvars.iv.next117
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [100001 x [17 x i32]], ptr @h, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %.not55 = icmp sgt i32 %91, %84
  br i1 %.not55, label %.critedge2, label %92

92:                                               ; preds = %86
  %93 = trunc nsw i64 %indvars.iv.next117 to i32
  store i32 %93, ptr @top, align 4, !tbaa !5
  %.not54 = icmp eq i64 %indvars.iv.next117, 0
  br i1 %.not54, label %.critedge2.thread, label %86, !llvm.loop !18

.critedge2:                                       ; preds = %86
  %94 = shl i64 %indvars.iv116, 32
  %sext131 = add i64 %94, -4294967296
  %95 = ashr exact i64 %sext131, 32
  %96 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = trunc nsw i64 %indvars.iv119 to i32
  %99 = tail call noundef i32 @_Z3rmqii(i32 noundef %98, i32 noundef %97)
  %100 = load i32, ptr %83, align 4, !tbaa !5
  %101 = add nsw i32 %100, -150000
  %102 = icmp sgt i32 %99, %101
  br i1 %102, label %103, label %.critedge2.thread

103:                                              ; preds = %.critedge2
  %104 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %indvars.iv119
  store i8 1, ptr %104, align 1, !tbaa !14
  br label %.critedge2.thread

.critedge2.thread:                                ; preds = %92, %thread-pre-split61, %103, %.critedge2
  %105 = load i32, ptr @top, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr @top, align 4, !tbaa !5
  %107 = sext i32 %105 to i64
  %108 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %107
  %109 = trunc nsw i64 %indvars.iv119 to i32
  store i32 %109, ptr %108, align 4, !tbaa !5
  %indvars.iv.next120 = add nsw i64 %indvars.iv119, -1
  %.not52 = icmp eq i64 %indvars.iv.next120, 0
  br i1 %.not52, label %._crit_edge87, label %thread-pre-split61, !llvm.loop !19

._crit_edge92:                                    ; preds = %126, %._crit_edge87.thread, %._crit_edge87
  %110 = tail call i32 @putchar(i32 noundef 10)
  %111 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %112 = icmp eq i32 %111, 1
  br i1 %112, label %.lr.ph93, label %._crit_edge94, !llvm.loop !20

.lr.ph91:                                         ; preds = %._crit_edge87, %126
  %113 = phi i32 [ %127, %126 ], [ %.pre, %._crit_edge87 ]
  %indvars.iv122 = phi i64 [ %indvars.iv.next123, %126 ], [ 1, %._crit_edge87 ]
  %114 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %indvars.iv122
  %115 = load i8, ptr %114, align 1, !tbaa !14, !range !21, !noundef !22
  %116 = trunc nuw i8 %115 to i1
  br i1 %116, label %126, label %117

117:                                              ; preds = %.lr.ph91
  %118 = load i8, ptr @first, align 1, !tbaa !14, !range !21, !noundef !22
  %119 = trunc nuw i8 %118 to i1
  br i1 %119, label %120, label %122

120:                                              ; preds = %117
  %121 = tail call i32 @putchar(i32 noundef 32)
  br label %123

122:                                              ; preds = %117
  store i8 1, ptr @first, align 1, !tbaa !14
  br label %123

123:                                              ; preds = %122, %120
  %124 = trunc nuw nsw i64 %indvars.iv122 to i32
  %125 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %124)
  %.pre127 = load i32, ptr @n, align 4, !tbaa !5
  br label %126

126:                                              ; preds = %.lr.ph91, %123
  %127 = phi i32 [ %113, %.lr.ph91 ], [ %.pre127, %123 ]
  %indvars.iv.next123 = add nuw nsw i64 %indvars.iv122, 1
  %128 = sext i32 %127 to i64
  %.not53.not = icmp slt i64 %indvars.iv122, %128
  br i1 %.not53.not, label %.lr.ph91, label %._crit_edge92, !llvm.loop !23

._crit_edge94:                                    ; preds = %._crit_edge92, %.preheader64
  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 nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) 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 = { inlinehint 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 #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 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" }

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

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


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