; LLVM IR from ERGO-Code/HiGHS :: src/parallel/HighsTaskExecutor.ll (ZN17HighsTaskExecutor14ExecutorHandle7disposeEv)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.highs::cache_aligned::Deleter" = type { i8 }
%"struct.HighsTaskExecutor::ExecutorHandle" = type <{ ptr, i8, [7 x i8] }>
%class.HighsTaskExecutor = type { %"struct.std::atomic", %"struct.std::atomic.0", %"class.std::shared_ptr", %"class.std::vector", %"class.std::vector.2" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i8 }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::unique_ptr<HighsSplitDeque, highs::cache_aligned::Deleter<HighsSplitDeque>>, std::allocator<std::unique_ptr<HighsSplitDeque, highs::cache_aligned::Deleter<HighsSplitDeque>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::unique_ptr<HighsSplitDeque, highs::cache_aligned::Deleter<HighsSplitDeque>>, std::allocator<std::unique_ptr<HighsSplitDeque, highs::cache_aligned::Deleter<HighsSplitDeque>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::unique_ptr<HighsSplitDeque, highs::cache_aligned::Deleter<HighsSplitDeque>>, std::allocator<std::unique_ptr<HighsSplitDeque, highs::cache_aligned::Deleter<HighsSplitDeque>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::unique_ptr<HighsSplitDeque, highs::cache_aligned::Deleter<HighsSplitDeque>>, std::allocator<std::unique_ptr<HighsSplitDeque, highs::cache_aligned::Deleter<HighsSplitDeque>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.2" = type { %"struct.std::_Vector_base.3" }
%"struct.std::_Vector_base.3" = type { %"struct.std::_Vector_base<std::thread, std::allocator<std::thread>>::_Vector_impl" }
%"struct.std::_Vector_base<std::thread, std::allocator<std::thread>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::thread, std::allocator<std::thread>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::thread, std::allocator<std::thread>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17HighsTaskExecutor14ExecutorHandle7disposeEv(ptr noundef nonnull align 8 dereferenceable(9) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"struct.highs::cache_aligned::Deleter", align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %"struct.HighsTaskExecutor::ExecutorHandle", ptr %4, i32 0, i32 0
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %27

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"struct.HighsTaskExecutor::ExecutorHandle", ptr %4, i32 0, i32 1
  %11 = load i8, ptr %10, align 8, !tbaa !12, !range !13, !noundef !14
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %16

13:                                               ; preds = %9
  %14 = getelementptr inbounds %"struct.HighsTaskExecutor::ExecutorHandle", ptr %4, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  call void @_ZN17HighsTaskExecutor17stopWorkerThreadsEb(ptr noundef nonnull align 8 dereferenceable(72) %15, i1 noundef zeroext false)
  br label %16

16:                                               ; preds = %13, %9
  %17 = getelementptr inbounds %"struct.HighsTaskExecutor::ExecutorHandle", ptr %4, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds %class.HighsTaskExecutor, ptr %18, i32 0, i32 0
  %20 = call noundef i32 @_ZNSt13__atomic_baseIiEmmEv(ptr noundef nonnull align 4 dereferenceable(4) %19) #3
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %25

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  %23 = getelementptr inbounds %"struct.HighsTaskExecutor::ExecutorHandle", ptr %4, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  call void @_ZNK5highs13cache_aligned7DeleterI17HighsTaskExecutorEclEPS2_(ptr noundef nonnull align 1 dereferenceable(1) %3, ptr noundef %24)
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  br label %25

25:                                               ; preds = %22, %16
  %26 = getelementptr inbounds %"struct.HighsTaskExecutor::ExecutorHandle", ptr %4, i32 0, i32 0
  store ptr null, ptr %26, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %25, %8
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17HighsTaskExecutor17stopWorkerThreadsEb(ptr noundef nonnull align 8 dereferenceable(72), i1 noundef zeroext) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNSt13__atomic_baseIiEmmEv(ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK5highs13cache_aligned7DeleterI17HighsTaskExecutorEclEPS2_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef) #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !6, i64 0}
!10 = !{!"_ZTSN17HighsTaskExecutor14ExecutorHandleE", !6, i64 0, !11, i64 8}
!11 = !{!"bool", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{i8 0, i8 2}
!14 = !{}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.highs::cache_aligned::Deleter" = type { i8 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17HighsTaskExecutor14ExecutorHandle7disposeEv(ptr nocapture noundef nonnull align 8 dereferenceable(9) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %"struct.highs::cache_aligned::Deleter", align 1
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %17, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i8, ptr %6, align 8, !tbaa !11, !range !12, !noundef !13
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %10

9:                                                ; preds = %5
  tail call void @_ZN17HighsTaskExecutor17stopWorkerThreadsEb(ptr noundef nonnull align 8 dereferenceable(72) %3, i1 noundef zeroext false)
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %9, %5
  %11 = phi ptr [ %.pre, %9 ], [ %3, %5 ]
  %12 = tail call noundef i32 @_ZNSt13__atomic_baseIiEmmEv(ptr noundef nonnull align 4 dereferenceable(4) %11) #3
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #3
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  call void @_ZNK5highs13cache_aligned7DeleterI17HighsTaskExecutorEclEPS2_(ptr noundef nonnull align 1 dereferenceable(1) %2, ptr noundef %15)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #3
  br label %16

16:                                               ; preds = %14, %10
  store ptr null, ptr %0, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %1, %16
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17HighsTaskExecutor17stopWorkerThreadsEb(ptr noundef nonnull align 8 dereferenceable(72), i1 noundef zeroext) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNSt13__atomic_baseIiEmmEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK5highs13cache_aligned7DeleterI17HighsTaskExecutorEclEPS2_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !7, i64 0}
!6 = !{!"_ZTSN17HighsTaskExecutor14ExecutorHandleE", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{i8 0, i8 2}
!13 = !{}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass