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

; 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 }
%union.anon = type { <4 x float> }
%"struct.JPH::AssertLastParam" = type { i8 }
%"class.JPH::CastConvexVsTriangles" = type <{ ptr, ptr, ptr, [8 x i8], %"class.JPH::Vec3", %"class.JPH::SubShapeIDCreator", ptr, %"class.JPH::ConvexShape::SupportBuffer", ptr, float, [4 x i8] }>
%"class.JPH::SubShapeIDCreator" = type { %"class.JPH::SubShapeID", i32 }
%"class.JPH::SubShapeID" = type { i32 }
%"class.JPH::ConvexShape::SupportBuffer" = type { [4160 x i8] }
%"struct.JPH::ShapeCastT" = type { ptr, %"class.JPH::Vec3", %"class.JPH::Mat44", %"class.JPH::Vec3", %"class.JPH::AABox" }
%"class.JPH::Mat44" = type { [4 x %"class.JPH::Vec4"] }
%"class.JPH::Vec4" = type { %union.anon.0 }
%union.anon.0 = type { <4 x float> }
%"class.JPH::AABox" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }

@.str = external hidden unnamed_addr constant [52 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [101 x i8], align 1

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

34:                                               ; preds = %8
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.JPH::ShapeCastT", ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 16, !tbaa !21
  %38 = call noundef zeroext i8 @_ZNK3JPH5Shape7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(26) %37)
  %39 = icmp eq i8 %38, 0
  br i1 %39, label %43, label %40

40:                                               ; preds = %34
  %41 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 24)
  br i1 %41, label %42, label %43

42:                                               ; preds = %40
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !25
  br label %43

43:                                               ; preds = %42, %40, %34
  br label %44

44:                                               ; preds = %43
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %17, ptr align 16 %9, i64 16, i1 false), !tbaa.struct !9
  %45 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 0
  %46 = load double, ptr %45, align 16
  %47 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 1
  %48 = load double, ptr %47, align 8
  %49 = call noundef zeroext i1 @_ZN3JPH12ScaleHelpers11IsInsideOutENS_4Vec3E(double %46, double %48)
  %50 = zext i1 %49 to i64
  %51 = select i1 %49, float -1.000000e+00, float 1.000000e+00
  %52 = getelementptr inbounds %"class.JPH::CastConvexVsTriangles", ptr %20, i32 0, i32 9
  store float %51, ptr %52, align 8, !tbaa !26
  ret void
}

; 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 zeroext i8 @_ZNK3JPH5Shape7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(26)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH12ScaleHelpers11IsInsideOutENS_4Vec3E(double, double) #3

attributes #0 = { 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 #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 = { 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 = !{i64 0, i64 4, !12, i64 4, i64 4, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 4224}
!15 = !{!"_ZTSN3JPH21CastConvexVsTrianglesE", !6, i64 0, !6, i64 8, !6, i64 16, !16, i64 32, !17, i64 48, !6, i64 56, !19, i64 64, !6, i64 4224, !20, i64 4232}
!16 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!17 = !{!"_ZTSN3JPH17SubShapeIDCreatorE", !18, i64 0, !13, i64 4}
!18 = !{!"_ZTSN3JPH10SubShapeIDE", !13, i64 0}
!19 = !{!"_ZTSN3JPH11ConvexShape13SupportBufferE", !7, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = !{!22, !6, i64 0}
!22 = !{!"_ZTSN3JPH10ShapeCastTINS_4Vec3ENS_5Mat44ENS_9ShapeCastEEE", !6, i64 0, !16, i64 16, !23, i64 32, !16, i64 96, !24, i64 112}
!23 = !{!"_ZTSN3JPH5Mat44E", !7, i64 0}
!24 = !{!"_ZTSN3JPH5AABoxE", !16, i64 0, !16, i64 16}
!25 = !{i64 2158230415}
!26 = !{!15, !20, i64 4232}


; 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 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [101 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH21CastConvexVsTrianglesC2ERKNS_9ShapeCastERKNS_17ShapeCastSettingsENS_4Vec3ERKNS_5Mat44ERKNS_17SubShapeIDCreatorERNS_18CollisionCollectorINS_15ShapeCastResultENS_33CollisionCollectorTraitsCastShapeEEE(ptr nocapture noundef nonnull writeonly align 16 dereferenceable(4236) %0, ptr noundef nonnull align 16 dereferenceable(144) %1, ptr noundef nonnull align 16 dereferenceable(36) %2, double %3, double %4, ptr noundef nonnull align 16 dereferenceable(64) %5, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(24) %7) unnamed_addr #0 align 2 {
  store ptr %1, ptr %0, align 16, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %2, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %5, ptr %10, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store double %3, ptr %11, align 16
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 40
  store double %4, ptr %.sroa.3.0..sroa_idx, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  %13 = load i64, ptr %6, align 4
  store i64 %13, ptr %12, align 16
  %14 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %7, ptr %14, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 4224
  store ptr null, ptr %15, align 16, !tbaa !10
  %16 = load ptr, ptr %1, align 16, !tbaa !18
  %17 = tail call noundef zeroext i8 @_ZNK3JPH5Shape7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(26) %16)
  %18 = icmp eq i8 %17, 0
  br i1 %18, label %22, label %19

19:                                               ; preds = %8
  %20 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 24)
  br i1 %20, label %21, label %22

21:                                               ; preds = %19
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !22
  br label %22

22:                                               ; preds = %8, %19, %21
  %23 = tail call noundef zeroext i1 @_ZN3JPH12ScaleHelpers11IsInsideOutENS_4Vec3E(double %3, double %4)
  %24 = select i1 %23, float -1.000000e+00, float 1.000000e+00
  %25 = getelementptr inbounds i8, ptr %0, i64 4232
  store float %24, ptr %25, align 8, !tbaa !23
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK3JPH5Shape7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(26)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH12ScaleHelpers11IsInsideOutENS_4Vec3E(double, double) local_unnamed_addr #2

attributes #0 = { 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 #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 = { 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 #3 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 4224}
!11 = !{!"_ZTSN3JPH21CastConvexVsTrianglesE", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 32, !13, i64 48, !6, i64 56, !16, i64 64, !6, i64 4224, !17, i64 4232}
!12 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!13 = !{!"_ZTSN3JPH17SubShapeIDCreatorE", !14, i64 0, !15, i64 4}
!14 = !{!"_ZTSN3JPH10SubShapeIDE", !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN3JPH11ConvexShape13SupportBufferE", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!19, !6, i64 0}
!19 = !{!"_ZTSN3JPH10ShapeCastTINS_4Vec3ENS_5Mat44ENS_9ShapeCastEEE", !6, i64 0, !12, i64 16, !20, i64 32, !12, i64 96, !21, i64 112}
!20 = !{!"_ZTSN3JPH5Mat44E", !7, i64 0}
!21 = !{!"_ZTSN3JPH5AABoxE", !12, i64 0, !12, i64 16}
!22 = !{i64 2158230415}
!23 = !{!11, !17, i64 4232}


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