; LLVM IR from devlinzhou/deterministic_physics :: UnrealDemo/Source/UnrealDemo/gphysics/src/collision/glacier_collision_algorithm._57574db1 (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.GShapeBox = type { %class.GShapeConvexBase.base, %class.GVector3 }
%class.GShapeConvexBase.base = type <{ ptr, %class.GShapeBase }>
%class.GShapeBase = type { i32 }
%class.GVector3 = type { %class.GFloat, %class.GFloat, %class.GFloat }
%class.GFloat = type { 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 uwtable
define dso_local noundef zeroext i1 @_ZN11GCG_Box_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 %class.GShapeBox, align 8
  %10 = alloca %class.GVector3, align 4
  %11 = alloca { i64, i32 }, align 8
  %12 = alloca { i64, i32 }, align 4
  %13 = alloca %class.GShapeBox, align 8
  %14 = alloca %class.GVector3, align 4
  %15 = alloca { i64, i32 }, align 8
  %16 = alloca { i64, i32 }, align 4
  %17 = alloca i8, align 1
  %18 = 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
  %19 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #6
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %class.GCObject, ptr %20, i32 0, i32 1
  %22 = call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %21)
  store { i64, i32 } %22, ptr %11, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %11, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %10, i64 12, i1 false)
  %23 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 0
  %24 = load i64, ptr %23, align 4
  %25 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 1
  %26 = load i32, ptr %25, align 4
  call void @_ZN9GShapeBoxC2E8GVector3(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 %24, i32 %26)
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #6
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.GCObject, ptr %27, i32 0, i32 1
  %29 = call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %28)
  store { i64, i32 } %29, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 8 %15, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %14, i64 12, i1 false)
  %30 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 0
  %31 = load i64, ptr %30, align 4
  %32 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 1
  %33 = load i32, ptr %32, align 4
  call void @_ZN9GShapeBoxC2E8GVector3(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 %31, i32 %33)
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #6
  store i8 0, ptr %17, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %class.GCObject, ptr %34, i32 0, i32 5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.GCObject, ptr %36, i32 0, i32 5
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = call noundef i32 @_ZN14GCollision_Box18Box_Box_Contact_PXERK9GShapeBoxRK13GTransform_QTS2_S5_P17GCollisionContactRb(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 4 dereferenceable(28) %35, ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 4 dereferenceable(28) %37, ptr noundef %38, ptr noundef nonnull align 1 dereferenceable(1) %17)
  store i32 %39, ptr %18, align 4, !tbaa !11
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %56

42:                                               ; preds = %4
  %43 = load i8, ptr %17, align 1, !tbaa !9, !range !13, !noundef !14
  %44 = trunc i8 %43 to i1
  br i1 %44, label %45, label %50

45:                                               ; preds = %42
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call noundef i32 @_ZNK8GCObject5GetIdEv(ptr noundef nonnull align 8 dereferenceable(240) %46)
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %class.GCollisionContact, ptr %48, i32 0, i32 1
  store i32 %47, ptr %49, align 8, !tbaa !15
  br label %55

50:                                               ; preds = %42
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = call noundef i32 @_ZNK8GCObject5GetIdEv(ptr noundef nonnull align 8 dereferenceable(240) %51)
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %class.GCollisionContact, ptr %53, i32 0, i32 1
  store i32 %52, ptr %54, align 8, !tbaa !15
  br label %55

55:                                               ; preds = %50, %45
  br label %56

56:                                               ; preds = %55, %4
  %57 = load i32, ptr %18, align 4, !tbaa !11
  %58 = icmp sgt i32 %57, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #6
  ret i1 %58
}

declare noundef i32 @_ZN14GCollision_Box18Box_Box_Contact_PXERK9GShapeBoxRK13GTransform_QTS2_S5_P17GCollisionContactRb(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) #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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !12, i64 8}
!16 = !{!"_ZTS17GCollisionContact", !17, i64 0, !12, i64 8, !12, i64 12, !7, i64 16}
!17 = !{!"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.GShapeBox = type { %class.GShapeConvexBase.base, %class.GVector3 }
%class.GShapeConvexBase.base = type <{ ptr, %class.GShapeBase }>
%class.GShapeBase = type { i32 }
%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 uwtable
define dso_local noundef zeroext i1 @_ZN11GCG_Box_Box16ProcessCollisionEPK8GCObjectS2_P17GCollisionContact(ptr nocapture noundef nonnull readnone align 8 dereferenceable(16) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #3 align 2 {
  %5 = alloca %class.GShapeBox, align 8
  %6 = alloca %class.GShapeBox, align 8
  %7 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #5
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = tail call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %.fca.0.extract7 = extractvalue { i64, i32 } %9, 0
  %.fca.1.extract8 = extractvalue { i64, i32 } %9, 1
  call void @_ZN9GShapeBoxC2E8GVector3(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 %.fca.0.extract7, i32 %.fca.1.extract8)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #5
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  %11 = call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  %.fca.0.extract = extractvalue { i64, i32 } %11, 0
  %.fca.1.extract = extractvalue { i64, i32 } %11, 1
  call void @_ZN9GShapeBoxC2E8GVector3(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 %.fca.0.extract, i32 %.fca.1.extract)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #5
  store i8 0, ptr %7, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 68
  %13 = getelementptr inbounds i8, ptr %2, i64 68
  %14 = call noundef i32 @_ZN14GCollision_Box18Box_Box_Contact_PXERK9GShapeBoxRK13GTransform_QTS2_S5_P17GCollisionContactRb(ptr noundef nonnull align 8 dereferenceable(24) %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, ptr noundef nonnull align 1 dereferenceable(1) %7)
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %19, label %.sink.split

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

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

declare noundef i32 @_ZN14GCollision_Box18Box_Box_Contact_PXERK9GShapeBoxRK13GTransform_QTS2_S5_P17GCollisionContactRb(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(28), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) 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, !6, i64 0}
!6 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !14, i64 8}
!12 = !{!"_ZTS17GCollisionContact", !13, i64 0, !14, i64 8, !14, i64 12, !7, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}


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