; LLVM IR from atlantis13579/Riemann :: Src/Geometry (ConvexHull3)

; 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::Matrix3" = type { [3 x [3 x float]] }
%"class.Maths::TVector3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Riemann34ComputePointCloudInertiaTensor_PCAEPKN5Maths8TVector3IfEEi(ptr dead_on_unwind noalias writable sret(%"class.Maths::Matrix3") align 4 %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.Maths::Matrix3", align 4
  %8 = alloca [3 x float], align 4
  %9 = alloca [3 x %"class.Maths::TVector3"], align 16
  %10 = alloca %"class.Maths::TVector3", align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 36, ptr %7) #5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load i32, ptr %6, align 4, !tbaa !9
  call void @_ZN5Maths7Matrix323ComputeCovarianceMatrixEPKNS_8TVector3IfEEi(ptr dead_on_unwind writable sret(%"class.Maths::Matrix3") align 4 %7, ptr noundef %11, i32 noundef %12)
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 36, ptr %9) #5
  %13 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i32 0, i32 0
  %14 = getelementptr inbounds %"class.Maths::TVector3", ptr %13, i64 3
  br label %15

15:                                               ; preds = %15, %3
  %16 = phi ptr [ %13, %3 ], [ %17, %15 ]
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %16)
  %17 = getelementptr inbounds %"class.Maths::TVector3", ptr %16, i64 1
  %18 = icmp eq ptr %17, %14
  br i1 %18, label %19, label %15

19:                                               ; preds = %15
  %20 = getelementptr inbounds [3 x float], ptr %8, i64 0, i64 0
  %21 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 0
  %22 = call noundef zeroext i1 @_ZNK5Maths7Matrix319SolveEigenSymmetricEPfPNS_8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(36) %7, ptr noundef %20, ptr noundef %21)
  %23 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 0
  %24 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 1
  %25 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 2
  %26 = call noundef float @_ZN5Maths11DeterminantIfEET_RKNS_8TVector3IS1_EES5_S5_(ptr noundef nonnull align 4 dereferenceable(12) %23, ptr noundef nonnull align 4 dereferenceable(12) %24, ptr noundef nonnull align 4 dereferenceable(12) %25)
  %27 = fcmp olt float %26, 0.000000e+00
  br i1 %27, label %28, label %32

28:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #5
  %29 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 2
  call void @_ZNK5Maths8TVector3IfEngEv(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %10, ptr noundef nonnull align 4 dereferenceable(12) %29)
  %30 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 2
  %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) %10)
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #5
  br label %32

32:                                               ; preds = %28, %19
  %33 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 0
  %34 = getelementptr inbounds %"class.Maths::TVector3", ptr %33, i32 0, i32 0
  %35 = load float, ptr %34, align 16, !tbaa !11
  %36 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 1
  %37 = getelementptr inbounds %"class.Maths::TVector3", ptr %36, i32 0, i32 0
  %38 = load float, ptr %37, align 4, !tbaa !11
  %39 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 2
  %40 = getelementptr inbounds %"class.Maths::TVector3", ptr %39, i32 0, i32 0
  %41 = load float, ptr %40, align 8, !tbaa !11
  %42 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 0
  %43 = getelementptr inbounds %"class.Maths::TVector3", ptr %42, i32 0, i32 1
  %44 = load float, ptr %43, align 4, !tbaa !14
  %45 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 1
  %46 = getelementptr inbounds %"class.Maths::TVector3", ptr %45, i32 0, i32 1
  %47 = load float, ptr %46, align 4, !tbaa !14
  %48 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 2
  %49 = getelementptr inbounds %"class.Maths::TVector3", ptr %48, i32 0, i32 1
  %50 = load float, ptr %49, align 4, !tbaa !14
  %51 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 0
  %52 = getelementptr inbounds %"class.Maths::TVector3", ptr %51, i32 0, i32 2
  %53 = load float, ptr %52, align 8, !tbaa !15
  %54 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 1
  %55 = getelementptr inbounds %"class.Maths::TVector3", ptr %54, i32 0, i32 2
  %56 = load float, ptr %55, align 4, !tbaa !15
  %57 = getelementptr inbounds [3 x %"class.Maths::TVector3"], ptr %9, i64 0, i64 2
  %58 = getelementptr inbounds %"class.Maths::TVector3", ptr %57, i32 0, i32 2
  %59 = load float, ptr %58, align 8, !tbaa !15
  call void @_ZN5Maths7Matrix3C2Efffffffff(ptr noundef nonnull align 4 dereferenceable(36) %0, float noundef %35, float noundef %38, float noundef %41, float noundef %44, float noundef %47, float noundef %50, float noundef %53, float noundef %56, float noundef %59)
  call void @llvm.lifetime.end.p0(i64 36, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 36, ptr %7) #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: mustprogress uwtable
declare dso_local void @_ZN5Maths7Matrix323ComputeCovarianceMatrixEPKNS_8TVector3IfEEi(ptr dead_on_unwind noalias writable sret(%"class.Maths::Matrix3") align 4, ptr noundef, i32 noundef) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK5Maths7Matrix319SolveEigenSymmetricEPfPNS_8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef, ptr noundef) #0 align 2

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

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

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

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

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 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN5Maths8TVector3IfEE", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = !{!12, !13, i64 8}


; 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::Matrix3" = type { [3 x [3 x float]] }
%"class.Maths::TVector3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Riemann34ComputePointCloudInertiaTensor_PCAEPKN5Maths8TVector3IfEEi(ptr dead_on_unwind noalias writable sret(%"class.Maths::Matrix3") align 4 %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca %"class.Maths::Matrix3", align 4
  %5 = alloca [3 x float], align 4
  %6 = alloca [3 x %"class.Maths::TVector3"], align 16
  %7 = alloca %"class.Maths::TVector3", align 4
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %4) #5
  call void @_ZN5Maths7Matrix323ComputeCovarianceMatrixEPKNS_8TVector3IfEEi(ptr dead_on_unwind nonnull writable sret(%"class.Maths::Matrix3") align 4 %4, ptr noundef %1, i32 noundef %2)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %6) #5
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %6)
  %.ptr.1 = getelementptr inbounds i8, ptr %6, i64 12
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1)
  %.ptr.2 = getelementptr inbounds i8, ptr %6, i64 24
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %8 = call noundef zeroext i1 @_ZNK5Maths7Matrix319SolveEigenSymmetricEPfPNS_8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(36) %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %9 = call noundef float @_ZN5Maths11DeterminantIfEET_RKNS_8TVector3IS1_EES5_S5_(ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1, ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %10 = fcmp olt float %9, 0.000000e+00
  br i1 %10, label %11, label %13

11:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #5
  call void @_ZNK5Maths8TVector3IfEngEv(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %7, ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %12 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2, ptr noundef nonnull align 4 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #5
  br label %13

13:                                               ; preds = %11, %3
  %14 = load float, ptr %6, align 16, !tbaa !5
  %15 = load float, ptr %.ptr.1, align 4, !tbaa !5
  %16 = load float, ptr %.ptr.2, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %6, i64 4
  %18 = load float, ptr %17, align 4, !tbaa !10
  %19 = getelementptr inbounds i8, ptr %6, i64 16
  %20 = load float, ptr %19, align 16, !tbaa !10
  %21 = getelementptr inbounds i8, ptr %6, i64 28
  %22 = load float, ptr %21, align 4, !tbaa !10
  %23 = getelementptr inbounds i8, ptr %6, i64 8
  %24 = load float, ptr %23, align 8, !tbaa !11
  %25 = getelementptr inbounds i8, ptr %6, i64 20
  %26 = load float, ptr %25, align 4, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %6, i64 32
  %28 = load float, ptr %27, align 16, !tbaa !11
  call void @_ZN5Maths7Matrix3C2Efffffffff(ptr noundef nonnull align 4 dereferenceable(36) %0, float noundef %14, float noundef %15, float noundef %16, float noundef %18, float noundef %20, float noundef %22, float noundef %24, float noundef %26, float noundef %28)
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %4) #5
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Maths7Matrix323ComputeCovarianceMatrixEPKNS_8TVector3IfEEi(ptr dead_on_unwind noalias writable sret(%"class.Maths::Matrix3") align 4, ptr noundef, i32 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK5Maths7Matrix319SolveEigenSymmetricEPfPNS_8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef, ptr noundef) local_unnamed_addr #0 align 2

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

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

; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

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 = { mustprogress 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 = { 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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN5Maths8TVector3IfEE", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!6, !7, i64 8}


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