; LLVM IR from Leet-Us-Code/DSA-A-Z-Practice :: Sid's Contests/Codechef contests/Basic Problems (JNext_spoj)

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

%"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" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4swapRxS_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca [1000000 x i64], align 16
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  br label %10

10:                                               ; preds = %111, %0
  %11 = load i64, ptr %2, align 8, !tbaa !5
  %12 = add nsw i64 %11, -1
  store i64 %12, ptr %2, align 8, !tbaa !5
  %13 = icmp ne i64 %11, 0
  br i1 %13, label %14, label %112

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8000000, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %24, %14
  %17 = load i64, ptr %5, align 8, !tbaa !5
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %20, label %27

20:                                               ; preds = %16
  %21 = load i64, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %21
  %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) %22)
  br label %24

24:                                               ; preds = %20
  %25 = load i64, ptr %5, align 8, !tbaa !5
  %26 = add nsw i64 %25, 1
  store i64 %26, ptr %5, align 8, !tbaa !5
  br label %16, !llvm.loop !9

27:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 -1, ptr %6, align 8, !tbaa !5
  %28 = load i64, ptr %3, align 8, !tbaa !5
  %29 = sub nsw i64 %28, 1
  store i64 %29, ptr %5, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %46, %27
  %31 = load i64, ptr %5, align 8, !tbaa !5
  %32 = icmp sgt i64 %31, 0
  br i1 %32, label %33, label %49

33:                                               ; preds = %30
  %34 = load i64, ptr %5, align 8, !tbaa !5
  %35 = sub nsw i64 %34, 1
  %36 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = load i64, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !5
  %41 = icmp slt i64 %37, %40
  br i1 %41, label %42, label %45

42:                                               ; preds = %33
  %43 = load i64, ptr %5, align 8, !tbaa !5
  %44 = sub nsw i64 %43, 1
  store i64 %44, ptr %6, align 8, !tbaa !5
  br label %49

45:                                               ; preds = %33
  br label %46

46:                                               ; preds = %45
  %47 = load i64, ptr %5, align 8, !tbaa !5
  %48 = add nsw i64 %47, -1
  store i64 %48, ptr %5, align 8, !tbaa !5
  br label %30, !llvm.loop !11

49:                                               ; preds = %42, %30
  %50 = load i64, ptr %6, align 8, !tbaa !5
  %51 = icmp eq i64 %50, -1
  br i1 %51, label %52, label %55

52:                                               ; preds = %49
  %53 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  %54 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %111

55:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %56 = load i64, ptr %5, align 8, !tbaa !5
  store i64 %56, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %57 = load i64, ptr %6, align 8, !tbaa !5
  %58 = add nsw i64 %57, 1
  store i64 %58, ptr %8, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %82, %55
  %60 = load i64, ptr %8, align 8, !tbaa !5
  %61 = load i64, ptr %3, align 8, !tbaa !5
  %62 = icmp slt i64 %60, %61
  br i1 %62, label %63, label %85

63:                                               ; preds = %59
  %64 = load i64, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !5
  %67 = load i64, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !5
  %70 = icmp sgt i64 %66, %69
  br i1 %70, label %71, label %81

71:                                               ; preds = %63
  %72 = load i64, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %72
  %74 = load i64, ptr %73, align 8, !tbaa !5
  %75 = load i64, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !5
  %78 = icmp slt i64 %74, %77
  br i1 %78, label %79, label %81

79:                                               ; preds = %71
  %80 = load i64, ptr %8, align 8, !tbaa !5
  store i64 %80, ptr %7, align 8, !tbaa !5
  br label %81

81:                                               ; preds = %79, %71, %63
  br label %82

82:                                               ; preds = %81
  %83 = load i64, ptr %8, align 8, !tbaa !5
  %84 = add nsw i64 %83, 1
  store i64 %84, ptr %8, align 8, !tbaa !5
  br label %59, !llvm.loop !12

85:                                               ; preds = %59
  %86 = load i64, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %86
  %88 = load i64, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %88
  call void @_Z4swapRxS_(ptr noundef nonnull align 8 dereferenceable(8) %87, ptr noundef nonnull align 8 dereferenceable(8) %89)
  %90 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 0
  %91 = load i64, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds i64, ptr %90, i64 %91
  %93 = getelementptr inbounds i64, ptr %92, i64 1
  %94 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 0
  %95 = load i64, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds i64, ptr %94, i64 %95
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef %93, ptr noundef %96)
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %97

97:                                               ; preds = %106, %85
  %98 = load i64, ptr %5, align 8, !tbaa !5
  %99 = load i64, ptr %3, align 8, !tbaa !5
  %100 = icmp slt i64 %98, %99
  br i1 %100, label %101, label %109

101:                                              ; preds = %97
  %102 = load i64, ptr %5, align 8, !tbaa !5
  %103 = getelementptr inbounds [1000000 x i64], ptr %4, i64 0, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !5
  %105 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %104)
  br label %106

106:                                              ; preds = %101
  %107 = load i64, ptr %5, align 8, !tbaa !5
  %108 = add nsw i64 %107, 1
  store i64 %108, ptr %5, align 8, !tbaa !5
  br label %97, !llvm.loop !13

109:                                              ; preds = %97
  %110 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %111

111:                                              ; preds = %109, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8000000, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %10, !llvm.loop !14

112:                                              ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %113 = load i32, ptr %1, align 4
  ret i32 %113
}

; 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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4

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

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

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

%"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" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4swapRxS_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca [1000000 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %invariant.gep = getelementptr inbounds i8, ptr %3, i64 8
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = add nsw i64 %5, -1
  store i64 %6, ptr %1, align 8, !tbaa !5
  %.not44 = icmp eq i64 %5, 0
  br i1 %.not44, label %._crit_edge47, label %.lr.ph46

.lr.ph46:                                         ; preds = %0, %._crit_edge43
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %7 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.start.p0(i64 8000000, ptr nonnull %3) #6
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %.lr.ph, label %.preheader32

.preheader32:                                     ; preds = %.lr.ph, %.lr.ph46
  %.lcssa = phi i64 [ %8, %.lr.ph46 ], [ %13, %.lr.ph ]
  br label %15

.lr.ph:                                           ; preds = %.lr.ph46, %.lr.ph
  %.02734 = phi i64 [ %12, %.lr.ph ], [ 0, %.lr.ph46 ]
  %10 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %.02734
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %12 = add nuw nsw i64 %.02734, 1
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = icmp slt i64 %12, %13
  br i1 %14, label %.lr.ph, label %.preheader32, !llvm.loop !9

15:                                               ; preds = %.preheader32, %17
  %indvar = phi i64 [ 0, %.preheader32 ], [ %indvar.next, %17 ]
  %.128.in = phi i64 [ %.lcssa, %.preheader32 ], [ %.128, %17 ]
  %16 = icmp sgt i64 %.128.in, 1
  br i1 %16, label %17, label %27

17:                                               ; preds = %15
  %.128 = add nsw i64 %.128.in, -1
  %18 = add nsw i64 %.128.in, -2
  %19 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %18
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %.128
  %22 = load i64, ptr %21, align 8, !tbaa !5
  %23 = icmp slt i64 %20, %22
  %indvar.next = add i64 %indvar, 1
  br i1 %23, label %.preheader, label %15, !llvm.loop !11

.preheader:                                       ; preds = %17
  %24 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %18
  %.not48 = icmp sgt i64 %.128.in, %.lcssa
  br i1 %.not48, label %._crit_edge, label %.lr.ph38.preheader

.lr.ph38.preheader:                               ; preds = %.preheader
  %25 = and i64 %indvar, 1
  %lcmp.mod.not.not = icmp eq i64 %25, 0
  %spec.select72 = select i1 %lcmp.mod.not.not, i64 %.128.in, i64 %.128
  %26 = icmp eq i64 %indvar, 0
  br i1 %26, label %._crit_edge, label %.lr.ph38

27:                                               ; preds = %15
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  br label %._crit_edge43

.lr.ph38:                                         ; preds = %.lr.ph38.preheader, %43
  %.037 = phi i64 [ %.0.1, %43 ], [ %spec.select72, %.lr.ph38.preheader ]
  %.02536 = phi i64 [ %.1.1, %43 ], [ %.128, %.lr.ph38.preheader ]
  %29 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %.037
  %30 = load i64, ptr %29, align 8, !tbaa !5
  %31 = icmp sgt i64 %30, %20
  br i1 %31, label %32, label %.lr.ph38.1

32:                                               ; preds = %.lr.ph38
  %33 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %.02536
  %34 = load i64, ptr %33, align 8, !tbaa !5
  %35 = icmp slt i64 %30, %34
  %spec.select = select i1 %35, i64 %.037, i64 %.02536
  br label %.lr.ph38.1

.lr.ph38.1:                                       ; preds = %32, %.lr.ph38
  %.1 = phi i64 [ %.02536, %.lr.ph38 ], [ %spec.select, %32 ]
  %.0 = add nuw nsw i64 %.037, 1
  %36 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %.0
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = icmp sgt i64 %37, %20
  br i1 %38, label %39, label %43

39:                                               ; preds = %.lr.ph38.1
  %40 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %.1
  %41 = load i64, ptr %40, align 8, !tbaa !5
  %42 = icmp slt i64 %37, %41
  %spec.select.1 = select i1 %42, i64 %.0, i64 %.1
  br label %43

43:                                               ; preds = %39, %.lr.ph38.1
  %.1.1 = phi i64 [ %.1, %.lr.ph38.1 ], [ %spec.select.1, %39 ]
  %.0.1 = add nuw nsw i64 %.037, 2
  %exitcond.not.1 = icmp eq i64 %.0.1, %.lcssa
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph38, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph38.preheader, %43, %.preheader
  %.025.lcssa = phi i64 [ %.128, %.preheader ], [ %.128, %.lr.ph38.preheader ], [ %.1.1, %43 ]
  %44 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %.025.lcssa
  call void @_Z4swapRxS_(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef nonnull align 8 dereferenceable(8) %44)
  %gep = getelementptr i64, ptr %invariant.gep, i64 %18
  %45 = load i64, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds i64, ptr %3, i64 %45
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull %gep, ptr noundef nonnull %46)
  %47 = load i64, ptr %2, align 8, !tbaa !5
  %48 = icmp sgt i64 %47, 0
  br i1 %48, label %.lr.ph42, label %._crit_edge43

.lr.ph42:                                         ; preds = %._crit_edge, %.lr.ph42
  %.240 = phi i64 [ %52, %.lr.ph42 ], [ 0, %._crit_edge ]
  %49 = getelementptr inbounds [1000000 x i64], ptr %3, i64 0, i64 %.240
  %50 = load i64, ptr %49, align 8, !tbaa !5
  %51 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %50)
  %52 = add nuw nsw i64 %.240, 1
  %53 = load i64, ptr %2, align 8, !tbaa !5
  %54 = icmp slt i64 %52, %53
  br i1 %54, label %.lr.ph42, label %._crit_edge43, !llvm.loop !13

._crit_edge43:                                    ; preds = %.lr.ph42, %._crit_edge, %27
  %_ZSt4cout.sink = phi ptr [ %28, %27 ], [ @_ZSt4cout, %._crit_edge ], [ @_ZSt4cout, %.lr.ph42 ]
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %_ZSt4cout.sink, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8000000, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  %56 = load i64, ptr %1, align 8, !tbaa !5
  %57 = add nsw i64 %56, -1
  store i64 %57, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %56, 0
  br i1 %.not, label %._crit_edge47, label %.lr.ph46, !llvm.loop !14

._crit_edge47:                                    ; preds = %._crit_edge43, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret i32 0
}

; 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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, 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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { "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 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 = !{!"long long", !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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass