; LLVM IR from tangjz/acm-icpc :: codeforces/1479B1.ll (Z5solvev)

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

@_ZZ5solvevE1a = external hidden global [100009 x i32], align 16
@_ZZ5solvevE3que = external hidden global [100009 x i32], align 16
@.str = 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
define dso_local void @_Z5solvev() #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
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %1)
  store i32 0, ptr @_ZZ5solvevE1a, align 16, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %30, %0
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %33

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

30:                                               ; preds = %17
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %3, align 4, !tbaa !5
  br label %12, !llvm.loop !9

33:                                               ; preds = %16
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %34 to i64
  %37 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE3que, i64 0, i64 %36
  store i32 0, ptr %37, align 4, !tbaa !5
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %39
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @_ZZ5solvevE3que, ptr noundef %40)
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %42
  %44 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @_ZZ5solvevE3que, ptr noundef %43)
  %45 = ptrtoint ptr %44 to i64
  %46 = sub i64 %45, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %47 = sdiv exact i64 %46, 4
  %48 = trunc i64 %47 to i32
  store i32 %48, ptr %2, align 4, !tbaa !5
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  call void @_Z7segInitii(i32 noundef 0, i32 noundef %50)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %52
  %54 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @_ZZ5solvevE3que, ptr noundef %53, ptr noundef nonnull align 4 dereferenceable(4) @_ZZ5solvevE1a)
  %55 = ptrtoint ptr %54 to i64
  %56 = sub i64 %55, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %57 = sdiv exact i64 %56, 4
  %58 = trunc i64 %57 to i32
  store i32 %58, ptr @_ZZ5solvevE1a, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %167, %33
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = load i32, ptr %1, align 4, !tbaa !5
  %62 = icmp sle i32 %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %170

64:                                               ; preds = %59
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %66
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %69
  %71 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @_ZZ5solvevE3que, ptr noundef %67, ptr noundef nonnull align 4 dereferenceable(4) %70)
  %72 = ptrtoint ptr %71 to i64
  %73 = sub i64 %72, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %74 = sdiv exact i64 %73, 4
  %75 = trunc i64 %74 to i32
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %77
  store i32 %75, ptr %78, align 4, !tbaa !5
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = icmp eq i32 %79, 1
  br i1 %80, label %81, label %85

81:                                               ; preds = %64
  %82 = load i32, ptr %2, align 4, !tbaa !5
  %83 = sub nsw i32 %82, 1
  %84 = load i32, ptr @_ZZ5solvevE1a, align 16, !tbaa !5
  call void @_Z6segUpdiiii(i32 noundef 0, i32 noundef %83, i32 noundef %84, i32 noundef 1)
  br label %167

85:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %86 = load i32, ptr %5, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = sub nsw i32 %90, 1
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = icmp ne i32 %89, %94
  %96 = zext i1 %95 to i32
  store i32 %96, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 -2147483648, ptr %7, align 4, !tbaa !5
  %97 = load i32, ptr %5, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = icmp sgt i32 %100, 0
  br i1 %101, label %102, label %113

102:                                              ; preds = %85
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %103 = load i32, ptr %2, align 4, !tbaa !5
  %104 = sub nsw i32 %103, 1
  %105 = load i32, ptr %5, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = sub nsw i32 %108, 1
  %110 = call noundef i32 @_Z6segQueiiii(i32 noundef 0, i32 noundef %104, i32 noundef 0, i32 noundef %109)
  store i32 %110, ptr %8, align 4, !tbaa !5
  %111 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %112 = load i32, ptr %111, align 4, !tbaa !5
  store i32 %112, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %113

113:                                              ; preds = %102, %85
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = load i32, ptr %2, align 4, !tbaa !5
  %119 = sub nsw i32 %118, 1
  %120 = icmp slt i32 %117, %119
  br i1 %120, label %121, label %134

121:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %122 = load i32, ptr %2, align 4, !tbaa !5
  %123 = sub nsw i32 %122, 1
  %124 = load i32, ptr %5, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = add nsw i32 %127, 1
  %129 = load i32, ptr %2, align 4, !tbaa !5
  %130 = sub nsw i32 %129, 1
  %131 = call noundef i32 @_Z6segQueiiii(i32 noundef 0, i32 noundef %123, i32 noundef %128, i32 noundef %130)
  store i32 %131, ptr %9, align 4, !tbaa !5
  %132 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %133 = load i32, ptr %132, align 4, !tbaa !5
  store i32 %133, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %134

134:                                              ; preds = %121, %113
  %135 = load i32, ptr %7, align 4, !tbaa !5
  %136 = icmp ne i32 %135, -2147483648
  br i1 %136, label %137, label %140

137:                                              ; preds = %134
  %138 = load i32, ptr %7, align 4, !tbaa !5
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %7, align 4, !tbaa !5
  br label %140

140:                                              ; preds = %137, %134
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %141 = load i32, ptr %2, align 4, !tbaa !5
  %142 = sub nsw i32 %141, 1
  %143 = load i32, ptr %5, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = load i32, ptr %5, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = call noundef i32 @_Z6segQueiiii(i32 noundef 0, i32 noundef %142, i32 noundef %146, i32 noundef %150)
  store i32 %151, ptr %10, align 4, !tbaa !5
  %152 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %153 = load i32, ptr %152, align 4, !tbaa !5
  store i32 %153, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %154 = load i32, ptr %2, align 4, !tbaa !5
  %155 = sub nsw i32 %154, 1
  %156 = load i32, ptr %5, align 4, !tbaa !5
  %157 = sub nsw i32 %156, 1
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = load i32, ptr %7, align 4, !tbaa !5
  %162 = load i32, ptr %6, align 4, !tbaa !5
  %163 = sub nsw i32 %161, %162
  call void @_Z6segUpdiiii(i32 noundef 0, i32 noundef %155, i32 noundef %160, i32 noundef %163)
  %164 = load i32, ptr %6, align 4, !tbaa !5
  %165 = load i32, ptr %4, align 4, !tbaa !5
  %166 = add nsw i32 %165, %164
  store i32 %166, ptr %4, align 4, !tbaa !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 %167

167:                                              ; preds = %140, %81
  %168 = load i32, ptr %5, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %5, align 4, !tbaa !5
  br label %59, !llvm.loop !11

170:                                              ; preds = %63
  %171 = load i32, ptr %2, align 4, !tbaa !5
  %172 = sub nsw i32 %171, 1
  %173 = load i32, ptr %2, align 4, !tbaa !5
  %174 = sub nsw i32 %173, 1
  %175 = call noundef i32 @_Z6segQueiiii(i32 noundef 0, i32 noundef %172, i32 noundef 0, i32 noundef %174)
  %176 = load i32, ptr %4, align 4, !tbaa !5
  %177 = add nsw i32 %175, %176
  %178 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %177)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret void
}

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z7segInitii(i32 noundef, i32 noundef) #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)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z6segUpdiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

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

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

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

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 = { "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 = { 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 #4 = { 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 #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}


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

@_ZZ5solvevE1a = external hidden global [100009 x i32], align 16
@_ZZ5solvevE3que = external hidden global [100009 x i32], align 16
@.str = 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
define dso_local void @_Z5solvev() local_unnamed_addr #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
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  store i32 0, ptr @_ZZ5solvevE1a, align 16, !tbaa !5
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %.not45 = icmp slt i32 %7, 1
  br i1 %.not45, label %._crit_edge, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %8 = and i64 %indvars.iv.next, 4294967295
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %.0.lcssa = phi i64 [ 0, %0 ], [ %8, %._crit_edge.loopexit ]
  %9 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE3que, i64 0, i64 %.0.lcssa
  store i32 0, ptr %9, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @_ZZ5solvevE3que, ptr noundef nonnull %10)
  %11 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @_ZZ5solvevE3que, ptr noundef nonnull %10)
  %12 = ptrtoint ptr %11 to i64
  %13 = sub i64 %12, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %14 = lshr exact i64 %13, 2
  %15 = trunc i64 %14 to i32
  %16 = add nsw i32 %15, -1
  call void @_Z7segInitii(i32 noundef 0, i32 noundef %16)
  %sext = shl i64 %13, 30
  %17 = ashr i64 %sext, 32
  %18 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %17
  %19 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @_ZZ5solvevE3que, ptr noundef nonnull %18, ptr noundef nonnull align 4 dereferenceable(4) @_ZZ5solvevE1a)
  %20 = ptrtoint ptr %19 to i64
  %21 = sub i64 %20, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %22 = lshr exact i64 %21, 2
  %23 = trunc i64 %22 to i32
  store i32 %23, ptr @_ZZ5solvevE1a, align 16, !tbaa !5
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %.not4348 = icmp slt i32 %24, 1
  br i1 %.not4348, label %._crit_edge53, label %25

25:                                               ; preds = %._crit_edge
  %26 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @_ZZ5solvevE3que, ptr noundef nonnull %18, ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @_ZZ5solvevE1a, i64 4))
  %27 = ptrtoint ptr %26 to i64
  %28 = sub i64 %27, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %29 = lshr exact i64 %28, 2
  %30 = trunc i64 %29 to i32
  store i32 %30, ptr getelementptr inbounds (i8, ptr @_ZZ5solvevE1a, i64 4), align 4, !tbaa !5
  %31 = load i32, ptr @_ZZ5solvevE1a, align 16, !tbaa !5
  call void @_Z6segUpdiiii(i32 noundef 0, i32 noundef %16, i32 noundef %31, i32 noundef 1)
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  %.not43.not.peel = icmp sgt i32 %.pre, 1
  br i1 %.not43.not.peel, label %.lr.ph52.peel.next, label %._crit_edge53

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv55 = phi i64 [ %indvars.iv.next56, %.lr.ph ], [ 1, %0 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %32 = getelementptr inbounds i32, ptr @_ZZ5solvevE1a, i64 %indvars.iv55
  %33 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %32)
  %34 = load i32, ptr %32, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %35 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE3que, i64 0, i64 %indvars.iv
  store i32 %34, ptr %35, align 4, !tbaa !5
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %36 = load i32, ptr %1, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %.not.not = icmp slt i64 %indvars.iv55, %37
  br i1 %.not.not, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !9

._crit_edge53:                                    ; preds = %69, %25, %._crit_edge
  %.039.lcssa = phi i32 [ 0, %._crit_edge ], [ 0, %25 ], [ %76, %69 ]
  %38 = call noundef i32 @_Z6segQueiiii(i32 noundef 0, i32 noundef %16, i32 noundef 0, i32 noundef %16)
  %39 = add nsw i32 %38, %.039.lcssa
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %39)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret void

.lr.ph52.peel.next:                               ; preds = %25, %69
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %69 ], [ 2, %25 ]
  %.03949 = phi i32 [ %76, %69 ], [ 0, %25 ]
  %41 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %indvars.iv60
  %42 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @_ZZ5solvevE3que, ptr noundef nonnull %18, ptr noundef nonnull align 4 dereferenceable(4) %41)
  %43 = ptrtoint ptr %42 to i64
  %44 = sub i64 %43, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %45 = lshr exact i64 %44, 2
  %46 = trunc i64 %45 to i32
  store i32 %46, ptr %41, align 4, !tbaa !5
  %47 = add nsw i64 %indvars.iv60, -1
  %48 = getelementptr inbounds [100009 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = icmp ne i32 %49, %46
  %51 = zext i1 %50 to i32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 -2147483648, ptr %2, align 4, !tbaa !5
  %52 = icmp sgt i32 %46, 0
  br i1 %52, label %53, label %58

53:                                               ; preds = %.lr.ph52.peel.next
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %54 = add nsw i32 %46, -1
  %55 = call noundef i32 @_Z6segQueiiii(i32 noundef 0, i32 noundef %16, i32 noundef 0, i32 noundef %54)
  store i32 %55, ptr %3, align 4, !tbaa !5
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %57 = load i32, ptr %56, align 4, !tbaa !5
  store i32 %57, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %.pre64 = load i32, ptr %41, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %53, %.lr.ph52.peel.next
  %.pr = phi i32 [ %57, %53 ], [ -2147483648, %.lr.ph52.peel.next ]
  %59 = phi i32 [ %.pre64, %53 ], [ %46, %.lr.ph52.peel.next ]
  %60 = icmp slt i32 %59, %16
  br i1 %60, label %61, label %thread-pre-split

61:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %62 = add nsw i32 %59, 1
  %63 = call noundef i32 @_Z6segQueiiii(i32 noundef 0, i32 noundef %16, i32 noundef %62, i32 noundef %16)
  store i32 %63, ptr %4, align 4, !tbaa !5
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %65 = load i32, ptr %64, align 4, !tbaa !5
  store i32 %65, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %58, %61
  %66 = phi i32 [ %65, %61 ], [ %.pr, %58 ]
  %.not44 = icmp eq i32 %66, -2147483648
  br i1 %.not44, label %69, label %67

67:                                               ; preds = %thread-pre-split
  %68 = add nsw i32 %66, 1
  store i32 %68, ptr %2, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %thread-pre-split, %67
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  %70 = load i32, ptr %41, align 4, !tbaa !5
  %71 = call noundef i32 @_Z6segQueiiii(i32 noundef 0, i32 noundef %16, i32 noundef %70, i32 noundef %70)
  store i32 %71, ptr %5, align 4, !tbaa !5
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %73 = load i32, ptr %72, align 4, !tbaa !5
  store i32 %73, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  %74 = load i32, ptr %48, align 4, !tbaa !5
  %75 = sub nsw i32 %73, %51
  call void @_Z6segUpdiiii(i32 noundef 0, i32 noundef %16, i32 noundef %74, i32 noundef %75)
  %76 = add nuw nsw i32 %.03949, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %.pre66 = load i32, ptr %1, align 4, !tbaa !5
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %77 = sext i32 %.pre66 to i64
  %.not43.not = icmp slt i64 %indvars.iv60, %77
  br i1 %.not43.not, label %.lr.ph52.peel.next, label %._crit_edge53, !llvm.loop !11
}

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z7segInitii(i32 noundef, i32 noundef) 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 #3

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

; 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 #4

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

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

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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { 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 #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}
!12 = !{!"llvm.loop.peeled.count", i32 1}


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