; LLVM IR from devlinzhou/deterministic_physics :: UnrealDemo/Source/UnrealDemo/gphysics/src/collision/glacier_collision_algorithm._308e2337 (P17GCollisionContact)

; 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.GShapeSphere = type { %class.GShapeConvexBase.base, %class.GFloat }
%class.GShapeConvexBase.base = type <{ ptr, %class.GShapeBase }>
%class.GShapeBase = type { i32 }
%class.GFloat = type { i32 }
%class.GShapePlane = type { %class.GShapeBase }
%class.GCollisionAlgorithm = type { ptr, i8, i32 }
%class.GCObject = type { ptr, %class.GCollisionShape, i32, i32, %class.GTransform_QT, %class.GTransform_QT, %class.GAABB, %class.GAABB, i32, ptr, i8, i32, %"class.std::set", %"class.std::vector" }
%class.GCollisionShape = type { i32, %class.GVector3, ptr }
%class.GVector3 = type { %class.GFloat, %class.GFloat, %class.GFloat }
%class.GTransform_QT = type { %class.GQuaternion, %class.GVector3 }
%class.GQuaternion = type { %class.GFloat, %class.GFloat, %class.GFloat, %class.GFloat }
%class.GAABB = type { %class.GVector3, %class.GVector3 }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.GCollisionContact = type { i64, i32, i32, [16 x %class.GManifoldPoint] }
%class.GManifoldPoint = type <{ %class.GVector3, %class.GVector3, %class.GFloat, i32, i8, [3 x i8] }>

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

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

; 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 i32 @_ZNK8GCObject5GetIdEv(ptr noundef nonnull align 8 dereferenceable(240)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12GShapeSphereC2E6GFloat(ptr noundef nonnull align 8 dereferenceable(16), i32) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN16GCG_Sphere_Plane16ProcessCollisionEPK8GCObjectS2_P17GCollisionContact(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #3 align 2 {
  %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.GShapeSphere, align 8
  %12 = alloca %class.GFloat, align 4
  %13 = alloca %class.GShapePlane, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %16 = getelementptr inbounds %class.GCollisionAlgorithm, ptr %15, i32 0, i32 1
  %17 = load i8, ptr %16, align 8, !tbaa !9, !range !13, !noundef !14
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %22

19:                                               ; preds = %4
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %class.GCObject, ptr %20, i32 0, i32 5
  br label %25

22:                                               ; preds = %4
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.GCObject, ptr %23, i32 0, i32 5
  br label %25

25:                                               ; preds = %22, %19
  %26 = phi ptr [ %21, %19 ], [ %24, %22 ]
  store ptr %26, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %27 = getelementptr inbounds %class.GCollisionAlgorithm, ptr %15, i32 0, i32 1
  %28 = load i8, ptr %27, align 8, !tbaa !9, !range !13, !noundef !14
  %29 = trunc i8 %28 to i1
  br i1 %29, label %30, label %33

30:                                               ; preds = %25
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %class.GCObject, ptr %31, i32 0, i32 5
  br label %36

33:                                               ; preds = %25
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %class.GCObject, ptr %34, i32 0, i32 5
  br label %36

36:                                               ; preds = %33, %30
  %37 = phi ptr [ %32, %30 ], [ %35, %33 ]
  store ptr %37, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #5
  %38 = getelementptr inbounds %class.GCollisionAlgorithm, ptr %15, i32 0, i32 1
  %39 = load i8, ptr %38, align 8, !tbaa !9, !range !13, !noundef !14
  %40 = trunc i8 %39 to i1
  br i1 %40, label %41, label %46

41:                                               ; preds = %36
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %class.GCObject, ptr %42, i32 0, i32 1
  %44 = call i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24) %43)
  %45 = getelementptr inbounds %class.GFloat, ptr %12, i32 0, i32 0
  store i32 %44, ptr %45, align 4
  br label %51

46:                                               ; preds = %36
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %class.GCObject, ptr %47, i32 0, i32 1
  %49 = call i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24) %48)
  %50 = getelementptr inbounds %class.GFloat, ptr %12, i32 0, i32 0
  store i32 %49, ptr %50, align 4
  br label %51

51:                                               ; preds = %46, %41
  %52 = getelementptr inbounds %class.GFloat, ptr %12, i32 0, i32 0
  %53 = load i32, ptr %52, align 4
  call void @_ZN12GShapeSphereC2E6GFloat(ptr noundef nonnull align 8 dereferenceable(16) %11, i32 %53)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @_ZN11GShapePlaneC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %13)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = call noundef i32 @_ZN17GCollision_Sphere20Sphere_Plane_ContactERK12GShapeSphereRK13GTransform_QTRK11GShapePlaneS5_P17GCollisionContact(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(28) %54, ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(28) %55, ptr noundef %56)
  store i32 %57, ptr %14, align 4, !tbaa !15
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %74

60:                                               ; preds = %51
  %61 = getelementptr inbounds %class.GCollisionAlgorithm, ptr %15, i32 0, i32 1
  %62 = load i8, ptr %61, align 8, !tbaa !9, !range !13, !noundef !14
  %63 = trunc i8 %62 to i1
  br i1 %63, label %64, label %67

64:                                               ; preds = %60
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = call noundef i32 @_ZNK8GCObject5GetIdEv(ptr noundef nonnull align 8 dereferenceable(240) %65)
  br label %70

67:                                               ; preds = %60
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = call noundef i32 @_ZNK8GCObject5GetIdEv(ptr noundef nonnull align 8 dereferenceable(240) %68)
  br label %70

70:                                               ; preds = %67, %64
  %71 = phi i32 [ %66, %64 ], [ %69, %67 ]
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %class.GCollisionContact, ptr %72, i32 0, i32 1
  store i32 %71, ptr %73, align 8, !tbaa !16
  br label %74

74:                                               ; preds = %70, %51
  %75 = load i32, ptr %14, align 4, !tbaa !15
  %76 = icmp sgt i32 %75, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret i1 %76
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11GShapePlaneC2Ev(ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

declare noundef i32 @_ZN17GCollision_Sphere20Sphere_Plane_ContactERK12GShapeSphereRK13GTransform_QTRK11GShapePlaneS5_P17GCollisionContact(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef) #4

attributes #0 = { 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 = { 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 = { 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 = { "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, !11, i64 8}
!10 = !{!"_ZTS19GCollisionAlgorithm", !11, i64 8, !12, i64 12}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!12, !12, i64 0}
!16 = !{!17, !12, i64 8}
!17 = !{!"_ZTS17GCollisionContact", !18, i64 0, !12, i64 8, !12, i64 12, !7, i64 16}
!18 = !{!"long", !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.GShapeSphere = type { %class.GShapeConvexBase.base, %class.GFloat }
%class.GShapeConvexBase.base = type <{ ptr, %class.GShapeBase }>
%class.GShapeBase = type { i32 }
%class.GFloat = type { i32 }
%class.GShapePlane = type { %class.GShapeBase }

; 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 nounwind uwtable
declare dso_local i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; 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 i32 @_ZNK8GCObject5GetIdEv(ptr noundef nonnull align 8 dereferenceable(240)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12GShapeSphereC2E6GFloat(ptr noundef nonnull align 8 dereferenceable(16), i32) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN16GCG_Sphere_Plane16ProcessCollisionEPK8GCObjectS2_P17GCollisionContact(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #3 align 2 {
  %5 = alloca %class.GShapeSphere, align 8
  %6 = alloca %class.GShapePlane, align 4
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i8, ptr %7, align 8, !tbaa !5, !range !11, !noundef !12
  %9 = trunc nuw i8 %8 to i1
  %10 = getelementptr inbounds i8, ptr %2, i64 68
  %11 = getelementptr inbounds i8, ptr %1, i64 68
  %12 = select i1 %9, ptr %10, ptr %11
  %13 = select i1 %9, ptr %11, ptr %10
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  %. = select i1 %9, ptr %2, ptr %1
  %14 = getelementptr inbounds i8, ptr %., i64 8
  %15 = tail call i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24) %14)
  call void @_ZN12GShapeSphereC2E6GFloat(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 %15)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @_ZN11GShapePlaneC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %6)
  %16 = call noundef i32 @_ZN17GCollision_Sphere20Sphere_Plane_ContactERK12GShapeSphereRK13GTransform_QTRK11GShapePlaneS5_P17GCollisionContact(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(28) %12, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(28) %13, ptr noundef %3)
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %22, label %17

17:                                               ; preds = %4
  %18 = load i8, ptr %7, align 8, !tbaa !5, !range !11, !noundef !12
  %19 = trunc nuw i8 %18 to i1
  %.15 = select i1 %19, ptr %2, ptr %1
  %20 = call noundef i32 @_ZNK8GCObject5GetIdEv(ptr noundef nonnull align 8 dereferenceable(240) %.15)
  %21 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %20, ptr %21, align 8, !tbaa !13
  br label %22

22:                                               ; preds = %17, %4
  %23 = icmp sgt i32 %16, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  ret i1 %23
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11GShapePlaneC2Ev(ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

declare noundef i32 @_ZN17GCollision_Sphere20Sphere_Plane_ContactERK12GShapeSphereRK13GTransform_QTRK11GShapePlaneS5_P17GCollisionContact(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef) local_unnamed_addr #4

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 = { 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 = { 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 = { "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, !7, i64 8}
!6 = !{!"_ZTS19GCollisionAlgorithm", !7, i64 8, !10, i64 12}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTS17GCollisionContact", !15, i64 0, !10, i64 8, !10, i64 12, !8, i64 16}
!15 = !{!"long", !8, i64 0}


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