; LLVM IR from atlantis13579/Riemann :: Src/Collision (GeometryObject)

; 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.Maths::TVector3" = type { float, float, float }
%"class.Riemann::Geometry" = type <{ ptr, i8, [3 x i8], %"class.Maths::TAABB3", %"struct.Maths::Transform", %"struct.Maths::Transform", %"struct.Riemann::CollisionData", %"struct.Riemann::MassParameters", float, ptr, i32, [4 x i8] }>
%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"struct.Maths::Transform" = type { %"class.Maths::TVector3", %"class.Maths::Quaternion" }
%"class.Maths::Quaternion" = type { float, float, float, float }
%"struct.Riemann::CollisionData" = type { i32, i32, i32, i32 }
%"struct.Riemann::MassParameters" = type { float, float, %"class.Maths::Matrix3", %"class.Maths::TVector3", %"class.Maths::TAABB3" }
%"class.Maths::Matrix3" = type { [3 x [3 x float]] }

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths9Transform21WorldToLocalDirectionERKNS_8TVector3IfEE(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 4 dereferenceable(12)) #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 nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths9Transform12LocalToWorldERKNS_8TVector3IfEE(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7Riemann8Geometry25GetSupportFace_WorldSpaceERKN5Maths8TVector3IfEERNS_11StaticArrayIS3_Li16EEE(ptr noundef nonnull align 8 dereferenceable(204) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(196) %2) #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.Maths::TVector3", align 4
  %8 = alloca i32, align 4
  %9 = alloca %"class.Maths::TVector3", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #4
  %11 = getelementptr inbounds %"class.Riemann::Geometry", ptr %10, i32 0, i32 4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNK5Maths9Transform21WorldToLocalDirectionERKNS_8TVector3IfEE(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %7, ptr noundef nonnull align 4 dereferenceable(28) %11, ptr noundef nonnull align 4 dereferenceable(12) %12)
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %10, align 8, !tbaa !9
  %15 = getelementptr inbounds ptr, ptr %14, i64 5
  %16 = load ptr, ptr %15, align 8
  call void %16(ptr noundef nonnull align 8 dereferenceable(204) %10, ptr noundef nonnull align 4 dereferenceable(12) %7, ptr noundef nonnull align 4 dereferenceable(196) %13)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %17

17:                                               ; preds = %32, %3
  %18 = load i32, ptr %8, align 4, !tbaa !11
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call noundef i32 @_ZNK7Riemann11StaticArrayIN5Maths8TVector3IfEELi16EE4sizeEv(ptr noundef nonnull align 4 dereferenceable(196) %19)
  %21 = icmp slt i32 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %35

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #4
  %24 = getelementptr inbounds %"class.Riemann::Geometry", ptr %10, i32 0, i32 4
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !11
  %27 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Riemann11StaticArrayIN5Maths8TVector3IfEELi16EEixEi(ptr noundef nonnull align 4 dereferenceable(196) %25, i32 noundef %26)
  call void @_ZNK5Maths9Transform12LocalToWorldERKNS_8TVector3IfEE(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %9, ptr noundef nonnull align 4 dereferenceable(28) %24, ptr noundef nonnull align 4 dereferenceable(12) %27)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i32, ptr %8, align 4, !tbaa !11
  %30 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Riemann11StaticArrayIN5Maths8TVector3IfEELi16EEixEi(ptr noundef nonnull align 4 dereferenceable(196) %28, i32 noundef %29)
  %31 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %30, ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #4
  br label %32

32:                                               ; preds = %23
  %33 = load i32, ptr %8, align 4, !tbaa !11
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %8, align 4, !tbaa !11
  br label %17, !llvm.loop !13

35:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7Riemann11StaticArrayIN5Maths8TVector3IfEELi16EE4sizeEv(ptr noundef nonnull align 4 dereferenceable(196)) #2 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.Maths::TVector3" = type { float, float, float }

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths9Transform21WorldToLocalDirectionERKNS_8TVector3IfEE(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 4 dereferenceable(12)) 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 nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths9Transform12LocalToWorldERKNS_8TVector3IfEE(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7Riemann8Geometry25GetSupportFace_WorldSpaceERKN5Maths8TVector3IfEERNS_11StaticArrayIS3_Li16EEE(ptr noundef nonnull align 8 dereferenceable(204) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(196) %2) local_unnamed_addr #3 align 2 {
  %4 = alloca %"class.Maths::TVector3", align 4
  %5 = alloca %"class.Maths::TVector3", align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #4
  %6 = getelementptr inbounds i8, ptr %0, i64 36
  call void @_ZNK5Maths9Transform21WorldToLocalDirectionERKNS_8TVector3IfEE(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %4, ptr noundef nonnull align 4 dereferenceable(28) %6, ptr noundef nonnull align 4 dereferenceable(12) %1)
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 40
  %9 = load ptr, ptr %8, align 8
  call void %9(ptr noundef nonnull align 8 dereferenceable(204) %0, ptr noundef nonnull align 4 dereferenceable(12) %4, ptr noundef nonnull align 4 dereferenceable(196) %2)
  %10 = call noundef i32 @_ZNK7Riemann11StaticArrayIN5Maths8TVector3IfEELi16EE4sizeEv(ptr noundef nonnull align 4 dereferenceable(196) %2)
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %3
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #4
  ret void

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.09 = phi i32 [ %15, %.lr.ph ], [ 0, %3 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  %12 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Riemann11StaticArrayIN5Maths8TVector3IfEELi16EEixEi(ptr noundef nonnull align 4 dereferenceable(196) %2, i32 noundef %.09)
  call void @_ZNK5Maths9Transform12LocalToWorldERKNS_8TVector3IfEE(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %5, ptr noundef nonnull align 4 dereferenceable(28) %6, ptr noundef nonnull align 4 dereferenceable(12) %12)
  %13 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Riemann11StaticArrayIN5Maths8TVector3IfEELi16EEixEi(ptr noundef nonnull align 4 dereferenceable(196) %2, i32 noundef %.09)
  %14 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %13, ptr noundef nonnull align 4 dereferenceable(12) %5)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  %15 = add nuw nsw i32 %.09, 1
  %16 = call noundef i32 @_ZNK7Riemann11StaticArrayIN5Maths8TVector3IfEELi16EE4sizeEv(ptr noundef nonnull align 4 dereferenceable(196) %2)
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !8
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7Riemann11StaticArrayIN5Maths8TVector3IfEELi16EE4sizeEv(ptr noundef nonnull align 4 dereferenceable(196)) local_unnamed_addr #2 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass