; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/121 Division 1/Problem B (B)

; 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 { i64, i64 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"struct.std::greater" = type { i8 }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@b = external dso_local global i64, align 8
@cur = external dso_local global i64, align 8
@a = external dso_local global [100100 x %"struct.std::pair"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 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 i64, align 8
  %4 = alloca %"struct.std::greater", align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %10 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %11 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %12 = getelementptr i8, ptr %11, i64 -24
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %13
  %15 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %14, ptr noundef null)
  %16 = load ptr, ptr @_ZSt4cerr, align 8, !tbaa !5
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr @_ZSt4cerr, i64 %18
  %20 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %19, ptr noundef null)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 4 dereferenceable(4) @k)
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @b)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %24

24:                                               ; preds = %42, %0
  %25 = load i32, ptr %2, align 4, !tbaa !8
  %26 = load i32, ptr @n, align 4, !tbaa !8
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

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

29:                                               ; preds = %24
  %30 = load i32, ptr %2, align 4, !tbaa !8
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %31
  %33 = getelementptr inbounds %"struct.std::pair", ptr %32, i32 0, i32 0
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %33)
  %35 = load i32, ptr %2, align 4, !tbaa !8
  %36 = sub nsw i32 0, %35
  %37 = sext i32 %36 to i64
  %38 = load i32, ptr %2, align 4, !tbaa !8
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %39
  %41 = getelementptr inbounds %"struct.std::pair", ptr %40, i32 0, i32 1
  store i64 %37, ptr %41, align 8, !tbaa !11
  br label %42

42:                                               ; preds = %29
  %43 = load i32, ptr %2, align 4, !tbaa !8
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %2, align 4, !tbaa !8
  br label %24, !llvm.loop !14

45:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  %46 = load i32, ptr @n, align 4, !tbaa !8
  %47 = sub nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  store i64 %48, ptr %3, align 8, !tbaa !16
  %49 = load i32, ptr @n, align 4, !tbaa !8
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %50
  %52 = getelementptr inbounds %"struct.std::pair", ptr %51, i64 -1
  call void @_ZSt4sortIPSt4pairIxxESt7greaterIS1_EEvT_S5_T0_(ptr noundef @a, ptr noundef %52)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !8
  br label %53

53:                                               ; preds = %67, %45
  %54 = load i32, ptr %5, align 4, !tbaa !8
  %55 = load i32, ptr @k, align 4, !tbaa !8
  %56 = sub nsw i32 %55, 1
  %57 = icmp slt i32 %54, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %70

59:                                               ; preds = %53
  %60 = load i32, ptr %5, align 4, !tbaa !8
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %61
  %63 = getelementptr inbounds %"struct.std::pair", ptr %62, i32 0, i32 0
  %64 = load i64, ptr %63, align 16, !tbaa !17
  %65 = load i64, ptr @cur, align 8, !tbaa !16
  %66 = add nsw i64 %65, %64
  store i64 %66, ptr @cur, align 8, !tbaa !16
  br label %67

67:                                               ; preds = %59
  %68 = load i32, ptr %5, align 4, !tbaa !8
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %5, align 4, !tbaa !8
  br label %53, !llvm.loop !18

70:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !8
  br label %71

71:                                               ; preds = %110, %70
  %72 = load i32, ptr %6, align 4, !tbaa !8
  %73 = load i32, ptr @k, align 4, !tbaa !8
  %74 = sub nsw i32 %73, 1
  %75 = icmp slt i32 %72, %74
  br i1 %75, label %77, label %76

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

77:                                               ; preds = %71
  %78 = load i64, ptr @b, align 8, !tbaa !16
  %79 = load i64, ptr @cur, align 8, !tbaa !16
  %80 = load i32, ptr %6, align 4, !tbaa !8
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %81
  %83 = getelementptr inbounds %"struct.std::pair", ptr %82, i32 0, i32 0
  %84 = load i64, ptr %83, align 16, !tbaa !17
  %85 = sub nsw i64 %79, %84
  %86 = load i32, ptr @k, align 4, !tbaa !8
  %87 = sub nsw i32 %86, 1
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %88
  %90 = getelementptr inbounds %"struct.std::pair", ptr %89, i32 0, i32 0
  %91 = load i64, ptr %90, align 16, !tbaa !17
  %92 = add nsw i64 %85, %91
  %93 = sub nsw i64 %78, %92
  %94 = load i32, ptr %6, align 4, !tbaa !8
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %95
  %97 = getelementptr inbounds %"struct.std::pair", ptr %96, i32 0, i32 0
  %98 = load i64, ptr %97, align 16, !tbaa !17
  %99 = icmp slt i64 %93, %98
  br i1 %99, label %100, label %109

100:                                              ; preds = %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %101 = load i32, ptr %6, align 4, !tbaa !8
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %102
  %104 = getelementptr inbounds %"struct.std::pair", ptr %103, i32 0, i32 1
  %105 = load i64, ptr %104, align 8, !tbaa !11
  %106 = sub nsw i64 0, %105
  store i64 %106, ptr %7, align 8, !tbaa !16
  %107 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %108 = load i64, ptr %107, align 8, !tbaa !16
  store i64 %108, ptr %3, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %109

109:                                              ; preds = %100, %77
  br label %110

110:                                              ; preds = %109
  %111 = load i32, ptr %6, align 4, !tbaa !8
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %6, align 4, !tbaa !8
  br label %71, !llvm.loop !19

113:                                              ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %114 = load i32, ptr @k, align 4, !tbaa !8
  %115 = sub nsw i32 %114, 1
  store i32 %115, ptr %8, align 4, !tbaa !8
  br label %116

116:                                              ; preds = %142, %113
  %117 = load i32, ptr %8, align 4, !tbaa !8
  %118 = load i32, ptr @n, align 4, !tbaa !8
  %119 = sub nsw i32 %118, 1
  %120 = icmp slt i32 %117, %119
  br i1 %120, label %122, label %121

121:                                              ; preds = %116
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %145

122:                                              ; preds = %116
  %123 = load i64, ptr @b, align 8, !tbaa !16
  %124 = load i64, ptr @cur, align 8, !tbaa !16
  %125 = sub nsw i64 %123, %124
  %126 = load i32, ptr %8, align 4, !tbaa !8
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %127
  %129 = getelementptr inbounds %"struct.std::pair", ptr %128, i32 0, i32 0
  %130 = load i64, ptr %129, align 16, !tbaa !17
  %131 = icmp slt i64 %125, %130
  br i1 %131, label %132, label %141

132:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %133 = load i32, ptr %8, align 4, !tbaa !8
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %134
  %136 = getelementptr inbounds %"struct.std::pair", ptr %135, i32 0, i32 1
  %137 = load i64, ptr %136, align 8, !tbaa !11
  %138 = sub nsw i64 0, %137
  store i64 %138, ptr %9, align 8, !tbaa !16
  %139 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %140 = load i64, ptr %139, align 8, !tbaa !16
  store i64 %140, ptr %3, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %141

141:                                              ; preds = %132, %122
  br label %142

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

145:                                              ; preds = %121
  %146 = load i64, ptr %3, align 8, !tbaa !16
  %147 = add nsw i64 %146, 1
  %148 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %147)
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %148, ptr noundef @.str)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

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 = { 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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"_ZTSSt4pairIxxE", !13, i64 0, !13, i64 8}
!13 = !{!"long long", !10, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !13, i64 0}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}
!20 = distinct !{!20, !15}


; 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 { i64, i64 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@b = external dso_local global i64, align 8
@cur = external dso_local local_unnamed_addr global i64, align 8
@a = external dso_local global [100100 x %"struct.std::pair"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %5 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %6 = getelementptr i8, ptr %5, i64 -24
  %7 = load i64, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %7
  %9 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %8, ptr noundef null)
  %10 = load ptr, ptr @_ZSt4cerr, align 8, !tbaa !5
  %11 = getelementptr i8, ptr %10, i64 -24
  %12 = load i64, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr @_ZSt4cerr, i64 %12
  %14 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %13, ptr noundef null)
  %15 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %16 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 4 dereferenceable(4) @k)
  %17 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @b)
  %18 = load i32, ptr @n, align 4, !tbaa !8
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre62 = sext i32 %18 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre62, %.._crit_edge_crit_edge ], [ %42, %.lr.ph ]
  %.lcssa26 = phi i32 [ %18, %.._crit_edge_crit_edge ], [ %41, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #8
  %20 = add nsw i32 %.lcssa26, -1
  %21 = sext i32 %20 to i64
  store i64 %21, ptr %1, align 8, !tbaa !11
  %22 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %.pre-phi
  %23 = getelementptr inbounds i8, ptr %22, i64 -16
  tail call void @_ZSt4sortIPSt4pairIxxESt7greaterIS1_EEvT_S5_T0_(ptr noundef nonnull @a, ptr noundef nonnull %23)
  %24 = load i32, ptr @k, align 4, !tbaa !8
  %25 = add i32 %24, -1
  %cur.promoted = load i64, ptr @cur, align 8, !tbaa !11
  %26 = icmp sgt i32 %24, 1
  br i1 %26, label %.lr.ph30.preheader, label %.preheader

.lr.ph30.preheader:                               ; preds = %._crit_edge
  %wide.trip.count = zext nneg i32 %25 to i64
  %min.iters.check = icmp ult i32 %24, 6
  br i1 %min.iters.check, label %.lr.ph30.preheader85, label %vector.ph

.lr.ph30.preheader85:                             ; preds = %middle.block, %.lr.ph30.preheader
  %indvars.iv42.ph = phi i64 [ 0, %.lr.ph30.preheader ], [ %n.vec, %middle.block ]
  %.ph = phi i64 [ %cur.promoted, %.lr.ph30.preheader ], [ %36, %middle.block ]
  br label %.lr.ph30

vector.ph:                                        ; preds = %.lr.ph30.preheader
  %n.mod.vf = and i64 %wide.trip.count, 3
  %27 = icmp eq i64 %n.mod.vf, 0
  %28 = select i1 %27, i64 4, i64 %n.mod.vf
  %n.vec = sub nsw i64 %wide.trip.count, %28
  %29 = insertelement <2 x i64> <i64 poison, i64 0>, i64 %cur.promoted, i64 0
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ %29, %vector.ph ], [ %33, %vector.body ]
  %vec.phi78 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %34, %vector.body ]
  %30 = or disjoint i64 %index, 2
  %31 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %index
  %32 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %30
  %wide.vec = load <4 x i64>, ptr %31, align 16, !tbaa !13
  %wide.vec79 = load <4 x i64>, ptr %32, align 16, !tbaa !13
  %strided.vec = shufflevector <4 x i64> %wide.vec, <4 x i64> poison, <2 x i32> <i32 0, i32 2>
  %strided.vec80 = shufflevector <4 x i64> %wide.vec79, <4 x i64> poison, <2 x i32> <i32 0, i32 2>
  %33 = add <2 x i64> %vec.phi, %strided.vec
  %34 = add <2 x i64> %vec.phi78, %strided.vec80
  %index.next = add nuw i64 %index, 4
  %35 = icmp eq i64 %index.next, %n.vec
  br i1 %35, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %34, %33
  %36 = tail call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  br label %.lr.ph30.preheader85

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %37 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv
  %38 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %37)
  %39 = sub nsw i64 0, %indvars.iv
  %40 = getelementptr inbounds i8, ptr %37, i64 8
  store i64 %39, ptr %40, align 8, !tbaa !19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %41 = load i32, ptr @n, align 4, !tbaa !8
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next, %42
  br i1 %43, label %.lr.ph, label %._crit_edge, !llvm.loop !20

.preheader25:                                     ; preds = %.lr.ph30
  store i64 %47, ptr @cur, align 8, !tbaa !11
  br i1 %26, label %.lr.ph33.preheader, label %.preheader

.lr.ph33.preheader:                               ; preds = %.preheader25
  %.pre51 = load i64, ptr @b, align 8, !tbaa !11
  br label %.lr.ph33

.lr.ph30:                                         ; preds = %.lr.ph30.preheader85, %.lr.ph30
  %indvars.iv42 = phi i64 [ %indvars.iv.next43, %.lr.ph30 ], [ %indvars.iv42.ph, %.lr.ph30.preheader85 ]
  %44 = phi i64 [ %47, %.lr.ph30 ], [ %.ph, %.lr.ph30.preheader85 ]
  %45 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv42
  %46 = load i64, ptr %45, align 16, !tbaa !13
  %47 = add nsw i64 %44, %46
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next43, %wide.trip.count
  br i1 %exitcond.not, label %.preheader25, label %.lr.ph30, !llvm.loop !21

.preheader:                                       ; preds = %73, %._crit_edge, %.preheader25
  %.pre58 = phi i64 [ %47, %.preheader25 ], [ %cur.promoted, %._crit_edge ], [ %76, %73 ]
  %48 = phi i64 [ %21, %.preheader25 ], [ %21, %._crit_edge ], [ %74, %73 ]
  %.lcssa = phi i32 [ %25, %.preheader25 ], [ %25, %._crit_edge ], [ %78, %73 ]
  %49 = load i32, ptr @n, align 4, !tbaa !8
  %50 = add nsw i32 %49, -1
  %51 = icmp slt i32 %.lcssa, %50
  br i1 %51, label %.lr.ph36.preheader, label %._crit_edge37

.lr.ph36.preheader:                               ; preds = %.preheader
  %52 = sext i32 %.lcssa to i64
  %.pre56 = load i64, ptr @b, align 8, !tbaa !11
  br label %.lr.ph36

.lr.ph33:                                         ; preds = %.lr.ph33.preheader, %73
  %53 = phi i64 [ %21, %.lr.ph33.preheader ], [ %74, %73 ]
  %54 = phi i32 [ %24, %.lr.ph33.preheader ], [ %75, %73 ]
  %55 = phi i64 [ %47, %.lr.ph33.preheader ], [ %76, %73 ]
  %56 = phi i64 [ %.pre51, %.lr.ph33.preheader ], [ %77, %73 ]
  %indvars.iv45 = phi i64 [ 0, %.lr.ph33.preheader ], [ %indvars.iv.next46, %73 ]
  %57 = phi i32 [ %25, %.lr.ph33.preheader ], [ %78, %73 ]
  %58 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv45
  %59 = load i64, ptr %58, align 16, !tbaa !13
  %60 = sext i32 %57 to i64
  %61 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %60
  %62 = load i64, ptr %61, align 16, !tbaa !13
  %63 = add i64 %56, %59
  %64 = add i64 %55, %62
  %65 = sub i64 %63, %64
  %66 = icmp slt i64 %65, %59
  br i1 %66, label %67, label %73

67:                                               ; preds = %.lr.ph33
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  %68 = getelementptr inbounds i8, ptr %58, i64 8
  %69 = load i64, ptr %68, align 8, !tbaa !19
  %70 = sub nsw i64 0, %69
  store i64 %70, ptr %2, align 8, !tbaa !11
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %72 = load i64, ptr %71, align 8, !tbaa !11
  store i64 %72, ptr %1, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  %.pre = load i64, ptr @b, align 8, !tbaa !11
  %.pre52 = load i64, ptr @cur, align 8, !tbaa !11
  %.pre54 = load i32, ptr @k, align 4, !tbaa !8
  br label %73

73:                                               ; preds = %.lr.ph33, %67
  %74 = phi i64 [ %53, %.lr.ph33 ], [ %72, %67 ]
  %75 = phi i32 [ %54, %.lr.ph33 ], [ %.pre54, %67 ]
  %76 = phi i64 [ %55, %.lr.ph33 ], [ %.pre52, %67 ]
  %77 = phi i64 [ %56, %.lr.ph33 ], [ %.pre, %67 ]
  %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
  %78 = add nsw i32 %75, -1
  %79 = sext i32 %78 to i64
  %80 = icmp slt i64 %indvars.iv.next46, %79
  br i1 %80, label %.lr.ph33, label %.preheader, !llvm.loop !22

._crit_edge37:                                    ; preds = %99, %.preheader
  %81 = phi i64 [ %48, %.preheader ], [ %100, %99 ]
  %82 = add nsw i64 %81, 1
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %82)
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %83, ptr noundef nonnull @.str)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #8
  ret i32 0

.lr.ph36:                                         ; preds = %.lr.ph36.preheader, %99
  %85 = phi i64 [ %48, %.lr.ph36.preheader ], [ %100, %99 ]
  %86 = phi i32 [ %49, %.lr.ph36.preheader ], [ %101, %99 ]
  %87 = phi i64 [ %.pre58, %.lr.ph36.preheader ], [ %102, %99 ]
  %88 = phi i64 [ %.pre56, %.lr.ph36.preheader ], [ %103, %99 ]
  %indvars.iv48 = phi i64 [ %52, %.lr.ph36.preheader ], [ %indvars.iv.next49, %99 ]
  %89 = sub nsw i64 %88, %87
  %90 = getelementptr inbounds [100100 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv48
  %91 = load i64, ptr %90, align 16, !tbaa !13
  %92 = icmp slt i64 %89, %91
  br i1 %92, label %93, label %99

93:                                               ; preds = %.lr.ph36
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %94 = getelementptr inbounds i8, ptr %90, i64 8
  %95 = load i64, ptr %94, align 8, !tbaa !19
  %96 = sub nsw i64 0, %95
  store i64 %96, ptr %3, align 8, !tbaa !11
  %97 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %98 = load i64, ptr %97, align 8, !tbaa !11
  store i64 %98, ptr %1, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  %.pre55 = load i64, ptr @b, align 8, !tbaa !11
  %.pre57 = load i64, ptr @cur, align 8, !tbaa !11
  %.pre59 = load i32, ptr @n, align 4, !tbaa !8
  br label %99

99:                                               ; preds = %.lr.ph36, %93
  %100 = phi i64 [ %85, %.lr.ph36 ], [ %98, %93 ]
  %101 = phi i32 [ %86, %.lr.ph36 ], [ %.pre59, %93 ]
  %102 = phi i64 [ %87, %.lr.ph36 ], [ %.pre57, %93 ]
  %103 = phi i64 [ %88, %.lr.ph36 ], [ %.pre55, %93 ]
  %indvars.iv.next49 = add nsw i64 %indvars.iv48, 1
  %104 = add nsw i32 %101, -1
  %105 = sext i32 %104 to i64
  %106 = icmp slt i64 %indvars.iv.next49, %105
  br i1 %106, label %.lr.ph36, label %._crit_edge37, !llvm.loop !23
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #2 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #6

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #7

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 = { 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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !10, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSSt4pairIxxE", !12, i64 0, !12, i64 8}
!15 = distinct !{!15, !16, !17, !18}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.isvectorized", i32 1}
!18 = !{!"llvm.loop.unroll.runtime.disable"}
!19 = !{!14, !12, i64 8}
!20 = distinct !{!20, !16}
!21 = distinct !{!21, !16, !18, !17}
!22 = distinct !{!22, !16}
!23 = distinct !{!23, !16}


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