; LLVM IR from lynx-family/primjs :: src/gc/thread_pool.ll (ZN14ByteThreadPool10WaitFinishEbPSt6vectorIiSaIiEE)

; 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::unique_lock" = type <{ ptr, i8, [7 x i8] }>
%class.ByteThreadPool = type { %"class.std::__cxx11::basic_string", %"struct.std::atomic", %"struct.std::atomic", %"class.std::queue", i32, i32, %"struct.std::atomic.3", %"struct.std::atomic.3", %"class.std::mutex", %"class.std::condition_variable", %"class.std::condition_variable", %"class.std::condition_variable", %"class.std::condition_variable", %"class.std::vector" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i8 }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<ByteTask *, std::allocator<ByteTask *>>::_Deque_impl" }
%"struct.std::_Deque_base<ByteTask *, std::allocator<ByteTask *>>::_Deque_impl" = type { %"struct.std::_Deque_base<ByteTask *, std::allocator<ByteTask *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<ByteTask *, std::allocator<ByteTask *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"struct.std::atomic.3" = type { %"struct.std::__atomic_base.4" }
%"struct.std::__atomic_base.4" = type { i32 }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::condition_variable" = type { %"class.std::__condvar" }
%"class.std::__condvar" = type { %union.pthread_cond_t }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<BytePoolThread *, std::allocator<BytePoolThread *>>::_Vector_impl" }
%"struct.std::_Vector_base<BytePoolThread *, std::allocator<BytePoolThread *>>::_Vector_impl" = type { %"struct.std::_Vector_base<BytePoolThread *, std::allocator<BytePoolThread *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<BytePoolThread *, std::allocator<BytePoolThread *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK14ByteThreadPool8IsExitedEv(ptr noundef nonnull align 8 dereferenceable(392)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt13__atomic_baseIiE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK14ByteThreadPool9IsRunningEv(ptr noundef nonnull align 8 dereferenceable(392)) #1 align 2

declare void @_ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(9)) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14ByteThreadPool4StopEv(ptr noundef nonnull align 8 dereferenceable(392)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14ByteThreadPool14DrainTaskQueueEv(ptr noundef nonnull align 8 dereferenceable(392)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(40)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(40)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14ByteThreadPool10WaitFinishEbPSt6vectorIiSaIiEE(ptr noundef nonnull align 8 dereferenceable(392) %0, i1 noundef zeroext %1, ptr noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.std::unique_lock", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %11 = zext i1 %1 to i8
  store i8 %11, ptr %5, align 1, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8
  %13 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %50

15:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %46, %15
  store ptr null, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %class.ByteThreadPool, ptr %12, i32 0, i32 8
  call void @_ZNSt5mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(40) %17)
  %18 = getelementptr inbounds %class.ByteThreadPool, ptr %12, i32 0, i32 3
  %19 = call noundef zeroext i1 @_ZNKSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %18)
  br i1 %19, label %29, label %20

20:                                               ; preds = %16
  %21 = call noundef zeroext i1 @_ZNK14ByteThreadPool9IsRunningEv(ptr noundef nonnull align 8 dereferenceable(392) %12)
  br i1 %21, label %22, label %29

22:                                               ; preds = %20
  %23 = call noundef zeroext i1 @_ZNK14ByteThreadPool8IsExitedEv(ptr noundef nonnull align 8 dereferenceable(392) %12)
  br i1 %23, label %29, label %24

24:                                               ; preds = %22
  %25 = getelementptr inbounds %class.ByteThreadPool, ptr %12, i32 0, i32 3
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %25)
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  store ptr %27, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.ByteThreadPool, ptr %12, i32 0, i32 3
  call void @_ZNSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %28)
  br label %29

29:                                               ; preds = %24, %22, %20, %16
  %30 = getelementptr inbounds %class.ByteThreadPool, ptr %12, i32 0, i32 8
  call void @_ZNSt5mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(40) %30)
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %45

33:                                               ; preds = %29
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = getelementptr inbounds ptr, ptr %35, i64 2
  %37 = load ptr, ptr %36, align 8
  call void %37(ptr noundef nonnull align 8 dereferenceable(8) %34, i64 noundef 0)
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = icmp eq ptr %38, null
  br i1 %39, label %44, label %40

40:                                               ; preds = %33
  %41 = load ptr, ptr %38, align 8, !tbaa !13
  %42 = getelementptr inbounds ptr, ptr %41, i64 1
  %43 = load ptr, ptr %42, align 8
  call void %43(ptr noundef nonnull align 8 dereferenceable(8) %38) #5
  br label %44

44:                                               ; preds = %40, %33
  br label %45

45:                                               ; preds = %44, %29
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = icmp ne ptr %47, null
  br i1 %48, label %16, label %49, !llvm.loop !15

49:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %50

50:                                               ; preds = %49, %3
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %51 = getelementptr inbounds %class.ByteThreadPool, ptr %12, i32 0, i32 8
  call void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9) %8, ptr noundef nonnull align 8 dereferenceable(40) %51)
  br label %52

52:                                               ; preds = %69, %50
  %53 = getelementptr inbounds %class.ByteThreadPool, ptr %12, i32 0, i32 7
  %54 = call noundef i32 @_ZNKSt13__atomic_baseIiE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %53, i32 noundef 5) #5
  %55 = getelementptr inbounds %class.ByteThreadPool, ptr %12, i32 0, i32 5
  %56 = load i32, ptr %55, align 4, !tbaa !17
  %57 = icmp ne i32 %54, %56
  br i1 %57, label %58, label %65

58:                                               ; preds = %52
  %59 = invoke noundef zeroext i1 @_ZNK14ByteThreadPool9IsRunningEv(ptr noundef nonnull align 8 dereferenceable(392) %12)
          to label %60 unwind label %70

60:                                               ; preds = %58
  br i1 %59, label %61, label %65

61:                                               ; preds = %60
  %62 = invoke noundef zeroext i1 @_ZNK14ByteThreadPool8IsExitedEv(ptr noundef nonnull align 8 dereferenceable(392) %12)
          to label %63 unwind label %70

63:                                               ; preds = %61
  %64 = xor i1 %62, true
  br label %65

65:                                               ; preds = %63, %60, %52
  %66 = phi i1 [ false, %60 ], [ false, %52 ], [ %64, %63 ]
  br i1 %66, label %67, label %74

67:                                               ; preds = %65
  %68 = getelementptr inbounds %class.ByteThreadPool, ptr %12, i32 0, i32 11
  invoke void @_ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE(ptr noundef nonnull align 8 dereferenceable(48) %68, ptr noundef nonnull align 8 dereferenceable(9) %8)
          to label %69 unwind label %70

69:                                               ; preds = %67
  br label %52, !llvm.loop !41

70:                                               ; preds = %67, %61, %58
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %9, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %10, align 4
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  br label %75

74:                                               ; preds = %65
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  call void @_ZN14ByteThreadPool4StopEv(ptr noundef nonnull align 8 dereferenceable(392) %12)
  call void @_ZN14ByteThreadPool14DrainTaskQueueEv(ptr noundef nonnull align 8 dereferenceable(392) %12)
  ret void

75:                                               ; preds = %70
  %76 = load ptr, ptr %9, align 8
  %77 = load i32, ptr %10, align 4
  %78 = insertvalue { ptr, i32 } poison, ptr %76, 0
  %79 = insertvalue { ptr, i32 } %78, i32 %77, 1
  resume { ptr, i32 } %79
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { alwaysinline 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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !30, i64 124}
!18 = !{!"_ZTS14ByteThreadPool", !19, i64 0, !22, i64 32, !22, i64 33, !24, i64 40, !30, i64 120, !30, i64 124, !31, i64 128, !31, i64 132, !33, i64 136, !35, i64 176, !35, i64 224, !35, i64 272, !35, i64 320, !37, i64 368}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !21, i64 8, !7, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSSt6atomicIbE", !23, i64 0}
!23 = !{!"_ZTSSt13__atomic_baseIbE", !10, i64 0}
!24 = !{!"_ZTSSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE", !25, i64 0}
!25 = !{!"_ZTSSt5dequeIP8ByteTaskSaIS1_EE", !26, i64 0}
!26 = !{!"_ZTSSt11_Deque_baseIP8ByteTaskSaIS1_EE", !27, i64 0}
!27 = !{!"_ZTSNSt11_Deque_baseIP8ByteTaskSaIS1_EE11_Deque_implE", !28, i64 0}
!28 = !{!"_ZTSNSt11_Deque_baseIP8ByteTaskSaIS1_EE16_Deque_impl_dataE", !6, i64 0, !21, i64 8, !29, i64 16, !29, i64 48}
!29 = !{!"_ZTSSt15_Deque_iteratorIP8ByteTaskRS1_PS1_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!30 = !{!"int", !7, i64 0}
!31 = !{!"_ZTSSt6atomicIiE", !32, i64 0}
!32 = !{!"_ZTSSt13__atomic_baseIiE", !30, i64 0}
!33 = !{!"_ZTSSt5mutex", !34, i64 0}
!34 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!35 = !{!"_ZTSSt18condition_variable", !36, i64 0}
!36 = !{!"_ZTSSt9__condvar", !7, i64 0}
!37 = !{!"_ZTSSt6vectorIP14BytePoolThreadSaIS1_EE", !38, i64 0}
!38 = !{!"_ZTSSt12_Vector_baseIP14BytePoolThreadSaIS1_EE", !39, i64 0}
!39 = !{!"_ZTSNSt12_Vector_baseIP14BytePoolThreadSaIS1_EE12_Vector_implE", !40, i64 0}
!40 = !{!"_ZTSNSt12_Vector_baseIP14BytePoolThreadSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!41 = distinct !{!41, !16}


; 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::unique_lock" = type <{ ptr, i8, [7 x i8] }>

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK14ByteThreadPool8IsExitedEv(ptr noundef nonnull align 8 dereferenceable(392)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt13__atomic_baseIiE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK14ByteThreadPool9IsRunningEv(ptr noundef nonnull align 8 dereferenceable(392)) local_unnamed_addr #1 align 2

declare void @_ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(9)) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14ByteThreadPool4StopEv(ptr noundef nonnull align 8 dereferenceable(392)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14ByteThreadPool14DrainTaskQueueEv(ptr noundef nonnull align 8 dereferenceable(392)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14ByteThreadPool10WaitFinishEbPSt6vectorIiSaIiEE(ptr noundef nonnull align 8 dereferenceable(392) %0, i1 noundef zeroext %1, ptr nocapture noundef readnone %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::unique_lock", align 8
  br i1 %1, label %.preheader, label %.critedge9

.preheader:                                       ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 136
  tail call void @_ZNSt5mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(40) %5)
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = tail call noundef zeroext i1 @_ZNKSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  br i1 %7, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %14
  %8 = tail call noundef zeroext i1 @_ZNK14ByteThreadPool9IsRunningEv(ptr noundef nonnull align 8 dereferenceable(392) %0)
  br i1 %8, label %9, label %.thread

9:                                                ; preds = %.lr.ph
  %10 = tail call noundef zeroext i1 @_ZNK14ByteThreadPool8IsExitedEv(ptr noundef nonnull align 8 dereferenceable(392) %0)
  br i1 %10, label %.thread, label %11

.thread:                                          ; preds = %.lr.ph, %9, %14, %.preheader
  tail call void @_ZNSt5mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(40) %5)
  br label %.critedge9

11:                                               ; preds = %9
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  tail call void @_ZNSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  tail call void @_ZNSt5mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(40) %5)
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %.critedge9, label %14

14:                                               ; preds = %11
  %15 = load ptr, ptr %13, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %17 = load ptr, ptr %16, align 8
  tail call void %17(ptr noundef nonnull align 8 dereferenceable(8) %13, i64 noundef 0)
  %18 = load ptr, ptr %13, align 8, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load ptr, ptr %19, align 8
  tail call void %20(ptr noundef nonnull align 8 dereferenceable(8) %13) #5
  tail call void @_ZNSt5mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(40) %5)
  %21 = tail call noundef zeroext i1 @_ZNKSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  br i1 %21, label %.thread, label %.lr.ph, !llvm.loop !11

.critedge9:                                       ; preds = %11, %.thread, %3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %22 = getelementptr inbounds i8, ptr %0, i64 136
  call void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9) %4, ptr noundef nonnull align 8 dereferenceable(40) %22)
  %23 = getelementptr inbounds i8, ptr %0, i64 132
  %24 = getelementptr inbounds i8, ptr %0, i64 124
  %25 = getelementptr inbounds i8, ptr %0, i64 272
  br label %26

26:                                               ; preds = %33, %.critedge9
  %27 = call noundef i32 @_ZNKSt13__atomic_baseIiE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %23, i32 noundef 5) #5
  %28 = load i32, ptr %24, align 4, !tbaa !13
  %.not7 = icmp eq i32 %27, %28
  br i1 %.not7, label %.critedge, label %29

29:                                               ; preds = %26
  %30 = call noundef zeroext i1 @_ZNK14ByteThreadPool9IsRunningEv(ptr noundef nonnull align 8 dereferenceable(392) %0)
  br i1 %30, label %31, label %.critedge

31:                                               ; preds = %29
  %32 = call noundef zeroext i1 @_ZNK14ByteThreadPool8IsExitedEv(ptr noundef nonnull align 8 dereferenceable(392) %0)
  br i1 %32, label %.critedge, label %33

33:                                               ; preds = %31
  invoke void @_ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE(ptr noundef nonnull align 8 dereferenceable(48) %25, ptr noundef nonnull align 8 dereferenceable(9) %4)
          to label %26 unwind label %34, !llvm.loop !38

34:                                               ; preds = %33
  %35 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %4) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  resume { ptr, i32 } %35

.critedge:                                        ; preds = %29, %26, %31
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %4) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  call void @_ZN14ByteThreadPool4StopEv(ptr noundef nonnull align 8 dereferenceable(392) %0)
  call void @_ZN14ByteThreadPool14DrainTaskQueueEv(ptr noundef nonnull align 8 dereferenceable(392) %0)
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { alwaysinline 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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !27, i64 124}
!14 = !{!"_ZTS14ByteThreadPool", !15, i64 0, !18, i64 32, !18, i64 33, !21, i64 40, !27, i64 120, !27, i64 124, !28, i64 128, !28, i64 132, !30, i64 136, !32, i64 176, !32, i64 224, !32, i64 272, !32, i64 320, !34, i64 368}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !7, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSSt6atomicIbE", !19, i64 0}
!19 = !{!"_ZTSSt13__atomic_baseIbE", !20, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{!"_ZTSSt5queueIP8ByteTaskSt5dequeIS1_SaIS1_EEE", !22, i64 0}
!22 = !{!"_ZTSSt5dequeIP8ByteTaskSaIS1_EE", !23, i64 0}
!23 = !{!"_ZTSSt11_Deque_baseIP8ByteTaskSaIS1_EE", !24, i64 0}
!24 = !{!"_ZTSNSt11_Deque_baseIP8ByteTaskSaIS1_EE11_Deque_implE", !25, i64 0}
!25 = !{!"_ZTSNSt11_Deque_baseIP8ByteTaskSaIS1_EE16_Deque_impl_dataE", !6, i64 0, !17, i64 8, !26, i64 16, !26, i64 48}
!26 = !{!"_ZTSSt15_Deque_iteratorIP8ByteTaskRS1_PS1_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!27 = !{!"int", !7, i64 0}
!28 = !{!"_ZTSSt6atomicIiE", !29, i64 0}
!29 = !{!"_ZTSSt13__atomic_baseIiE", !27, i64 0}
!30 = !{!"_ZTSSt5mutex", !31, i64 0}
!31 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!32 = !{!"_ZTSSt18condition_variable", !33, i64 0}
!33 = !{!"_ZTSSt9__condvar", !7, i64 0}
!34 = !{!"_ZTSSt6vectorIP14BytePoolThreadSaIS1_EE", !35, i64 0}
!35 = !{!"_ZTSSt12_Vector_baseIP14BytePoolThreadSaIS1_EE", !36, i64 0}
!36 = !{!"_ZTSNSt12_Vector_baseIP14BytePoolThreadSaIS1_EE12_Vector_implE", !37, i64 0}
!37 = !{!"_ZTSNSt12_Vector_baseIP14BytePoolThreadSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!38 = distinct !{!38, !12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass