; LLVM IR from jrouwe/JoltPhysics :: Jolt/Core (JobSystemWithBarrier)

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

%"struct.JPH::AssertLastParam" = type { i8 }
%"class.std::chrono::duration" = type { i64 }
%"class.JPH::JobSystem::JobHandle" = type { %"class.JPH::Ref" }
%"class.JPH::Ref" = type { ptr }
%"class.JPH::JobSystemWithBarrier::BarrierImpl" = type { %"class.JPH::JobSystem::Barrier", %"struct.std::atomic", [2048 x %"struct.std::atomic.0"], [48 x i8], %"struct.std::atomic.2", [60 x i8], %"struct.std::atomic.2", %"struct.std::atomic.4", [56 x i8], %"class.JPH::Semaphore" }
%"class.JPH::JobSystem::Barrier" = type { ptr }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i8 }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { ptr }
%"struct.std::atomic.2" = type { %"struct.std::__atomic_base.3" }
%"struct.std::__atomic_base.3" = type { i32 }
%"struct.std::atomic.4" = type { %"struct.std::__atomic_base.5" }
%"struct.std::__atomic_base.5" = type { i32 }
%"class.JPH::Semaphore" = type { %"struct.std::atomic.4", %union.sem_t, [24 x i8] }
%union.sem_t = type { i64, [24 x i8] }

@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH9JobSystem3Job10SetBarrierEPNS0_7BarrierE(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef) #3 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNSt13__atomic_baseIjEppEi(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #1 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNSt11this_thread9sleep_forIlSt5ratioILl1ELl1000000EEEEvRKNSt6chrono8durationIT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8)) #3

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH20JobSystemWithBarrier11BarrierImpl7AddJobsEPKNS_9JobSystem9JobHandleEj(ptr noundef nonnull align 64 dereferenceable(16640) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #5 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %"struct.JPH::AssertLastParam", align 1
  %13 = alloca %"class.std::chrono::duration", align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %15 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #6
  store i8 0, ptr %7, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %16, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds %"class.JPH::JobSystem::JobHandle", ptr %17, i64 %19
  store ptr %20, ptr %9, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %68, %3
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = icmp ult ptr %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %71

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call noundef ptr @_ZNK3JPH3RefINS_9JobSystem3JobEE6GetPtrEv(ptr noundef nonnull align 8 dereferenceable(8) %27)
  store ptr %28, ptr %10, align 8, !tbaa !5
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = call noundef zeroext i1 @_ZN3JPH9JobSystem3Job10SetBarrierEPNS0_7BarrierE(ptr noundef nonnull align 8 dereferenceable(56) %29, ptr noundef %15)
  br i1 %30, label %31, label %67

31:                                               ; preds = %26
  %32 = getelementptr inbounds %"class.JPH::JobSystemWithBarrier::BarrierImpl", ptr %15, i32 0, i32 7
  %33 = call noundef i32 @_ZNSt13__atomic_baseIiEppEi(ptr noundef nonnull align 4 dereferenceable(4) %32, i32 noundef 0) #6
  %34 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %35 = trunc i8 %34 to i1
  br i1 %35, label %42, label %36

36:                                               ; preds = %31
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = call noundef zeroext i1 @_ZNK3JPH9JobSystem3Job13CanBeExecutedEv(ptr noundef nonnull align 8 dereferenceable(56) %37)
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  store i8 1, ptr %7, align 1, !tbaa !11
  %40 = getelementptr inbounds %"class.JPH::JobSystemWithBarrier::BarrierImpl", ptr %15, i32 0, i32 7
  %41 = call noundef i32 @_ZNSt13__atomic_baseIiEppEi(ptr noundef nonnull align 4 dereferenceable(4) %40, i32 noundef 0) #6
  br label %42

42:                                               ; preds = %39, %36, %31
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN3JPH9JobSystem3Job6AddRefEv(ptr noundef nonnull align 8 dereferenceable(56) %43)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %44 = getelementptr inbounds %"class.JPH::JobSystemWithBarrier::BarrierImpl", ptr %15, i32 0, i32 6
  %45 = call noundef i32 @_ZNSt13__atomic_baseIjEppEi(ptr noundef nonnull align 4 dereferenceable(4) %44, i32 noundef 0) #6
  store i32 %45, ptr %11, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %58, %42
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = getelementptr inbounds %"class.JPH::JobSystemWithBarrier::BarrierImpl", ptr %15, i32 0, i32 4
  %49 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %48) #6
  %50 = sub i32 %47, %49
  %51 = icmp uge i32 %50, 2048
  br i1 %51, label %52, label %59

52:                                               ; preds = %46
  br label %53

53:                                               ; preds = %52
  %54 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 86, ptr noundef @.str.3)
  br i1 %54, label %55, label %56

55:                                               ; preds = %53
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !15
  br label %56

56:                                               ; preds = %55, %53
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 100, ptr %14, align 4, !tbaa !9
  call void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000000EEEC2IivEERKT_(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 4 dereferenceable(4) %14)
  call void @_ZNSt11this_thread9sleep_forIlSt5ratioILl1ELl1000000EEEEvRKNSt6chrono8durationIT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8) %13)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %46, !llvm.loop !16

59:                                               ; preds = %46
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = getelementptr inbounds %"class.JPH::JobSystemWithBarrier::BarrierImpl", ptr %15, i32 0, i32 2
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = and i32 %62, 2047
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds [2048 x %"struct.std::atomic.0"], ptr %61, i64 0, i64 %64
  %66 = call noundef ptr @_ZNSt6atomicIPN3JPH9JobSystem3JobEEaSES3_(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef %60) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %67

67:                                               ; preds = %59, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %"class.JPH::JobSystem::JobHandle", ptr %69, i32 1
  store ptr %70, ptr %8, align 8, !tbaa !5
  br label %21, !llvm.loop !18

71:                                               ; preds = %25
  %72 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %73 = trunc i8 %72 to i1
  br i1 %73, label %74, label %76

74:                                               ; preds = %71
  %75 = getelementptr inbounds %"class.JPH::JobSystemWithBarrier::BarrierImpl", ptr %15, i32 0, i32 9
  call void @_ZN3JPH9Semaphore7ReleaseEj(ptr noundef nonnull align 64 dereferenceable(40) %75, i32 noundef 1)
  br label %76

76:                                               ; preds = %74, %71
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #6
  ret void
}

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 = { 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 #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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{i64 2157458854}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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::chrono::duration" = type { i64 }
%"class.JPH::JobSystem::JobHandle" = type { %"class.JPH::Ref" }
%"class.JPH::Ref" = type { ptr }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { ptr }

@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 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

; 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 ptr @_ZNSt6atomicIPN3JPH9JobSystem3JobEEaSES3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH9JobSystem3Job10SetBarrierEPNS0_7BarrierE(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef) local_unnamed_addr #3 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNSt13__atomic_baseIjEppEi(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #1 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 #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNSt11this_thread9sleep_forIlSt5ratioILl1ELl1000000EEEEvRKNSt6chrono8durationIT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH20JobSystemWithBarrier11BarrierImpl7AddJobsEPKNS_9JobSystem9JobHandleEj(ptr noundef nonnull align 64 dereferenceable(16640) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #5 align 2 {
  %4 = alloca %"class.std::chrono::duration", align 8
  %5 = alloca i32, align 4
  %6 = zext i32 %2 to i64
  %7 = getelementptr inbounds %"class.JPH::JobSystem::JobHandle", ptr %1, i64 %6
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge20.thread, label %.lr.ph19

.lr.ph19:                                         ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 16516
  %9 = getelementptr inbounds i8, ptr %0, i64 16512
  %10 = getelementptr inbounds i8, ptr %0, i64 16448
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  br label %13

._crit_edge20:                                    ; preds = %38
  %12 = trunc nuw i8 %.2 to i1
  br i1 %12, label %41, label %._crit_edge20.thread

13:                                               ; preds = %.lr.ph19, %38
  %.017 = phi i8 [ 0, %.lr.ph19 ], [ %.2, %38 ]
  %.01516 = phi ptr [ %1, %.lr.ph19 ], [ %39, %38 ]
  %14 = call noundef ptr @_ZNK3JPH3RefINS_9JobSystem3JobEE6GetPtrEv(ptr noundef nonnull align 8 dereferenceable(8) %.01516)
  %15 = call noundef zeroext i1 @_ZN3JPH9JobSystem3Job10SetBarrierEPNS0_7BarrierE(ptr noundef nonnull align 8 dereferenceable(56) %14, ptr noundef nonnull %0)
  br i1 %15, label %16, label %38

16:                                               ; preds = %13
  %17 = call noundef i32 @_ZNSt13__atomic_baseIiEppEi(ptr noundef nonnull align 4 dereferenceable(4) %8, i32 noundef 0) #6
  %18 = trunc nuw i8 %.017 to i1
  br i1 %18, label %23, label %19

19:                                               ; preds = %16
  %20 = call noundef zeroext i1 @_ZNK3JPH9JobSystem3Job13CanBeExecutedEv(ptr noundef nonnull align 8 dereferenceable(56) %14)
  br i1 %20, label %21, label %23

21:                                               ; preds = %19
  %22 = call noundef i32 @_ZNSt13__atomic_baseIiEppEi(ptr noundef nonnull align 4 dereferenceable(4) %8, i32 noundef 0) #6
  br label %23

23:                                               ; preds = %21, %19, %16
  %.1 = phi i8 [ %.017, %16 ], [ 1, %21 ], [ %.017, %19 ]
  call void @_ZN3JPH9JobSystem3Job6AddRefEv(ptr noundef nonnull align 8 dereferenceable(56) %14)
  %24 = call noundef i32 @_ZNSt13__atomic_baseIjEppEi(ptr noundef nonnull align 4 dereferenceable(4) %9, i32 noundef 0) #6
  %25 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %10) #6
  %26 = sub i32 %24, %25
  %27 = icmp ugt i32 %26, 2047
  br i1 %27, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %23, %30
  %28 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jS1_NS_15AssertLastParamE(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 86, ptr noundef nonnull @.str.3)
  br i1 %28, label %29, label %30

29:                                               ; preds = %.lr.ph
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !5
  br label %30

30:                                               ; preds = %29, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  store i32 100, ptr %5, align 4, !tbaa !6
  call void @_ZNSt6chrono8durationIlSt5ratioILl1ELl1000000EEEC2IivEERKT_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @_ZNSt11this_thread9sleep_forIlSt5ratioILl1ELl1000000EEEEvRKNSt6chrono8durationIT_T0_EE(ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %31 = call noundef i32 @_ZNKSt13__atomic_baseIjEcvjEv(ptr noundef nonnull align 4 dereferenceable(4) %10) #6
  %32 = sub i32 %24, %31
  %33 = icmp ugt i32 %32, 2047
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %30, %23
  %34 = and i32 %24, 2047
  %35 = zext nneg i32 %34 to i64
  %36 = getelementptr inbounds [2048 x %"struct.std::atomic.0"], ptr %11, i64 0, i64 %35
  %37 = call noundef ptr @_ZNSt6atomicIPN3JPH9JobSystem3JobEEaSES3_(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef nonnull %14) #6
  br label %38

38:                                               ; preds = %._crit_edge, %13
  %.2 = phi i8 [ %.1, %._crit_edge ], [ %.017, %13 ]
  %39 = getelementptr inbounds i8, ptr %.01516, i64 8
  %40 = icmp ult ptr %39, %7
  br i1 %40, label %13, label %._crit_edge20, !llvm.loop !12

41:                                               ; preds = %._crit_edge20
  %42 = getelementptr inbounds i8, ptr %0, i64 16576
  call void @_ZN3JPH9Semaphore7ReleaseEj(ptr noundef nonnull align 64 dereferenceable(40) %42, i32 noundef 1)
  br label %._crit_edge20.thread

._crit_edge20.thread:                             ; preds = %3, %41, %._crit_edge20
  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 = { 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 = { 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 #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 = { 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 = !{i64 2157458854}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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