; LLVM IR from devlinzhou/deterministic_physics :: UnrealDemo/Source/UnrealDemo/gphysics/src/utils (glacier_physics_utils)

; 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.GMatrix3 = type { [3 x [3 x %class.GFloat]] }
%class.GVector3 = type { %class.GFloat, %class.GFloat, %class.GFloat }
%class.GColor = type { i32 }
%class.GTransform_QT = type { %class.GQuaternion, %class.GVector3 }
%class.GQuaternion = type { %class.GFloat, %class.GFloat, %class.GFloat, %class.GFloat }

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12GPhyscsUtils20DrawCoordinateSystemEP12IGlacierDrawRK13GTransform_QT6GFloat(ptr noundef %0, ptr noundef nonnull align 4 dereferenceable(28) %1, i32 %2) #2 align 2 {
  %4 = alloca %class.GFloat, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %class.GMatrix3, align 4
  %8 = alloca %class.GVector3, align 4
  %9 = alloca { i64, i32 }, align 8
  %10 = alloca %class.GColor, align 4
  %11 = alloca %class.GVector3, align 4
  %12 = alloca { i64, i32 }, align 8
  %13 = alloca %class.GColor, align 4
  %14 = alloca %class.GVector3, align 4
  %15 = alloca { i64, i32 }, align 8
  %16 = alloca %class.GColor, align 4
  %17 = getelementptr inbounds %class.GFloat, ptr %4, i32 0, i32 0
  store i32 %2, ptr %17, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 36, ptr %7) #5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.GTransform_QT, ptr %18, i32 0, i32 0
  call void @_ZN8GMatrix3C2ERK11GQuaternion(ptr noundef nonnull align 4 dereferenceable(36) %7, ptr noundef nonnull align 4 dereferenceable(16) %19)
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %class.GTransform_QT, ptr %21, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.GTransform_QT, ptr %23, i32 0, i32 1
  %25 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK8GMatrix36GetRowEj(ptr noundef nonnull align 4 dereferenceable(36) %7, i32 noundef 0)
  %26 = call { i64, i32 } @_ZNK8GVector3plERKS_(ptr noundef nonnull align 4 dereferenceable(12) %24, ptr noundef nonnull align 4 dereferenceable(12) %25)
  store { i64, i32 } %26, ptr %9, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 8 %9, i64 12, i1 false)
  %27 = call i32 @_ZN6GColor3RedEv()
  %28 = getelementptr inbounds %class.GColor, ptr %10, i32 0, i32 0
  store i32 %27, ptr %28, align 4
  %29 = getelementptr inbounds %class.GColor, ptr %10, i32 0, i32 0
  %30 = load i32, ptr %29, align 4
  %31 = load ptr, ptr %20, align 8, !tbaa !9
  %32 = getelementptr inbounds ptr, ptr %31, i64 0
  %33 = load ptr, ptr %32, align 8
  call void %33(ptr noundef nonnull align 8 dereferenceable(8) %20, ptr noundef nonnull align 4 dereferenceable(12) %22, ptr noundef nonnull align 4 dereferenceable(12) %8, i32 %30)
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.GTransform_QT, ptr %35, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #5
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.GTransform_QT, ptr %37, i32 0, i32 1
  %39 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK8GMatrix36GetRowEj(ptr noundef nonnull align 4 dereferenceable(36) %7, i32 noundef 1)
  %40 = call { i64, i32 } @_ZNK8GVector3plERKS_(ptr noundef nonnull align 4 dereferenceable(12) %38, ptr noundef nonnull align 4 dereferenceable(12) %39)
  store { i64, i32 } %40, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 8 %12, i64 12, i1 false)
  %41 = call i32 @_ZN6GColor5GreenEv()
  %42 = getelementptr inbounds %class.GColor, ptr %13, i32 0, i32 0
  store i32 %41, ptr %42, align 4
  %43 = getelementptr inbounds %class.GColor, ptr %13, i32 0, i32 0
  %44 = load i32, ptr %43, align 4
  %45 = load ptr, ptr %34, align 8, !tbaa !9
  %46 = getelementptr inbounds ptr, ptr %45, i64 0
  %47 = load ptr, ptr %46, align 8
  call void %47(ptr noundef nonnull align 8 dereferenceable(8) %34, ptr noundef nonnull align 4 dereferenceable(12) %36, ptr noundef nonnull align 4 dereferenceable(12) %11, i32 %44)
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #5
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %class.GTransform_QT, ptr %49, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %class.GTransform_QT, ptr %51, i32 0, i32 1
  %53 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK8GMatrix36GetRowEj(ptr noundef nonnull align 4 dereferenceable(36) %7, i32 noundef 2)
  %54 = call { i64, i32 } @_ZNK8GVector3plERKS_(ptr noundef nonnull align 4 dereferenceable(12) %52, ptr noundef nonnull align 4 dereferenceable(12) %53)
  store { i64, i32 } %54, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 8 %15, i64 12, i1 false)
  %55 = call i32 @_ZN6GColor4BlueEv()
  %56 = getelementptr inbounds %class.GColor, ptr %16, i32 0, i32 0
  store i32 %55, ptr %56, align 4
  %57 = getelementptr inbounds %class.GColor, ptr %16, i32 0, i32 0
  %58 = load i32, ptr %57, align 4
  %59 = load ptr, ptr %48, align 8, !tbaa !9
  %60 = getelementptr inbounds ptr, ptr %59, i64 0
  %61 = load ptr, ptr %60, align 8
  call void %61(ptr noundef nonnull align 8 dereferenceable(8) %48, ptr noundef nonnull align 4 dereferenceable(12) %50, ptr noundef nonnull align 4 dereferenceable(12) %14, i32 %58)
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 36, ptr %7) #5
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8GMatrix3C2ERK11GQuaternion(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 4 dereferenceable(16)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i32 } @_ZNK8GVector3plERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZN6GColor3RedEv() #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZN6GColor5GreenEv() #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZN6GColor4BlueEv() #2 align 2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = !{!"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}


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

; 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 uwtable
define dso_local void @_ZN12GPhyscsUtils20DrawCoordinateSystemEP12IGlacierDrawRK13GTransform_QT6GFloat(ptr noundef %0, ptr noundef nonnull align 4 dereferenceable(28) %1, i32 %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %class.GMatrix3, align 4
  %5 = alloca %class.GVector3, align 8
  %6 = alloca %class.GVector3, align 8
  %7 = alloca %class.GVector3, align 8
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %4) #4
  call void @_ZN8GMatrix3C2ERK11GQuaternion(ptr noundef nonnull align 4 dereferenceable(36) %4, ptr noundef nonnull align 4 dereferenceable(16) %1)
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  %9 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK8GMatrix36GetRowEj(ptr noundef nonnull align 4 dereferenceable(36) %4, i32 noundef 0)
  %10 = call { i64, i32 } @_ZNK8GVector3plERKS_(ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %9)
  %.fca.0.extract8 = extractvalue { i64, i32 } %10, 0
  %.fca.1.extract9 = extractvalue { i64, i32 } %10, 1
  store i64 %.fca.0.extract8, ptr %5, align 8
  %.sroa.211.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %.fca.1.extract9, ptr %.sroa.211.0..sroa_idx, align 8
  %11 = call i32 @_ZN6GColor3RedEv()
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8
  call void %13(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %5, i32 %11)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #4
  %14 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK8GMatrix36GetRowEj(ptr noundef nonnull align 4 dereferenceable(36) %4, i32 noundef 1)
  %15 = call { i64, i32 } @_ZNK8GVector3plERKS_(ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %14)
  %.fca.0.extract3 = extractvalue { i64, i32 } %15, 0
  %.fca.1.extract4 = extractvalue { i64, i32 } %15, 1
  store i64 %.fca.0.extract3, ptr %6, align 8
  %.sroa.26.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %.fca.1.extract4, ptr %.sroa.26.0..sroa_idx, align 8
  %16 = call i32 @_ZN6GColor5GreenEv()
  %17 = load ptr, ptr %0, align 8, !tbaa !5
  %18 = load ptr, ptr %17, align 8
  call void %18(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %6, i32 %16)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #4
  %19 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK8GMatrix36GetRowEj(ptr noundef nonnull align 4 dereferenceable(36) %4, i32 noundef 2)
  %20 = call { i64, i32 } @_ZNK8GVector3plERKS_(ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %19)
  %.fca.0.extract = extractvalue { i64, i32 } %20, 0
  %.fca.1.extract = extractvalue { i64, i32 } %20, 1
  store i64 %.fca.0.extract, ptr %7, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  %21 = call i32 @_ZN6GColor4BlueEv()
  %22 = load ptr, ptr %0, align 8, !tbaa !5
  %23 = load ptr, ptr %22, align 8
  call void %23(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %7, i32 %21)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %4) #4
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8GMatrix3C2ERK11GQuaternion(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 4 dereferenceable(16)) unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i32 } @_ZNK8GVector3plERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZN6GColor3RedEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZN6GColor5GreenEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZN6GColor4BlueEv() local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass