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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4enki13TaskSchedulerC2Ev(ptr noundef nonnull align 8 dereferenceable(220) %0) unnamed_addr #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 0
  call void @llvm.memset.p0.i64(ptr align 8 %4, i8 0, i64 24, i1 false)
  %5 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 1
  call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 24, i1 false)
  %6 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 2
  store i32 0, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 4
  store ptr null, ptr %7, align 8, !tbaa !20
  %8 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 5
  store ptr null, ptr %8, align 8, !tbaa !21
  %9 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 6
  call void @_ZNSt6atomicIbEC2Eb(ptr noundef nonnull align 1 dereferenceable(1) %9, i1 noundef zeroext false) #4
  %10 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 7
  %11 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 8
  %12 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 10
  call void @_ZNSt6atomicIiEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %12, i32 noundef 0) #4
  %13 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 11
  call void @_ZNSt6atomicIiEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef 0) #4
  %14 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 12
  call void @_ZNSt6atomicIiEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %14, i32 noundef 0) #4
  %15 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 13
  store i32 0, ptr %15, align 8, !tbaa !22
  %16 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 15
  store ptr null, ptr %16, align 8, !tbaa !23
  %17 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 16
  store ptr null, ptr %17, align 8, !tbaa !24
  %18 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 17
  store i32 0, ptr %18, align 8, !tbaa !25
  %19 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 18
  store i8 0, ptr %19, align 4, !tbaa !26
  %20 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 20
  call void @_ZN4enki19TaskSchedulerConfigC2Ev(ptr noundef nonnull align 8 dereferenceable(96) %20)
  %21 = getelementptr inbounds %"class.enki::TaskScheduler", ptr %3, i32 0, i32 21
  call void @_ZNSt6atomicIiEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %21, i32 noundef 0) #4
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6atomicIbEC2Eb(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext) unnamed_addr #2 align 2

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

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #4 = { 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, !11, i64 48}
!10 = !{!"_ZTSN4enki13TaskSchedulerE", !7, i64 0, !7, i64 24, !11, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 73, !12, i64 74, !15, i64 76, !15, i64 80, !15, i64 84, !11, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !14, i64 116, !17, i64 120, !15, i64 216}
!11 = !{!"int", !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", !11, i64 0}
!17 = !{!"_ZTSN4enki19TaskSchedulerConfigE", !11, i64 0, !11, i64 4, !18, i64 8, !19, i64 72}
!18 = !{!"_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}
!19 = !{!"_ZTSN4enki15CustomAllocatorE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!10, !6, i64 56}
!21 = !{!10, !6, i64 64}
!22 = !{!10, !11, i64 88}
!23 = !{!10, !6, i64 96}
!24 = !{!10, !6, i64 104}
!25 = !{!10, !11, i64 112}
!26 = !{!10, !14, i64 116}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4enki13TaskSchedulerC2Ev(ptr noundef nonnull align 8 dereferenceable(220) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 56
  %3 = getelementptr inbounds i8, ptr %0, i64 72
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(52) %0, i8 0, i64 52, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, i8 0, i64 16, i1 false)
  tail call void @_ZNSt6atomicIbEC2Eb(ptr noundef nonnull align 1 dereferenceable(1) %3, i1 noundef zeroext false) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 76
  tail call void @_ZNSt6atomicIiEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef 0) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  tail call void @_ZNSt6atomicIiEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef 0) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 84
  tail call void @_ZNSt6atomicIiEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %6, i32 noundef 0) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 88
  store i32 0, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 96
  %9 = getelementptr inbounds i8, ptr %0, i64 120
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(21) %8, i8 0, i64 21, i1 false)
  tail call void @_ZN4enki19TaskSchedulerConfigC2Ev(ptr noundef nonnull align 8 dereferenceable(96) %9)
  %10 = getelementptr inbounds i8, ptr %0, i64 216
  tail call void @_ZNSt6atomicIiEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %10, i32 noundef 0) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4enki19TaskSchedulerConfigC2Ev(ptr noundef nonnull align 8 dereferenceable(96)) unnamed_addr #2 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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, !9, i64 88}
!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}


; Effective O3 passes: EarlyCSEPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass