; LLVM IR from devlinzhou/deterministic_physics :: UnrealDemo/Source/UnrealDemo/gphysics/src/collision/glacier_collision_algorithm._170966cf (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.GShapePlane = type { %class.GShapeBase }
%class.GShapeBase = type { i32 }
%class.GShapeBox = type { %class.GShapeConvexBase.base, %class.GVector3 }
%class.GShapeConvexBase.base = type <{ ptr, %class.GShapeBase }>
%class.GVector3 = type { %class.GFloat, %class.GFloat, %class.GFloat }
%class.GFloat = type { i32 }
%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.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: 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: 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 nounwind uwtable
declare dso_local { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9GShapeBoxC2E8GVector3(ptr noundef nonnull align 8 dereferenceable(24), i64, i32) unnamed_addr #4 align 2

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

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

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

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

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

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

36:                                               ; preds = %28
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.GCObject, ptr %37, i32 0, i32 5
  br label %39

39:                                               ; preds = %36, %33
  %40 = phi ptr [ %35, %33 ], [ %38, %36 ]
  store ptr %40, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  call void @_ZN11GShapePlaneC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #6
  %41 = getelementptr inbounds %class.GCollisionAlgorithm, ptr %18, i32 0, i32 1
  %42 = load i8, ptr %41, align 8, !tbaa !9, !range !13, !noundef !14
  %43 = trunc i8 %42 to i1
  br i1 %43, label %44, label %48

44:                                               ; preds = %39
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %class.GCObject, ptr %45, i32 0, i32 1
  %47 = call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %46)
  store { i64, i32 } %47, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 8 %14, i64 12, i1 false)
  br label %52

48:                                               ; preds = %39
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %class.GCObject, ptr %49, i32 0, i32 1
  %51 = call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %50)
  store { i64, i32 } %51, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 8 %15, i64 12, i1 false)
  br label %52

52:                                               ; preds = %48, %44
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %13, i64 12, i1 false)
  %53 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 0
  %54 = load i64, ptr %53, align 4
  %55 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 1
  %56 = load i32, ptr %55, align 4
  call void @_ZN9GShapeBoxC2E8GVector3(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 %54, i32 %56)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = call noundef i32 @_ZN14GCollision_Box17Plane_Box_ContactERK11GShapePlaneRK13GTransform_QTRK9GShapeBoxS5_P17GCollisionContact(ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(28) %57, ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef nonnull align 4 dereferenceable(28) %58, ptr noundef %59)
  store i32 %60, ptr %17, align 4, !tbaa !15
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %77

63:                                               ; preds = %52
  %64 = getelementptr inbounds %class.GCollisionAlgorithm, ptr %18, i32 0, i32 1
  %65 = load i8, ptr %64, align 8, !tbaa !9, !range !13, !noundef !14
  %66 = trunc i8 %65 to i1
  br i1 %66, label %67, label %70

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

70:                                               ; preds = %63
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = call noundef i32 @_ZNK8GCObject5GetIdEv(ptr noundef nonnull align 8 dereferenceable(240) %71)
  br label %73

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

77:                                               ; preds = %73, %52
  %78 = load i32, ptr %17, align 4, !tbaa !15
  %79 = icmp sgt i32 %78, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret i1 %79
}

declare noundef i32 @_ZN14GCollision_Box17Plane_Box_ContactERK11GShapePlaneRK13GTransform_QTRK9GShapeBoxS5_P17GCollisionContact(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef) #5

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 = { 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 #4 = { 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 = { "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, !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.GShapePlane = type { %class.GShapeBase }
%class.GShapeBase = type { i32 }
%class.GShapeBox = type { %class.GShapeConvexBase.base, %class.GVector3 }
%class.GShapeConvexBase.base = type <{ ptr, %class.GShapeBase }>
%class.GVector3 = type { %class.GFloat, %class.GFloat, %class.GFloat }
%class.GFloat = type { i32 }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN13GCG_Plane_Box16ProcessCollisionEPK8GCObjectS2_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.GShapePlane, align 4
  %6 = alloca %class.GShapeBox, align 8
  %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 4, ptr nonnull %5) #5
  call void @_ZN11GShapePlaneC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #5
  %14 = load i8, ptr %7, align 8, !tbaa !5, !range !11, !noundef !12
  %15 = trunc nuw i8 %14 to i1
  %. = select i1 %15, ptr %1, ptr %2
  %16 = getelementptr inbounds i8, ptr %., i64 8
  %17 = call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %16)
  %.sroa.3.0 = extractvalue { i64, i32 } %17, 1
  %.sroa.07.0 = extractvalue { i64, i32 } %17, 0
  call void @_ZN9GShapeBoxC2E8GVector3(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 %.sroa.07.0, i32 %.sroa.3.0)
  %18 = call noundef i32 @_ZN14GCollision_Box17Plane_Box_ContactERK11GShapePlaneRK13GTransform_QTRK9GShapeBoxS5_P17GCollisionContact(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(28) %12, ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 4 dereferenceable(28) %13, ptr noundef %3)
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %24, label %19

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

24:                                               ; preds = %19, %4
  %25 = icmp sgt i32 %18, 0
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  ret i1 %25
}

declare noundef i32 @_ZN14GCollision_Box17Plane_Box_ContactERK11GShapePlaneRK13GTransform_QTRK9GShapeBoxS5_P17GCollisionContact(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(24), 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 = { 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 = { 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