; LLVM IR from tommasocerruti/algolab-2024 :: src/week05/boats/solution.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.anon = type { i8 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<boat_t, std::allocator<boat_t>>::_Vector_impl" }
%"struct.std::_Vector_base<boat_t, std::allocator<boat_t>>::_Vector_impl" = type { %"struct.std::_Vector_base<boat_t, std::allocator<boat_t>>::_Vector_impl_data" }
%"struct.std::_Vector_base<boat_t, std::allocator<boat_t>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.boat_t = type { i32, i32, i32, i32 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::priority_queue", align 8
  %3 = alloca %"class.std::vector", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.boat_t, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.boat_t, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #8
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.start.p0(i64 32, ptr %2) #8
  call void @llvm.lifetime.start.p0(i64 24, ptr %3) #8
  call void @llvm.memset.p0.i64(ptr align 8 %3, i8 0, i64 24, i1 false)
  call void @_ZNSt6vectorI6boat_tSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #8
  invoke void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0EC2ERKS4_OS3_"(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 dereferenceable(1) @comp_boats, ptr noundef nonnull align 8 dereferenceable(24) %3)
          to label %14 unwind label %20

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

15:                                               ; preds = %40, %14
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %24, label %19

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

20:                                               ; preds = %0
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %4, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %5, align 4
  call void @_ZNSt6vectorI6boat_tSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #8
  br label %102

24:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %25 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %26 unwind label %43

26:                                               ; preds = %24
  %27 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 4 dereferenceable(4) %8)
          to label %28 unwind label %43

28:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #8
  %29 = getelementptr inbounds %struct.boat_t, ptr %9, i32 0, i32 0
  %30 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %30, ptr %29, align 4, !tbaa !9
  %31 = getelementptr inbounds %struct.boat_t, ptr %9, i32 0, i32 1
  %32 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %32, ptr %31, align 4, !tbaa !11
  %33 = getelementptr inbounds %struct.boat_t, ptr %9, i32 0, i32 2
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = sub nsw i32 %34, %35
  store i32 %36, ptr %33, align 4, !tbaa !12
  %37 = getelementptr inbounds %struct.boat_t, ptr %9, i32 0, i32 3
  %38 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %38, ptr %37, align 4, !tbaa !13
  invoke void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E4pushEOS0_"(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 4 dereferenceable(16) %9)
          to label %39 unwind label %47

39:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %6, align 4, !tbaa !5
  br label %15, !llvm.loop !14

43:                                               ; preds = %26, %24
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %4, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %5, align 4
  br label %51

47:                                               ; preds = %28
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %4, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #8
  br label %51

51:                                               ; preds = %47, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  br label %101

52:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 -2147483648, ptr %11, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %93, %52
  %54 = invoke noundef zeroext i1 @"_ZNKSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E5emptyEv"(ptr noundef nonnull align 8 dereferenceable(25) %2)
          to label %55 unwind label %70

55:                                               ; preds = %53
  %56 = xor i1 %54, true
  br i1 %56, label %57, label %94

57:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #8
  %58 = invoke noundef nonnull align 4 dereferenceable(16) ptr @"_ZNKSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E3topEv"(ptr noundef nonnull align 8 dereferenceable(25) %2)
          to label %59 unwind label %74

59:                                               ; preds = %57
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %58, i64 16, i1 false), !tbaa.struct !16
  invoke void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E3popEv"(ptr noundef nonnull align 8 dereferenceable(25) %2)
          to label %60 unwind label %74

60:                                               ; preds = %59
  %61 = load i32, ptr %11, align 4, !tbaa !5
  %62 = getelementptr inbounds %struct.boat_t, ptr %12, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !12
  %64 = icmp sle i32 %61, %63
  br i1 %64, label %65, label %78

65:                                               ; preds = %60
  %66 = load i32, ptr %10, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %10, align 4, !tbaa !5
  %68 = getelementptr inbounds %struct.boat_t, ptr %12, i32 0, i32 3
  %69 = load i32, ptr %68, align 4, !tbaa !13
  store i32 %69, ptr %11, align 4, !tbaa !5
  br label %93

70:                                               ; preds = %97, %94, %53
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %4, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %5, align 4
  br label %100

74:                                               ; preds = %83, %59, %57
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %4, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #8
  br label %100

78:                                               ; preds = %60
  %79 = load i32, ptr %11, align 4, !tbaa !5
  %80 = getelementptr inbounds %struct.boat_t, ptr %12, i32 0, i32 1
  %81 = load i32, ptr %80, align 4, !tbaa !11
  %82 = icmp sle i32 %79, %81
  br i1 %82, label %83, label %92

83:                                               ; preds = %78
  %84 = load i32, ptr %11, align 4, !tbaa !5
  %85 = getelementptr inbounds %struct.boat_t, ptr %12, i32 0, i32 2
  store i32 %84, ptr %85, align 4, !tbaa !12
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = getelementptr inbounds %struct.boat_t, ptr %12, i32 0, i32 0
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = add nsw i32 %86, %88
  %90 = getelementptr inbounds %struct.boat_t, ptr %12, i32 0, i32 3
  store i32 %89, ptr %90, align 4, !tbaa !13
  invoke void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E4pushERKS0_"(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 4 dereferenceable(16) %12)
          to label %91 unwind label %74

91:                                               ; preds = %83
  br label %92

92:                                               ; preds = %91, %78
  br label %93

93:                                               ; preds = %92, %65
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #8
  br label %53, !llvm.loop !17

94:                                               ; preds = %55
  %95 = load i32, ptr %10, align 4, !tbaa !5
  %96 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %95)
          to label %97 unwind label %70

97:                                               ; preds = %94
  %98 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %96, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %99 unwind label %70

99:                                               ; preds = %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0ED2Ev"(ptr noundef nonnull align 8 dereferenceable(25) %2) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #8
  ret void

100:                                              ; preds = %74, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %101

101:                                              ; preds = %100, %51
  call void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0ED2Ev"(ptr noundef nonnull align 8 dereferenceable(25) %2) #8
  br label %102

102:                                              ; preds = %101, %20
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #8
  br label %103

103:                                              ; preds = %102
  %104 = load ptr, ptr %4, align 8
  %105 = load i32, ptr %5, align 4
  %106 = insertvalue { ptr, i32 } poison, ptr %104, 0
  %107 = insertvalue { ptr, i32 } %106, i32 %105, 1
  resume { ptr, i32 } %107
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI6boat_tSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0EC2ERKS4_OS3_"(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI6boat_tSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4 align 2

; 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 hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E4pushEOS0_"(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(16)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @"_ZNKSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E5emptyEv"(ptr noundef nonnull align 8 dereferenceable(25)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 4 dereferenceable(16) ptr @"_ZNKSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E3topEv"(ptr noundef nonnull align 8 dereferenceable(25)) #4 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E3popEv"(ptr noundef nonnull align 8 dereferenceable(25)) #0 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E4pushERKS0_"(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(16)) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 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)) #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0ED2Ev"(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #7 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS6boat_t", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 12}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5, i64 12, i64 4, !5}
!17 = distinct !{!17, !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"

%"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.anon = type { i8 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<boat_t, std::allocator<boat_t>>::_Vector_impl" }
%"struct.std::_Vector_base<boat_t, std::allocator<boat_t>>::_Vector_impl" = type { %"struct.std::_Vector_base<boat_t, std::allocator<boat_t>>::_Vector_impl_data" }
%"struct.std::_Vector_base<boat_t, std::allocator<boat_t>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.boat_t = type { i32, i32, i32, i32 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::priority_queue", align 8
  %3 = alloca %"class.std::vector", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %struct.boat_t, align 4
  %7 = alloca %struct.boat_t, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, i8 0, i64 24, i1 false)
  call void @_ZNSt6vectorI6boat_tSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #8
  invoke void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0EC2ERKS4_OS3_"(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 1 dereferenceable(1) @comp_boats, ptr noundef nonnull align 8 dereferenceable(24) %3)
          to label %9 unwind label %19

9:                                                ; preds = %0
  call void @_ZNSt6vectorI6boat_tSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #8
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %.preheader

.lr.ph:                                           ; preds = %9
  %12 = getelementptr inbounds i8, ptr %6, i64 4
  %13 = getelementptr inbounds i8, ptr %6, i64 8
  %14 = getelementptr inbounds i8, ptr %6, i64 12
  br label %21

.preheader:                                       ; preds = %29, %9
  %15 = call noundef zeroext i1 @"_ZNKSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E5emptyEv"(ptr noundef nonnull align 8 dereferenceable(25) %2)
  br i1 %15, label %._crit_edge, label %.lr.ph28

.lr.ph28:                                         ; preds = %.preheader
  %16 = getelementptr inbounds i8, ptr %7, i64 8
  %17 = getelementptr inbounds i8, ptr %7, i64 12
  %18 = getelementptr inbounds i8, ptr %7, i64 4
  br label %38

19:                                               ; preds = %0
  %20 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6vectorI6boat_tSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #8
  br label %61

21:                                               ; preds = %.lr.ph, %29
  %.01125 = phi i32 [ 0, %.lr.ph ], [ %30, %29 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  %22 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %4)
          to label %23 unwind label %33

23:                                               ; preds = %21
  %24 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %25 unwind label %33

25:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #8
  %26 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %26, ptr %6, align 4, !tbaa !9
  %27 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %27, ptr %12, align 4, !tbaa !11
  %28 = sub nsw i32 %27, %26
  store i32 %28, ptr %13, align 4, !tbaa !12
  store i32 %27, ptr %14, align 4, !tbaa !13
  invoke void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E4pushEOS0_"(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 4 dereferenceable(16) %6)
          to label %29 unwind label %35

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  %30 = add nuw nsw i32 %.01125, 1
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %21, label %.preheader, !llvm.loop !14

33:                                               ; preds = %23, %21
  %34 = landingpad { ptr, i32 }
          cleanup
  br label %37

35:                                               ; preds = %25
  %36 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #8
  br label %37

37:                                               ; preds = %35, %33
  %.pn20 = phi { ptr, i32 } [ %36, %35 ], [ %34, %33 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  br label %60

38:                                               ; preds = %.lr.ph28, %54
  %.027 = phi i32 [ -2147483648, %.lr.ph28 ], [ %.1, %54 ]
  %.0926 = phi i32 [ 0, %.lr.ph28 ], [ %.110, %54 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #8
  %39 = call noundef nonnull align 4 dereferenceable(16) ptr @"_ZNKSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E3topEv"(ptr noundef nonnull align 8 dereferenceable(25) %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %7, ptr noundef nonnull align 4 dereferenceable(16) %39, i64 16, i1 false), !tbaa.struct !16
  invoke void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E3popEv"(ptr noundef nonnull align 8 dereferenceable(25) %2)
          to label %40 unwind label %47

40:                                               ; preds = %38
  %41 = load i32, ptr %16, align 4, !tbaa !12
  %.not = icmp sgt i32 %.027, %41
  br i1 %.not, label %49, label %42

42:                                               ; preds = %40
  %43 = add nsw i32 %.0926, 1
  %44 = load i32, ptr %17, align 4, !tbaa !13
  br label %54

45:                                               ; preds = %57, %._crit_edge
  %46 = landingpad { ptr, i32 }
          cleanup
  br label %60

47:                                               ; preds = %51, %38
  %48 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #8
  br label %60

49:                                               ; preds = %40
  %50 = load i32, ptr %18, align 4, !tbaa !11
  %.not18 = icmp sgt i32 %.027, %50
  br i1 %.not18, label %54, label %51

51:                                               ; preds = %49
  store i32 %.027, ptr %16, align 4, !tbaa !12
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = add nsw i32 %52, %.027
  store i32 %53, ptr %17, align 4, !tbaa !13
  invoke void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E4pushERKS0_"(ptr noundef nonnull align 8 dereferenceable(25) %2, ptr noundef nonnull align 4 dereferenceable(16) %7)
          to label %54 unwind label %47

54:                                               ; preds = %49, %51, %42
  %.110 = phi i32 [ %43, %42 ], [ %.0926, %51 ], [ %.0926, %49 ]
  %.1 = phi i32 [ %44, %42 ], [ %.027, %51 ], [ %.027, %49 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #8
  %55 = call noundef zeroext i1 @"_ZNKSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E5emptyEv"(ptr noundef nonnull align 8 dereferenceable(25) %2)
  br i1 %55, label %._crit_edge, label %38, !llvm.loop !17

._crit_edge:                                      ; preds = %54, %.preheader
  %.09.lcssa = phi i32 [ 0, %.preheader ], [ %.110, %54 ]
  %56 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.09.lcssa)
          to label %57 unwind label %45

57:                                               ; preds = %._crit_edge
  %58 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %56, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %59 unwind label %45

59:                                               ; preds = %57
  call void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0ED2Ev"(ptr noundef nonnull align 8 dereferenceable(25) %2) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret void

60:                                               ; preds = %45, %47, %37
  %.pn20.pn = phi { ptr, i32 } [ %.pn20, %37 ], [ %48, %47 ], [ %46, %45 ]
  call void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0ED2Ev"(ptr noundef nonnull align 8 dereferenceable(25) %2) #8
  br label %61

61:                                               ; preds = %60, %19
  %.pn20.pn.pn = phi { ptr, i32 } [ %.pn20.pn, %60 ], [ %20, %19 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  resume { ptr, i32 } %.pn20.pn.pn
}

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

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 #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI6boat_tSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0EC2ERKS4_OS3_"(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI6boat_tSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4 align 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: mustprogress uwtable
declare hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E4pushEOS0_"(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @"_ZNKSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E5emptyEv"(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 4 dereferenceable(16) ptr @"_ZNKSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E3topEv"(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E3popEv"(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0E4pushERKS0_"(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #0 align 2

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

; 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 #0 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)) #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @"_ZNSt14priority_queueI6boat_tSt6vectorIS0_SaIS0_EE3$_0ED2Ev"(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #7 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS6boat_t", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 12}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5, i64 12, i64 4, !5}
!17 = distinct !{!17, !15}


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