; LLVM IR from jrouwe/JoltPhysics :: Jolt/Core/JobSystemThreadPool.ll (ZN3JPH19JobSystemThreadPool11StopThreadsEv)

; 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.JPH::JobSystemThreadPool" = type <{ %"class.JPH::JobSystemWithBarrier", %"class.std::function", %"class.std::function", [40 x i8], %"class.JPH::FixedSizeFreeList", %"class.JPH::Array", [1024 x %"struct.std::atomic.2"], ptr, [32 x i8], %"struct.std::atomic", [60 x i8], %"class.JPH::Semaphore", %"struct.std::atomic.6", [63 x i8] }>
%"class.JPH::JobSystemWithBarrier" = type { %"class.JPH::JobSystem", i32, ptr }
%"class.JPH::JobSystem" = type { ptr }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%"class.JPH::FixedSizeFreeList" = type <{ i32, i32, i32, i32, i32, [4 x i8], ptr, [32 x i8], %"class.JPH::Mutex", %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic.0", %"struct.std::atomic", [60 x i8] }>
%"class.JPH::Mutex" = type { %"class.std::mutex", %"class.std::thread::id" }
%"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::thread::id" = type { i64 }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i64 }
%"class.JPH::Array" = type { i64, i64, ptr }
%"struct.std::atomic.2" = type { %"struct.std::__atomic_base.3" }
%"struct.std::__atomic_base.3" = type { ptr }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::Semaphore" = type { %"struct.std::atomic.4", %union.sem_t, [24 x i8] }
%"struct.std::atomic.4" = type { %"struct.std::__atomic_base.5" }
%"struct.std::__atomic_base.5" = type { i32 }
%union.sem_t = type { i64, [24 x i8] }
%"struct.std::atomic.6" = type { %"struct.std::__atomic_base.7" }
%"struct.std::__atomic_base.7" = type { i8 }
%"class.std::thread" = type { %"class.std::thread::id" }

@_ZN3JPH4FreeE = external global ptr, align 8

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

; 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 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext) #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH19JobSystemThreadPool11StopThreadsEv(ptr noundef nonnull align 64 dereferenceable(8768) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  %10 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 5
  %11 = call noundef zeroext i1 @_ZNK3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  br label %72

13:                                               ; preds = %1
  %14 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 12
  %15 = call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %14, i1 noundef zeroext true) #6
  %16 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 11
  %17 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 5
  %18 = call noundef i64 @_ZNK3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  %19 = trunc i64 %18 to i32
  call void @_ZN3JPH9Semaphore7ReleaseEj(ptr noundef nonnull align 64 dereferenceable(40) %16, i32 noundef %19)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %20 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 5
  store ptr %20, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call noundef ptr @_ZN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %21)
  store ptr %22, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call noundef ptr @_ZN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %23)
  store ptr %24, ptr %5, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %37, %13
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = icmp ne ptr %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %40

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %31, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call noundef zeroext i1 @_ZNKSt6thread8joinableEv(ptr noundef nonnull align 8 dereferenceable(8) %32) #6
  br i1 %33, label %34, label %36

34:                                               ; preds = %30
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZNSt6thread4joinEv(ptr noundef nonnull align 8 dereferenceable(8) %35)
  br label %36

36:                                               ; preds = %34, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %37

37:                                               ; preds = %36
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %"class.std::thread", ptr %38, i32 1
  store ptr %39, ptr %4, align 8, !tbaa !5
  br label %25

40:                                               ; preds = %29
  %41 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 5
  call void @_ZN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %41)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %62, %40
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 9
  %45 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %44) #6
  %46 = icmp ne i32 %43, %45
  br i1 %46, label %48, label %47

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

48:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %49 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 6
  %50 = load i32, ptr %7, align 4, !tbaa !9
  %51 = and i32 %50, 1023
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds [1024 x %"struct.std::atomic.2"], ptr %49, i64 0, i64 %52
  %54 = call noundef ptr @_ZNSt6atomicIPN3JPH9JobSystem3JobEE8exchangeES3_St12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef null, i32 noundef 5) #6
  store ptr %54, ptr %8, align 8, !tbaa !5
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %61

57:                                               ; preds = %48
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = call noundef i32 @_ZN3JPH9JobSystem3Job7ExecuteEv(ptr noundef nonnull align 8 dereferenceable(56) %58)
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN3JPH9JobSystem3Job7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(56) %60)
  br label %61

61:                                               ; preds = %57, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = add i32 %63, 1
  store i32 %64, ptr %7, align 4, !tbaa !9
  br label %42, !llvm.loop !11

65:                                               ; preds = %47
  %66 = load ptr, ptr @_ZN3JPH4FreeE, align 8, !tbaa !5
  %67 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 7
  %68 = load ptr, ptr %67, align 8, !tbaa !13
  call void %66(ptr noundef %68)
  %69 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 7
  store ptr null, ptr %69, align 8, !tbaa !13
  %70 = getelementptr inbounds %"class.JPH::JobSystemThreadPool", ptr %9, i32 0, i32 9
  %71 = call noundef i32 @_ZNSt13__atomic_baseIjEaSEj(ptr noundef nonnull align 4 dereferenceable(4) %70, i32 noundef 0) #6
  br label %72

72:                                               ; preds = %65, %12
  ret void
}

declare void @_ZN3JPH9Semaphore7ReleaseEj(ptr noundef nonnull align 64 dereferenceable(40), i32 noundef) #4

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

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

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

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

declare void @_ZNSt6thread4joinEv(ptr noundef nonnull align 8 dereferenceable(8)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) #5 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH9JobSystem3Job7ExecuteEv(ptr noundef nonnull align 8 dereferenceable(56)) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH9JobSystem3Job7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(56)) #5 align 2

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 = { 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 #3 = { 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 #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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 8536}
!14 = !{!"_ZTSN3JPH19JobSystemThreadPoolE", !15, i64 0, !17, i64 24, !17, i64 56, !19, i64 128, !29, i64 320, !7, i64 344, !6, i64 8536, !25, i64 8576, !30, i64 8640, !33, i64 8704}
!15 = !{!"_ZTSN3JPH20JobSystemWithBarrierE", !16, i64 0, !10, i64 8, !6, i64 16}
!16 = !{!"_ZTSN3JPH9JobSystemE"}
!17 = !{!"_ZTSSt8functionIFviEE", !18, i64 0, !6, i64 24}
!18 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!19 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_9JobSystem3JobEEE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !20, i64 64, !25, i64 112, !25, i64 116, !27, i64 120, !25, i64 128}
!20 = !{!"_ZTSN3JPH5MutexE", !21, i64 0, !23, i64 40}
!21 = !{!"_ZTSSt5mutex", !22, i64 0}
!22 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!23 = !{!"_ZTSNSt6thread2idE", !24, i64 0}
!24 = !{!"long", !7, i64 0}
!25 = !{!"_ZTSSt6atomicIjE", !26, i64 0}
!26 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!27 = !{!"_ZTSSt6atomicImE", !28, i64 0}
!28 = !{!"_ZTSSt13__atomic_baseImE", !24, i64 0}
!29 = !{!"_ZTSN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEEE", !24, i64 0, !24, i64 8, !6, i64 16}
!30 = !{!"_ZTSN3JPH9SemaphoreE", !31, i64 0, !7, i64 8}
!31 = !{!"_ZTSSt6atomicIiE", !32, i64 0}
!32 = !{!"_ZTSSt13__atomic_baseIiE", !10, i64 0}
!33 = !{!"_ZTSSt6atomicIbE", !34, i64 0}
!34 = !{!"_ZTSSt13__atomic_baseIbE", !35, i64 0}
!35 = !{!"bool", !7, i64 0}


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

%"struct.std::atomic.2" = type { %"struct.std::__atomic_base.3" }
%"struct.std::__atomic_base.3" = type { ptr }

@_ZN3JPH4FreeE = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH19JobSystemThreadPool11StopThreadsEv(ptr noundef nonnull align 64 dereferenceable(8768) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 320
  %3 = tail call noundef zeroext i1 @_ZNK3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  br i1 %3, label %33, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 8704
  %6 = tail call noundef zeroext i1 @_ZNSt6atomicIbEaSEb(ptr noundef nonnull align 1 dereferenceable(1) %5, i1 noundef zeroext true) #5
  %7 = getelementptr inbounds i8, ptr %0, i64 8640
  %8 = tail call noundef i64 @_ZNK3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %9 = trunc i64 %8 to i32
  tail call void @_ZN3JPH9Semaphore7ReleaseEj(ptr noundef nonnull align 64 dereferenceable(40) %7, i32 noundef %9)
  %10 = tail call noundef ptr @_ZN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %11 = tail call noundef ptr @_ZN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %.not18 = icmp eq ptr %10, %11
  br i1 %.not18, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %17, %4
  tail call void @_ZN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %12 = getelementptr inbounds i8, ptr %0, i64 8576
  %13 = tail call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %12) #5
  %.not1620 = icmp eq i32 %13, 0
  br i1 %.not1620, label %._crit_edge24, label %.lr.ph23

.lr.ph23:                                         ; preds = %._crit_edge
  %14 = getelementptr inbounds i8, ptr %0, i64 344
  br label %23

.lr.ph:                                           ; preds = %4, %17
  %.019 = phi ptr [ %18, %17 ], [ %10, %4 ]
  %15 = tail call noundef zeroext i1 @_ZNKSt6thread8joinableEv(ptr noundef nonnull align 8 dereferenceable(8) %.019) #5
  br i1 %15, label %16, label %17

16:                                               ; preds = %.lr.ph
  tail call void @_ZNSt6thread4joinEv(ptr noundef nonnull align 8 dereferenceable(8) %.019)
  br label %17

17:                                               ; preds = %16, %.lr.ph
  %18 = getelementptr inbounds i8, ptr %.019, i64 8
  %.not = icmp eq ptr %18, %11
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge24:                                    ; preds = %30, %._crit_edge
  %19 = load ptr, ptr @_ZN3JPH4FreeE, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %0, i64 8536
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  tail call void %19(ptr noundef %21)
  store ptr null, ptr %20, align 8, !tbaa !9
  %22 = tail call noundef i32 @_ZNSt13__atomic_baseIjEaSEj(ptr noundef nonnull align 4 dereferenceable(4) %12, i32 noundef 0) #5
  br label %33

23:                                               ; preds = %.lr.ph23, %30
  %.01421 = phi i32 [ 0, %.lr.ph23 ], [ %31, %30 ]
  %24 = and i32 %.01421, 1023
  %25 = zext nneg i32 %24 to i64
  %26 = getelementptr inbounds [1024 x %"struct.std::atomic.2"], ptr %14, i64 0, i64 %25
  %27 = tail call noundef ptr @_ZNSt6atomicIPN3JPH9JobSystem3JobEE8exchangeES3_St12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %26, ptr noundef null, i32 noundef 5) #5
  %.not17 = icmp eq ptr %27, null
  br i1 %.not17, label %30, label %28

28:                                               ; preds = %23
  %29 = tail call noundef i32 @_ZN3JPH9JobSystem3Job7ExecuteEv(ptr noundef nonnull align 8 dereferenceable(56) %27)
  tail call void @_ZN3JPH9JobSystem3Job7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(56) %27)
  br label %30

30:                                               ; preds = %28, %23
  %31 = add i32 %.01421, 1
  %32 = tail call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %12) #5
  %.not16 = icmp eq i32 %31, %32
  br i1 %.not16, label %._crit_edge24, label %23, !llvm.loop !33

33:                                               ; preds = %1, %._crit_edge24
  ret void
}

declare void @_ZN3JPH9Semaphore7ReleaseEj(ptr noundef nonnull align 64 dereferenceable(40), i32 noundef) local_unnamed_addr #3

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

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

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

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

declare void @_ZNSt6thread4joinEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3JPH9JobSystem3Job7ExecuteEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH9JobSystem3Job7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #4 align 2

attributes #0 = { 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 #1 = { 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 #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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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, !6, i64 8536}
!10 = !{!"_ZTSN3JPH19JobSystemThreadPoolE", !11, i64 0, !14, i64 24, !14, i64 56, !16, i64 128, !26, i64 320, !7, i64 344, !6, i64 8536, !22, i64 8576, !27, i64 8640, !30, i64 8704}
!11 = !{!"_ZTSN3JPH20JobSystemWithBarrierE", !12, i64 0, !13, i64 8, !6, i64 16}
!12 = !{!"_ZTSN3JPH9JobSystemE"}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSSt8functionIFviEE", !15, i64 0, !6, i64 24}
!15 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!16 = !{!"_ZTSN3JPH17FixedSizeFreeListINS_9JobSystem3JobEEE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !6, i64 24, !17, i64 64, !22, i64 112, !22, i64 116, !24, i64 120, !22, i64 128}
!17 = !{!"_ZTSN3JPH5MutexE", !18, i64 0, !20, i64 40}
!18 = !{!"_ZTSSt5mutex", !19, i64 0}
!19 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!20 = !{!"_ZTSNSt6thread2idE", !21, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSSt6atomicIjE", !23, i64 0}
!23 = !{!"_ZTSSt13__atomic_baseIjE", !13, i64 0}
!24 = !{!"_ZTSSt6atomicImE", !25, i64 0}
!25 = !{!"_ZTSSt13__atomic_baseImE", !21, i64 0}
!26 = !{!"_ZTSN3JPH5ArrayISt6threadNS_12STLAllocatorIS1_EEEE", !21, i64 0, !21, i64 8, !6, i64 16}
!27 = !{!"_ZTSN3JPH9SemaphoreE", !28, i64 0, !7, i64 8}
!28 = !{!"_ZTSSt6atomicIiE", !29, i64 0}
!29 = !{!"_ZTSSt13__atomic_baseIiE", !13, i64 0}
!30 = !{!"_ZTSSt6atomicIbE", !31, i64 0}
!31 = !{!"_ZTSSt13__atomic_baseIbE", !32, i64 0}
!32 = !{!"bool", !7, i64 0}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}


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