; LLVM IR from atlantis13579/Riemann :: Src/CollisionPrimitive (ConvexMesh)

; 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::ConvexMesh" = type { ptr, ptr, ptr, ptr, i16, i16, i16, i16, %"class.std::vector", %"class.Maths::TAABB3" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl" }
%"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl" = type { %"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }

; 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 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 float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1 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)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7Riemann10ConvexMesh10GetSupportERKN5Maths8TVector3IfEE(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4 %0, ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 4 dereferenceable(12) %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca i16, align 2
  %9 = alloca float, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store float 0xC7EFFFFFE0000000, ptr %7, align 4, !tbaa !9
  call void @_ZN5Maths8TVector3IfE4ZeroEv(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %0)
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #3
  store i16 0, ptr %8, align 2, !tbaa !11
  br label %11

11:                                               ; preds = %39, %3
  %12 = load i16, ptr %8, align 2, !tbaa !11
  %13 = zext i16 %12 to i32
  %14 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %10, i32 0, i32 4
  %15 = load i16, ptr %14, align 8, !tbaa !13
  %16 = zext i16 %15 to i32
  %17 = icmp slt i32 %13, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #3
  br label %42

19:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %20 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %10, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !21
  %22 = load i16, ptr %8, align 2, !tbaa !11
  %23 = zext i16 %22 to i64
  %24 = getelementptr inbounds %"class.Maths::TVector3", ptr %21, i64 %23
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %24, ptr noundef nonnull align 4 dereferenceable(12) %25)
  store float %26, ptr %9, align 4, !tbaa !9
  %27 = load float, ptr %9, align 4, !tbaa !9
  %28 = load float, ptr %7, align 4, !tbaa !9
  %29 = fcmp ogt float %27, %28
  br i1 %29, label %30, label %38

30:                                               ; preds = %19
  %31 = load float, ptr %9, align 4, !tbaa !9
  store float %31, ptr %7, align 4, !tbaa !9
  %32 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %10, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !21
  %34 = load i16, ptr %8, align 2, !tbaa !11
  %35 = zext i16 %34 to i64
  %36 = getelementptr inbounds %"class.Maths::TVector3", ptr %33, i64 %35
  %37 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %36)
  br label %38

38:                                               ; preds = %30, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %39

39:                                               ; preds = %38
  %40 = load i16, ptr %8, align 2, !tbaa !11
  %41 = add i16 %40, 1
  store i16 %41, ptr %8, align 2, !tbaa !11
  br label %11, !llvm.loop !22

42:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Maths8TVector3IfE4ZeroEv(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4) #2 align 2

attributes #0 = { 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 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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !12, i64 32}
!14 = !{!"_ZTSN7Riemann10ConvexMeshE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !12, i64 34, !12, i64 36, !12, i64 38, !15, i64 40, !19, i64 64}
!15 = !{!"_ZTSSt6vectorIcSaIcEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIcSaIcEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIcSaIcEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIcSaIcEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"_ZTSN5Maths6TAABB3IfEE", !20, i64 0, !20, i64 12}
!20 = !{!"_ZTSN5Maths8TVector3IfEE", !10, i64 0, !10, i64 4, !10, i64 8}
!21 = !{!14, !6, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0 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 #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7Riemann10ConvexMesh10GetSupportERKN5Maths8TVector3IfEE(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(88) %1, ptr noundef nonnull align 4 dereferenceable(12) %2) local_unnamed_addr #1 align 2 {
  tail call void @_ZN5Maths8TVector3IfE4ZeroEv(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %0)
  %4 = getelementptr inbounds i8, ptr %1, i64 32
  %5 = load i16, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i16 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %14, %3
  ret void

.lr.ph:                                           ; preds = %3, %14
  %indvars.iv = phi i64 [ %indvars.iv.next, %14 ], [ 0, %3 ]
  %.011 = phi float [ %.1, %14 ], [ 0xC7EFFFFFE0000000, %3 ]
  %6 = load ptr, ptr %1, align 8, !tbaa !18
  %7 = getelementptr inbounds %"class.Maths::TVector3", ptr %6, i64 %indvars.iv
  %8 = tail call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %7, ptr noundef nonnull align 4 dereferenceable(12) %2)
  %9 = fcmp ogt float %8, %.011
  br i1 %9, label %10, label %14

10:                                               ; preds = %.lr.ph
  %11 = load ptr, ptr %1, align 8, !tbaa !18
  %12 = getelementptr inbounds %"class.Maths::TVector3", ptr %11, i64 %indvars.iv
  %13 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN5Maths8TVector3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %12)
  br label %14

14:                                               ; preds = %10, %.lr.ph
  %.1 = phi float [ %8, %10 ], [ %.011, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i16, ptr %4, align 8, !tbaa !5
  %16 = zext i16 %15 to i64
  %17 = icmp ult i64 %indvars.iv.next, %16
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !19
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Maths8TVector3IfE4ZeroEv(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4) local_unnamed_addr #1 align 2

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

!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 32}
!6 = !{!"_ZTSN7Riemann10ConvexMeshE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 34, !10, i64 36, !10, i64 38, !11, i64 40, !15, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"_ZTSSt6vectorIcSaIcEE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIcSaIcEE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIcSaIcEE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIcSaIcEE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!15 = !{!"_ZTSN5Maths6TAABB3IfEE", !16, i64 0, !16, i64 12}
!16 = !{!"_ZTSN5Maths8TVector3IfEE", !17, i64 0, !17, i64 4, !17, i64 8}
!17 = !{!"float", !8, i64 0}
!18 = !{!6, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass