; LLVM IR from devlinzhou/deterministic_physics :: UnrealDemo/Source/UnrealDemo/gphysics/src/collision (glacier_contact)

; 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.GFloat = type { i32 }
%class.GCollisionContact = type { i64, i32, i32, [16 x %class.GManifoldPoint] }
%class.GManifoldPoint = type <{ %class.GVector3, %class.GVector3, %class.GFloat, i32, i8, [3 x i8] }>
%class.GVector3 = type { %class.GFloat, %class.GFloat, %class.GFloat }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17GCollisionContact15AddContactPointERK8GVector3S2_6GFloatj(ptr noundef nonnull align 8 dereferenceable(592) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, i32 %3, i32 noundef %4) #0 align 2 {
  %6 = alloca %class.GFloat, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = getelementptr inbounds %class.GFloat, ptr %6, i32 0, i32 0
  store i32 %3, ptr %12, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !9
  %13 = load ptr, ptr %7, align 8
  %14 = getelementptr inbounds %class.GCollisionContact, ptr %13, i32 0, i32 2
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp sle i32 0, %15
  br i1 %16, label %17, label %41

17:                                               ; preds = %5
  %18 = getelementptr inbounds %class.GCollisionContact, ptr %13, i32 0, i32 2
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = icmp slt i32 %19, 15
  br i1 %20, label %21, label %41

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %22 = getelementptr inbounds %class.GCollisionContact, ptr %13, i32 0, i32 3
  %23 = getelementptr inbounds %class.GCollisionContact, ptr %13, i32 0, i32 2
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %23, align 4, !tbaa !11
  %26 = sext i32 %24 to i64
  %27 = getelementptr inbounds [16 x %class.GManifoldPoint], ptr %22, i64 0, i64 %26
  store ptr %27, ptr %11, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.GManifoldPoint, ptr %29, i32 0, i32 0
  %31 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN8GVector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %30, ptr noundef nonnull align 4 dereferenceable(12) %28)
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = getelementptr inbounds %class.GManifoldPoint, ptr %33, i32 0, i32 1
  %35 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN8GVector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %34, ptr noundef nonnull align 4 dereferenceable(12) %32)
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.GManifoldPoint, ptr %36, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %37, ptr align 4 %6, i64 4, i1 false), !tbaa.struct !14
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = getelementptr inbounds %class.GManifoldPoint, ptr %39, i32 0, i32 3
  store i32 %38, ptr %40, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %41

41:                                               ; preds = %21, %17, %5
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN8GVector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #2 align 2

; 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) #3

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

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 nosync 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"_ZTS17GCollisionContact", !13, i64 0, !10, i64 8, !10, i64 12, !7, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{i64 0, i64 4, !9}
!15 = !{!16, !10, i64 28}
!16 = !{!"_ZTS14GManifoldPoint", !17, i64 0, !17, i64 12, !18, i64 24, !10, i64 28, !19, i64 32}
!17 = !{!"_ZTS8GVector3", !18, i64 0, !18, i64 4, !18, i64 8}
!18 = !{!"_ZTS6GFloat", !10, i64 0}
!19 = !{!"bool", !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.GManifoldPoint = type <{ %class.GVector3, %class.GVector3, %class.GFloat, i32, i8, [3 x i8] }>
%class.GVector3 = type { %class.GFloat, %class.GFloat, %class.GFloat }
%class.GFloat = type { i32 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN17GCollisionContact15AddContactPointERK8GVector3S2_6GFloatj(ptr noundef nonnull align 8 dereferenceable(592) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, i32 %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %or.cond = icmp ult i32 %7, 15
  br i1 %or.cond, label %8, label %18

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = add nuw nsw i32 %7, 1
  store i32 %10, ptr %6, align 4, !tbaa !5
  %11 = zext nneg i32 %7 to i64
  %12 = getelementptr inbounds [16 x %class.GManifoldPoint], ptr %9, i64 0, i64 %11
  %13 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN8GVector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %12, ptr noundef nonnull align 4 dereferenceable(12) %1)
  %14 = getelementptr inbounds i8, ptr %12, i64 12
  %15 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN8GVector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %14, ptr noundef nonnull align 4 dereferenceable(12) %2)
  %16 = getelementptr inbounds i8, ptr %12, i64 24
  store i32 %3, ptr %16, align 4, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %12, i64 28
  store i32 %4, ptr %17, align 4, !tbaa !12
  br label %18

18:                                               ; preds = %8, %5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN8GVector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

attributes #0 = { 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 #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" }

!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, !10, i64 12}
!6 = !{!"_ZTS17GCollisionContact", !7, i64 0, !10, i64 8, !10, i64 12, !8, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!13, !10, i64 28}
!13 = !{!"_ZTS14GManifoldPoint", !14, i64 0, !14, i64 12, !15, i64 24, !10, i64 28, !16, i64 32}
!14 = !{!"_ZTS8GVector3", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"_ZTS6GFloat", !10, i64 0}
!16 = !{!"bool", !8, i64 0}


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