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

; 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
@year = external dso_local global [50002 x i32], align 16
@st = external dso_local global [50002 x [19 x i32]], align 16
@Log = external dso_local global [50002 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %14

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

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

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [50002 x i32], ptr @year, i64 0, i64 %21
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %24
  %26 = getelementptr inbounds [19 x i32], ptr %25, i64 0, i64 0
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %22, ptr noundef %26)
  br label %28

28:                                               ; preds = %19
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

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

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

35:                                               ; preds = %32
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %80

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

37:                                               ; preds = %73, %36
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = shl i32 1, %40
  %42 = sub nsw i32 %39, %41
  %43 = add nsw i32 %42, 1
  %44 = icmp sle i32 %38, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %37
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %76

46:                                               ; preds = %37
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %48
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [19 x i32], ptr %49, i64 0, i64 %52
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sub nsw i32 %55, 1
  %57 = shl i32 1, %56
  %58 = add nsw i32 %54, %57
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %59
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = sub nsw i32 %61, 1
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [19 x i32], ptr %60, i64 0, i64 %63
  %65 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %53, ptr noundef nonnull align 4 dereferenceable(4) %64)
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %68
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [19 x i32], ptr %69, i64 0, i64 %71
  store i32 %66, ptr %72, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %46
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %5, align 4, !tbaa !5
  br label %37, !llvm.loop !11

76:                                               ; preds = %45
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %3, align 4, !tbaa !5
  br label %32, !llvm.loop !12

80:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 -1, ptr %8, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %104, %80
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = load i32, ptr @n, align 4, !tbaa !5
  %84 = icmp sle i32 %82, %83
  br i1 %84, label %86, label %85

85:                                               ; preds = %81
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %107

86:                                               ; preds = %81
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = icmp eq i32 %87, %88
  br i1 %89, label %90, label %98

90:                                               ; preds = %86
  %91 = load i32, ptr %8, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %8, align 4, !tbaa !5
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [50002 x i32], ptr @Log, i64 0, i64 %94
  store i32 %92, ptr %95, align 4, !tbaa !5
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = shl i32 %96, 1
  store i32 %97, ptr %7, align 4, !tbaa !5
  br label %103

98:                                               ; preds = %86
  %99 = load i32, ptr %8, align 4, !tbaa !5
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [50002 x i32], ptr @Log, i64 0, i64 %101
  store i32 %99, ptr %102, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %98, %90
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %6, align 4, !tbaa !5
  br label %81, !llvm.loop !13

107:                                              ; preds = %85
  %108 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m)
  br label %109

109:                                              ; preds = %239, %107
  %110 = load i32, ptr @m, align 4, !tbaa !5
  %111 = add nsw i32 %110, -1
  store i32 %111, ptr @m, align 4, !tbaa !5
  %112 = icmp ne i32 %110, 0
  br i1 %112, label %113, label %240

113:                                              ; preds = %109
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %114 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %9, ptr noundef %10)
  %115 = load i32, ptr @n, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds i32, ptr @year, i64 %116
  %118 = getelementptr inbounds i32, ptr %117, i64 1
  %119 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef getelementptr inbounds (i32, ptr @year, i64 1), ptr noundef %118, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %120 = ptrtoint ptr %119 to i64
  %121 = sub i64 %120, ptrtoint (ptr @year to i64)
  %122 = sdiv exact i64 %121, 4
  %123 = trunc i64 %122 to i32
  store i32 %123, ptr %11, align 4, !tbaa !5
  %124 = load i32, ptr @n, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds i32, ptr @year, i64 %125
  %127 = getelementptr inbounds i32, ptr %126, i64 1
  %128 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef getelementptr inbounds (i32, ptr @year, i64 1), ptr noundef %127, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %129 = ptrtoint ptr %128 to i64
  %130 = sub i64 %129, ptrtoint (ptr @year to i64)
  %131 = sdiv exact i64 %130, 4
  %132 = trunc i64 %131 to i32
  store i32 %132, ptr %12, align 4, !tbaa !5
  %133 = load i32, ptr %11, align 4, !tbaa !5
  %134 = load i32, ptr @n, align 4, !tbaa !5
  %135 = icmp sle i32 %133, %134
  br i1 %135, label %136, label %212

136:                                              ; preds = %113
  %137 = load i32, ptr %11, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [50002 x i32], ptr @year, i64 0, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = icmp eq i32 %140, %141
  br i1 %142, label %143, label %212

143:                                              ; preds = %136
  %144 = load i32, ptr %12, align 4, !tbaa !5
  %145 = load i32, ptr @n, align 4, !tbaa !5
  %146 = icmp sle i32 %144, %145
  br i1 %146, label %147, label %194

147:                                              ; preds = %143
  %148 = load i32, ptr %12, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [50002 x i32], ptr @year, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = load i32, ptr %10, align 4, !tbaa !5
  %153 = icmp eq i32 %151, %152
  br i1 %153, label %154, label %194

154:                                              ; preds = %147
  %155 = load i32, ptr %11, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %156
  %158 = getelementptr inbounds [19 x i32], ptr %157, i64 0, i64 0
  %159 = load i32, ptr %158, align 4, !tbaa !5
  %160 = load i32, ptr %12, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %161
  %163 = getelementptr inbounds [19 x i32], ptr %162, i64 0, i64 0
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = icmp sge i32 %159, %164
  br i1 %165, label %166, label %191

166:                                              ; preds = %154
  %167 = load i32, ptr %11, align 4, !tbaa !5
  %168 = add nsw i32 %167, 1
  %169 = load i32, ptr %12, align 4, !tbaa !5
  %170 = sub nsw i32 %169, 1
  %171 = call noundef i32 @_Z5queryii(i32 noundef %168, i32 noundef %170)
  %172 = load i32, ptr %12, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %173
  %175 = getelementptr inbounds [19 x i32], ptr %174, i64 0, i64 0
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = icmp slt i32 %171, %176
  br i1 %177, label %178, label %191

178:                                              ; preds = %166
  %179 = load i32, ptr %12, align 4, !tbaa !5
  %180 = load i32, ptr %11, align 4, !tbaa !5
  %181 = sub nsw i32 %179, %180
  %182 = load i32, ptr %10, align 4, !tbaa !5
  %183 = load i32, ptr %9, align 4, !tbaa !5
  %184 = sub nsw i32 %182, %183
  %185 = icmp eq i32 %181, %184
  br i1 %185, label %186, label %188

186:                                              ; preds = %178
  %187 = call i32 @puts(ptr noundef @.str.2)
  br label %190

188:                                              ; preds = %178
  %189 = call i32 @puts(ptr noundef @.str.3)
  br label %190

190:                                              ; preds = %188, %186
  br label %193

191:                                              ; preds = %166, %154
  %192 = call i32 @puts(ptr noundef @.str.4)
  br label %193

193:                                              ; preds = %191, %190
  br label %211

194:                                              ; preds = %147, %143
  %195 = load i32, ptr %11, align 4, !tbaa !5
  %196 = add nsw i32 %195, 1
  %197 = load i32, ptr %12, align 4, !tbaa !5
  %198 = sub nsw i32 %197, 1
  %199 = call noundef i32 @_Z5queryii(i32 noundef %196, i32 noundef %198)
  %200 = load i32, ptr %11, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %201
  %203 = getelementptr inbounds [19 x i32], ptr %202, i64 0, i64 0
  %204 = load i32, ptr %203, align 4, !tbaa !5
  %205 = icmp slt i32 %199, %204
  br i1 %205, label %206, label %208

206:                                              ; preds = %194
  %207 = call i32 @puts(ptr noundef @.str.3)
  br label %210

208:                                              ; preds = %194
  %209 = call i32 @puts(ptr noundef @.str.4)
  br label %210

210:                                              ; preds = %208, %206
  br label %211

211:                                              ; preds = %210, %193
  br label %239

212:                                              ; preds = %136, %113
  %213 = load i32, ptr %12, align 4, !tbaa !5
  %214 = load i32, ptr @n, align 4, !tbaa !5
  %215 = icmp sle i32 %213, %214
  br i1 %215, label %216, label %236

216:                                              ; preds = %212
  %217 = load i32, ptr %12, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [50002 x i32], ptr @year, i64 0, i64 %218
  %220 = load i32, ptr %219, align 4, !tbaa !5
  %221 = load i32, ptr %10, align 4, !tbaa !5
  %222 = icmp eq i32 %220, %221
  br i1 %222, label %223, label %236

223:                                              ; preds = %216
  %224 = load i32, ptr %11, align 4, !tbaa !5
  %225 = load i32, ptr %12, align 4, !tbaa !5
  %226 = sub nsw i32 %225, 1
  %227 = call noundef i32 @_Z5queryii(i32 noundef %224, i32 noundef %226)
  %228 = load i32, ptr %12, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %229
  %231 = getelementptr inbounds [19 x i32], ptr %230, i64 0, i64 0
  %232 = load i32, ptr %231, align 4, !tbaa !5
  %233 = icmp sge i32 %227, %232
  br i1 %233, label %234, label %236

234:                                              ; preds = %223
  %235 = call i32 @puts(ptr noundef @.str.4)
  br label %238

236:                                              ; preds = %223, %216, %212
  %237 = call i32 @puts(ptr noundef @.str.3)
  br label %238

238:                                              ; preds = %236, %234
  br label %239

239:                                              ; preds = %238, %211
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %109, !llvm.loop !14

240:                                              ; preds = %109
  ret i32 0
}

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

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

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

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

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5queryii(i32 noundef, i32 noundef) #3

declare i32 @puts(ptr noundef) #1

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

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

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

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

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

.preheader64.preheader:                           ; preds = %.lr.ph, %0
  %.ph = phi i32 [ %4, %0 ], [ %8, %.lr.ph ]
  br label %.preheader64

.preheader64:                                     ; preds = %.preheader64.preheader, %._crit_edge
  %10 = phi i32 [ %20, %._crit_edge ], [ %.ph, %.preheader64.preheader ]
  %indvars.iv87 = phi i64 [ %indvars.iv.next88, %._crit_edge ], [ 1, %.preheader64.preheader ]
  %11 = trunc nuw nsw i64 %indvars.iv87 to i32
  %.neg = shl nsw i32 -1, %11
  %12 = add nsw i32 %.neg, 1
  %13 = add i32 %12, %10
  %.not6368 = icmp slt i32 %13, 1
  br i1 %.not6368, label %._crit_edge, label %.lr.ph70

.lr.ph70:                                         ; preds = %.preheader64
  %14 = add nsw i64 %indvars.iv87, -1
  %15 = trunc nuw nsw i64 %14 to i32
  %16 = shl nuw nsw i32 1, %15
  %17 = zext nneg i32 %16 to i64
  br label %21

.preheader:                                       ; preds = %._crit_edge
  %.not5472 = icmp slt i32 %20, 1
  br i1 %.not5472, label %._crit_edge77, label %.lr.ph76.preheader

.lr.ph76.preheader:                               ; preds = %.preheader
  %18 = zext nneg i32 %20 to i64
  %xtraiter = and i64 %18, 1
  %19 = icmp eq i32 %20, 1
  br i1 %19, label %._crit_edge77.loopexit.unr-lcssa, label %.lr.ph76.preheader.new

.lr.ph76.preheader.new:                           ; preds = %.lr.ph76.preheader
  %unroll_iter = and i64 %18, 2147483646
  br label %.lr.ph76

._crit_edge:                                      ; preds = %21, %.preheader64
  %20 = phi i32 [ %10, %.preheader64 ], [ %28, %21 ]
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next88, 19
  br i1 %exitcond.not, label %.preheader, label %.preheader64, !llvm.loop !11

21:                                               ; preds = %.lr.ph70, %21
  %indvars.iv84 = phi i64 [ 1, %.lr.ph70 ], [ %indvars.iv.next85, %21 ]
  %22 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %indvars.iv84, i64 %14
  %23 = add nuw nsw i64 %indvars.iv84, %17
  %24 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %23, i64 %14
  %25 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %22, ptr noundef nonnull align 4 dereferenceable(4) %24)
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %indvars.iv84, i64 %indvars.iv87
  store i32 %26, ptr %27, align 4, !tbaa !5
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = add i32 %12, %28
  %30 = sext i32 %29 to i64
  %.not63.not = icmp slt i64 %indvars.iv84, %30
  br i1 %.not63.not, label %21, label %._crit_edge, !llvm.loop !12

._crit_edge77.loopexit.unr-lcssa.loopexit:        ; preds = %.lr.ph76
  %31 = zext i32 %.147.1 to i64
  br label %._crit_edge77.loopexit.unr-lcssa

._crit_edge77.loopexit.unr-lcssa:                 ; preds = %._crit_edge77.loopexit.unr-lcssa.loopexit, %.lr.ph76.preheader
  %indvars.iv90.unr = phi i64 [ 1, %.lr.ph76.preheader ], [ %indvars.iv.next91.1, %._crit_edge77.loopexit.unr-lcssa.loopexit ]
  %.04575.unr = phi i32 [ -1, %.lr.ph76.preheader ], [ %.04575.sink.1, %._crit_edge77.loopexit.unr-lcssa.loopexit ]
  %.04674.unr = phi i64 [ 1, %.lr.ph76.preheader ], [ %31, %._crit_edge77.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge77, label %.lr.ph76.epil

.lr.ph76.epil:                                    ; preds = %._crit_edge77.loopexit.unr-lcssa
  %32 = icmp eq i64 %indvars.iv90.unr, %.04674.unr
  %33 = zext i1 %32 to i32
  %.04575.sink.epil = add nsw i32 %.04575.unr, %33
  %34 = getelementptr inbounds [50002 x i32], ptr @Log, i64 0, i64 %indvars.iv90.unr
  store i32 %.04575.sink.epil, ptr %34, align 4
  br label %._crit_edge77

._crit_edge77:                                    ; preds = %.lr.ph76.epil, %._crit_edge77.loopexit.unr-lcssa, %.preheader
  %35 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m)
  %36 = load i32, ptr @m, align 4, !tbaa !5
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr @m, align 4, !tbaa !5
  %.not5579 = icmp eq i32 %36, 0
  br i1 %.not5579, label %._crit_edge82, label %.lr.ph81

.lr.ph76:                                         ; preds = %.lr.ph76, %.lr.ph76.preheader.new
  %indvars.iv90 = phi i64 [ 1, %.lr.ph76.preheader.new ], [ %indvars.iv.next91.1, %.lr.ph76 ]
  %.04575 = phi i32 [ -1, %.lr.ph76.preheader.new ], [ %.04575.sink.1, %.lr.ph76 ]
  %.04674 = phi i32 [ 1, %.lr.ph76.preheader.new ], [ %.147.1, %.lr.ph76 ]
  %niter = phi i64 [ 0, %.lr.ph76.preheader.new ], [ %niter.next.1, %.lr.ph76 ]
  %38 = zext i32 %.04674 to i64
  %39 = icmp eq i64 %indvars.iv90, %38
  %40 = zext i1 %39 to i32
  %.04575.sink = add nsw i32 %.04575, %40
  %41 = zext i1 %39 to i32
  %.147 = shl i32 %.04674, %41
  %42 = getelementptr inbounds [50002 x i32], ptr @Log, i64 0, i64 %indvars.iv90
  store i32 %.04575.sink, ptr %42, align 4
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %43 = zext i32 %.147 to i64
  %44 = icmp eq i64 %indvars.iv.next91, %43
  %45 = zext i1 %44 to i32
  %.04575.sink.1 = add nsw i32 %.04575.sink, %45
  %46 = zext i1 %44 to i32
  %.147.1 = shl i32 %.147, %46
  %47 = getelementptr inbounds [50002 x i32], ptr @Log, i64 0, i64 %indvars.iv.next91
  store i32 %.04575.sink.1, ptr %47, align 4
  %indvars.iv.next91.1 = add nuw nsw i64 %indvars.iv90, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge77.loopexit.unr-lcssa.loopexit, label %.lr.ph76, !llvm.loop !13

.lr.ph81:                                         ; preds = %._crit_edge77, %114
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %48 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @year, i64 4), i64 %50
  %51 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @year, i64 4), ptr noundef nonnull %gep, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %52 = ptrtoint ptr %51 to i64
  %53 = sub i64 %52, ptrtoint (ptr @year to i64)
  %54 = lshr exact i64 %53, 2
  %55 = trunc i64 %54 to i32
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %gep78 = getelementptr i32, ptr getelementptr inbounds (i8, ptr @year, i64 4), i64 %57
  %58 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @year, i64 4), ptr noundef nonnull %gep78, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %59 = ptrtoint ptr %58 to i64
  %60 = sub i64 %59, ptrtoint (ptr @year to i64)
  %61 = lshr exact i64 %60, 2
  %62 = trunc i64 %61 to i32
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %.not56 = icmp slt i32 %63, %55
  br i1 %.not56, label %101, label %64

64:                                               ; preds = %.lr.ph81
  %sext = shl i64 %53, 30
  %65 = ashr i64 %sext, 32
  %66 = getelementptr inbounds [50002 x i32], ptr @year, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = load i32, ptr %1, align 4, !tbaa !5
  %69 = icmp eq i32 %67, %68
  br i1 %69, label %70, label %101

70:                                               ; preds = %64
  %.not60 = icmp slt i32 %63, %62
  br i1 %.not60, label %94, label %71

71:                                               ; preds = %70
  %sext61 = shl i64 %60, 30
  %72 = ashr i64 %sext61, 32
  %73 = getelementptr inbounds [50002 x i32], ptr @year, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = load i32, ptr %2, align 4, !tbaa !5
  %76 = icmp eq i32 %74, %75
  br i1 %76, label %77, label %94

77:                                               ; preds = %71
  %78 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %65
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %72
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %.not62 = icmp slt i32 %79, %81
  br i1 %.not62, label %114, label %82

82:                                               ; preds = %77
  %83 = add nsw i32 %55, 1
  %84 = add nsw i32 %62, -1
  %85 = call noundef i32 @_Z5queryii(i32 noundef %83, i32 noundef %84)
  %86 = load i32, ptr %80, align 4, !tbaa !5
  %87 = icmp slt i32 %85, %86
  br i1 %87, label %88, label %114

88:                                               ; preds = %82
  %89 = sub nsw i32 %62, %55
  %90 = load i32, ptr %2, align 4, !tbaa !5
  %91 = load i32, ptr %1, align 4, !tbaa !5
  %92 = sub nsw i32 %90, %91
  %93 = icmp eq i32 %89, %92
  %.str.2..str.3 = select i1 %93, ptr @.str.2, ptr @.str.3
  br label %114

94:                                               ; preds = %71, %70
  %95 = add nsw i32 %55, 1
  %96 = add nsw i32 %62, -1
  %97 = call noundef i32 @_Z5queryii(i32 noundef %95, i32 noundef %96)
  %98 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %65
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = icmp slt i32 %97, %99
  %.str.3..str.4 = select i1 %100, ptr @.str.3, ptr @.str.4
  br label %114

101:                                              ; preds = %64, %.lr.ph81
  %.not57 = icmp slt i32 %63, %62
  br i1 %.not57, label %113, label %102

102:                                              ; preds = %101
  %sext58 = shl i64 %60, 30
  %103 = ashr i64 %sext58, 32
  %104 = getelementptr inbounds [50002 x i32], ptr @year, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = load i32, ptr %2, align 4, !tbaa !5
  %107 = icmp eq i32 %105, %106
  br i1 %107, label %108, label %113

108:                                              ; preds = %102
  %109 = add nsw i32 %62, -1
  %110 = call noundef i32 @_Z5queryii(i32 noundef %55, i32 noundef %109)
  %111 = getelementptr inbounds [50002 x [19 x i32]], ptr @st, i64 0, i64 %103
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %.not59 = icmp slt i32 %110, %112
  br i1 %.not59, label %113, label %114

113:                                              ; preds = %108, %102, %101
  br label %114

114:                                              ; preds = %108, %94, %77, %82, %88, %113
  %.str.4.sink = phi ptr [ @.str.3, %113 ], [ %.str.2..str.3, %88 ], [ @.str.4, %82 ], [ @.str.4, %77 ], [ %.str.3..str.4, %94 ], [ @.str.4, %108 ]
  %115 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.4.sink)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %116 = load i32, ptr @m, align 4, !tbaa !5
  %117 = add nsw i32 %116, -1
  store i32 %117, ptr @m, align 4, !tbaa !5
  %.not55 = icmp eq i32 %116, 0
  br i1 %.not55, label %._crit_edge82, label %.lr.ph81, !llvm.loop !14

._crit_edge82:                                    ; preds = %114, %._crit_edge77
  ret i32 0
}

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

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5queryii(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #1

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

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

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


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