; LLVM IR from zig-gamedev/zphysics :: libs/JoltC (JoltPhysicsC)

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

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [46 x i8], align 1
@__PRETTY_FUNCTION__.JPC_Shape_CastRay = external hidden unnamed_addr constant [115 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
declare hidden noundef ptr @_ZL5toJphPK9JPC_Shape(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local zeroext i1 @JPC_Shape_CastRay(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %20

11:                                               ; preds = %4
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %20

14:                                               ; preds = %11
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %20

17:                                               ; preds = %14
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br label %20

20:                                               ; preds = %17, %14, %11, %4
  %21 = phi i1 [ false, %14 ], [ false, %11 ], [ false, %4 ], [ %19, %17 ]
  br i1 %21, label %22, label %23

22:                                               ; preds = %20
  br label %25

23:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.24, ptr noundef @.str.1, i32 noundef 1968, ptr noundef @__PRETTY_FUNCTION__.JPC_Shape_CastRay) #3
  unreachable

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24, %22
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call noundef ptr @_ZL5toJphPK9JPC_Shape(ptr noundef %26)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call noundef ptr @_ZL5toJphPK11JPC_RayCast(ptr noundef %28)
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = call noundef ptr @_ZL5toJphPK21JPC_SubShapeIDCreator(ptr noundef %30)
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = call noundef ptr @_ZL5toJphP17JPC_RayCastResult(ptr noundef %32)
  %34 = load ptr, ptr %27, align 8, !tbaa !9
  %35 = getelementptr inbounds ptr, ptr %34, i64 15
  %36 = load ptr, ptr %35, align 8
  %37 = call noundef zeroext i1 %36(ptr noundef nonnull align 8 dereferenceable(26) %27, ptr noundef nonnull align 16 dereferenceable(32) %29, ptr noundef nonnull align 4 dereferenceable(8) %31, ptr noundef nonnull align 1 %33)
  ret i1 %37
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJphPK11JPC_RayCast(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJphPK21JPC_SubShapeIDCreator(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJphP17JPC_RayCastResult(ptr noundef) #1

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 = { 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 #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, !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 = !{!"vtable pointer", !8, i64 0}


; 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.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [46 x i8], align 1
@__PRETTY_FUNCTION__.JPC_Shape_CastRay = external hidden unnamed_addr constant [115 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
declare hidden noundef ptr @_ZL5toJphPK9JPC_Shape(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @JPC_Shape_CastRay(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %6 = insertelement <4 x ptr> %5, ptr %1, i64 1
  %7 = insertelement <4 x ptr> %6, ptr %2, i64 2
  %8 = insertelement <4 x ptr> %7, ptr %3, i64 3
  %9 = icmp eq <4 x ptr> %8, zeroinitializer
  %10 = bitcast <4 x i1> %9 to i4
  %11 = icmp eq i4 %10, 0
  br i1 %11, label %12, label %.critedge

.critedge:                                        ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.1, i32 noundef 1968, ptr noundef nonnull @__PRETTY_FUNCTION__.JPC_Shape_CastRay) #3
  unreachable

12:                                               ; preds = %4
  %13 = tail call noundef ptr @_ZL5toJphPK9JPC_Shape(ptr noundef nonnull %0)
  %14 = tail call noundef ptr @_ZL5toJphPK11JPC_RayCast(ptr noundef nonnull %1)
  %15 = tail call noundef ptr @_ZL5toJphPK21JPC_SubShapeIDCreator(ptr noundef nonnull %2)
  %16 = tail call noundef ptr @_ZL5toJphP17JPC_RayCastResult(ptr noundef nonnull %3)
  %17 = load ptr, ptr %13, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 120
  %19 = load ptr, ptr %18, align 8
  %20 = tail call noundef zeroext i1 %19(ptr noundef nonnull align 8 dereferenceable(26) %13, ptr noundef nonnull align 16 dereferenceable(32) %14, ptr noundef nonnull align 4 dereferenceable(8) %15, ptr noundef nonnull align 1 %16)
  ret i1 %20
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJphPK11JPC_RayCast(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJphPK21JPC_SubShapeIDCreator(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJphP17JPC_RayCastResult(ptr noundef) local_unnamed_addr #1

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 = { 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 #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, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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