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

; 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.enki::SubTaskSet" = type { ptr, %"struct.enki::TaskSetPartition" }
%"struct.enki::TaskSetPartition" = type { i32, i32 }
%"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 }
%"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.enki::ThreadDataStore" = type { ptr, %"struct.std::atomic.2", i32, [48 x i8] }
%"struct.std::atomic.2" = type { i32 }
%"class.enki::ITaskSet" = type <{ %"class.enki::ICompletable", i32, i32, i32, [4 x i8] }>

@.str.3 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__._ZN4enki13TaskScheduler19AddTaskSetToPipeIntEPNS_8ITaskSetEj = external hidden unnamed_addr constant [68 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4enki13TaskScheduler19AddTaskSetToPipeIntEPNS_8ITaskSetEj(ptr noundef nonnull align 8 dereferenceable(220) %0, ptr noundef %1, i32 noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.enki::SubTaskSet", align 8
  %10 = alloca %"struct.enki::SubTaskSet", align 8
  %11 = 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
  %12 = load ptr, ptr %4, align 8
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"class.enki::ICompletable", ptr %13, i32 0, i32 2
  %15 = call noundef i32 @_ZNKSt13__atomic_baseIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) %14) #7
  %16 = icmp eq i32 %15, 2
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  br label %20

18:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.14, ptr noundef @.str.3, i32 noundef 863, ptr noundef @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler19AddTaskSetToPipeIntEPNS_8ITaskSetEj) #8
  unreachable

19:                                               ; No predecessors!
  br label %20

20:                                               ; preds = %19, %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %21 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %12, i32 0, i32 4
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %22, i64 %24
  %26 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %25, i32 0, i32 1
  %27 = call noundef i32 @_ZNKSt6atomicIN4enki11ThreadStateEE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %26, i32 noundef 0) #7
  store i32 %27, ptr %7, align 4, !tbaa !21
  %28 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %12, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %29, i64 %31
  %33 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %32, i32 0, i32 1
  call void @_ZNSt6atomicIN4enki11ThreadStateEE5storeES1_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %33, i32 noundef 2, i32 noundef 0) #7
  call void @_ZSt19atomic_thread_fenceSt12memory_order(i32 noundef 2) #7
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.enki::ITaskSet", ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 8, !tbaa !23
  %37 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %12, i32 0, i32 13
  %38 = load i32, ptr %37, align 8, !tbaa !27
  %39 = udiv i32 %36, %38
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"class.enki::ITaskSet", ptr %40, i32 0, i32 3
  store i32 %39, ptr %41, align 8, !tbaa !28
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.enki::ITaskSet", ptr %42, i32 0, i32 3
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.enki::ITaskSet", ptr %44, i32 0, i32 2
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %43, ptr noundef nonnull align 4 dereferenceable(4) %45)
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.enki::ITaskSet", ptr %48, i32 0, i32 3
  store i32 %47, ptr %49, align 8, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %"class.enki::ITaskSet", ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !23
  %53 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %12, i32 0, i32 17
  %54 = load i32, ptr %53, align 8, !tbaa !29
  %55 = udiv i32 %52, %54
  store i32 %55, ptr %8, align 4, !tbaa !9
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %"class.enki::ITaskSet", ptr %56, i32 0, i32 2
  %58 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %57)
  %59 = load i32, ptr %58, align 4, !tbaa !9
  store i32 %59, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #7
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.enki::SubTaskSet", ptr %9, i32 0, i32 0
  store ptr %60, ptr %61, align 8, !tbaa !30
  %62 = getelementptr inbounds %"struct.enki::SubTaskSet", ptr %9, i32 0, i32 1
  %63 = getelementptr inbounds %"struct.enki::TaskSetPartition", ptr %62, i32 0, i32 0
  store i32 0, ptr %63, align 8, !tbaa !33
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %"class.enki::ITaskSet", ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 8, !tbaa !23
  %67 = getelementptr inbounds %"struct.enki::SubTaskSet", ptr %9, i32 0, i32 1
  %68 = getelementptr inbounds %"struct.enki::TaskSetPartition", ptr %67, i32 0, i32 1
  store i32 %66, ptr %68, align 4, !tbaa !34
  %69 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !35
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8
  %73 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 1
  %74 = load i64, ptr %73, align 8
  call void @_ZN4enki13TaskScheduler15SplitAndAddTaskEjNS_10SubTaskSetEj(ptr noundef nonnull align 8 dereferenceable(220) %12, i32 noundef %69, ptr %72, i64 %74, i32 noundef %70)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %"class.enki::ICompletable", ptr %75, i32 0, i32 2
  %77 = call noundef i32 @_ZNSt13__atomic_baseIiE9fetch_subEiSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %76, i32 noundef 1, i32 noundef 4) #7
  store i32 %77, ptr %11, align 4, !tbaa !9
  %78 = load i32, ptr %11, align 4, !tbaa !9
  %79 = icmp eq i32 2, %78
  br i1 %79, label %80, label %83

80:                                               ; preds = %20
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load i32, ptr %6, align 4, !tbaa !9
  call void @_ZN4enki13TaskScheduler12TaskCompleteEPNS_12ICompletableEbj(ptr noundef nonnull align 8 dereferenceable(220) %12, ptr noundef %81, i1 noundef zeroext true, i32 noundef %82)
  br label %83

83:                                               ; preds = %80, %20
  %84 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %12, i32 0, i32 4
  %85 = load ptr, ptr %84, align 8, !tbaa !11
  %86 = load i32, ptr %6, align 4, !tbaa !9
  %87 = zext i32 %86 to i64
  %88 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %85, i64 %87
  %89 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %88, i32 0, i32 1
  %90 = load i32, ptr %7, align 4, !tbaa !21
  call void @_ZNSt6atomicIN4enki11ThreadStateEE5storeES1_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %89, i32 noundef %90, i32 noundef 3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  ret void
}

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #5

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4enki13TaskScheduler12TaskCompleteEPNS_12ICompletableEbj(ptr noundef nonnull align 8 dereferenceable(220), ptr noundef, i1 noundef zeroext, i32 noundef) #0 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZSt19atomic_thread_fenceSt12memory_order(i32 noundef) #4

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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { alwaysinline 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { noreturn 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 = !{!24, !10, i64 40}
!24 = !{!"_ZTSN4enki8ITaskSetE", !25, i64 0, !10, i64 40, !10, i64 44, !10, i64 48}
!25 = !{!"_ZTSN4enki12ICompletableE", !26, i64 8, !16, i64 12, !16, i64 16, !10, i64 20, !16, i64 24, !6, i64 32}
!26 = !{!"_ZTSN4enki12TaskPriorityE", !7, i64 0}
!27 = !{!12, !10, i64 88}
!28 = !{!24, !10, i64 48}
!29 = !{!12, !10, i64 112}
!30 = !{!31, !6, i64 0}
!31 = !{!"_ZTSN4enki10SubTaskSetE", !6, i64 0, !32, i64 8}
!32 = !{!"_ZTSN4enki16TaskSetPartitionE", !10, i64 0, !10, i64 4}
!33 = !{!31, !10, i64 8}
!34 = !{!31, !10, i64 12}
!35 = !{i64 0, i64 8, !5, i64 8, i64 4, !9, i64 12, i64 4, !9}


; 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 }

@.str.3 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__._ZN4enki13TaskScheduler19AddTaskSetToPipeIntEPNS_8ITaskSetEj = external hidden unnamed_addr constant [68 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4enki13TaskScheduler19AddTaskSetToPipeIntEPNS_8ITaskSetEj(ptr noundef nonnull align 8 dereferenceable(220) %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca i32, align 4
  %5 = getelementptr inbounds i8, ptr %1, i64 12
  %6 = tail call noundef i32 @_ZNKSt13__atomic_baseIiEcviEv(ptr noundef nonnull align 4 dereferenceable(4) %5) #6
  %7 = icmp eq i32 %6, 2
  br i1 %7, label %9, label %8

8:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.3, i32 noundef 863, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4enki13TaskScheduler19AddTaskSetToPipeIntEPNS_8ITaskSetEj) #7
  unreachable

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = zext i32 %2 to i64
  %13 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %11, i64 %12, i32 1
  %14 = tail call noundef i32 @_ZNKSt6atomicIN4enki11ThreadStateEE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef 0) #6
  %15 = load ptr, ptr %10, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %15, i64 %12, i32 1
  tail call void @_ZNSt6atomicIN4enki11ThreadStateEE5storeES1_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %16, i32 noundef 2, i32 noundef 0) #6
  tail call void @_ZSt19atomic_thread_fenceSt12memory_order(i32 noundef 2) #6
  %17 = getelementptr inbounds i8, ptr %1, i64 40
  %18 = load i32, ptr %17, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %0, i64 88
  %20 = load i32, ptr %19, align 8, !tbaa !23
  %21 = udiv i32 %18, %20
  %22 = getelementptr inbounds i8, ptr %1, i64 48
  store i32 %21, ptr %22, align 8, !tbaa !24
  %23 = getelementptr inbounds i8, ptr %1, i64 44
  %24 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %22, ptr noundef nonnull align 4 dereferenceable(4) %23)
  %25 = load i32, ptr %24, align 4, !tbaa !25
  store i32 %25, ptr %22, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %26 = load i32, ptr %17, align 8, !tbaa !19
  %27 = getelementptr inbounds i8, ptr %0, i64 112
  %28 = load i32, ptr %27, align 8, !tbaa !26
  %29 = udiv i32 %26, %28
  store i32 %29, ptr %4, align 4, !tbaa !25
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %23)
  %31 = load i32, ptr %30, align 4, !tbaa !25
  store i32 %31, ptr %4, align 4, !tbaa !25
  %32 = load i32, ptr %17, align 8, !tbaa !19
  %.sroa.4.12.insert.ext = zext i32 %32 to i64
  %.sroa.4.12.insert.shift = shl nuw i64 %.sroa.4.12.insert.ext, 32
  call void @_ZN4enki13TaskScheduler15SplitAndAddTaskEjNS_10SubTaskSetEj(ptr noundef nonnull align 8 dereferenceable(220) %0, i32 noundef %2, ptr %1, i64 %.sroa.4.12.insert.shift, i32 noundef %31)
  %33 = call noundef i32 @_ZNSt13__atomic_baseIiE9fetch_subEiSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef 1, i32 noundef 4) #6
  %34 = icmp eq i32 %33, 2
  br i1 %34, label %35, label %36

35:                                               ; preds = %9
  call void @_ZN4enki13TaskScheduler12TaskCompleteEPNS_12ICompletableEbj(ptr noundef nonnull align 8 dereferenceable(220) %0, ptr noundef nonnull %1, i1 noundef zeroext true, i32 noundef %2)
  br label %36

36:                                               ; preds = %35, %9
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.enki::ThreadDataStore", ptr %37, i64 %12, i32 1
  call void @_ZNSt6atomicIN4enki11ThreadStateEE5storeES1_St12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %38, i32 noundef %14, i32 noundef 3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  ret void
}

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

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

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

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

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZSt19atomic_thread_fenceSt12memory_order(i32 noundef) local_unnamed_addr #4

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass