; 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::Mat44" = type { [4 x %"class.JPH::Vec4"] }
%"class.JPH::Vec4" = type { %union.anon.8 }
%union.anon.8 = type { <4 x float> }
%"class.JPH::Quat" = type { %"class.JPH::Vec4" }
%"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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

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

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

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZNK3JPH5Mat44mlERKS0_(ptr dead_on_unwind noalias writable sret(%"class.JPH::Mat44") align 16, ptr noundef nonnull align 16 dereferenceable(64), ptr noundef nonnull align 16 dereferenceable(64)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH13CompoundShape14TransformShapeERKNS_5Mat44ERNS_18CollisionCollectorINS_16TransformedShapeENS_36CollisionCollectorTraitsCollideShapeEEE(ptr noundef nonnull align 16 dereferenceable(108) %0, ptr noundef nonnull align 16 dereferenceable(64) %1, ptr noundef nonnull align 1 %2) unnamed_addr #4 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %"class.JPH::Mat44", align 16
  %12 = alloca %"class.JPH::Mat44", align 16
  %13 = alloca %"class.JPH::Quat", align 16
  %14 = alloca %"class.JPH::Vec3", align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %16 = getelementptr inbounds %"class.JPH::CompoundShape", ptr %15, i32 0, i32 4
  store ptr %16, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = call noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  store ptr %18, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = call noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %19)
  store ptr %20, ptr %9, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %61, %3
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = icmp ne ptr %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %64

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %27, ptr %10, align 8, !tbaa !5
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.JPH::CompoundShape::SubShape", ptr %28, i32 0, i32 0
  %30 = call noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %29)
  call void @llvm.lifetime.start.p0(i64 64, ptr %11) #5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %12) #5
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = call { double, double } @_ZNK3JPH13CompoundShape8SubShape11GetRotationEv(ptr noundef nonnull align 8 dereferenceable(37) %32)
  %34 = getelementptr inbounds %"class.JPH::Quat", ptr %13, i32 0, i32 0
  %35 = getelementptr inbounds %"class.JPH::Vec4", ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %union.anon.8, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds { double, double }, ptr %36, i32 0, i32 0
  %38 = extractvalue { double, double } %33, 0
  store double %38, ptr %37, align 16
  %39 = getelementptr inbounds { double, double }, ptr %36, i32 0, i32 1
  %40 = extractvalue { double, double } %33, 1
  store double %40, ptr %39, align 8
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = call { double, double } @_ZNK3JPH13CompoundShape8SubShape14GetPositionCOMEv(ptr noundef nonnull align 8 dereferenceable(37) %41)
  %43 = getelementptr inbounds %"class.JPH::Vec3", ptr %14, i32 0, i32 0
  %44 = getelementptr inbounds %union.anon.7, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds { double, double }, ptr %44, i32 0, i32 0
  %46 = extractvalue { double, double } %42, 0
  store double %46, ptr %45, align 16
  %47 = getelementptr inbounds { double, double }, ptr %44, i32 0, i32 1
  %48 = extractvalue { double, double } %42, 1
  store double %48, ptr %47, align 8
  %49 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %50 = load double, ptr %49, align 16
  %51 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  %52 = load double, ptr %51, align 8
  %53 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 0
  %54 = load double, ptr %53, align 16
  %55 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 1
  %56 = load double, ptr %55, align 8
  call void @_ZN3JPH5Mat4420sRotationTranslationENS_4QuatENS_4Vec3E(ptr dead_on_unwind writable sret(%"class.JPH::Mat44") align 16 %12, double %50, double %52, double %54, double %56)
  call void @_ZNK3JPH5Mat44mlERKS0_(ptr dead_on_unwind writable sret(%"class.JPH::Mat44") align 16 %11, ptr noundef nonnull align 16 dereferenceable(64) %31, ptr noundef nonnull align 16 dereferenceable(64) %12)
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %30, align 8, !tbaa !9
  %59 = getelementptr inbounds ptr, ptr %58, i64 21
  %60 = load ptr, ptr %59, align 8
  call void %60(ptr noundef nonnull align 8 dereferenceable(26) %30, ptr noundef nonnull align 16 dereferenceable(64) %11, ptr noundef nonnull align 1 %57)
  call void @llvm.lifetime.end.p0(i64 64, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %61

61:                                               ; preds = %26
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.JPH::CompoundShape::SubShape", ptr %62, i32 1
  store ptr %63, ptr %8, align 8, !tbaa !5
  br label %21

64:                                               ; preds = %25
  ret void
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3JPH5Mat4420sRotationTranslationENS_4QuatENS_4Vec3E(ptr dead_on_unwind noalias writable sret(%"class.JPH::Mat44") align 16, double, double, double, double) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { alwaysinline 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 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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 = { 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"

%"class.JPH::Mat44" = type { [4 x %"class.JPH::Vec4"] }
%"class.JPH::Vec4" = type { %union.anon.8 }
%union.anon.8 = type { <4 x float> }

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

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

; 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 #1 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 #1 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 #1 align 2

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

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZNK3JPH5Mat44mlERKS0_(ptr dead_on_unwind noalias writable sret(%"class.JPH::Mat44") align 16, ptr noundef nonnull align 16 dereferenceable(64), ptr noundef nonnull align 16 dereferenceable(64)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH13CompoundShape14TransformShapeERKNS_5Mat44ERNS_18CollisionCollectorINS_16TransformedShapeENS_36CollisionCollectorTraitsCollideShapeEEE(ptr noundef nonnull align 16 dereferenceable(108) %0, ptr noundef nonnull align 16 dereferenceable(64) %1, ptr noundef nonnull align 1 %2) unnamed_addr #4 align 2 {
  %4 = alloca %"class.JPH::Mat44", align 16
  %5 = alloca %"class.JPH::Mat44", align 16
  %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)
  %.not14 = icmp eq ptr %7, %8
  br i1 %.not14, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %3
  ret void

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.015 = phi ptr [ %19, %.lr.ph ], [ %7, %3 ]
  %9 = call noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %.015)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %5) #5
  %10 = call { double, double } @_ZNK3JPH13CompoundShape8SubShape11GetRotationEv(ptr noundef nonnull align 8 dereferenceable(37) %.015)
  %11 = extractvalue { double, double } %10, 0
  %12 = extractvalue { double, double } %10, 1
  %13 = call { double, double } @_ZNK3JPH13CompoundShape8SubShape14GetPositionCOMEv(ptr noundef nonnull align 8 dereferenceable(37) %.015)
  %14 = extractvalue { double, double } %13, 0
  %15 = extractvalue { double, double } %13, 1
  call void @_ZN3JPH5Mat4420sRotationTranslationENS_4QuatENS_4Vec3E(ptr dead_on_unwind nonnull writable sret(%"class.JPH::Mat44") align 16 %5, double %11, double %12, double %14, double %15)
  call void @_ZNK3JPH5Mat44mlERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.JPH::Mat44") align 16 %4, ptr noundef nonnull align 16 dereferenceable(64) %1, ptr noundef nonnull align 16 dereferenceable(64) %5)
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 168
  %18 = load ptr, ptr %17, align 8
  call void %18(ptr noundef nonnull align 8 dereferenceable(26) %9, ptr noundef nonnull align 16 dereferenceable(64) %4, ptr noundef nonnull align 1 %2)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #5
  %19 = getelementptr inbounds i8, ptr %.015, i64 40
  %.not = icmp eq ptr %19, %8
  br i1 %.not, label %._crit_edge, label %.lr.ph
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3JPH5Mat4420sRotationTranslationENS_4QuatENS_4Vec3E(ptr dead_on_unwind noalias writable sret(%"class.JPH::Mat44") align 16, double, double, double, double) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { alwaysinline 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 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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 = { 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: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass