; LLVM IR from NVIDIA/DALI :: dali/pipeline/util/thread_pool.ll (ZN4dali10ThreadPool11WaitForWorkEb)

; 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.anon = type { ptr }
%"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] }
%"class.dali::ThreadPool" = type { %"class.std::vector", %"class.std::priority_queue", i8, i8, i8, i32, %"class.std::mutex", %"class.std::condition_variable", %"class.std::condition_variable", %"class.std::vector.5" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = 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 }
%"class.std::priority_queue" = type <{ %"class.std::vector.0", [8 x i8] }>
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::pair<long, std::function<void (int)>>, std::allocator<std::pair<long, std::function<void (int)>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long, std::function<void (int)>>, std::allocator<std::pair<long, std::function<void (int)>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long, std::function<void (int)>>, std::allocator<std::pair<long, std::function<void (int)>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long, std::function<void (int)>>, std::allocator<std::pair<long, std::function<void (int)>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<std::queue<std::__cxx11::basic_string<char>>, std::allocator<std::queue<std::__cxx11::basic_string<char>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::queue<std::__cxx11::basic_string<char>>, std::allocator<std::queue<std::__cxx11::basic_string<char>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::queue<std::__cxx11::basic_string<char>>, std::allocator<std::queue<std::__cxx11::basic_string<char>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::queue<std::__cxx11::basic_string<char>>, std::allocator<std::queue<std::__cxx11::basic_string<char>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZTISt13runtime_error = external constant ptr
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1

; 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 void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

declare ptr @__cxa_allocate_exception(i64)

declare void @__cxa_throw(ptr, ptr, ptr)

declare void @__cxa_free_exception(ptr)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali10ThreadPool11WaitForWorkEb(ptr noundef nonnull align 8 dereferenceable(224) %0, i1 noundef zeroext %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca %"class.std::unique_lock", align 8
  %6 = alloca %class.anon, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca %"class.std::__cxx11::basic_string", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %11 = zext i1 %1 to i8
  store i8 %11, ptr %4, align 1, !tbaa !9
  %12 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #5
  %13 = getelementptr inbounds %"class.dali::ThreadPool", ptr %12, i32 0, i32 6
  call void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9) %5, ptr noundef nonnull align 8 dereferenceable(40) %13)
  %14 = getelementptr inbounds %"class.dali::ThreadPool", ptr %12, i32 0, i32 8
  %15 = getelementptr inbounds %class.anon, ptr %6, i32 0, i32 0
  store ptr %12, ptr %15, align 8, !tbaa !11
  %16 = getelementptr inbounds %class.anon, ptr %6, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8
  invoke void @"_ZNSt18condition_variable4waitIZN4dali10ThreadPool11WaitForWorkEbE3$_0EEvRSt11unique_lockISt5mutexET_"(ptr noundef nonnull align 8 dereferenceable(48) %14, ptr noundef nonnull align 8 dereferenceable(9) %5, ptr %17)
          to label %18 unwind label %29

18:                                               ; preds = %2
  %19 = getelementptr inbounds %"class.dali::ThreadPool", ptr %12, i32 0, i32 4
  store i8 0, ptr %19, align 2, !tbaa !13
  %20 = load i8, ptr %4, align 1, !tbaa !9, !range !34, !noundef !35
  %21 = trunc i8 %20 to i1
  br i1 %21, label %22, label %76

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !36
  br label %23

23:                                               ; preds = %71, %22
  %24 = load i64, ptr %9, align 8, !tbaa !36
  %25 = getelementptr inbounds %"class.dali::ThreadPool", ptr %12, i32 0, i32 0
  %26 = call noundef i64 @_ZNKSt6vectorISt6threadSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %25) #5
  %27 = icmp ult i64 %24, %26
  br i1 %27, label %33, label %28

28:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %75

29:                                               ; preds = %2
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %7, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %8, align 4
  br label %77

33:                                               ; preds = %23
  %34 = getelementptr inbounds %"class.dali::ThreadPool", ptr %12, i32 0, i32 9
  %35 = load i64, ptr %9, align 8, !tbaa !36
  %36 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %34, i64 noundef %35) #5
  %37 = invoke noundef zeroext i1 @_ZNKSt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS5_SaIS5_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %36)
          to label %38 unwind label %52

38:                                               ; preds = %33
  br i1 %37, label %70, label %39

39:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #5
  %40 = getelementptr inbounds %"class.dali::ThreadPool", ptr %12, i32 0, i32 9
  %41 = load i64, ptr %9, align 8, !tbaa !36
  %42 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %40, i64 noundef %41) #5
  %43 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS5_SaIS5_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %42)
          to label %44 unwind label %56

44:                                               ; preds = %39
  invoke void @_ZN4dali11make_stringIJA17_cmA3_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEES8_DpRKT_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %10, ptr noundef nonnull align 1 dereferenceable(17) @.str.8, ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 1 dereferenceable(3) @.str.4, ptr noundef nonnull align 8 dereferenceable(32) %43)
          to label %45 unwind label %56

45:                                               ; preds = %44
  %46 = getelementptr inbounds %"class.dali::ThreadPool", ptr %12, i32 0, i32 9
  %47 = load i64, ptr %9, align 8, !tbaa !36
  %48 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %46, i64 noundef %47) #5
  invoke void @_ZNSt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS5_SaIS5_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %48)
          to label %49 unwind label %60

49:                                               ; preds = %45
  %50 = call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16) %50, ptr noundef nonnull align 8 dereferenceable(32) %10)
          to label %51 unwind label %64

51:                                               ; preds = %49
  invoke void @__cxa_throw(ptr %50, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #6
          to label %83 unwind label %60

52:                                               ; preds = %33
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %7, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %8, align 4
  br label %74

56:                                               ; preds = %44, %39
  %57 = landingpad { ptr, i32 }
          cleanup
  %58 = extractvalue { ptr, i32 } %57, 0
  store ptr %58, ptr %7, align 8
  %59 = extractvalue { ptr, i32 } %57, 1
  store i32 %59, ptr %8, align 4
  br label %69

60:                                               ; preds = %51, %45
  %61 = landingpad { ptr, i32 }
          cleanup
  %62 = extractvalue { ptr, i32 } %61, 0
  store ptr %62, ptr %7, align 8
  %63 = extractvalue { ptr, i32 } %61, 1
  store i32 %63, ptr %8, align 4
  br label %68

64:                                               ; preds = %49
  %65 = landingpad { ptr, i32 }
          cleanup
  %66 = extractvalue { ptr, i32 } %65, 0
  store ptr %66, ptr %7, align 8
  %67 = extractvalue { ptr, i32 } %65, 1
  store i32 %67, ptr %8, align 4
  call void @__cxa_free_exception(ptr %50) #5
  br label %68

68:                                               ; preds = %64, %60
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #5
  br label %69

69:                                               ; preds = %68, %56
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #5
  br label %74

70:                                               ; preds = %38
  br label %71

71:                                               ; preds = %70
  %72 = load i64, ptr %9, align 8, !tbaa !36
  %73 = add i64 %72, 1
  store i64 %73, ptr %9, align 8, !tbaa !36
  br label %23, !llvm.loop !38

74:                                               ; preds = %69, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %77

75:                                               ; preds = %28
  br label %76

76:                                               ; preds = %75, %18
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #5
  ret void

77:                                               ; preds = %74, %29
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #5
  br label %78

78:                                               ; preds = %77
  %79 = load ptr, ptr %7, align 8
  %80 = load i32, ptr %8, align 4
  %81 = insertvalue { ptr, i32 } poison, ptr %79, 0
  %82 = insertvalue { ptr, i32 } %81, i32 %80, 1
  resume { ptr, i32 } %82

83:                                               ; preds = %51
  unreachable
}

; 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: 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 hidden void @"_ZNSt18condition_variable4waitIZN4dali10ThreadPool11WaitForWorkEbE3$_0EEvRSt11unique_lockISt5mutexET_"(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(9), ptr) #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali11make_stringIJA17_cmA3_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEES8_DpRKT_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 1 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 1 dereferenceable(3), ptr noundef nonnull align 8 dereferenceable(32)) #2

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

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

declare void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #3

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

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 = { "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 "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 }
attributes #6 = { noreturn }

!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 = !{!12, !6, i64 0}
!12 = !{!"_ZTSZN4dali10ThreadPool11WaitForWorkEbE3$_0", !6, i64 0}
!13 = !{!14, !10, i64 58}
!14 = !{!"_ZTSN4dali10ThreadPoolE", !15, i64 0, !19, i64 24, !10, i64 56, !10, i64 57, !10, i64 58, !25, i64 60, !26, i64 64, !28, i64 104, !28, i64 152, !30, i64 200}
!15 = !{!"_ZTSSt6vectorISt6threadSaIS0_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseISt6threadSaIS0_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt6threadSaIS0_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseISt6threadSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"_ZTSSt14priority_queueISt4pairIlSt8functionIFviEEESt6vectorIS4_SaIS4_EEN4dali10ThreadPool14SortByPriorityEE", !20, i64 0, !24, i64 24}
!20 = !{!"_ZTSSt6vectorISt4pairIlSt8functionIFviEEESaIS4_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseISt4pairIlSt8functionIFviEEESaIS4_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseISt4pairIlSt8functionIFviEEESaIS4_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseISt4pairIlSt8functionIFviEEESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!"_ZTSN4dali10ThreadPool14SortByPriorityE"}
!25 = !{!"int", !7, i64 0}
!26 = !{!"_ZTSSt5mutex", !27, i64 0}
!27 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!28 = !{!"_ZTSSt18condition_variable", !29, i64 0}
!29 = !{!"_ZTSSt9__condvar", !7, i64 0}
!30 = !{!"_ZTSSt6vectorISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EE", !31, i64 0}
!31 = !{!"_ZTSSt12_Vector_baseISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EE12_Vector_implE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!34 = !{i8 0, i8 2}
!35 = !{}
!36 = !{!37, !37, i64 0}
!37 = !{!"long", !7, i64 0}
!38 = distinct !{!38, !39}
!39 = !{!"llvm.loop.mustprogress"}


; 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] }>
%"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] }

@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZTISt13runtime_error = external constant ptr
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1

; 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 void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali10ThreadPool11WaitForWorkEb(ptr noundef nonnull align 8 dereferenceable(224) %0, i1 noundef zeroext %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.std::unique_lock", align 8
  %4 = alloca i64, align 8
  %5 = alloca %"class.std::__cxx11::basic_string", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  %6 = getelementptr inbounds i8, ptr %0, i64 64
  call void @_ZNSt11unique_lockISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(9) %3, ptr noundef nonnull align 8 dereferenceable(40) %6)
  %7 = getelementptr inbounds i8, ptr %0, i64 152
  invoke void @"_ZNSt18condition_variable4waitIZN4dali10ThreadPool11WaitForWorkEbE3$_0EEvRSt11unique_lockISt5mutexET_"(ptr noundef nonnull align 8 dereferenceable(48) %7, ptr noundef nonnull align 8 dereferenceable(9) %3, ptr nonnull %0)
          to label %8 unwind label %13

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %0, i64 58
  store i8 0, ptr %9, align 2, !tbaa !5
  br i1 %1, label %10, label %39

10:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store i64 0, ptr %4, align 8, !tbaa !30
  %11 = call noundef i64 @_ZNKSt6vectorISt6threadSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  %.not = icmp eq i64 %11, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %12 = getelementptr inbounds i8, ptr %0, i64 200
  br label %15

._crit_edge:                                      ; preds = %35, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %39

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

15:                                               ; preds = %.lr.ph, %35
  %16 = phi i64 [ 0, %.lr.ph ], [ %36, %35 ]
  %17 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %16) #5
  %18 = call noundef zeroext i1 @_ZNKSt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS5_SaIS5_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %17)
  br i1 %18, label %35, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #5
  %20 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %16) #5
  %21 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS5_SaIS5_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %20)
  invoke void @_ZN4dali11make_stringIJA17_cmA3_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEES8_DpRKT_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %5, ptr noundef nonnull align 1 dereferenceable(17) @.str.8, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 1 dereferenceable(3) @.str.4, ptr noundef nonnull align 8 dereferenceable(32) %21)
          to label %22 unwind label %27

22:                                               ; preds = %19
  %23 = load i64, ptr %4, align 8, !tbaa !30
  %24 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %23) #5
  call void @_ZNSt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS5_SaIS5_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %24)
  %25 = call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(32) %5)
          to label %26 unwind label %31

26:                                               ; preds = %22
  invoke void @__cxa_throw(ptr nonnull %25, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #6
          to label %41 unwind label %29

27:                                               ; preds = %19
  %28 = landingpad { ptr, i32 }
          cleanup
  br label %34

29:                                               ; preds = %26
  %30 = landingpad { ptr, i32 }
          cleanup
  br label %33

31:                                               ; preds = %22
  %32 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %25) #5
  br label %33

33:                                               ; preds = %31, %29
  %.pn = phi { ptr, i32 } [ %30, %29 ], [ %32, %31 ]
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #5
  br label %34

34:                                               ; preds = %33, %27
  %.pn.pn = phi { ptr, i32 } [ %.pn, %33 ], [ %28, %27 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %40

35:                                               ; preds = %15
  %36 = add nuw i64 %16, 1
  store i64 %36, ptr %4, align 8, !tbaa !30
  %37 = call noundef i64 @_ZNKSt6vectorISt6threadSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  %38 = icmp ult i64 %36, %37
  br i1 %38, label %15, label %._crit_edge, !llvm.loop !32

39:                                               ; preds = %._crit_edge, %8
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %3) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  ret void

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

41:                                               ; preds = %26
  unreachable
}

; 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: 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 hidden void @"_ZNSt18condition_variable4waitIZN4dali10ThreadPool11WaitForWorkEbE3$_0EEvRSt11unique_lockISt5mutexET_"(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(9), ptr) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali11make_stringIJA17_cmA3_cNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEES8_DpRKT_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 1 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 1 dereferenceable(3), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

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

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

declare void @_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #3

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

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 = { "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 "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 }
attributes #6 = { noreturn }

!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, !20, i64 58}
!6 = !{!"_ZTSN4dali10ThreadPoolE", !7, i64 0, !14, i64 24, !20, i64 56, !20, i64 57, !20, i64 58, !21, i64 60, !22, i64 64, !24, i64 104, !24, i64 152, !26, i64 200}
!7 = !{!"_ZTSSt6vectorISt6threadSaIS0_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseISt6threadSaIS0_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseISt6threadSaIS0_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseISt6threadSaIS0_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"_ZTSSt14priority_queueISt4pairIlSt8functionIFviEEESt6vectorIS4_SaIS4_EEN4dali10ThreadPool14SortByPriorityEE", !15, i64 0, !19, i64 24}
!15 = !{!"_ZTSSt6vectorISt4pairIlSt8functionIFviEEESaIS4_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseISt4pairIlSt8functionIFviEEESaIS4_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt4pairIlSt8functionIFviEEESaIS4_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseISt4pairIlSt8functionIFviEEESaIS4_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!19 = !{!"_ZTSN4dali10ThreadPool14SortByPriorityE"}
!20 = !{!"bool", !12, i64 0}
!21 = !{!"int", !12, i64 0}
!22 = !{!"_ZTSSt5mutex", !23, i64 0}
!23 = !{!"_ZTSSt12__mutex_base", !12, i64 0}
!24 = !{!"_ZTSSt18condition_variable", !25, i64 0}
!25 = !{!"_ZTSSt9__condvar", !12, i64 0}
!26 = !{!"_ZTSSt6vectorISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseISt5queueINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS6_SaIS6_EEESaISA_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!30 = !{!31, !31, i64 0}
!31 = !{!"long", !12, i64 0}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


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