; 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::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"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 }
%"struct.Riemann::ConvexMeshFace" = type { %"class.Riemann::Plane3", i16, i8, i8 }
%"class.Riemann::Plane3" = type { %"class.Maths::TVector3", float }
%"struct.Riemann::ConvexMeshEdge" = type { i16, i16 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Riemann10ConvexMesh13SetConvexDataEPN5Maths8TVector3IfEEtPNS_14ConvexMeshFaceEtPttPhtb(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1, i16 noundef zeroext %2, ptr noundef %3, i16 noundef zeroext %4, ptr noundef %5, i16 noundef zeroext %6, ptr noundef %7, i16 noundef zeroext %8, i1 noundef zeroext %9) #0 align 2 {
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i16, align 2
  %14 = alloca ptr, align 8
  %15 = alloca i16, align 2
  %16 = alloca ptr, align 8
  %17 = alloca i16, align 2
  %18 = alloca ptr, align 8
  %19 = alloca i16, align 2
  %20 = alloca i8, align 1
  %21 = alloca i32, align 4
  %22 = alloca %"class.Maths::TAABB3", align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store i16 %2, ptr %13, align 2, !tbaa !9
  store ptr %3, ptr %14, align 8, !tbaa !5
  store i16 %4, ptr %15, align 2, !tbaa !9
  store ptr %5, ptr %16, align 8, !tbaa !5
  store i16 %6, ptr %17, align 2, !tbaa !9
  store ptr %7, ptr %18, align 8, !tbaa !5
  store i16 %8, ptr %19, align 2, !tbaa !9
  %23 = zext i1 %9 to i8
  store i8 %23, ptr %20, align 1, !tbaa !11
  %24 = load ptr, ptr %11, align 8
  %25 = load i16, ptr %13, align 2, !tbaa !9
  %26 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 4
  store i16 %25, ptr %26, align 8, !tbaa !13
  %27 = load i16, ptr %15, align 2, !tbaa !9
  %28 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 6
  store i16 %27, ptr %28, align 4, !tbaa !22
  %29 = load i16, ptr %17, align 2, !tbaa !9
  %30 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 5
  store i16 %29, ptr %30, align 2, !tbaa !23
  %31 = load i16, ptr %19, align 2, !tbaa !9
  %32 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 7
  store i16 %31, ptr %32, align 2, !tbaa !24
  store i16 0, ptr %17, align 2, !tbaa !9
  %33 = load i8, ptr %20, align 1, !tbaa !11, !range !25, !noundef !26
  %34 = trunc i8 %33 to i1
  br i1 %34, label %79, label %35

35:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %36 = load i16, ptr %13, align 2, !tbaa !9
  %37 = zext i16 %36 to i64
  %38 = mul i64 12, %37
  %39 = load i16, ptr %15, align 2, !tbaa !9
  %40 = zext i16 %39 to i64
  %41 = mul i64 20, %40
  %42 = add i64 %38, %41
  %43 = load i16, ptr %17, align 2, !tbaa !9
  %44 = zext i16 %43 to i64
  %45 = mul i64 4, %44
  %46 = add i64 %42, %45
  %47 = load i16, ptr %19, align 2, !tbaa !9
  %48 = zext i16 %47 to i64
  %49 = mul i64 1, %48
  %50 = add i64 %46, %49
  %51 = trunc i64 %50 to i32
  store i32 %51, ptr %21, align 4, !tbaa !27
  %52 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 8
  %53 = load i32, ptr %21, align 4, !tbaa !27
  %54 = sext i32 %53 to i64
  call void @_ZNSt6vectorIcSaIcEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %52, i64 noundef %54)
  %55 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 8
  %56 = call noundef ptr @_ZNSt6vectorIcSaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %55) #3
  %57 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 0
  store ptr %56, ptr %57, align 8, !tbaa !29
  %58 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !29
  %60 = load i16, ptr %13, align 2, !tbaa !9
  %61 = zext i16 %60 to i32
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds %"class.Maths::TVector3", ptr %59, i64 %62
  %64 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 2
  store ptr %63, ptr %64, align 8, !tbaa !30
  %65 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !30
  %67 = load i16, ptr %15, align 2, !tbaa !9
  %68 = zext i16 %67 to i32
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds %"struct.Riemann::ConvexMeshFace", ptr %66, i64 %69
  %71 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 1
  store ptr %70, ptr %71, align 8, !tbaa !31
  %72 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 1
  %73 = load ptr, ptr %72, align 8, !tbaa !31
  %74 = load i16, ptr %17, align 2, !tbaa !9
  %75 = zext i16 %74 to i32
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds %"struct.Riemann::ConvexMeshEdge", ptr %73, i64 %76
  %78 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 3
  store ptr %77, ptr %78, align 8, !tbaa !32
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %88

79:                                               ; preds = %10
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  %81 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 0
  store ptr %80, ptr %81, align 8, !tbaa !29
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 2
  store ptr %82, ptr %83, align 8, !tbaa !30
  %84 = load ptr, ptr %16, align 8, !tbaa !5
  %85 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 1
  store ptr %84, ptr %85, align 8, !tbaa !31
  %86 = load ptr, ptr %18, align 8, !tbaa !5
  %87 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 3
  store ptr %86, ptr %87, align 8, !tbaa !32
  br label %88

88:                                               ; preds = %79, %35
  call void @llvm.lifetime.start.p0(i64 24, ptr %22) #3
  call void @_ZNK7Riemann10ConvexMesh21ComputeBoundingVolumeEv(ptr dead_on_unwind writable sret(%"class.Maths::TAABB3") align 4 %22, ptr noundef nonnull align 8 dereferenceable(88) %24)
  %89 = getelementptr inbounds %"class.Riemann::ConvexMesh", ptr %24, i32 0, i32 9
  %90 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24) %89, ptr noundef nonnull align 4 dereferenceable(24) %22)
  call void @llvm.lifetime.end.p0(i64 24, ptr %22) #3
  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 @_ZNSt6vectorIcSaIcEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNSt6vectorIcSaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) #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 uwtable
declare dso_local void @_ZNK7Riemann10ConvexMesh21ComputeBoundingVolumeEv(ptr dead_on_unwind noalias writable sret(%"class.Maths::TAABB3") align 4, ptr noundef nonnull align 8 dereferenceable(88)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) #2 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 = { 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 = { 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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !10, i64 32}
!14 = !{!"_ZTSN7Riemann10ConvexMeshE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 34, !10, i64 36, !10, 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", !21, i64 0, !21, i64 4, !21, i64 8}
!21 = !{!"float", !7, i64 0}
!22 = !{!14, !10, i64 36}
!23 = !{!14, !10, i64 34}
!24 = !{!14, !10, i64 38}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!28, !28, i64 0}
!28 = !{!"int", !7, i64 0}
!29 = !{!14, !6, i64 0}
!30 = !{!14, !6, i64 16}
!31 = !{!14, !6, i64 8}
!32 = !{!14, !6, i64 24}


; 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::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"class.Maths::TVector3" = type { float, float, float }
%"struct.Riemann::ConvexMeshFace" = type { %"class.Riemann::Plane3", i16, i8, i8 }
%"class.Riemann::Plane3" = type { %"class.Maths::TVector3", float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Riemann10ConvexMesh13SetConvexDataEPN5Maths8TVector3IfEEtPNS_14ConvexMeshFaceEtPttPhtb(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1, i16 noundef zeroext %2, ptr noundef %3, i16 noundef zeroext %4, ptr noundef %5, i16 noundef zeroext %6, ptr noundef %7, i16 noundef zeroext %8, i1 noundef zeroext %9) local_unnamed_addr #0 align 2 {
  %11 = alloca %"class.Maths::TAABB3", align 4
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  store i16 %2, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 36
  store i16 %4, ptr %13, align 4, !tbaa !18
  %14 = getelementptr inbounds i8, ptr %0, i64 34
  store i16 %6, ptr %14, align 2, !tbaa !19
  %15 = getelementptr inbounds i8, ptr %0, i64 38
  store i16 %8, ptr %15, align 2, !tbaa !20
  br i1 %9, label %28, label %16

16:                                               ; preds = %10
  %17 = zext i16 %2 to i64
  %18 = mul nuw nsw i64 %17, 12
  %19 = zext i16 %4 to i64
  %20 = mul nuw nsw i64 %19, 20
  %21 = add nuw nsw i64 %20, %18
  %22 = zext i16 %8 to i64
  %23 = add nuw nsw i64 %21, %22
  %24 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @_ZNSt6vectorIcSaIcEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %23)
  %25 = tail call noundef ptr @_ZNSt6vectorIcSaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %24) #3
  %26 = getelementptr inbounds %"class.Maths::TVector3", ptr %25, i64 %17
  %27 = getelementptr inbounds %"struct.Riemann::ConvexMeshFace", ptr %26, i64 %19
  br label %28

28:                                               ; preds = %10, %16
  %.sink19 = phi ptr [ %25, %16 ], [ %1, %10 ]
  %.sink18 = phi ptr [ %26, %16 ], [ %3, %10 ]
  %.sink17 = phi ptr [ %27, %16 ], [ %5, %10 ]
  %.sink = phi ptr [ %27, %16 ], [ %7, %10 ]
  store ptr %.sink19, ptr %0, align 8
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %.sink18, ptr %29, align 8
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %.sink17, ptr %30, align 8
  %31 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %.sink, ptr %31, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %11) #3
  call void @_ZNK7Riemann10ConvexMesh21ComputeBoundingVolumeEv(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TAABB3") align 4 %11, ptr noundef nonnull align 8 dereferenceable(88) %0)
  %32 = getelementptr inbounds i8, ptr %0, i64 64
  %33 = call noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24) %32, ptr noundef nonnull align 4 dereferenceable(24) %11)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %11) #3
  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 @_ZNSt6vectorIcSaIcEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNSt6vectorIcSaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) 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 uwtable
declare dso_local void @_ZNK7Riemann10ConvexMesh21ComputeBoundingVolumeEv(ptr dead_on_unwind noalias writable sret(%"class.Maths::TAABB3") align 4, ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(24) ptr @_ZN5Maths6TAABB3IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(24)) local_unnamed_addr #2 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 = { 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 = { 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, !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, !10, i64 36}
!19 = !{!6, !10, i64 34}
!20 = !{!6, !10, i64 38}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,ReassociatePass,SROAPass,TailCallElimPass