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

; 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::Dependency" = type { ptr, ptr, ptr }
%"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 }

@.str.3 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._ZN4enki10DependencyC2EOS0_ = external hidden unnamed_addr constant [44 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4enki12ICompletable13GetIsCompleteEv(ptr noundef nonnull align 8 dereferenceable(40)) #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4enki10DependencyC2EOS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %"class.enki::Dependency", ptr %6, i32 0, i32 0
  store ptr null, ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds %"class.enki::Dependency", ptr %6, i32 0, i32 1
  store ptr null, ptr %8, align 8, !tbaa !11
  %9 = getelementptr inbounds %"class.enki::Dependency", ptr %6, i32 0, i32 2
  store ptr null, ptr %9, align 8, !tbaa !12
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %"class.enki::Dependency", ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds %"class.enki::Dependency", ptr %6, i32 0, i32 1
  store ptr %12, ptr %13, align 8, !tbaa !11
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.enki::Dependency", ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %"class.enki::Dependency", ptr %6, i32 0, i32 0
  store ptr %16, ptr %17, align 8, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.enki::Dependency", ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds %"class.enki::Dependency", ptr %6, i32 0, i32 2
  store ptr %20, ptr %21, align 8, !tbaa !12
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.enki::Dependency", ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %72

26:                                               ; preds = %2
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.enki::Dependency", ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %32

31:                                               ; preds = %26
  br label %34

32:                                               ; preds = %26
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.3, i32 noundef 1472, ptr noundef @__PRETTY_FUNCTION__._ZN4enki10DependencyC2EOS0_) #4
  unreachable

33:                                               ; No predecessors!
  br label %34

34:                                               ; preds = %33, %31
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.enki::Dependency", ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = invoke noundef zeroext i1 @_ZNK4enki12ICompletable13GetIsCompleteEv(ptr noundef nonnull align 8 dereferenceable(40) %37)
          to label %39 unwind label %73

39:                                               ; preds = %34
  br i1 %38, label %40, label %41

40:                                               ; preds = %39
  br label %43

41:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.24, ptr noundef @.str.3, i32 noundef 1473, ptr noundef @__PRETTY_FUNCTION__._ZN4enki10DependencyC2EOS0_) #4
  unreachable

42:                                               ; No predecessors!
  br label %43

43:                                               ; preds = %42, %40
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.enki::Dependency", ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = invoke noundef zeroext i1 @_ZNK4enki12ICompletable13GetIsCompleteEv(ptr noundef nonnull align 8 dereferenceable(40) %46)
          to label %48 unwind label %73

48:                                               ; preds = %43
  br i1 %47, label %49, label %50

49:                                               ; preds = %48
  br label %52

50:                                               ; preds = %48
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.3, i32 noundef 1474, ptr noundef @__PRETTY_FUNCTION__._ZN4enki10DependencyC2EOS0_) #4
  unreachable

51:                                               ; No predecessors!
  br label %52

52:                                               ; preds = %51, %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %53 = getelementptr inbounds %"class.enki::Dependency", ptr %6, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = getelementptr inbounds %"class.enki::ICompletable", ptr %54, i32 0, i32 6
  store ptr %55, ptr %5, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %67, %52
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %71

60:                                               ; preds = %56
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %64 = icmp eq ptr %61, %63
  br i1 %64, label %65, label %67

65:                                               ; preds = %60
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %6, ptr %66, align 8, !tbaa !5
  br label %71

67:                                               ; preds = %60
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  %70 = getelementptr inbounds %"class.enki::Dependency", ptr %69, i32 0, i32 2
  store ptr %70, ptr %5, align 8, !tbaa !5
  br label %56, !llvm.loop !13

71:                                               ; preds = %65, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %72

72:                                               ; preds = %71, %2
  ret void

73:                                               ; preds = %43, %34
  %74 = landingpad { ptr, i32 }
          catch ptr null
  %75 = extractvalue { ptr, i32 } %74, 0
  call void @__clang_call_terminate(ptr %75) #4
  unreachable
}

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 = { noinline noreturn nounwind uwtable "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 "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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, !6, i64 0}
!10 = !{!"_ZTSN4enki10DependencyE", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!10, !6, i64 8}
!12 = !{!10, !6, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

@.str.3 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._ZN4enki10DependencyC2EOS0_ = external hidden unnamed_addr constant [44 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [45 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4enki10DependencyC2EOS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull readonly align 8 dereferenceable(24) %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, i8 0, i64 24, i1 false)
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %1, align 8, !tbaa !10
  store ptr %7, ptr %0, align 8, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  store ptr %9, ptr %4, align 8, !tbaa !11
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %.loopexit, label %10

10:                                               ; preds = %2
  %.not15 = icmp eq ptr %7, null
  br i1 %.not15, label %11, label %12

11:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.3, i32 noundef 1472, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4enki10DependencyC2EOS0_) #3
  unreachable

12:                                               ; preds = %10
  %13 = tail call noundef zeroext i1 @_ZNK4enki12ICompletable13GetIsCompleteEv(ptr noundef nonnull align 8 dereferenceable(40) %6)
  br i1 %13, label %15, label %14

14:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.3, i32 noundef 1473, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4enki10DependencyC2EOS0_) #3
  unreachable

15:                                               ; preds = %12
  %16 = load ptr, ptr %1, align 8, !tbaa !10
  %17 = tail call noundef zeroext i1 @_ZNK4enki12ICompletable13GetIsCompleteEv(ptr noundef nonnull align 8 dereferenceable(40) %16)
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.3, i32 noundef 1474, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4enki10DependencyC2EOS0_) #3
  unreachable

19:                                               ; preds = %15
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 32
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %.not1618 = icmp eq ptr %22, null
  br i1 %.not1618, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %19
  %23 = icmp eq ptr %22, %1
  br i1 %23, label %.lr.ph._crit_edge, label %.lr.ph23

.lr.ph23:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %24 = phi ptr [ %26, %.lr.ph ], [ %22, %.lr.ph.preheader ]
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !12
  %.not16 = icmp eq ptr %26, null
  br i1 %.not16, label %.loopexit, label %.lr.ph, !llvm.loop !13

.lr.ph:                                           ; preds = %.lr.ph23
  %27 = icmp eq ptr %26, %1
  br i1 %27, label %.lr.ph._crit_edge.loopexit, label %.lr.ph23, !llvm.loop !13

.lr.ph._crit_edge.loopexit:                       ; preds = %.lr.ph
  %28 = getelementptr inbounds i8, ptr %24, i64 16
  br label %.lr.ph._crit_edge

.lr.ph._crit_edge:                                ; preds = %.lr.ph._crit_edge.loopexit, %.lr.ph.preheader
  %.019.lcssa = phi ptr [ %21, %.lr.ph.preheader ], [ %28, %.lr.ph._crit_edge.loopexit ]
  store ptr %0, ptr %.019.lcssa, align 8, !tbaa !12
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph23, %19, %.lr.ph._crit_edge, %2
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { 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 nounwind willreturn memory(argmem: write) }
attributes #3 = { 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, !7, i64 8}
!6 = !{!"_ZTSN4enki10DependencyE", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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