; LLVM IR from aras-p/ToyPathTracer :: Cpp/Source/enkiTS/TaskScheduler.ll (ZN4enki13TaskScheduler21WaitForNewPinnedTasksEv)

; 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.enki::TaskScheduler" = type <{ [3 x ptr], [3 x ptr], i32, [4 x i8], ptr, ptr, %"struct.std::atomic", %"struct.std::atomic", %"struct.std::atomic", i8, %"struct.std::atomic.0", %"struct.std::atomic.0", %"struct.std::atomic.0", i32, [4 x i8], ptr, ptr, i32, i8, [3 x i8], %"struct.enki::TaskSchedulerConfig", %"struct.std::atomic.0", [4 x i8] }>
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i8 }
%"struct.enki::TaskSchedulerConfig" = type { i32, i32, %"struct.enki::ProfilerCallbacks", %"struct.enki::CustomAllocator" }
%"struct.enki::ProfilerCallbacks" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.enki::CustomAllocator" = type { ptr, ptr, ptr }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i32 }
%"struct.enki::ThreadDataStore" = type { ptr, %"struct.std::atomic.2", i32, [48 x i8] }
%"struct.std::atomic.2" = type { i32 }
%"class.enki::PinnedTaskList" = type { %"class.enki::LocklessMultiWriteIntrusiveList" }
%"class.enki::LocklessMultiWriteIntrusiveList" = type { %"struct.std::atomic.5", %"class.enki::IPinnedTask" }
%"struct.std::atomic.5" = type { %"struct.std::__atomic_base.6" }
%"struct.std::__atomic_base.6" = type { ptr }
%"class.enki::IPinnedTask" = type { %"class.enki::ICompletable", i32, %"struct.std::atomic.5" }
%"class.enki::ICompletable" = type { ptr, i32, %"struct.std::atomic.0", %"struct.std::atomic.0", i32, %"struct.std::atomic.0", ptr }

@_ZL13gtl_threadNum = external hidden thread_local global i32, align 4
@.str.3 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN4enki13TaskScheduler21WaitForNewPinnedTasksEv = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #2

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

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_112SafeCallbackEPFvjEj(ptr noundef, i32 noundef) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN4enki13SemaphoreWaitERNS_13semaphoreid_tE(ptr noundef nonnull align 1) #5

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4enki13TaskScheduler21WaitForNewPinnedTasksEv(ptr noundef nonnull align 8 dereferenceable(220) %0) #4 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  %9 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZL13gtl_threadNum)
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = icmp ne i32 %10, -1
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  br label %15

13:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.3, i32 noundef 1164, ptr noundef @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler21WaitForNewPinnedTasksEv) #6
  unreachable

14:                                               ; No predecessors!
  br label %15

15:                                               ; preds = %14, %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %16 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZL13gtl_threadNum)
  %17 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %17, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %18 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %8, i32 0, i32 4
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %19, i64 %21
  %23 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %22, i32 0, i32 1
  %24 = call noundef i32 @_ZNKSt6atomicIN4enki11ThreadStateEE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %23, i32 noundef 0) #7
  store i32 %24, ptr %4, align 4, !tbaa !21
  %25 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %8, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = load i32, ptr %3, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %26, i64 %28
  %30 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %29, i32 0, i32 1
  call void @_ZNSt6atomicIN4enki11ThreadStateEE5storeES1_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %30, i32 noundef 8, i32 noundef 5) #7
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #7
  store i8 0, ptr %5, align 1, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %47, %15
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 3
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  store i32 2, ptr %7, align 4
  br label %50

35:                                               ; preds = %31
  %36 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %8, i32 0, i32 1
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [3 x ptr], ptr %36, i64 0, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = load i32, ptr %3, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds %"class.enki::PinnedTaskList", ptr %40, i64 %42
  %44 = call noundef zeroext i1 @_ZNK4enki31LocklessMultiWriteIntrusiveListINS_11IPinnedTaskEE11IsListEmptyEv(ptr noundef nonnull align 8 dereferenceable(64) %43)
  br i1 %44, label %46, label %45

45:                                               ; preds = %35
  store i8 1, ptr %5, align 1, !tbaa !23
  store i32 2, ptr %7, align 4
  br label %50

46:                                               ; preds = %35
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %6, align 4, !tbaa !9
  br label %31, !llvm.loop !24

50:                                               ; preds = %45, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %51

51:                                               ; preds = %50
  %52 = load i8, ptr %5, align 1, !tbaa !23, !range !26, !noundef !27
  %53 = trunc i8 %52 to i1
  br i1 %53, label %72, label %54

54:                                               ; preds = %51
  %55 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %8, i32 0, i32 20
  %56 = getelementptr inbounds %"struct.enki::TaskSchedulerConfig", ptr %55, i32 0, i32 2
  %57 = getelementptr inbounds %"struct.enki::ProfilerCallbacks", ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %57, align 8, !tbaa !28
  %59 = load i32, ptr %3, align 4, !tbaa !9
  call void @_ZN12_GLOBAL__N_112SafeCallbackEPFvjEj(ptr noundef %58, i32 noundef %59)
  %60 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %8, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = load i32, ptr %3, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %61, i64 %63
  %65 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 64, !tbaa !29
  call void @_ZN4enki13SemaphoreWaitERNS_13semaphoreid_tE(ptr noundef nonnull align 1 %66)
  %67 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %8, i32 0, i32 20
  %68 = getelementptr inbounds %"struct.enki::TaskSchedulerConfig", ptr %67, i32 0, i32 2
  %69 = getelementptr inbounds %"struct.enki::ProfilerCallbacks", ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !32
  %71 = load i32, ptr %3, align 4, !tbaa !9
  call void @_ZN12_GLOBAL__N_112SafeCallbackEPFvjEj(ptr noundef %70, i32 noundef %71)
  br label %72

72:                                               ; preds = %54, %51
  %73 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %8, i32 0, i32 4
  %74 = load ptr, ptr %73, align 8, !tbaa !11
  %75 = load i32, ptr %3, align 4, !tbaa !9
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %74, i64 %76
  %78 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %77, i32 0, i32 1
  %79 = load i32, ptr %4, align 4, !tbaa !21
  call void @_ZNSt6atomicIN4enki11ThreadStateEE5storeES1_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %78, i32 noundef %79, i32 noundef 3) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  ret void
}

attributes #0 = { noreturn 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = { 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 = { noreturn nounwind }
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, !6, i64 56}
!12 = !{!"_ZTSN4enki13TaskSchedulerE", !7, i64 0, !7, i64 24, !10, i64 48, !6, i64 56, !6, i64 64, !13, i64 72, !13, i64 73, !13, i64 74, !16, i64 76, !16, i64 80, !16, i64 84, !10, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !15, i64 116, !18, i64 120, !16, i64 216}
!13 = !{!"_ZTSSt6atomicIbE", !14, i64 0}
!14 = !{!"_ZTSSt13__atomic_baseIbE", !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTSSt6atomicIiE", !17, i64 0}
!17 = !{!"_ZTSSt13__atomic_baseIiE", !10, i64 0}
!18 = !{!"_ZTSN4enki19TaskSchedulerConfigE", !10, i64 0, !10, i64 4, !19, i64 8, !20, i64 72}
!19 = !{!"_ZTSN4enki17ProfilerCallbacksE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!20 = !{!"_ZTSN4enki15CustomAllocatorE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!22, !22, i64 0}
!22 = !{!"_ZTSN4enki11ThreadStateE", !7, i64 0}
!23 = !{!15, !15, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!12, !6, i64 144}
!29 = !{!30, !6, i64 0}
!30 = !{!"_ZTSN4enki15ThreadDataStoreE", !6, i64 0, !31, i64 8, !10, i64 12, !7, i64 16}
!31 = !{!"_ZTSSt6atomicIN4enki11ThreadStateEE", !22, i64 0}
!32 = !{!12, !6, i64 152}


; 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.enki::ThreadDataStore" = type { ptr, %"struct.std::atomic.2", i32, [48 x i8] }
%"struct.std::atomic.2" = type { i32 }
%"class.enki::PinnedTaskList" = type { %"class.enki::LocklessMultiWriteIntrusiveList" }
%"class.enki::LocklessMultiWriteIntrusiveList" = type { %"struct.std::atomic.5", %"class.enki::IPinnedTask" }
%"struct.std::atomic.5" = type { %"struct.std::__atomic_base.6" }
%"struct.std::__atomic_base.6" = type { ptr }
%"class.enki::IPinnedTask" = type { %"class.enki::ICompletable", i32, %"struct.std::atomic.5" }
%"class.enki::ICompletable" = type { ptr, i32, %"struct.std::atomic.0", %"struct.std::atomic.0", i32, %"struct.std::atomic.0", ptr }
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i32 }

@_ZL13gtl_threadNum = external hidden thread_local local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN4enki13TaskScheduler21WaitForNewPinnedTasksEv = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #1

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

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_112SafeCallbackEPFvjEj(ptr noundef, i32 noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN4enki13SemaphoreWaitERNS_13semaphoreid_tE(ptr noundef nonnull align 1) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4enki13TaskScheduler21WaitForNewPinnedTasksEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(220) %0) local_unnamed_addr #3 align 2 {
  %2 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZL13gtl_threadNum)
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %3, -1
  br i1 %.not, label %4, label %5

4:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.3, i32 noundef 1164, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler21WaitForNewPinnedTasksEv) #5
  unreachable

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = zext i32 %3 to i64
  %9 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %7, i64 %8, i32 1
  %10 = tail call noundef i32 @_ZNKSt6atomicIN4enki11ThreadStateEE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %9, i32 noundef 0) #6
  %11 = load ptr, ptr %6, align 8, !tbaa !9
  %12 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %11, i64 %8, i32 1
  tail call void @_ZNSt6atomicIN4enki11ThreadStateEE5storeES1_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %12, i32 noundef 8, i32 noundef 5) #6
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load ptr, ptr %13, align 8, !tbaa !20
  %15 = getelementptr inbounds %"class.enki::PinnedTaskList", ptr %14, i64 %8
  %16 = tail call noundef zeroext i1 @_ZNK4enki31LocklessMultiWriteIntrusiveListINS_11IPinnedTaskEE11IsListEmptyEv(ptr noundef nonnull align 8 dereferenceable(64) %15)
  br i1 %16, label %17, label %.loopexit

17:                                               ; preds = %5
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  %19 = load ptr, ptr %18, align 8, !tbaa !20
  %20 = getelementptr inbounds %"class.enki::PinnedTaskList", ptr %19, i64 %8
  %21 = tail call noundef zeroext i1 @_ZNK4enki31LocklessMultiWriteIntrusiveListINS_11IPinnedTaskEE11IsListEmptyEv(ptr noundef nonnull align 8 dereferenceable(64) %20)
  br i1 %21, label %22, label %.loopexit

22:                                               ; preds = %17
  %23 = getelementptr inbounds i8, ptr %0, i64 40
  %24 = load ptr, ptr %23, align 8, !tbaa !20
  %25 = getelementptr inbounds %"class.enki::PinnedTaskList", ptr %24, i64 %8
  %26 = tail call noundef zeroext i1 @_ZNK4enki31LocklessMultiWriteIntrusiveListINS_11IPinnedTaskEE11IsListEmptyEv(ptr noundef nonnull align 8 dereferenceable(64) %25)
  br i1 %26, label %.critedge, label %.loopexit

.critedge:                                        ; preds = %22
  %27 = getelementptr inbounds i8, ptr %0, i64 144
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  tail call void @_ZN12_GLOBAL__N_112SafeCallbackEPFvjEj(ptr noundef %28, i32 noundef %3)
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %29, i64 %8
  %31 = load ptr, ptr %30, align 64, !tbaa !22
  tail call void @_ZN4enki13SemaphoreWaitERNS_13semaphoreid_tE(ptr noundef nonnull align 1 %31)
  %32 = getelementptr inbounds i8, ptr %0, i64 152
  %33 = load ptr, ptr %32, align 8, !tbaa !26
  tail call void @_ZN12_GLOBAL__N_112SafeCallbackEPFvjEj(ptr noundef %33, i32 noundef %3)
  br label %.loopexit

.loopexit:                                        ; preds = %5, %17, %22, %.critedge
  %34 = load ptr, ptr %6, align 8, !tbaa !9
  %35 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %34, i64 %8, i32 1
  tail call void @_ZNSt6atomicIN4enki11ThreadStateEE5storeES1_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %35, i32 noundef %10, i32 noundef 3) #6
  ret void
}

attributes #0 = { noreturn 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = { 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 = { noreturn nounwind }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 56}
!10 = !{!"_ZTSN4enki13TaskSchedulerE", !7, i64 0, !7, i64 24, !6, i64 48, !11, i64 56, !11, i64 64, !12, i64 72, !12, i64 73, !12, i64 74, !15, i64 76, !15, i64 80, !15, i64 84, !6, i64 88, !11, i64 96, !11, i64 104, !6, i64 112, !14, i64 116, !17, i64 120, !15, i64 216}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"_ZTSSt6atomicIbE", !13, i64 0}
!13 = !{!"_ZTSSt13__atomic_baseIbE", !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSSt6atomicIiE", !16, i64 0}
!16 = !{!"_ZTSSt13__atomic_baseIiE", !6, i64 0}
!17 = !{!"_ZTSN4enki19TaskSchedulerConfigE", !6, i64 0, !6, i64 4, !18, i64 8, !19, i64 72}
!18 = !{!"_ZTSN4enki17ProfilerCallbacksE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!19 = !{!"_ZTSN4enki15CustomAllocatorE", !11, i64 0, !11, i64 8, !11, i64 16}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !11, i64 144}
!22 = !{!23, !11, i64 0}
!23 = !{!"_ZTSN4enki15ThreadDataStoreE", !11, i64 0, !24, i64 8, !6, i64 12, !7, i64 16}
!24 = !{!"_ZTSSt6atomicIN4enki11ThreadStateEE", !25, i64 0}
!25 = !{!"_ZTSN4enki11ThreadStateE", !7, i64 0}
!26 = !{!10, !11, i64 152}


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