; LLVM IR from simbody/simbody :: SimTKcommon/src/ParallelWorkQueue.ll (ZN5SimTK21ParallelWorkQueueImplC2Eii)

; 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::thread" = type { %"class.std::thread::id" }
%"class.std::thread::id" = type { i64 }
%"class.std::reference_wrapper" = type { ptr }
%"class.SimTK::ParallelWorkQueueImpl" = type { %"class.SimTK::PIMPLImplementation.base", i32, i32, i8, %"class.std::queue", %"class.std::mutex", %"class.std::condition_variable", %"class.std::condition_variable", %"class.SimTK::Array_" }
%"class.SimTK::PIMPLImplementation.base" = type <{ ptr, i32 }>
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<SimTK::ParallelWorkQueue::Task *, std::allocator<SimTK::ParallelWorkQueue::Task *>>::_Deque_impl" }
%"struct.std::_Deque_base<SimTK::ParallelWorkQueue::Task *, std::allocator<SimTK::ParallelWorkQueue::Task *>>::_Deque_impl" = type { %"struct.std::_Deque_base<SimTK::ParallelWorkQueue::Task *, std::allocator<SimTK::ParallelWorkQueue::Task *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<SimTK::ParallelWorkQueue::Task *, std::allocator<SimTK::ParallelWorkQueue::Task *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::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.SimTK::Array_" = type { %"class.SimTK::ArrayView_" }
%"class.SimTK::ArrayView_" = type { %"class.SimTK::ArrayViewConst_" }
%"class.SimTK::ArrayViewConst_" = type { ptr, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5SimTK21ParallelWorkQueueImplC2Eii(ptr noundef nonnull align 8 dereferenceable(256) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"class.std::thread", align 8
  %11 = alloca %"class.std::reference_wrapper", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %4, align 8
  call void @_ZN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(12) %12, ptr noundef null)
  %13 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 1
  %14 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %14, ptr %13, align 4, !tbaa !11
  %15 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 2
  store i32 0, ptr %15, align 8, !tbaa !29
  %16 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 3
  store i8 0, ptr %16, align 4, !tbaa !30
  %17 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 4
  invoke void @_ZNSt5queueIPN5SimTK17ParallelWorkQueue4TaskESt5dequeIS3_SaIS3_EEEC2IS6_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %17)
          to label %18 unwind label %32

18:                                               ; preds = %3
  %19 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 5
  call void @_ZNSt5mutexC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %19) #7
  %20 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 6
  call void @_ZNSt18condition_variableC1Ev(ptr noundef nonnull align 8 dereferenceable(48) %20) #7
  %21 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 7
  call void @_ZNSt18condition_variableC1Ev(ptr noundef nonnull align 8 dereferenceable(48) %21) #7
  %22 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 8
  invoke void @_ZN5SimTK6Array_ISt6threadjEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %22)
          to label %23 unwind label %36

23:                                               ; preds = %18
  %24 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 8
  %25 = load i32, ptr %6, align 4, !tbaa !9
  invoke void @_ZN5SimTK6Array_ISt6threadjE6resizeEj(ptr noundef nonnull align 8 dereferenceable(16) %24, i32 noundef %25)
          to label %26 unwind label %40

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %53, %26
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %44, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %65

32:                                               ; preds = %3
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %7, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %8, align 4
  br label %68

36:                                               ; preds = %18
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %7, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %8, align 4
  br label %67

40:                                               ; preds = %23
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %7, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %8, align 4
  br label %66

44:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %45 = call ptr @_ZSt3refIN5SimTK21ParallelWorkQueueImplEESt17reference_wrapperIT_ERS3_(ptr noundef nonnull align 8 dereferenceable(256) %12) #7
  %46 = getelementptr inbounds %"class.std::reference_wrapper", ptr %11, i32 0, i32 0
  store ptr %45, ptr %46, align 8
  invoke void @_ZNSt6threadC2IRFvRN5SimTK21ParallelWorkQueueImplEEJSt17reference_wrapperIS2_EEvEEOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull @_ZN5SimTKL10threadBodyERNS_21ParallelWorkQueueImplE, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %47 unwind label %56

47:                                               ; preds = %44
  %48 = getelementptr inbounds %"class.SimTK::ParallelWorkQueueImpl", ptr %12, i32 0, i32 8
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN5SimTK6Array_ISt6threadjEixEj(ptr noundef nonnull align 8 dereferenceable(16) %48, i32 noundef %49)
          to label %51 unwind label %60

51:                                               ; preds = %47
  %52 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6threadaSEOS_(ptr noundef nonnull align 8 dereferenceable(8) %50, ptr noundef nonnull align 8 dereferenceable(8) %10) #7
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %53

53:                                               ; preds = %51
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %9, align 4, !tbaa !9
  br label %27, !llvm.loop !31

56:                                               ; preds = %44
  %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 %64

60:                                               ; preds = %47
  %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
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #7
  br label %64

64:                                               ; preds = %60, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %66

65:                                               ; preds = %31
  ret void

66:                                               ; preds = %64, %40
  call void @_ZN5SimTK6Array_ISt6threadjED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %22) #7
  br label %67

67:                                               ; preds = %66, %36
  call void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %21) #7
  call void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %20) #7
  call void @_ZNSt5queueIPN5SimTK17ParallelWorkQueue4TaskESt5dequeIS3_SaIS3_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %17) #7
  br label %68

68:                                               ; preds = %67, %32
  call void @_ZN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEED2Ev(ptr noundef nonnull align 8 dereferenceable(12) %12) #7
  br label %69

69:                                               ; preds = %68
  %70 = load ptr, ptr %7, align 8
  %71 = load i32, ptr %8, align 4
  %72 = insertvalue { ptr, i32 } poison, ptr %70, 0
  %73 = insertvalue { ptr, i32 } %72, i32 %71, 1
  resume { ptr, i32 } %73
}

declare void @_ZN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef) unnamed_addr #1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare void @_ZNSt18condition_variableC1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5SimTK6Array_ISt6threadjE6resizeEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5SimTKL10threadBodyERNS_21ParallelWorkQueueImplE(ptr noundef nonnull align 8 dereferenceable(256)) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local ptr @_ZSt3refIN5SimTK21ParallelWorkQueueImplEESt17reference_wrapperIT_ERS3_(ptr noundef nonnull align 8 dereferenceable(256)) #5

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN5SimTK6Array_ISt6threadjEixEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #6 align 2

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

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

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

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

; Function Attrs: nounwind
declare void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIPN5SimTK17ParallelWorkQueue4TaskESt5dequeIS3_SaIS3_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #5 align 2

; Function Attrs: nounwind
declare void @_ZN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEED2Ev(ptr noundef nonnull align 8 dereferenceable(12)) unnamed_addr #3

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 = { "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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { alwaysinline 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 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"_ZTSN5SimTK21ParallelWorkQueueImplE", !13, i64 0, !10, i64 12, !10, i64 16, !14, i64 20, !15, i64 24, !22, i64 104, !24, i64 144, !24, i64 192, !26, i64 240}
!13 = !{!"_ZTSN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEEE", !6, i64 0, !10, i64 8}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSSt5queueIPN5SimTK17ParallelWorkQueue4TaskESt5dequeIS3_SaIS3_EEE", !16, i64 0}
!16 = !{!"_ZTSSt5dequeIPN5SimTK17ParallelWorkQueue4TaskESaIS3_EE", !17, i64 0}
!17 = !{!"_ZTSSt11_Deque_baseIPN5SimTK17ParallelWorkQueue4TaskESaIS3_EE", !18, i64 0}
!18 = !{!"_ZTSNSt11_Deque_baseIPN5SimTK17ParallelWorkQueue4TaskESaIS3_EE11_Deque_implE", !19, i64 0}
!19 = !{!"_ZTSNSt11_Deque_baseIPN5SimTK17ParallelWorkQueue4TaskESaIS3_EE16_Deque_impl_dataE", !6, i64 0, !20, i64 8, !21, i64 16, !21, i64 48}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSSt15_Deque_iteratorIPN5SimTK17ParallelWorkQueue4TaskERS3_PS3_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!22 = !{!"_ZTSSt5mutex", !23, i64 0}
!23 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!24 = !{!"_ZTSSt18condition_variable", !25, i64 0}
!25 = !{!"_ZTSSt9__condvar", !7, i64 0}
!26 = !{!"_ZTSN5SimTK6Array_ISt6threadjEE", !27, i64 0}
!27 = !{!"_ZTSN5SimTK10ArrayView_ISt6threadjEE", !28, i64 0}
!28 = !{!"_ZTSN5SimTK15ArrayViewConst_ISt6threadjEE", !6, i64 0, !10, i64 8, !10, i64 12}
!29 = !{!12, !10, i64 16}
!30 = !{!12, !14, i64 20}
!31 = distinct !{!31, !32}
!32 = !{!"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::thread" = type { %"class.std::thread::id" }
%"class.std::thread::id" = type { i64 }
%"class.std::reference_wrapper" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5SimTK21ParallelWorkQueueImplC2Eii(ptr noundef nonnull align 8 dereferenceable(256) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::thread", align 8
  %5 = alloca %"class.std::reference_wrapper", align 8
  tail call void @_ZN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef null)
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %1, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 0, ptr %7, align 8, !tbaa !27
  %8 = getelementptr inbounds i8, ptr %0, i64 20
  store i8 0, ptr %8, align 4, !tbaa !28
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  invoke void @_ZNSt5queueIPN5SimTK17ParallelWorkQueue4TaskESt5dequeIS3_SaIS3_EEEC2IS6_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
          to label %10 unwind label %17

10:                                               ; preds = %3
  %11 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @_ZNSt5mutexC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %11) #7
  %12 = getelementptr inbounds i8, ptr %0, i64 144
  tail call void @_ZNSt18condition_variableC1Ev(ptr noundef nonnull align 8 dereferenceable(48) %12) #7
  %13 = getelementptr inbounds i8, ptr %0, i64 192
  tail call void @_ZNSt18condition_variableC1Ev(ptr noundef nonnull align 8 dereferenceable(48) %13) #7
  %14 = getelementptr inbounds i8, ptr %0, i64 240
  invoke void @_ZN5SimTK6Array_ISt6threadjEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %14)
          to label %15 unwind label %19

15:                                               ; preds = %10
  invoke void @_ZN5SimTK6Array_ISt6threadjE6resizeEj(ptr noundef nonnull align 8 dereferenceable(16) %14, i32 noundef %2)
          to label %.preheader unwind label %21

.preheader:                                       ; preds = %15
  %16 = icmp sgt i32 %2, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %26, %.preheader
  ret void

17:                                               ; preds = %3
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %36

19:                                               ; preds = %10
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %35

21:                                               ; preds = %15
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %34

.lr.ph:                                           ; preds = %.preheader, %26
  %.017 = phi i32 [ %28, %26 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %23 = call ptr @_ZSt3refIN5SimTK21ParallelWorkQueueImplEESt17reference_wrapperIT_ERS3_(ptr noundef nonnull align 8 dereferenceable(256) %0) #7
  store ptr %23, ptr %5, align 8
  invoke void @_ZNSt6threadC2IRFvRN5SimTK21ParallelWorkQueueImplEEJSt17reference_wrapperIS2_EEvEEOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull @_ZN5SimTKL10threadBodyERNS_21ParallelWorkQueueImplE, ptr noundef nonnull align 8 dereferenceable(8) %5)
          to label %24 unwind label %29

24:                                               ; preds = %.lr.ph
  %25 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN5SimTK6Array_ISt6threadjEixEj(ptr noundef nonnull align 8 dereferenceable(16) %14, i32 noundef %.017)
          to label %26 unwind label %31

26:                                               ; preds = %24
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6threadaSEOS_(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  %28 = add nuw nsw i32 %.017, 1
  %exitcond.not = icmp eq i32 %28, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !29

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

31:                                               ; preds = %24
  %32 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  br label %33

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

34:                                               ; preds = %33, %21
  %.pn.pn = phi { ptr, i32 } [ %.pn, %33 ], [ %22, %21 ]
  call void @_ZN5SimTK6Array_ISt6threadjED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %14) #7
  br label %35

35:                                               ; preds = %34, %19
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %34 ], [ %20, %19 ]
  call void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %13) #7
  call void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %12) #7
  call void @_ZNSt5queueIPN5SimTK17ParallelWorkQueue4TaskESt5dequeIS3_SaIS3_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %9) #7
  br label %36

36:                                               ; preds = %35, %17
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn, %35 ], [ %18, %17 ]
  call void @_ZN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEED2Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) #7
  resume { ptr, i32 } %.pn.pn.pn.pn
}

declare void @_ZN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef) unnamed_addr #1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare void @_ZNSt18condition_variableC1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5SimTK6Array_ISt6threadjE6resizeEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5SimTKL10threadBodyERNS_21ParallelWorkQueueImplE(ptr noundef nonnull align 8 dereferenceable(256)) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local ptr @_ZSt3refIN5SimTK21ParallelWorkQueueImplEESt17reference_wrapperIT_ERS3_(ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #5

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN5SimTK6Array_ISt6threadjEixEj(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #6 align 2

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

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

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

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

; Function Attrs: nounwind
declare void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueIPN5SimTK17ParallelWorkQueue4TaskESt5dequeIS3_SaIS3_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #5 align 2

; Function Attrs: nounwind
declare void @_ZN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEED2Ev(ptr noundef nonnull align 8 dereferenceable(12)) unnamed_addr #3

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 = { "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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { alwaysinline 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 = { 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, !11, i64 12}
!6 = !{!"_ZTSN5SimTK21ParallelWorkQueueImplE", !7, i64 0, !11, i64 12, !11, i64 16, !12, i64 20, !13, i64 24, !20, i64 104, !22, i64 144, !22, i64 192, !24, i64 240}
!7 = !{!"_ZTSN5SimTK19PIMPLImplementationINS_17ParallelWorkQueueENS_21ParallelWorkQueueImplEEE", !8, i64 0, !11, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"_ZTSSt5queueIPN5SimTK17ParallelWorkQueue4TaskESt5dequeIS3_SaIS3_EEE", !14, i64 0}
!14 = !{!"_ZTSSt5dequeIPN5SimTK17ParallelWorkQueue4TaskESaIS3_EE", !15, i64 0}
!15 = !{!"_ZTSSt11_Deque_baseIPN5SimTK17ParallelWorkQueue4TaskESaIS3_EE", !16, i64 0}
!16 = !{!"_ZTSNSt11_Deque_baseIPN5SimTK17ParallelWorkQueue4TaskESaIS3_EE11_Deque_implE", !17, i64 0}
!17 = !{!"_ZTSNSt11_Deque_baseIPN5SimTK17ParallelWorkQueue4TaskESaIS3_EE16_Deque_impl_dataE", !8, i64 0, !18, i64 8, !19, i64 16, !19, i64 48}
!18 = !{!"long", !9, i64 0}
!19 = !{!"_ZTSSt15_Deque_iteratorIPN5SimTK17ParallelWorkQueue4TaskERS3_PS3_E", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!20 = !{!"_ZTSSt5mutex", !21, i64 0}
!21 = !{!"_ZTSSt12__mutex_base", !9, i64 0}
!22 = !{!"_ZTSSt18condition_variable", !23, i64 0}
!23 = !{!"_ZTSSt9__condvar", !9, i64 0}
!24 = !{!"_ZTSN5SimTK6Array_ISt6threadjEE", !25, i64 0}
!25 = !{!"_ZTSN5SimTK10ArrayView_ISt6threadjEE", !26, i64 0}
!26 = !{!"_ZTSN5SimTK15ArrayViewConst_ISt6threadjEE", !8, i64 0, !11, i64 8, !11, i64 12}
!27 = !{!6, !11, i64 16}
!28 = !{!6, !12, i64 20}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


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