; LLVM IR from tangjz/acm-icpc :: hdu/5406.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"

%"struct.std::pair" = type { i32, i32 }

@_ZZ5solvevE3que = external hidden global [1001 x i32], align 16
@_ZZ5solvevE1f = external hidden global [2 x [1001 x i32]], align 16
@_ZZ5solvevE1a = external hidden global [1001 x %"struct.std::pair"], 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 [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 [2 x 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.memset.p0.i64(ptr align 4 %3, i8 0, i64 8, i1 false)
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %44, %0
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %47

16:                                               ; preds = %11
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [1001 x %"struct.std::pair"], ptr @_ZZ5solvevE1a, i64 0, i64 %18
  %20 = getelementptr inbounds %"struct.std::pair", ptr %19, i32 0, i32 0
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1001 x %"struct.std::pair"], ptr @_ZZ5solvevE1a, i64 0, i64 %22
  %24 = getelementptr inbounds %"struct.std::pair", ptr %23, i32 0, i32 1
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %20, ptr noundef %24)
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1001 x %"struct.std::pair"], ptr @_ZZ5solvevE1a, i64 0, i64 %27
  %29 = getelementptr inbounds %"struct.std::pair", ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !9
  %31 = sub nsw i32 0, %30
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [1001 x %"struct.std::pair"], ptr @_ZZ5solvevE1a, i64 0, i64 %33
  %35 = getelementptr inbounds %"struct.std::pair", ptr %34, i32 0, i32 0
  store i32 %31, ptr %35, align 8, !tbaa !9
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [1001 x %"struct.std::pair"], ptr @_ZZ5solvevE1a, i64 0, i64 %37
  %39 = getelementptr inbounds %"struct.std::pair", ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3que, i64 0, i64 %42
  store i32 %40, ptr %43, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %16
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %4, align 4, !tbaa !5
  br label %11, !llvm.loop !12

47:                                               ; preds = %15
  %48 = load i32, ptr %1, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds %"struct.std::pair", ptr @_ZZ5solvevE1a, i64 %49
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef @_ZZ5solvevE1a, ptr noundef %50)
  %51 = load i32, ptr %1, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %52
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @_ZZ5solvevE3que, ptr noundef %53)
  %54 = load i32, ptr %1, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %55
  %57 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @_ZZ5solvevE3que, ptr noundef %56)
  %58 = ptrtoint ptr %57 to i64
  %59 = sub i64 %58, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %60 = sdiv exact i64 %59, 4
  %61 = trunc i64 %60 to i32
  store i32 %61, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %142, %47
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = load i32, ptr %1, align 4, !tbaa !5
  %65 = icmp slt i32 %63, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %145

67:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %69
  %71 = load i32, ptr %5, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1001 x %"struct.std::pair"], ptr @_ZZ5solvevE1a, i64 0, i64 %72
  %74 = getelementptr inbounds %"struct.std::pair", ptr %73, i32 0, i32 1
  %75 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @_ZZ5solvevE3que, ptr noundef %70, ptr noundef nonnull align 4 dereferenceable(4) %74)
  %76 = ptrtoint ptr %75 to i64
  %77 = sub i64 %76, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %78 = sdiv exact i64 %77, 4
  %79 = trunc i64 %78 to i32
  store i32 %79, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %137, %67
  %81 = load i32, ptr %8, align 4, !tbaa !5
  %82 = icmp slt i32 %81, 2
  br i1 %82, label %84, label %83

83:                                               ; preds = %80
  store i32 8, ptr %6, align 4
  br label %140

84:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %85 = load i32, ptr %8, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2 x [1001 x i32]], ptr @_ZZ5solvevE1f, i64 0, i64 %86
  %88 = getelementptr inbounds [1001 x i32], ptr %87, i64 0, i64 0
  %89 = load i32, ptr %8, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [2 x [1001 x i32]], ptr @_ZZ5solvevE1f, i64 0, i64 %90
  %92 = getelementptr inbounds [1001 x i32], ptr %91, i64 0, i64 0
  %93 = load i32, ptr %8, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i32, ptr %92, i64 %97
  %99 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef %88, ptr noundef %98, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %100 = load i32, ptr %8, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [2 x [1001 x i32]], ptr @_ZZ5solvevE1f, i64 0, i64 %101
  %103 = getelementptr inbounds [1001 x i32], ptr %102, i64 0, i64 0
  %104 = ptrtoint ptr %99 to i64
  %105 = ptrtoint ptr %103 to i64
  %106 = sub i64 %104, %105
  %107 = sdiv exact i64 %106, 4
  %108 = trunc i64 %107 to i32
  store i32 %108, ptr %9, align 4, !tbaa !5
  %109 = load i32, ptr %9, align 4, !tbaa !5
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = icmp eq i32 %109, %113
  br i1 %114, label %115, label %127

115:                                              ; preds = %84
  %116 = load i32, ptr %7, align 4, !tbaa !5
  %117 = load i32, ptr %8, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [2 x [1001 x i32]], ptr @_ZZ5solvevE1f, i64 0, i64 %118
  %120 = load i32, ptr %8, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %122, align 4, !tbaa !5
  %125 = sext i32 %123 to i64
  %126 = getelementptr inbounds [1001 x i32], ptr %119, i64 0, i64 %125
  store i32 %116, ptr %126, align 4, !tbaa !5
  store i32 8, ptr %6, align 4
  br label %134

127:                                              ; preds = %84
  %128 = load i32, ptr %8, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [2 x [1001 x i32]], ptr @_ZZ5solvevE1f, i64 0, i64 %129
  %131 = load i32, ptr %9, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [1001 x i32], ptr %130, i64 0, i64 %132
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %133, ptr noundef nonnull align 4 dereferenceable(4) %7) #6
  store i32 0, ptr %6, align 4
  br label %134

134:                                              ; preds = %127, %115
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  %135 = load i32, ptr %6, align 4
  switch i32 %135, label %140 [
    i32 0, label %136
  ]

136:                                              ; preds = %134
  br label %137

137:                                              ; preds = %136
  %138 = load i32, ptr %8, align 4, !tbaa !5
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %8, align 4, !tbaa !5
  br label %80, !llvm.loop !14

140:                                              ; preds = %134, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %141

141:                                              ; preds = %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %142

142:                                              ; preds = %141
  %143 = load i32, ptr %5, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %5, align 4, !tbaa !5
  br label %62, !llvm.loop !15

145:                                              ; preds = %66
  %146 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 0
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 1
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = add nsw i32 %147, %149
  %151 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %150)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; 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 @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef, ptr noundef) #4

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

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

; Function Attrs: 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 uwtable
declare dso_local noundef ptr @_ZSt11upper_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 void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #5

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

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

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.std::pair" = type { i32, i32 }

@_ZZ5solvevE3que = external hidden global [1001 x i32], align 16
@_ZZ5solvevE1f = external hidden global [2 x [1001 x i32]], align 16
@_ZZ5solvevE1a = external hidden global [1001 x %"struct.std::pair"], 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 [4 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %.sroa.0 = alloca i32, align 4
  %.sroa.6 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %.sroa.0)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %.sroa.6)
  store i32 0, ptr %.sroa.0, align 4
  store i32 0, ptr %.sroa.6, align 4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = sext i32 %4 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %28, %.lr.ph ]
  %6 = getelementptr inbounds %"struct.std::pair", ptr @_ZZ5solvevE1a, i64 %.pre-phi
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull @_ZZ5solvevE1a, ptr noundef nonnull %6)
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %8
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @_ZZ5solvevE3que, ptr noundef nonnull %9)
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %11
  %13 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @_ZZ5solvevE3que, ptr noundef nonnull %12)
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph41, label %._crit_edge42

.lr.ph41:                                         ; preds = %._crit_edge
  %16 = ptrtoint ptr %13 to i64
  %17 = sub i64 %16, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %sext = shl i64 %17, 30
  %18 = ashr i64 %sext, 32
  %19 = getelementptr inbounds i32, ptr @_ZZ5solvevE3que, i64 %18
  br label %33

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %20 = getelementptr inbounds [1001 x %"struct.std::pair"], ptr @_ZZ5solvevE1a, i64 0, i64 %indvars.iv
  %21 = getelementptr inbounds i8, ptr %20, i64 4
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %20, ptr noundef nonnull %21)
  %23 = load i32, ptr %20, align 8, !tbaa !9
  %24 = sub nsw i32 0, %23
  store i32 %24, ptr %20, align 8, !tbaa !9
  %25 = load i32, ptr %21, align 4, !tbaa !11
  %26 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3que, i64 0, i64 %indvars.iv
  store i32 %25, ptr %26, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = icmp slt i64 %indvars.iv.next, %28
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge42.loopexit:                           ; preds = %.loopexit
  %.sroa.0.0..sroa.0.0..sroa.0.0..pre = load i32, ptr %.sroa.0, align 4, !tbaa !5
  %.sroa.6.0..sroa.6.0..sroa.6.4..pre = load i32, ptr %.sroa.6, align 4, !tbaa !5
  %30 = add nsw i32 %.sroa.6.0..sroa.6.0..sroa.6.4..pre, %.sroa.0.0..sroa.0.0..sroa.0.0..pre
  br label %._crit_edge42

._crit_edge42:                                    ; preds = %._crit_edge42.loopexit, %._crit_edge
  %31 = phi i32 [ %30, %._crit_edge42.loopexit ], [ 0, %._crit_edge ]
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %31)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %.sroa.0)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %.sroa.6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret void

33:                                               ; preds = %.lr.ph41, %.loopexit
  %indvars.iv53 = phi i64 [ 0, %.lr.ph41 ], [ %indvars.iv.next54, %.loopexit ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %34 = getelementptr inbounds [1001 x %"struct.std::pair"], ptr @_ZZ5solvevE1a, i64 0, i64 %indvars.iv53, i32 1
  %35 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @_ZZ5solvevE3que, ptr noundef nonnull %19, ptr noundef nonnull align 4 dereferenceable(4) %34)
  %36 = ptrtoint ptr %35 to i64
  %37 = sub i64 %36, ptrtoint (ptr @_ZZ5solvevE3que to i64)
  %38 = lshr exact i64 %37, 2
  %39 = trunc i64 %38 to i32
  store i32 %39, ptr %2, align 4, !tbaa !5
  %.sroa.0.0..sroa.0.0..sroa.0.0.57 = load i32, ptr %.sroa.0, align 4, !tbaa !5
  %40 = sext i32 %.sroa.0.0..sroa.0.0..sroa.0.0.57 to i64
  %41 = getelementptr inbounds i32, ptr @_ZZ5solvevE1f, i64 %40
  %42 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @_ZZ5solvevE1f, ptr noundef nonnull %41, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %43 = ptrtoint ptr %42 to i64
  %44 = sub i64 %43, ptrtoint (ptr @_ZZ5solvevE1f to i64)
  %45 = lshr exact i64 %44, 2
  %46 = trunc i64 %45 to i32
  %.not = icmp eq i32 %.sroa.0.0..sroa.0.0..sroa.0.0.57, %46
  br i1 %.not, label %.thread, label %50

.thread:                                          ; preds = %50, %33
  %.lcssa46.sroa.phi = phi ptr [ %.sroa.0, %33 ], [ %.sroa.6, %50 ]
  %.lcssa46 = phi i64 [ 0, %33 ], [ 1, %50 ]
  %.lcssa44 = phi i32 [ %.sroa.0.0..sroa.0.0..sroa.0.0.57, %33 ], [ %.sroa.6.0..sroa.6.0..sroa.6.4.58, %50 ]
  %.lcssa = phi i64 [ %40, %33 ], [ %53, %50 ]
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = add nsw i32 %.lcssa44, 1
  store i32 %48, ptr %.lcssa46.sroa.phi, align 4, !tbaa !5
  %49 = getelementptr inbounds [2 x [1001 x i32]], ptr @_ZZ5solvevE1f, i64 0, i64 %.lcssa46, i64 %.lcssa
  store i32 %47, ptr %49, align 4, !tbaa !5
  br label %.loopexit

50:                                               ; preds = %33
  %sext31 = shl i64 %44, 30
  %51 = ashr i64 %sext31, 32
  %52 = getelementptr inbounds [2 x [1001 x i32]], ptr @_ZZ5solvevE1f, i64 0, i64 0, i64 %51
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %52, ptr noundef nonnull align 4 dereferenceable(4) %2) #5
  %.sroa.6.0..sroa.6.0..sroa.6.4.58 = load i32, ptr %.sroa.6, align 4, !tbaa !5
  %53 = sext i32 %.sroa.6.0..sroa.6.0..sroa.6.4.58 to i64
  %54 = getelementptr inbounds i32, ptr getelementptr inbounds (i8, ptr @_ZZ5solvevE1f, i64 4004), i64 %53
  %55 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZZ5solvevE1f, i64 4004), ptr noundef nonnull %54, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %56 = ptrtoint ptr %55 to i64
  %57 = sub i64 %56, ptrtoint (ptr getelementptr inbounds (i8, ptr @_ZZ5solvevE1f, i64 4004) to i64)
  %58 = lshr exact i64 %57, 2
  %59 = trunc i64 %58 to i32
  %.not.1 = icmp eq i32 %.sroa.6.0..sroa.6.0..sroa.6.4.58, %59
  br i1 %.not.1, label %.thread, label %.loopexit.loopexit

.loopexit.loopexit:                               ; preds = %50
  %sext31.1 = shl i64 %57, 30
  %60 = ashr i64 %sext31.1, 32
  %61 = getelementptr inbounds [2 x [1001 x i32]], ptr @_ZZ5solvevE1f, i64 0, i64 1, i64 %60
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %61, ptr noundef nonnull align 4 dereferenceable(4) %2) #5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.thread
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %62 = load i32, ptr %1, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = icmp slt i64 %indvars.iv.next54, %63
  br i1 %64, label %33, label %._crit_edge42.loopexit, !llvm.loop !14
}

; 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 @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef, ptr noundef) local_unnamed_addr #3

; 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 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 noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

; 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 = !{!10, !6, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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