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

; 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: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Vec3mlES0_(ptr noundef nonnull align 16 dereferenceable(16), double, double) #2 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZN3JPHmlEfNS_4Vec3E(float noundef, double, double) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH13CompoundShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108), double, double) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local { double, double } @_ZNK3JPH13CompoundShape14MakeScaleValidENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108) %0, double %1, double %2) unnamed_addr #3 align 2 {
  %4 = alloca %"class.JPH::Vec3", align 16
  %5 = alloca %"class.JPH::Vec3", align 16
  %6 = alloca ptr, align 8
  %7 = alloca %"class.JPH::Vec3", align 16
  %8 = alloca %"class.JPH::Vec3", align 16
  %9 = alloca %"class.JPH::Vec3", align 16
  %10 = alloca i32, align 4
  %11 = alloca %"class.JPH::Vec3", align 16
  %12 = alloca %"class.JPH::Vec3", align 16
  %13 = alloca %"class.JPH::Vec3", align 16
  %14 = alloca %"class.JPH::Vec3", align 16
  %15 = alloca %"class.JPH::Vec3", align 16
  %16 = alloca %"class.JPH::Vec3", align 16
  %17 = alloca %"class.JPH::Vec3", align 16
  %18 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 0
  store double %1, ptr %18, align 16
  %19 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 1
  store double %2, ptr %19, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 %5, i64 16, i1 false), !tbaa.struct !9
  %21 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  %22 = load double, ptr %21, align 16
  %23 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  %24 = load double, ptr %23, align 8
  %25 = call { double, double } @_ZN3JPH12ScaleHelpers16MakeNonZeroScaleENS_4Vec3E(double %22, double %24)
  %26 = getelementptr inbounds %"class.JPH::Vec3", ptr %7, i32 0, i32 0
  %27 = getelementptr inbounds %union.anon.7, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds { double, double }, ptr %27, i32 0, i32 0
  %29 = extractvalue { double, double } %25, 0
  store double %29, ptr %28, align 16
  %30 = getelementptr inbounds { double, double }, ptr %27, i32 0, i32 1
  %31 = extractvalue { double, double } %25, 1
  store double %31, ptr %30, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 %7, i64 16, i1 false), !tbaa.struct !9
  %32 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 0
  %33 = load double, ptr %32, align 16
  %34 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 1
  %35 = load double, ptr %34, align 8
  %36 = call noundef zeroext i1 @_ZNK3JPH13CompoundShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108) %20, double %33, double %35)
  br i1 %36, label %37, label %38

37:                                               ; preds = %3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 %7, i64 16, i1 false), !tbaa.struct !9
  store i32 1, ptr %10, align 4
  br label %96

38:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #7
  %39 = call { double, double } @_ZNK3JPH4Vec33AbsEv(ptr noundef nonnull align 16 dereferenceable(16) %7)
  %40 = getelementptr inbounds %"class.JPH::Vec3", ptr %12, i32 0, i32 0
  %41 = getelementptr inbounds %union.anon.7, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds { double, double }, ptr %41, i32 0, i32 0
  %43 = extractvalue { double, double } %39, 0
  store double %43, ptr %42, align 16
  %44 = getelementptr inbounds { double, double }, ptr %41, i32 0, i32 1
  %45 = extractvalue { double, double } %39, 1
  store double %45, ptr %44, align 8
  %46 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 0
  %47 = load double, ptr %46, align 16
  %48 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 1
  %49 = load double, ptr %48, align 8
  %50 = call { double, double } @_ZN3JPH12ScaleHelpers16MakeUniformScaleENS_4Vec3E(double %47, double %49)
  %51 = getelementptr inbounds %"class.JPH::Vec3", ptr %11, i32 0, i32 0
  %52 = getelementptr inbounds %union.anon.7, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds { double, double }, ptr %52, i32 0, i32 0
  %54 = extractvalue { double, double } %50, 0
  store double %54, ptr %53, align 16
  %55 = getelementptr inbounds { double, double }, ptr %52, i32 0, i32 1
  %56 = extractvalue { double, double } %50, 1
  store double %56, ptr %55, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #7
  %57 = call { double, double } @_ZNK3JPH4Vec37GetSignEv(ptr noundef nonnull align 16 dereferenceable(16) %7)
  %58 = getelementptr inbounds %"class.JPH::Vec3", ptr %14, i32 0, i32 0
  %59 = getelementptr inbounds %union.anon.7, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds { double, double }, ptr %59, i32 0, i32 0
  %61 = extractvalue { double, double } %57, 0
  store double %61, ptr %60, align 16
  %62 = getelementptr inbounds { double, double }, ptr %59, i32 0, i32 1
  %63 = extractvalue { double, double } %57, 1
  store double %63, ptr %62, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %15, ptr align 16 %11, i64 16, i1 false), !tbaa.struct !9
  %64 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %65 = load double, ptr %64, align 16
  %66 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  %67 = load double, ptr %66, align 8
  %68 = call { double, double } @_ZNK3JPH4Vec3mlES0_(ptr noundef nonnull align 16 dereferenceable(16) %14, double %65, double %67)
  %69 = getelementptr inbounds %"class.JPH::Vec3", ptr %13, i32 0, i32 0
  %70 = getelementptr inbounds %union.anon.7, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds { double, double }, ptr %70, i32 0, i32 0
  %72 = extractvalue { double, double } %68, 0
  store double %72, ptr %71, align 16
  %73 = getelementptr inbounds { double, double }, ptr %70, i32 0, i32 1
  %74 = extractvalue { double, double } %68, 1
  store double %74, ptr %73, align 8
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %16, ptr align 16 %13, i64 16, i1 false), !tbaa.struct !9
  %75 = getelementptr inbounds { double, double }, ptr %16, i32 0, i32 0
  %76 = load double, ptr %75, align 16
  %77 = getelementptr inbounds { double, double }, ptr %16, i32 0, i32 1
  %78 = load double, ptr %77, align 8
  %79 = call noundef zeroext i1 @_ZNK3JPH13CompoundShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108) %20, double %76, double %78)
  br i1 %79, label %80, label %81

80:                                               ; preds = %38
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 %13, i64 16, i1 false), !tbaa.struct !9
  store i32 1, ptr %10, align 4
  br label %95

81:                                               ; preds = %38
  %82 = call noundef float @_ZNK3JPH4Vec34GetXEv(ptr noundef nonnull align 16 dereferenceable(16) %7)
  %83 = call noundef float @_ZN3JPH4SignIfEET_S1_(float noundef %82)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %17, ptr align 16 %11, i64 16, i1 false), !tbaa.struct !9
  %84 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 0
  %85 = load double, ptr %84, align 16
  %86 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 1
  %87 = load double, ptr %86, align 8
  %88 = call { double, double } @_ZN3JPHmlEfNS_4Vec3E(float noundef %83, double %85, double %87)
  %89 = getelementptr inbounds %"class.JPH::Vec3", ptr %4, i32 0, i32 0
  %90 = getelementptr inbounds %union.anon.7, ptr %89, i32 0, i32 0
  %91 = getelementptr inbounds { double, double }, ptr %90, i32 0, i32 0
  %92 = extractvalue { double, double } %88, 0
  store double %92, ptr %91, align 16
  %93 = getelementptr inbounds { double, double }, ptr %90, i32 0, i32 1
  %94 = extractvalue { double, double } %88, 1
  store double %94, ptr %93, align 8
  store i32 1, ptr %10, align 4
  br label %95

95:                                               ; preds = %81, %80
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #7
  br label %96

96:                                               ; preds = %95, %37
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #7
  %97 = getelementptr inbounds %"class.JPH::Vec3", ptr %4, i32 0, i32 0
  %98 = getelementptr inbounds %union.anon.7, ptr %97, i32 0, i32 0
  %99 = load { double, double }, ptr %98, align 16
  ret { double, double } %99
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3JPH12ScaleHelpers16MakeNonZeroScaleENS_4Vec3E(double, double) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3JPH12ScaleHelpers16MakeUniformScaleENS_4Vec3E(double, double) #4

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

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3JPH4SignIfEET_S1_(float noundef) #5

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK3JPH4Vec34GetXEv(ptr noundef nonnull align 16 dereferenceable(16)) #6 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { alwaysinline 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 #6 = { alwaysinline mustprogress nounwind 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 #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 = !{i64 0, i64 16, !10}
!10 = !{!7, !7, 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::Vec3" = type { %union.anon.7 }
%union.anon.7 = 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: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZNK3JPH4Vec3mlES0_(ptr noundef nonnull align 16 dereferenceable(16), double, double) local_unnamed_addr #1 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZN3JPHmlEfNS_4Vec3E(float noundef, double, double) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH13CompoundShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108), double, double) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local { double, double } @_ZNK3JPH13CompoundShape14MakeScaleValidENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108) %0, double %1, double %2) unnamed_addr #2 align 2 {
  %4 = alloca %"class.JPH::Vec3", align 16
  %5 = alloca %"class.JPH::Vec3", align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  %6 = tail call { double, double } @_ZN3JPH12ScaleHelpers16MakeNonZeroScaleENS_4Vec3E(double %1, double %2)
  %7 = extractvalue { double, double } %6, 0
  store double %7, ptr %4, align 16
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  %9 = extractvalue { double, double } %6, 1
  store double %9, ptr %8, align 8
  %10 = tail call noundef zeroext i1 @_ZNK3JPH13CompoundShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108) %0, double %7, double %9)
  br i1 %10, label %30, label %11

11:                                               ; preds = %3
  %12 = call { double, double } @_ZNK3JPH4Vec33AbsEv(ptr noundef nonnull align 16 dereferenceable(16) %4)
  %13 = extractvalue { double, double } %12, 0
  %14 = extractvalue { double, double } %12, 1
  %15 = call { double, double } @_ZN3JPH12ScaleHelpers16MakeUniformScaleENS_4Vec3E(double %13, double %14)
  %16 = extractvalue { double, double } %15, 0
  %17 = extractvalue { double, double } %15, 1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  %18 = call { double, double } @_ZNK3JPH4Vec37GetSignEv(ptr noundef nonnull align 16 dereferenceable(16) %4)
  %19 = extractvalue { double, double } %18, 0
  store double %19, ptr %5, align 16
  %20 = getelementptr inbounds i8, ptr %5, i64 8
  %21 = extractvalue { double, double } %18, 1
  store double %21, ptr %20, align 8
  %22 = call { double, double } @_ZNK3JPH4Vec3mlES0_(ptr noundef nonnull align 16 dereferenceable(16) %5, double %16, double %17)
  %23 = extractvalue { double, double } %22, 0
  %24 = extractvalue { double, double } %22, 1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  %25 = call noundef zeroext i1 @_ZNK3JPH13CompoundShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 16 dereferenceable(108) %0, double %23, double %24)
  br i1 %25, label %30, label %26

26:                                               ; preds = %11
  %27 = call noundef float @_ZNK3JPH4Vec34GetXEv(ptr noundef nonnull align 16 dereferenceable(16) %4)
  %28 = call noundef float @_ZN3JPH4SignIfEET_S1_(float noundef %27)
  %29 = call { double, double } @_ZN3JPHmlEfNS_4Vec3E(float noundef %28, double %16, double %17)
  br label %30

30:                                               ; preds = %3, %26, %11
  %.fca.1.insert.merged = phi { double, double } [ %29, %26 ], [ %22, %11 ], [ %6, %3 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  ret { double, double } %.fca.1.insert.merged
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3JPH12ScaleHelpers16MakeNonZeroScaleENS_4Vec3E(double, double) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { double, double } @_ZN3JPH12ScaleHelpers16MakeUniformScaleENS_4Vec3E(double, double) local_unnamed_addr #3

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

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3JPH4SignIfEET_S1_(float noundef) local_unnamed_addr #4

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK3JPH4Vec34GetXEv(ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #5 align 2

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass