; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Collision/Shape (CompoundShape)

; 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.JPH::Vec3" = type { %union.anon.7 }
%union.anon.7 = type { <4 x float> }
%"class.JPH::CompoundShape" = type <{ %"class.JPH::Shape.base", [6 x i8], %"class.JPH::Vec3", %"class.JPH::AABox", %"class.JPH::Array.11", float, [4 x i8] }>
%"class.JPH::Shape.base" = type <{ ptr, %"class.JPH::RefTarget.10", [4 x i8], i64, i8, i8 }>
%"class.JPH::RefTarget.10" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::Array.11" = type { i64, i64, ptr }
%"struct.JPH::CompoundShape::SubShape" = type <{ %"class.JPH::RefConst.9", %"class.JPH::Float3", %"class.JPH::Float3", i32, i8, [3 x i8] }>
%"class.JPH::RefConst.9" = type { ptr }
%"class.JPH::Float3" = type { float, float, float }

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

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

; 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) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH13CompoundShape8SubShape14TransformScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37), double, double) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3JPH13CompoundShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108) %0, double %1, double %2) unnamed_addr #4 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca %"class.JPH::Vec3", align 16
  %6 = alloca ptr, align 8
  %7 = alloca %"class.JPH::Vec3", align 16
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca %"class.JPH::Vec3", align 16
  %14 = alloca %"class.JPH::Vec3", align 16
  %15 = alloca %"class.JPH::Vec3", align 16
  %16 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 0
  store double %1, ptr %16, align 16
  %17 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 1
  store double %2, ptr %17, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 %5, i64 16, i1 false), !tbaa.struct !9
  %19 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  %20 = load double, ptr %19, align 16
  %21 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  %22 = load double, ptr %21, align 8
  %23 = call noundef zeroext i1 @_ZNK3JPH5Shape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(26) %18, double %20, double %22)
  br i1 %23, label %25, label %24

24:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  br label %80

25:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %26 = getelementptr inbounds %"class.JPH::CompoundShape", ptr %18, i32 0, i32 4
  store ptr %26, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %27)
  store ptr %28, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = call noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %29)
  store ptr %30, ptr %10, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %74, %25
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = icmp ne ptr %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 2, ptr %11, align 4
  br label %77

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %37, ptr %12, align 8, !tbaa !5
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %13, ptr align 16 %5, i64 16, i1 false), !tbaa.struct !9
  %39 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %40 = load double, ptr %39, align 16
  %41 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  %42 = load double, ptr %41, align 8
  %43 = call noundef zeroext i1 @_ZNK3JPH13CompoundShape8SubShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37) %38, double %40, double %42)
  br i1 %43, label %45, label %44

44:                                               ; preds = %36
  store i1 false, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %71

45:                                               ; preds = %36
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.JPH::CompoundShape::SubShape", ptr %46, i32 0, i32 0
  %48 = call noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %47)
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %15, ptr align 16 %5, i64 16, i1 false), !tbaa.struct !9
  %50 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %51 = load double, ptr %50, align 16
  %52 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  %53 = load double, ptr %52, align 8
  %54 = call { double, double } @_ZNK3JPH13CompoundShape8SubShape14TransformScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37) %49, double %51, double %53)
  %55 = getelementptr inbounds %"class.JPH::Vec3", ptr %14, i32 0, i32 0
  %56 = getelementptr inbounds %union.anon.7, ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds { double, double }, ptr %56, i32 0, i32 0
  %58 = extractvalue { double, double } %54, 0
  store double %58, ptr %57, align 16
  %59 = getelementptr inbounds { double, double }, ptr %56, i32 0, i32 1
  %60 = extractvalue { double, double } %54, 1
  store double %60, ptr %59, align 8
  %61 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 0
  %62 = load double, ptr %61, align 16
  %63 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 1
  %64 = load double, ptr %63, align 8
  %65 = load ptr, ptr %48, align 8, !tbaa !11
  %66 = getelementptr inbounds ptr, ptr %65, i64 32
  %67 = load ptr, ptr %66, align 8
  %68 = call noundef zeroext i1 %67(ptr noundef nonnull align 8 dereferenceable(26) %48, double %62, double %64)
  br i1 %68, label %70, label %69

69:                                               ; preds = %45
  store i1 false, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %71

70:                                               ; preds = %45
  store i32 0, ptr %11, align 4
  br label %71

71:                                               ; preds = %70, %69, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  %72 = load i32, ptr %11, align 4
  switch i32 %72, label %77 [
    i32 0, label %73
  ]

73:                                               ; preds = %71
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %"struct.JPH::CompoundShape::SubShape", ptr %75, i32 1
  store ptr %76, ptr %9, align 8, !tbaa !5
  br label %31

77:                                               ; preds = %71, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %78 = load i32, ptr %11, align 4
  switch i32 %78, label %82 [
    i32 2, label %79
    i32 1, label %80
  ]

79:                                               ; preds = %77
  store i1 true, ptr %4, align 1
  br label %80

80:                                               ; preds = %79, %77, %24
  %81 = load i1, ptr %4, align 1
  ret i1 %81

82:                                               ; preds = %77
  unreachable
}

declare noundef zeroext i1 @_ZNK3JPH5Shape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(26), double, double) unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH13CompoundShape8SubShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37), double, double) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #4 = { 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 #5 = { "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 }

!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 = !{i64 0, i64 16, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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"

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH13CompoundShape8SubShape14TransformScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37), double, double) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3JPH13CompoundShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108) %0, double %1, double %2) unnamed_addr #2 align 2 {
  %4 = tail call noundef zeroext i1 @_ZNK3JPH5Shape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(26) %0, double %1, double %2)
  br i1 %4, label %5, label %.critedge

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  %7 = tail call noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %8 = tail call noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %.not22 = icmp eq ptr %7, %8
  br i1 %.not22, label %.critedge, label %.lr.ph

9:                                                ; preds = %12
  %10 = getelementptr inbounds i8, ptr %.01923, i64 40
  %.not = icmp eq ptr %10, %8
  br i1 %.not, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %9
  %.01923 = phi ptr [ %10, %9 ], [ %7, %5 ]
  %11 = tail call noundef zeroext i1 @_ZNK3JPH13CompoundShape8SubShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37) %.01923, double %1, double %2)
  br i1 %11, label %12, label %.critedge

12:                                               ; preds = %.lr.ph
  %13 = tail call noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %.01923)
  %14 = tail call { double, double } @_ZNK3JPH13CompoundShape8SubShape14TransformScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37) %.01923, double %1, double %2)
  %15 = extractvalue { double, double } %14, 0
  %16 = extractvalue { double, double } %14, 1
  %17 = load ptr, ptr %13, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 256
  %19 = load ptr, ptr %18, align 8
  %20 = tail call noundef zeroext i1 %19(ptr noundef nonnull align 8 dereferenceable(26) %13, double %15, double %16)
  br i1 %20, label %9, label %.critedge

.critedge:                                        ; preds = %.lr.ph, %9, %12, %5, %3
  %.3 = phi i1 [ false, %3 ], [ true, %5 ], [ false, %.lr.ph ], [ true, %9 ], [ false, %12 ]
  ret i1 %.3
}

declare noundef zeroext i1 @_ZNK3JPH5Shape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(26), double, double) unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH13CompoundShape8SubShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37), double, double) local_unnamed_addr #1 align 2

attributes #0 = { 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 #1 = { inlinehint 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 #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 = { "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" }

!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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass