; LLVM IR from AdarshGaur/Competitive-Programming :: Codeforces/Random Problems/B. Minimize the Permutation.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"

%"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
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i64, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %18 = load i64, ptr %1, align 8, !tbaa !5
  %19 = call ptr @llvm.stacksave.p0()
  store ptr %19, ptr %2, align 8
  %20 = alloca i64, i64 %18, align 16
  store i64 %18, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store ptr %20, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %21 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %21, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %22 = load ptr, ptr %4, align 8, !tbaa !9
  %23 = mul nuw i64 8, %18
  %24 = udiv i64 %23, 8
  %25 = getelementptr inbounds i64, ptr %22, i64 %24
  store ptr %25, ptr %6, align 8, !tbaa !9
  br label %26

26:                                               ; preds = %35, %0
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = icmp ne ptr %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %38

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %32, ptr %7, align 8, !tbaa !9
  %33 = load ptr, ptr %7, align 8, !tbaa !9
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %33)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %35

35:                                               ; preds = %31
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  %37 = getelementptr inbounds i64, ptr %36, i32 1
  store ptr %37, ptr %5, align 8, !tbaa !9
  br label %26

38:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %92, %38
  %40 = load i64, ptr %8, align 8, !tbaa !5
  %41 = load i64, ptr %1, align 8, !tbaa !5
  %42 = icmp slt i64 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  store i32 4, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %95

44:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %45 = load i64, ptr %8, align 8, !tbaa !5
  %46 = add nsw i64 %45, 1
  store i64 %46, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %47 = load i64, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds i64, ptr %20, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !5
  store i64 %49, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store i64 -1, ptr %12, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %65, %44
  %51 = load i64, ptr %10, align 8, !tbaa !5
  %52 = load i64, ptr %1, align 8, !tbaa !5
  %53 = icmp slt i64 %51, %52
  br i1 %53, label %54, label %68

54:                                               ; preds = %50
  %55 = load i64, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds i64, ptr %20, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !5
  %58 = load i64, ptr %11, align 8, !tbaa !5
  %59 = icmp slt i64 %57, %58
  br i1 %59, label %60, label %65

60:                                               ; preds = %54
  %61 = load i64, ptr %10, align 8, !tbaa !5
  %62 = getelementptr inbounds i64, ptr %20, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !5
  store i64 %63, ptr %11, align 8, !tbaa !5
  %64 = load i64, ptr %10, align 8, !tbaa !5
  store i64 %64, ptr %12, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %60, %54
  %66 = load i64, ptr %10, align 8, !tbaa !5
  %67 = add nsw i64 %66, 1
  store i64 %67, ptr %10, align 8, !tbaa !5
  br label %50, !llvm.loop !11

68:                                               ; preds = %50
  %69 = load i64, ptr %12, align 8, !tbaa !5
  %70 = icmp eq i64 %69, -1
  br i1 %70, label %71, label %72

71:                                               ; preds = %68
  store i32 6, ptr %9, align 4
  br label %89

72:                                               ; preds = %68
  %73 = load i64, ptr %12, align 8, !tbaa !5
  store i64 %73, ptr %10, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %78, %72
  %75 = load i64, ptr %10, align 8, !tbaa !5
  %76 = load i64, ptr %8, align 8, !tbaa !5
  %77 = icmp sgt i64 %75, %76
  br i1 %77, label %78, label %86

78:                                               ; preds = %74
  %79 = load i64, ptr %10, align 8, !tbaa !5
  %80 = getelementptr inbounds i64, ptr %20, i64 %79
  %81 = load i64, ptr %10, align 8, !tbaa !5
  %82 = sub nsw i64 %81, 1
  %83 = getelementptr inbounds i64, ptr %20, i64 %82
  call void @_ZSt4swapIlENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8) %80, ptr noundef nonnull align 8 dereferenceable(8) %83) #5
  %84 = load i64, ptr %10, align 8, !tbaa !5
  %85 = add nsw i64 %84, -1
  store i64 %85, ptr %10, align 8, !tbaa !5
  br label %74, !llvm.loop !13

86:                                               ; preds = %74
  %87 = load i64, ptr %12, align 8, !tbaa !5
  %88 = sub nsw i64 %87, 1
  store i64 %88, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %9, align 4
  br label %89

89:                                               ; preds = %86, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %90 = load i32, ptr %9, align 4
  switch i32 %90, label %118 [
    i32 0, label %91
    i32 6, label %92
  ]

91:                                               ; preds = %89
  br label %92

92:                                               ; preds = %91, %89
  %93 = load i64, ptr %8, align 8, !tbaa !5
  %94 = add nsw i64 %93, 1
  store i64 %94, ptr %8, align 8, !tbaa !5
  br label %39, !llvm.loop !14

95:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store ptr %20, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %96 = load ptr, ptr %13, align 8, !tbaa !9
  store ptr %96, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %97 = load ptr, ptr %13, align 8, !tbaa !9
  %98 = mul nuw i64 8, %18
  %99 = udiv i64 %98, 8
  %100 = getelementptr inbounds i64, ptr %97, i64 %99
  store ptr %100, ptr %15, align 8, !tbaa !9
  br label %101

101:                                              ; preds = %112, %95
  %102 = load ptr, ptr %14, align 8, !tbaa !9
  %103 = load ptr, ptr %15, align 8, !tbaa !9
  %104 = icmp ne ptr %102, %103
  br i1 %104, label %106, label %105

105:                                              ; preds = %101
  store i32 11, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %115

106:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %107 = load ptr, ptr %14, align 8, !tbaa !9
  %108 = load i64, ptr %107, align 8, !tbaa !5
  store i64 %108, ptr %16, align 8, !tbaa !5
  %109 = load i64, ptr %16, align 8, !tbaa !5
  %110 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %109)
  %111 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %110, ptr noundef @.str)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %112

112:                                              ; preds = %106
  %113 = load ptr, ptr %14, align 8, !tbaa !9
  %114 = getelementptr inbounds i64, ptr %113, i32 1
  store ptr %114, ptr %14, align 8, !tbaa !9
  br label %101

115:                                              ; preds = %105
  %116 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  %117 = load ptr, ptr %2, align 8
  call void @llvm.stackrestore.p0(ptr %117)
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret void

118:                                              ; preds = %89
  unreachable
}

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #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 nounwind uwtable
declare dso_local void @_ZSt4swapIlENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

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

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


; 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
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %2 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = call ptr @llvm.stacksave.p0()
  %5 = alloca i64, i64 %3, align 16
  %6 = getelementptr inbounds i64, ptr %5, i64 %3
  %.not46 = icmp eq i64 %3, 0
  br i1 %.not46, label %.preheader45, label %.lr.ph

.preheader45:                                     ; preds = %.lr.ph, %0
  %7 = load i64, ptr %1, align 8, !tbaa !5
  %8 = icmp sgt i64 %7, 0
  br i1 %8, label %.lr.ph57, label %.preheader

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.047 = phi ptr [ %10, %.lr.ph ], [ %5, %0 ]
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %.047)
  %10 = getelementptr inbounds i8, ptr %.047, i64 8
  %.not = icmp eq ptr %10, %6
  br i1 %.not, label %.preheader45, label %.lr.ph

.preheader:                                       ; preds = %._crit_edge55, %.preheader45
  br i1 %.not46, label %._crit_edge61, label %.lr.ph60

.lr.ph57:                                         ; preds = %.preheader45, %._crit_edge55
  %.pre62 = phi i64 [ %.pre63, %._crit_edge55 ], [ %7, %.preheader45 ]
  %11 = phi i64 [ %41, %._crit_edge55 ], [ %7, %.preheader45 ]
  %.03256 = phi i64 [ %.pre-phi, %._crit_edge55 ], [ 0, %.preheader45 ]
  %.03848 = add nsw i64 %.03256, 1
  %12 = icmp slt i64 %.03848, %11
  br i1 %12, label %.lr.ph52.preheader, label %._crit_edge55

.lr.ph52.preheader:                               ; preds = %.lr.ph57
  %13 = getelementptr inbounds i64, ptr %5, i64 %.03256
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = xor i64 %.03256, -1
  %16 = add i64 %11, %15
  %17 = add i64 %11, -2
  %18 = sub i64 %17, %.03256
  %xtraiter = and i64 %16, 3
  %19 = icmp ult i64 %18, 3
  br i1 %19, label %._crit_edge.unr-lcssa, label %.lr.ph52.preheader.new

.lr.ph52.preheader.new:                           ; preds = %.lr.ph52.preheader
  %unroll_iter = and i64 %16, -4
  br label %.lr.ph52

.lr.ph52:                                         ; preds = %.lr.ph52, %.lr.ph52.preheader.new
  %.03851 = phi i64 [ %.03848, %.lr.ph52.preheader.new ], [ %.038.3, %.lr.ph52 ]
  %.03450 = phi i64 [ -1, %.lr.ph52.preheader.new ], [ %spec.select43.3, %.lr.ph52 ]
  %.03649 = phi i64 [ %14, %.lr.ph52.preheader.new ], [ %spec.select.3, %.lr.ph52 ]
  %niter = phi i64 [ 0, %.lr.ph52.preheader.new ], [ %niter.next.3, %.lr.ph52 ]
  %20 = getelementptr inbounds i64, ptr %5, i64 %.03851
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = icmp slt i64 %21, %.03649
  %spec.select = call i64 @llvm.smin.i64(i64 %21, i64 %.03649)
  %spec.select43 = select i1 %22, i64 %.03851, i64 %.03450
  %.038 = add nsw i64 %.03851, 1
  %23 = getelementptr inbounds i64, ptr %5, i64 %.038
  %24 = load i64, ptr %23, align 8, !tbaa !5
  %25 = icmp slt i64 %24, %spec.select
  %spec.select.1 = call i64 @llvm.smin.i64(i64 %24, i64 %spec.select)
  %spec.select43.1 = select i1 %25, i64 %.038, i64 %spec.select43
  %.038.1 = add nsw i64 %.03851, 2
  %26 = getelementptr inbounds i64, ptr %5, i64 %.038.1
  %27 = load i64, ptr %26, align 8, !tbaa !5
  %28 = icmp slt i64 %27, %spec.select.1
  %spec.select.2 = call i64 @llvm.smin.i64(i64 %27, i64 %spec.select.1)
  %spec.select43.2 = select i1 %28, i64 %.038.1, i64 %spec.select43.1
  %.038.2 = add nsw i64 %.03851, 3
  %29 = getelementptr inbounds i64, ptr %5, i64 %.038.2
  %30 = load i64, ptr %29, align 8, !tbaa !5
  %31 = icmp slt i64 %30, %spec.select.2
  %spec.select.3 = call i64 @llvm.smin.i64(i64 %30, i64 %spec.select.2)
  %spec.select43.3 = select i1 %31, i64 %.038.2, i64 %spec.select43.2
  %.038.3 = add nsw i64 %.03851, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.unr-lcssa, label %.lr.ph52, !llvm.loop !9

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph52, %.lr.ph52.preheader
  %spec.select43.lcssa.ph = phi i64 [ poison, %.lr.ph52.preheader ], [ %spec.select43.3, %.lr.ph52 ]
  %.03851.unr = phi i64 [ %.03848, %.lr.ph52.preheader ], [ %.038.3, %.lr.ph52 ]
  %.03450.unr = phi i64 [ -1, %.lr.ph52.preheader ], [ %spec.select43.3, %.lr.ph52 ]
  %.03649.unr = phi i64 [ %14, %.lr.ph52.preheader ], [ %spec.select.3, %.lr.ph52 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph52.epil

.lr.ph52.epil:                                    ; preds = %._crit_edge.unr-lcssa, %.lr.ph52.epil
  %.03851.epil = phi i64 [ %.038.epil, %.lr.ph52.epil ], [ %.03851.unr, %._crit_edge.unr-lcssa ]
  %.03450.epil = phi i64 [ %spec.select43.epil, %.lr.ph52.epil ], [ %.03450.unr, %._crit_edge.unr-lcssa ]
  %.03649.epil = phi i64 [ %spec.select.epil, %.lr.ph52.epil ], [ %.03649.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph52.epil ], [ 0, %._crit_edge.unr-lcssa ]
  %32 = getelementptr inbounds i64, ptr %5, i64 %.03851.epil
  %33 = load i64, ptr %32, align 8, !tbaa !5
  %34 = icmp slt i64 %33, %.03649.epil
  %spec.select.epil = call i64 @llvm.smin.i64(i64 %33, i64 %.03649.epil)
  %spec.select43.epil = select i1 %34, i64 %.03851.epil, i64 %.03450.epil
  %.038.epil = add nsw i64 %.03851.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph52.epil, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph52.epil, %._crit_edge.unr-lcssa
  %spec.select43.lcssa = phi i64 [ %spec.select43.lcssa.ph, %._crit_edge.unr-lcssa ], [ %spec.select43.epil, %.lr.ph52.epil ]
  %35 = icmp eq i64 %spec.select43.lcssa, -1
  br i1 %35, label %._crit_edge55, label %.preheader44

.preheader44:                                     ; preds = %._crit_edge
  %36 = icmp sgt i64 %spec.select43.lcssa, %.03256
  br i1 %36, label %.lr.ph54, label %._crit_edge55

.lr.ph54:                                         ; preds = %.preheader44, %.lr.ph54
  %.13953 = phi i64 [ %39, %.lr.ph54 ], [ %spec.select43.lcssa, %.preheader44 ]
  %37 = getelementptr inbounds i64, ptr %5, i64 %.13953
  %38 = getelementptr i8, ptr %37, i64 -8
  call void @_ZSt4swapIlENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8) %37, ptr noundef nonnull align 8 dereferenceable(8) %38) #6
  %39 = add nsw i64 %.13953, -1
  %40 = icmp sgt i64 %39, %.03256
  br i1 %40, label %.lr.ph54, label %._crit_edge55.loopexit, !llvm.loop !13

._crit_edge55.loopexit:                           ; preds = %.lr.ph54
  %.pre.pre = load i64, ptr %1, align 8, !tbaa !5
  br label %._crit_edge55

._crit_edge55:                                    ; preds = %.lr.ph57, %.preheader44, %._crit_edge55.loopexit, %._crit_edge
  %.pre-phi = phi i64 [ %.03848, %._crit_edge ], [ %spec.select43.lcssa, %._crit_edge55.loopexit ], [ %spec.select43.lcssa, %.preheader44 ], [ %.03848, %.lr.ph57 ]
  %.pre63 = phi i64 [ %.pre62, %._crit_edge ], [ %.pre.pre, %._crit_edge55.loopexit ], [ %.pre62, %.preheader44 ], [ %.pre62, %.lr.ph57 ]
  %41 = phi i64 [ %11, %._crit_edge ], [ %.pre.pre, %._crit_edge55.loopexit ], [ %.pre62, %.preheader44 ], [ %11, %.lr.ph57 ]
  %42 = icmp slt i64 %.pre-phi, %41
  br i1 %42, label %.lr.ph57, label %.preheader, !llvm.loop !14

._crit_edge61:                                    ; preds = %.lr.ph60, %.preheader
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.1)
  call void @llvm.stackrestore.p0(ptr %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret void

.lr.ph60:                                         ; preds = %.preheader, %.lr.ph60
  %.03359 = phi ptr [ %47, %.lr.ph60 ], [ %5, %.preheader ]
  %44 = load i64, ptr %.03359, align 8, !tbaa !5
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %44)
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %45, ptr noundef nonnull @.str)
  %47 = getelementptr inbounds i8, ptr %.03359, i64 8
  %.not42 = icmp eq ptr %47, %6
  br i1 %.not42, label %._crit_edge61, label %.lr.ph60
}

; 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 uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #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 nounwind uwtable
declare dso_local void @_ZSt4swapIlENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #5

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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #3 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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