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

; 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.enkiParamsTaskSet = type { ptr, i32, i32, i32 }
%struct.enkiTaskSet = type { %"class.enki::ITaskSet.base", ptr, ptr }
%"class.enki::ITaskSet.base" = type <{ %"class.enki::ICompletable", i32, 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::ITaskSet" = type <{ %"class.enki::ICompletable", i32, i32, i32, [4 x i8] }>

@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__.enkiSetParamsTaskSet = external hidden unnamed_addr constant [60 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @enkiSetParamsTaskSet(ptr noundef %0, ptr noundef byval(%struct.enkiParamsTaskSet) align 8 %1) #1 {
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.enkiParamsTaskSet, ptr %1, i32 0, i32 3
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = icmp slt i32 %5, 3
  br i1 %6, label %7, label %8

7:                                                ; preds = %2
  br label %10

8:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.3, i32 noundef 247, ptr noundef @__PRETTY_FUNCTION__.enkiSetParamsTaskSet) #2
  unreachable

9:                                                ; No predecessors!
  br label %10

10:                                               ; preds = %9, %7
  %11 = getelementptr inbounds %struct.enkiParamsTaskSet, ptr %1, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.enkiTaskSet, ptr %13, i32 0, i32 2
  store ptr %12, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds %struct.enkiParamsTaskSet, ptr %1, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !20
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.enki::ITaskSet", ptr %17, i32 0, i32 1
  store i32 %16, ptr %18, align 8, !tbaa !21
  %19 = getelementptr inbounds %struct.enkiParamsTaskSet, ptr %1, i32 0, i32 2
  %20 = load i32, ptr %19, align 4, !tbaa !22
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.enki::ITaskSet", ptr %21, i32 0, i32 2
  store i32 %20, ptr %22, align 4, !tbaa !23
  %23 = getelementptr inbounds %struct.enkiParamsTaskSet, ptr %1, i32 0, i32 3
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %"class.enki::ICompletable", ptr %25, i32 0, i32 1
  store i32 %24, ptr %26, align 8, !tbaa !24
  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 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 = { 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, !11, i64 16}
!10 = !{!"_ZTS17enkiParamsTaskSet", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!14, !6, i64 64}
!14 = !{!"_ZTS11enkiTaskSet", !15, i64 0, !6, i64 56, !6, i64 64}
!15 = !{!"_ZTSN4enki8ITaskSetE", !16, i64 0, !11, i64 40, !11, i64 44, !11, i64 48}
!16 = !{!"_ZTSN4enki12ICompletableE", !17, i64 8, !18, i64 12, !18, i64 16, !11, i64 20, !18, i64 24, !6, i64 32}
!17 = !{!"_ZTSN4enki12TaskPriorityE", !7, i64 0}
!18 = !{!"_ZTSSt6atomicIiE", !19, i64 0}
!19 = !{!"_ZTSSt13__atomic_baseIiE", !11, i64 0}
!20 = !{!10, !11, i64 8}
!21 = !{!15, !11, i64 40}
!22 = !{!10, !11, i64 12}
!23 = !{!15, !11, i64 44}
!24 = !{!16, !17, i64 8}


; 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.enkiParamsTaskSet = type { ptr, i32, i32, i32 }

@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__.enkiSetParamsTaskSet = external hidden unnamed_addr constant [60 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 nounwind uwtable
define dso_local void @enkiSetParamsTaskSet(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly byval(%struct.enkiParamsTaskSet) align 8 %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 16
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp slt i32 %4, 3
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 noundef 247, ptr noundef nonnull @__PRETTY_FUNCTION__.enkiSetParamsTaskSet) #2
  unreachable

7:                                                ; preds = %2
  %8 = load ptr, ptr %1, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %8, ptr %9, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = load <2 x i32>, ptr %10, align 8, !tbaa !19
  store <2 x i32> %12, ptr %11, align 8, !tbaa !19
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %4, ptr %13, align 8, !tbaa !20
  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 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 = { 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 16}
!6 = !{!"_ZTS17enkiParamsTaskSet", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !7, i64 64}
!13 = !{!"_ZTS11enkiTaskSet", !14, i64 0, !7, i64 56, !7, i64 64}
!14 = !{!"_ZTSN4enki8ITaskSetE", !15, i64 0, !10, i64 40, !10, i64 44, !10, i64 48}
!15 = !{!"_ZTSN4enki12ICompletableE", !16, i64 8, !17, i64 12, !17, i64 16, !10, i64 20, !17, i64 24, !7, i64 32}
!16 = !{!"_ZTSN4enki12TaskPriorityE", !8, i64 0}
!17 = !{!"_ZTSSt6atomicIiE", !18, i64 0}
!18 = !{!"_ZTSSt13__atomic_baseIiE", !10, i64 0}
!19 = !{!10, !10, i64 0}
!20 = !{!15, !16, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass