; 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::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: 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: alwaysinline mustprogress uwtable
declare dso_local void @_ZNK3JPH13CompoundShape8SubShape24GetLocalTransformNoScaleENS_4Vec3E(ptr dead_on_unwind noalias writable sret(%"class.JPH::Mat44") align 16, ptr noundef nonnull align 8 dereferenceable(37), double, double) #4 align 2

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

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

31:                                               ; preds = %69, %7
  %32 = load ptr, ptr %15, align 8, !tbaa !5
  %33 = load ptr, ptr %16, align 8, !tbaa !5
  %34 = icmp ne ptr %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %72

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %37 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %37, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %18) #7
  %38 = load ptr, ptr %17, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %19, ptr align 16 %8, i64 16, i1 false), !tbaa.struct !11
  %39 = getelementptr inbounds { double, double }, ptr %19, i32 0, i32 0
  %40 = load double, ptr %39, align 16
  %41 = getelementptr inbounds { double, double }, ptr %19, i32 0, i32 1
  %42 = load double, ptr %41, align 8
  call void @_ZNK3JPH13CompoundShape8SubShape24GetLocalTransformNoScaleENS_4Vec3E(ptr dead_on_unwind writable sret(%"class.JPH::Mat44") align 16 %18, ptr noundef nonnull align 8 dereferenceable(37) %38, double %40, double %42)
  %43 = load ptr, ptr %17, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.JPH::CompoundShape::SubShape", ptr %43, i32 0, i32 0
  %45 = call noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %44)
  call void @llvm.lifetime.start.p0(i64 64, ptr %20) #7
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZNK3JPH5Mat44mlERKS0_(ptr dead_on_unwind writable sret(%"class.JPH::Mat44") align 16 %20, ptr noundef nonnull align 16 dereferenceable(64) %46, ptr noundef nonnull align 16 dereferenceable(64) %18)
  %47 = load ptr, ptr %17, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %22, ptr align 16 %8, i64 16, i1 false), !tbaa.struct !11
  %48 = getelementptr inbounds { double, double }, ptr %22, i32 0, i32 0
  %49 = load double, ptr %48, align 16
  %50 = getelementptr inbounds { double, double }, ptr %22, i32 0, i32 1
  %51 = load double, ptr %50, align 8
  %52 = call { double, double } @_ZNK3JPH13CompoundShape8SubShape14TransformScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37) %47, double %49, double %51)
  %53 = getelementptr inbounds %"class.JPH::Vec3", ptr %21, i32 0, i32 0
  %54 = getelementptr inbounds %union.anon.7, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds { double, double }, ptr %54, i32 0, i32 0
  %56 = extractvalue { double, double } %52, 0
  store double %56, ptr %55, align 16
  %57 = getelementptr inbounds { double, double }, ptr %54, i32 0, i32 1
  %58 = extractvalue { double, double } %52, 1
  store double %58, ptr %57, align 8
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = load i32, ptr %12, align 4, !tbaa !9
  %61 = load i32, ptr %13, align 4, !tbaa !9
  %62 = getelementptr inbounds { double, double }, ptr %21, i32 0, i32 0
  %63 = load double, ptr %62, align 16
  %64 = getelementptr inbounds { double, double }, ptr %21, i32 0, i32 1
  %65 = load double, ptr %64, align 8
  %66 = load ptr, ptr %45, align 8, !tbaa !13
  %67 = getelementptr inbounds ptr, ptr %66, i64 19
  %68 = load ptr, ptr %67, align 8
  call void %68(ptr noundef nonnull align 8 dereferenceable(26) %45, ptr noundef nonnull align 16 dereferenceable(64) %20, double %63, double %65, ptr noundef nonnull align 1 %59, i32 noundef %60, i32 noundef %61)
  call void @llvm.lifetime.end.p0(i64 64, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 64, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %69

69:                                               ; preds = %36
  %70 = load ptr, ptr %15, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.JPH::CompoundShape::SubShape", ptr %70, i32 1
  store ptr %71, ptr %15, align 8, !tbaa !5
  br label %31

72:                                               ; preds = %35
  ret void
}

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 = { 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 = { 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 #5 = { 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 #6 = { 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 #7 = { 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 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 16, !12}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"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 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 #2 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZNK3JPH13CompoundShape8SubShape24GetLocalTransformNoScaleENS_4Vec3E(ptr dead_on_unwind noalias writable sret(%"class.JPH::Mat44") align 16, ptr noundef nonnull align 8 dereferenceable(37), double, double) local_unnamed_addr #3 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 #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH13CompoundShape23CollideSoftBodyVerticesERKNS_5Mat44ENS_4Vec3ERKNS_29CollideSoftBodyVertexIteratorEji(ptr noundef nonnull align 16 dereferenceable(108) %0, ptr noundef nonnull align 16 dereferenceable(64) %1, double %2, double %3, ptr noundef nonnull align 1 %4, i32 noundef %5, i32 noundef %6) unnamed_addr #5 align 2 {
  %8 = alloca %"class.JPH::Mat44", align 16
  %9 = alloca %"class.JPH::Mat44", align 16
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = tail call noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  %12 = tail call noundef ptr @_ZNK3JPH5ArrayINS_13CompoundShape8SubShapeENS_12STLAllocatorIS2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  %.not18 = icmp eq ptr %11, %12
  br i1 %.not18, label %._crit_edge, label %.lr.ph

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

.lr.ph:                                           ; preds = %7, %.lr.ph
  %.019 = phi ptr [ %20, %.lr.ph ], [ %11, %7 ]
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %8) #6
  call void @_ZNK3JPH13CompoundShape8SubShape24GetLocalTransformNoScaleENS_4Vec3E(ptr dead_on_unwind nonnull writable sret(%"class.JPH::Mat44") align 16 %8, ptr noundef nonnull align 8 dereferenceable(37) %.019, double %2, double %3)
  %13 = call noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %.019)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %9) #6
  call void @_ZNK3JPH5Mat44mlERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.JPH::Mat44") align 16 %9, ptr noundef nonnull align 16 dereferenceable(64) %1, ptr noundef nonnull align 16 dereferenceable(64) %8)
  %14 = call { double, double } @_ZNK3JPH13CompoundShape8SubShape14TransformScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(37) %.019, double %2, double %3)
  %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 152
  %19 = load ptr, ptr %18, align 8
  call void %19(ptr noundef nonnull align 8 dereferenceable(26) %13, ptr noundef nonnull align 16 dereferenceable(64) %9, double %15, double %16, ptr noundef nonnull align 1 %4, i32 noundef %5, i32 noundef %6)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #6
  %20 = getelementptr inbounds i8, ptr %.019, i64 40
  %.not = icmp eq ptr %20, %12
  br i1 %.not, label %._crit_edge, label %.lr.ph
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass