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

; 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::ConvexShape::SupportBuffer" = type { [4160 x i8] }
%"class.JPH::Vec3" = type { %union.anon.4 }
%union.anon.4 = type { <4 x float> }
%"class.JPH::GJKClosestPoint" = type <{ [4 x %"class.JPH::Vec3"], [4 x %"class.JPH::Vec3"], [4 x %"class.JPH::Vec3"], i32, [12 x i8] }>
%"struct.JPH::RayCastT" = type { %"class.JPH::Vec3", %"class.JPH::Vec3" }
%"class.JPH::BroadPhaseCastResult" = type { %"class.JPH::BodyID", float }
%"class.JPH::BodyID" = type { i32 }
%"class.JPH::RayCastResult" = type { %"class.JPH::BroadPhaseCastResult", %"class.JPH::SubShapeID" }
%"class.JPH::SubShapeID" = type { i32 }

; 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: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH17SubShapeIDCreator5GetIDEv(ptr noundef nonnull align 4 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3JPH11ConvexShape7CastRayERKNS_7RayCastERKNS_17SubShapeIDCreatorERNS_13RayCastResultE(ptr noundef nonnull align 8 dereferenceable(44) %0, ptr noundef nonnull align 16 dereferenceable(32) %1, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(12) %3) unnamed_addr #3 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %"class.JPH::ConvexShape::SupportBuffer", align 16
  %11 = alloca ptr, align 8
  %12 = alloca %"class.JPH::Vec3", align 16
  %13 = alloca %"class.JPH::GJKClosestPoint", align 16
  %14 = alloca %"class.JPH::Vec3", align 16
  %15 = alloca %"class.JPH::Vec3", align 16
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4160, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %18 = call { double, double } @_ZN3JPH4Vec34sOneEv()
  %19 = getelementptr inbounds %"class.JPH::Vec3", ptr %12, i32 0, i32 0
  %20 = getelementptr inbounds %union.anon.4, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds { double, double }, ptr %20, i32 0, i32 0
  %22 = extractvalue { double, double } %18, 0
  store double %22, ptr %21, align 16
  %23 = getelementptr inbounds { double, double }, ptr %20, i32 0, i32 1
  %24 = extractvalue { double, double } %18, 1
  store double %24, ptr %23, align 8
  %25 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 0
  %26 = load double, ptr %25, align 16
  %27 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 1
  %28 = load double, ptr %27, align 8
  %29 = load ptr, ptr %17, align 8, !tbaa !9
  %30 = getelementptr inbounds ptr, ptr %29, i64 35
  %31 = load ptr, ptr %30, align 8
  %32 = call noundef ptr %31(ptr noundef nonnull align 8 dereferenceable(44) %17, i32 noundef 1, ptr noundef nonnull align 16 dereferenceable(4160) %10, double %26, double %28)
  store ptr %32, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 208, ptr %13) #6
  call void @_ZN3JPH15GJKClosestPointC2Ev(ptr noundef nonnull align 16 dereferenceable(196) %13) #6
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.JPH::RayCastT", ptr %33, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %14, ptr align 16 %34, i64 16, i1 false), !tbaa.struct !11
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.JPH::RayCastT", ptr %35, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %15, ptr align 16 %36, i64 16, i1 false), !tbaa.struct !11
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %"class.JPH::BroadPhaseCastResult", ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 0
  %41 = load double, ptr %40, align 16
  %42 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 1
  %43 = load double, ptr %42, align 8
  %44 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %45 = load double, ptr %44, align 16
  %46 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  %47 = load double, ptr %46, align 8
  %48 = call noundef zeroext i1 @_ZN3JPH15GJKClosestPoint7CastRayINS_11ConvexShape7SupportEEEbNS_4Vec3ES4_fRKT_Rf(ptr noundef nonnull align 16 dereferenceable(196) %13, double %41, double %43, double %45, double %47, float noundef 0x3F1A36E2E0000000, ptr noundef nonnull align 8 dereferenceable(8) %37, ptr noundef nonnull align 4 dereferenceable(4) %39)
  br i1 %48, label %49, label %54

49:                                               ; preds = %4
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH17SubShapeIDCreator5GetIDEv(ptr noundef nonnull align 4 dereferenceable(8) %50)
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.JPH::RayCastResult", ptr %52, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %53, ptr align 4 %51, i64 4, i1 false), !tbaa.struct !13
  store i1 true, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %55

54:                                               ; preds = %4
  store i1 false, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %55

55:                                               ; preds = %54, %49
  call void @llvm.lifetime.end.p0(i64 208, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4160, ptr %10) #6
  %56 = load i1, ptr %5, align 1
  ret i1 %56
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZN3JPH4Vec34sOneEv() #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH15GJKClosestPointC2Ev(ptr noundef nonnull align 16 dereferenceable(196)) unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH15GJKClosestPoint7CastRayINS_11ConvexShape7SupportEEEbNS_4Vec3ES4_fRKT_Rf(ptr noundef nonnull align 16 dereferenceable(196), double, double, double, double, float noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 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 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 = { 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}
!11 = !{i64 0, i64 16, !12}
!12 = !{!7, !7, i64 0}
!13 = !{i64 0, i64 4, !14}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !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::ConvexShape::SupportBuffer" = type { [4160 x i8] }
%"class.JPH::GJKClosestPoint" = type <{ [4 x %"class.JPH::Vec3"], [4 x %"class.JPH::Vec3"], [4 x %"class.JPH::Vec3"], i32, [12 x i8] }>
%"class.JPH::Vec3" = type { %union.anon.4 }
%union.anon.4 = 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: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH17SubShapeIDCreator5GetIDEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3JPH11ConvexShape7CastRayERKNS_7RayCastERKNS_17SubShapeIDCreatorERNS_13RayCastResultE(ptr noundef nonnull align 8 dereferenceable(44) %0, ptr nocapture noundef nonnull readonly align 16 dereferenceable(32) %1, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(12) %3) unnamed_addr #2 align 2 {
  %5 = alloca %"class.JPH::ConvexShape::SupportBuffer", align 16
  %6 = alloca %"class.JPH::GJKClosestPoint", align 16
  call void @llvm.lifetime.start.p0(i64 4160, ptr nonnull %5) #5
  %7 = tail call { double, double } @_ZN3JPH4Vec34sOneEv()
  %8 = extractvalue { double, double } %7, 0
  %9 = extractvalue { double, double } %7, 1
  %10 = load ptr, ptr %0, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 280
  %12 = load ptr, ptr %11, align 8
  %13 = call noundef ptr %12(ptr noundef nonnull align 8 dereferenceable(44) %0, i32 noundef 1, ptr noundef nonnull align 16 dereferenceable(4160) %5, double %8, double %9)
  call void @llvm.lifetime.start.p0(i64 208, ptr nonnull %6) #5
  call void @_ZN3JPH15GJKClosestPointC2Ev(ptr noundef nonnull align 16 dereferenceable(196) %6) #5
  %.sroa.01.0.copyload = load double, ptr %1, align 16
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 8
  %.sroa.22.0.copyload = load double, ptr %.sroa.22.0..sroa_idx, align 8, !tbaa !8
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  %.sroa.0.0.copyload = load double, ptr %14, align 16
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 24
  %.sroa.2.0.copyload = load double, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !8
  %15 = getelementptr inbounds i8, ptr %3, i64 4
  %16 = call noundef zeroext i1 @_ZN3JPH15GJKClosestPoint7CastRayINS_11ConvexShape7SupportEEEbNS_4Vec3ES4_fRKT_Rf(ptr noundef nonnull align 16 dereferenceable(196) %6, double %.sroa.01.0.copyload, double %.sroa.22.0.copyload, double %.sroa.0.0.copyload, double %.sroa.2.0.copyload, float noundef 0x3F1A36E2E0000000, ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 4 dereferenceable(4) %15)
  br i1 %16, label %17, label %21

17:                                               ; preds = %4
  %18 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH17SubShapeIDCreator5GetIDEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %19 = getelementptr inbounds i8, ptr %3, i64 8
  %20 = load i32, ptr %18, align 4, !tbaa !10
  store i32 %20, ptr %19, align 4, !tbaa !10
  br label %21

21:                                               ; preds = %4, %17
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4160, ptr nonnull %5) #5
  ret i1 %16
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local { double, double } @_ZN3JPH4Vec34sOneEv() local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH15GJKClosestPointC2Ev(ptr noundef nonnull align 16 dereferenceable(196)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH15GJKClosestPoint7CastRayINS_11ConvexShape7SupportEEEbNS_4Vec3ES4_fRKT_Rf(ptr noundef nonnull align 16 dereferenceable(196), double, double, double, double, float noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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"="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 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 = { 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"}
!8 = !{!9, !9, i64 0}
!9 = !{!"omnipotent char", !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !9, i64 0}


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