; LLVM IR from forestLoop/Learning-ITMO-Academy-Pilot-Course :: two-pointers/3-I.ll (Z16min_good_segmentRKSt6vectorIiSaIiEEi)

; 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.KnapsackStack = type { %"class.std::stack", %"class.std::stack.0" }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::stack.0" = type { %"class.std::deque.1" }
%"class.std::deque.1" = type { %"class.std::_Deque_base.2" }
%"class.std::_Deque_base.2" = type { %"struct.std::_Deque_base<std::bitset<1001>, std::allocator<std::bitset<1001>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::bitset<1001>, std::allocator<std::bitset<1001>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::bitset<1001>, std::allocator<std::bitset<1001>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::bitset<1001>, std::allocator<std::bitset<1001>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator.6", %"struct.std::_Deque_iterator.6" }
%"struct.std::_Deque_iterator.6" = type { ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z4goodR13KnapsackStackS0_i(ptr noundef nonnull align 8 dereferenceable(160), ptr noundef nonnull align 8 dereferenceable(160), i32 noundef) #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 uwtable
declare dso_local void @_Z3addR13KnapsackStacki(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef) #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z16min_good_segmentRKSt6vectorIiSaIiEEi(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %class.KnapsackStack, align 8
  %6 = alloca %class.KnapsackStack, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 160, ptr %5) #4
  call void @_ZN13KnapsackStackC2Ev(ptr noundef nonnull align 8 dereferenceable(160) %5)
  call void @llvm.lifetime.start.p0(i64 160, ptr %6) #4
  invoke void @_ZN13KnapsackStackC2Ev(ptr noundef nonnull align 8 dereferenceable(160) %6)
          to label %15 unwind label %26

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #4
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %71, %15
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %30, label %25

25:                                               ; preds = %21
  store i32 2, ptr %13, align 4
  br label %78

26:                                               ; preds = %2
  %27 = landingpad { ptr, i32 }
          cleanup
  %28 = extractvalue { ptr, i32 } %27, 0
  store ptr %28, ptr %7, align 8
  %29 = extractvalue { ptr, i32 } %27, 1
  store i32 %29, ptr %8, align 4
  br label %89

30:                                               ; preds = %21
  br label %31

31:                                               ; preds = %49, %30
  %32 = load i32, ptr %12, align 4, !tbaa !9
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %35, label %40

35:                                               ; preds = %31
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = invoke noundef zeroext i1 @_Z4goodR13KnapsackStackS0_i(ptr noundef nonnull align 8 dereferenceable(160) %5, ptr noundef nonnull align 8 dereferenceable(160) %6, i32 noundef %36)
          to label %38 unwind label %50

38:                                               ; preds = %35
  %39 = xor i1 %37, true
  br label %40

40:                                               ; preds = %38, %31
  %41 = phi i1 [ false, %31 ], [ %39, %38 ]
  br i1 %41, label %42, label %54

42:                                               ; preds = %40
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load i32, ptr %12, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %12, align 4, !tbaa !9
  %46 = sext i32 %44 to i64
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %43, i64 noundef %46) #4
  %48 = load i32, ptr %47, align 4, !tbaa !9
  invoke void @_Z3addR13KnapsackStacki(ptr noundef nonnull align 8 dereferenceable(160) %5, i32 noundef %48)
          to label %49 unwind label %50

49:                                               ; preds = %42
  br label %31, !llvm.loop !11

50:                                               ; preds = %68, %58, %42, %35
  %51 = landingpad { ptr, i32 }
          cleanup
  %52 = extractvalue { ptr, i32 } %51, 0
  store ptr %52, ptr %7, align 8
  %53 = extractvalue { ptr, i32 } %51, 1
  store i32 %53, ptr %8, align 4
  br label %79

54:                                               ; preds = %40
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = icmp sge i32 %55, %56
  br i1 %57, label %58, label %63

58:                                               ; preds = %54
  %59 = load i32, ptr %4, align 4, !tbaa !9
  %60 = invoke noundef zeroext i1 @_Z4goodR13KnapsackStackS0_i(ptr noundef nonnull align 8 dereferenceable(160) %5, ptr noundef nonnull align 8 dereferenceable(160) %6, i32 noundef %59)
          to label %61 unwind label %50

61:                                               ; preds = %58
  br i1 %60, label %63, label %62

62:                                               ; preds = %61
  store i32 2, ptr %13, align 4
  br label %78

63:                                               ; preds = %61, %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %64 = load i32, ptr %12, align 4, !tbaa !9
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = sub nsw i32 %64, %65
  store i32 %66, ptr %14, align 4, !tbaa !9
  %67 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %14)
          to label %68 unwind label %74

68:                                               ; preds = %63
  %69 = load i32, ptr %67, align 4, !tbaa !9
  store i32 %69, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  invoke void @_Z6removeR13KnapsackStackS0_(ptr noundef nonnull align 8 dereferenceable(160) %5, ptr noundef nonnull align 8 dereferenceable(160) %6)
          to label %70 unwind label %50

70:                                               ; preds = %68
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %11, align 4, !tbaa !9
  br label %21, !llvm.loop !13

74:                                               ; preds = %63
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %7, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %79

78:                                               ; preds = %62, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %80

79:                                               ; preds = %74, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %6) #4
  br label %89

80:                                               ; preds = %78
  %81 = load i32, ptr %10, align 4, !tbaa !9
  %82 = load i32, ptr %9, align 4, !tbaa !9
  %83 = icmp sgt i32 %81, %82
  br i1 %83, label %84, label %85

84:                                               ; preds = %80
  br label %87

85:                                               ; preds = %80
  %86 = load i32, ptr %10, align 4, !tbaa !9
  br label %87

87:                                               ; preds = %85, %84
  %88 = phi i32 [ -1, %84 ], [ %86, %85 ]
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %6) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr %6) #4
  call void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %5) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr %5) #4
  ret i32 %88

89:                                               ; preds = %79, %26
  call void @llvm.lifetime.end.p0(i64 160, ptr %6) #4
  call void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %5) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr %5) #4
  br label %90

90:                                               ; preds = %89
  %91 = load ptr, ptr %7, align 8
  %92 = load i32, ptr %8, align 4
  %93 = insertvalue { ptr, i32 } poison, ptr %91, 0
  %94 = insertvalue { ptr, i32 } %93, i32 %92, 1
  resume { ptr, i32 } %94
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13KnapsackStackC2Ev(ptr noundef nonnull align 8 dereferenceable(160)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160)) unnamed_addr #3 align 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 = { 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 = { 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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.KnapsackStack = type { %"class.std::stack", %"class.std::stack.0" }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::stack.0" = type { %"class.std::deque.1" }
%"class.std::deque.1" = type { %"class.std::_Deque_base.2" }
%"class.std::_Deque_base.2" = type { %"struct.std::_Deque_base<std::bitset<1001>, std::allocator<std::bitset<1001>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::bitset<1001>, std::allocator<std::bitset<1001>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::bitset<1001>, std::allocator<std::bitset<1001>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::bitset<1001>, std::allocator<std::bitset<1001>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator.6", %"struct.std::_Deque_iterator.6" }
%"struct.std::_Deque_iterator.6" = type { ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z4goodR13KnapsackStackS0_i(ptr noundef nonnull align 8 dereferenceable(160), ptr noundef nonnull align 8 dereferenceable(160), i32 noundef) 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 uwtable
declare dso_local void @_Z3addR13KnapsackStacki(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z16min_good_segmentRKSt6vectorIiSaIiEEi(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.KnapsackStack, align 8
  %4 = alloca %class.KnapsackStack, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %3) #5
  call void @_ZN13KnapsackStackC2Ev(ptr noundef nonnull align 8 dereferenceable(160) %3)
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %4) #5
  invoke void @_ZN13KnapsackStackC2Ev(ptr noundef nonnull align 8 dereferenceable(160) %4)
          to label %7 unwind label %13

7:                                                ; preds = %2
  %8 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  %9 = trunc i64 %8 to i32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr %5, align 4, !tbaa !5
  %11 = icmp sgt i32 %9, 0
  br i1 %11, label %.preheader, label %._crit_edge

.preheader:                                       ; preds = %7, %29
  %.025 = phi i32 [ %.129, %29 ], [ 0, %7 ]
  %.01724 = phi i32 [ %30, %29 ], [ 0, %7 ]
  %12 = sext i32 %.025 to i64
  %smax = call i32 @llvm.smax.i32(i32 %.025, i32 %9)
  %wide.trip.count = zext nneg i32 %smax to i64
  br label %15

13:                                               ; preds = %2
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %34

15:                                               ; preds = %.preheader, %19
  %indvars.iv = phi i64 [ %12, %.preheader ], [ %indvars.iv.next, %19 ]
  %exitcond.not = icmp eq i64 %indvars.iv, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %16

16:                                               ; preds = %15
  %17 = invoke noundef zeroext i1 @_Z4goodR13KnapsackStackS0_i(ptr noundef nonnull align 8 dereferenceable(160) %3, ptr noundef nonnull align 8 dereferenceable(160) %4, i32 noundef %1)
          to label %18 unwind label %.loopexit

18:                                               ; preds = %16
  br i1 %17, label %.critedge.thread.loopexit, label %19

19:                                               ; preds = %18
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %20 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #5
  %21 = load i32, ptr %20, align 4, !tbaa !5
  invoke void @_Z3addR13KnapsackStacki(ptr noundef nonnull align 8 dereferenceable(160) %3, i32 noundef %21)
          to label %15 unwind label %.loopexit, !llvm.loop !9

.loopexit:                                        ; preds = %16, %19
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %22

.loopexit.split-lp:                               ; preds = %.critedge, %.critedge.thread
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %22

22:                                               ; preds = %.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %4) #5
  br label %34

.critedge:                                        ; preds = %15
  %23 = invoke noundef zeroext i1 @_Z4goodR13KnapsackStackS0_i(ptr noundef nonnull align 8 dereferenceable(160) %3, ptr noundef nonnull align 8 dereferenceable(160) %4, i32 noundef %1)
          to label %24 unwind label %.loopexit.split-lp

24:                                               ; preds = %.critedge
  br i1 %23, label %.critedge.thread, label %._crit_edge.loopexit

.critedge.thread.loopexit:                        ; preds = %18
  %25 = trunc nsw i64 %indvars.iv to i32
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %.critedge.thread.loopexit, %24
  %.129 = phi i32 [ %25, %.critedge.thread.loopexit ], [ %smax, %24 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  %26 = sub nsw i32 %.129, %.01724
  store i32 %26, ptr %6, align 4, !tbaa !5
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %28 = load i32, ptr %27, align 4, !tbaa !5
  store i32 %28, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  invoke void @_Z6removeR13KnapsackStackS0_(ptr noundef nonnull align 8 dereferenceable(160) %3, ptr noundef nonnull align 8 dereferenceable(160) %4)
          to label %29 unwind label %.loopexit.split-lp

29:                                               ; preds = %.critedge.thread
  %30 = add nuw nsw i32 %.01724, 1
  %exitcond31.not = icmp eq i32 %30, %9
  br i1 %exitcond31.not, label %._crit_edge.loopexit, label %.preheader, !llvm.loop !11

._crit_edge.loopexit:                             ; preds = %24, %29
  %.pre = load i32, ptr %5, align 4
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %7
  %31 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %10, %7 ]
  %32 = icmp sgt i32 %31, %9
  %33 = select i1 %32, i32 -1, i32 %31
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %4) #5
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %4) #5
  call void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %3) #5
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %3) #5
  ret i32 %33

34:                                               ; preds = %22, %13
  %.pn = phi { ptr, i32 } [ %lpad.phi, %22 ], [ %14, %13 ]
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %4) #5
  call void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160) %3) #5
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %3) #5
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13KnapsackStackC2Ev(ptr noundef nonnull align 8 dereferenceable(160)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN13KnapsackStackD2Ev(ptr noundef nonnull align 8 dereferenceable(160)) unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

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 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }

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

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


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