; LLVM IR from Slingshot-Physics/slingshot-community :: common/geometry/src/inertia.ll (ZN8geometry13inertiaTensorENS_5types14shapeCapsule_tE)

; 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.Matrix33 = type { [9 x float] }
%"struct.geometry::types::shapeCapsule_t" = type { float, float }
%"struct.geometry::types::shapeSphere_t" = type { float }
%"struct.geometry::types::shapeCylinder_t" = type { float, float }
%class.Vector3 = type { [3 x float] }

; 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: mustprogress uwtable
declare dso_local void @_ZN7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8Matrix334diagERK7Vector3(ptr dead_on_unwind noalias writable sret(%class.Matrix33) align 4, 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 uwtable
define dso_local void @_ZN8geometry13inertiaTensorENS_5types14shapeCapsule_tE(ptr dead_on_unwind noalias writable sret(%class.Matrix33) align 4 %0, <2 x float> %1) #5 {
  %3 = alloca ptr, align 8
  %4 = alloca %"struct.geometry::types::shapeCapsule_t", align 4
  %5 = alloca float, align 4
  %6 = alloca %"struct.geometry::types::shapeCapsule_t", align 4
  %7 = alloca %"struct.geometry::types::shapeSphere_t", align 4
  %8 = alloca float, align 4
  %9 = alloca %"struct.geometry::types::shapeSphere_t", align 4
  %10 = alloca %"struct.geometry::types::shapeCylinder_t", align 4
  %11 = alloca float, align 4
  %12 = alloca %"struct.geometry::types::shapeCylinder_t", align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca %class.Vector3, align 4
  store ptr %0, ptr %3, align 8
  store <2 x float> %1, ptr %4, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %4, i64 8, i1 false), !tbaa.struct !5
  %17 = load <2 x float>, ptr %6, align 4
  %18 = call noundef float @_ZN8geometry6volumeENS_5types14shapeCapsule_tE(<2 x float> %17)
  %19 = fdiv float 1.000000e+00, %18
  store float %19, ptr %5, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %20 = getelementptr inbounds %"struct.geometry::types::shapeSphere_t", ptr %7, i32 0, i32 0
  %21 = getelementptr inbounds %"struct.geometry::types::shapeCapsule_t", ptr %4, i32 0, i32 0
  %22 = load float, ptr %21, align 4, !tbaa !10
  store float %22, ptr %20, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %7, i64 4, i1 false), !tbaa.struct !14
  %23 = getelementptr inbounds %"struct.geometry::types::shapeSphere_t", ptr %9, i32 0, i32 0
  %24 = load float, ptr %23, align 4
  %25 = call noundef float @_ZN8geometry6volumeENS_5types13shapeSphere_tE(float %24)
  %26 = load float, ptr %5, align 4, !tbaa !6
  %27 = fmul float %25, %26
  store float %27, ptr %8, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %28 = getelementptr inbounds %"struct.geometry::types::shapeCylinder_t", ptr %10, i32 0, i32 0
  %29 = getelementptr inbounds %"struct.geometry::types::shapeCapsule_t", ptr %4, i32 0, i32 0
  %30 = load float, ptr %29, align 4, !tbaa !10
  store float %30, ptr %28, align 4, !tbaa !15
  %31 = getelementptr inbounds %"struct.geometry::types::shapeCylinder_t", ptr %10, i32 0, i32 1
  %32 = getelementptr inbounds %"struct.geometry::types::shapeCapsule_t", ptr %4, i32 0, i32 1
  %33 = load float, ptr %32, align 4, !tbaa !17
  store float %33, ptr %31, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !5
  %34 = load <2 x float>, ptr %12, align 4
  %35 = call noundef float @_ZN8geometry6volumeENS_5types15shapeCylinder_tE(<2 x float> %34)
  %36 = load float, ptr %5, align 4, !tbaa !6
  %37 = fmul float %35, %36
  store float %37, ptr %11, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %38 = getelementptr inbounds %"struct.geometry::types::shapeCapsule_t", ptr %4, i32 0, i32 0
  %39 = load float, ptr %38, align 4, !tbaa !10
  %40 = getelementptr inbounds %"struct.geometry::types::shapeCapsule_t", ptr %4, i32 0, i32 0
  %41 = load float, ptr %40, align 4, !tbaa !10
  %42 = fmul float %39, %41
  store float %42, ptr %13, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %43 = getelementptr inbounds %"struct.geometry::types::shapeCapsule_t", ptr %4, i32 0, i32 1
  %44 = load float, ptr %43, align 4, !tbaa !17
  %45 = getelementptr inbounds %"struct.geometry::types::shapeCapsule_t", ptr %4, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !17
  %47 = fmul float %44, %46
  store float %47, ptr %14, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %48 = getelementptr inbounds %"struct.geometry::types::shapeCapsule_t", ptr %4, i32 0, i32 0
  %49 = load float, ptr %48, align 4, !tbaa !10
  %50 = getelementptr inbounds %"struct.geometry::types::shapeCapsule_t", ptr %4, i32 0, i32 1
  %51 = load float, ptr %50, align 4, !tbaa !17
  %52 = fmul float %49, %51
  store float %52, ptr %15, align 4, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 12, ptr %16) #7
  call void @_ZN7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %16)
  %53 = load float, ptr %11, align 4, !tbaa !6
  %54 = load float, ptr %14, align 4, !tbaa !6
  %55 = fdiv float %54, 1.200000e+01
  %56 = load float, ptr %13, align 4, !tbaa !6
  %57 = fdiv float %56, 4.000000e+00
  %58 = fadd float %55, %57
  %59 = load float, ptr %8, align 4, !tbaa !6
  %60 = load float, ptr %13, align 4, !tbaa !6
  %61 = fmul float 2.000000e+00, %60
  %62 = fdiv float %61, 5.000000e+00
  %63 = load float, ptr %14, align 4, !tbaa !6
  %64 = fdiv float %63, 2.000000e+00
  %65 = fadd float %62, %64
  %66 = load float, ptr %15, align 4, !tbaa !6
  %67 = fmul float 3.000000e+00, %66
  %68 = fdiv float %67, 8.000000e+00
  %69 = fadd float %65, %68
  %70 = fmul float %59, %69
  %71 = call float @llvm.fmuladd.f32(float %53, float %58, float %70)
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %16, i32 noundef 0)
  store float %71, ptr %72, align 4, !tbaa !6
  %73 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %16, i32 noundef 0)
  %74 = load float, ptr %73, align 4, !tbaa !6
  %75 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %16, i32 noundef 1)
  store float %74, ptr %75, align 4, !tbaa !6
  %76 = load float, ptr %11, align 4, !tbaa !6
  %77 = load float, ptr %13, align 4, !tbaa !6
  %78 = fmul float %76, %77
  %79 = fdiv float %78, 2.000000e+00
  %80 = load float, ptr %8, align 4, !tbaa !6
  %81 = fmul float %80, 2.000000e+00
  %82 = load float, ptr %13, align 4, !tbaa !6
  %83 = fmul float %81, %82
  %84 = fdiv float %83, 5.000000e+00
  %85 = fadd float %79, %84
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %16, i32 noundef 2)
  store float %85, ptr %86, align 4, !tbaa !6
  call void @_ZN8Matrix334diagERK7Vector3(ptr dead_on_unwind writable sret(%class.Matrix33) align 4 %0, ptr noundef nonnull align 4 dereferenceable(12) %16)
  call void @llvm.lifetime.end.p0(i64 12, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  ret void
}

declare noundef float @_ZN8geometry6volumeENS_5types14shapeCapsule_tE(<2 x float>) #6

declare noundef float @_ZN8geometry6volumeENS_5types13shapeSphere_tE(float) #6

declare noundef float @_ZN8geometry6volumeENS_5types15shapeCylinder_tE(<2 x float>) #6

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { mustprogress uwtable "min-legal-vector-width"="64" "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 #6 = { "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 #7 = { 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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"_ZTSN8geometry5types14shapeCapsule_tE", !7, i64 0, !7, i64 4}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTSN8geometry5types13shapeSphere_tE", !7, i64 0}
!14 = !{i64 0, i64 4, !6}
!15 = !{!16, !7, i64 0}
!16 = !{!"_ZTSN8geometry5types15shapeCylinder_tE", !7, i64 0, !7, i64 4}
!17 = !{!11, !7, i64 4}
!18 = !{!16, !7, i64 4}


; 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.Matrix33 = type { [9 x float] }
%class.Vector3 = type { [3 x 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: mustprogress uwtable
declare dso_local void @_ZN7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8Matrix334diagERK7Vector3(ptr dead_on_unwind noalias writable sret(%class.Matrix33) align 4, 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: mustprogress uwtable
define dso_local void @_ZN8geometry13inertiaTensorENS_5types14shapeCapsule_tE(ptr dead_on_unwind noalias writable sret(%class.Matrix33) align 4 %0, <2 x float> %1) local_unnamed_addr #4 {
  %3 = extractelement <2 x float> %1, i64 0
  %4 = alloca %class.Vector3, align 4
  %5 = tail call noundef float @_ZN8geometry6volumeENS_5types14shapeCapsule_tE(<2 x float> %1)
  %6 = fdiv float 1.000000e+00, %5
  %7 = tail call noundef float @_ZN8geometry6volumeENS_5types13shapeSphere_tE(float %3)
  %8 = fmul float %7, %6
  %9 = tail call noundef float @_ZN8geometry6volumeENS_5types15shapeCylinder_tE(<2 x float> %1)
  %10 = fmul float %6, %9
  %shift = shufflevector <2 x float> %1, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %11 = fmul <2 x float> %shift, %1
  %12 = extractelement <2 x float> %11, i64 0
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #6
  call void @_ZN7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %4)
  %13 = fmul <2 x float> %1, %1
  %14 = extractelement <2 x float> %13, i64 1
  %15 = fdiv float %14, 1.200000e+01
  %16 = extractelement <2 x float> %13, i64 0
  %17 = fmul float %16, 2.500000e-01
  %18 = fadd float %15, %17
  %19 = fmul <2 x float> %13, <float 2.000000e+00, float 5.000000e-01>
  %20 = extractelement <2 x float> %19, i64 0
  %21 = fdiv float %20, 5.000000e+00
  %22 = extractelement <2 x float> %19, i64 1
  %23 = fadd float %22, %21
  %24 = fmul float %12, 3.000000e+00
  %25 = fmul float %24, 1.250000e-01
  %26 = fadd float %25, %23
  %27 = fmul float %26, %8
  %28 = call float @llvm.fmuladd.f32(float %10, float %18, float %27)
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef 0)
  store float %28, ptr %29, align 4, !tbaa !5
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef 0)
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef 1)
  store float %31, ptr %32, align 4, !tbaa !5
  %33 = fmul float %16, %10
  %34 = fmul float %33, 5.000000e-01
  %35 = fmul float %8, 2.000000e+00
  %36 = fmul float %16, %35
  %37 = fdiv float %36, 5.000000e+00
  %38 = fadd float %34, %37
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef 2)
  store float %38, ptr %39, align 4, !tbaa !5
  call void @_ZN8Matrix334diagERK7Vector3(ptr dead_on_unwind writable sret(%class.Matrix33) align 4 %0, ptr noundef nonnull align 4 dereferenceable(12) %4)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #6
  ret void
}

declare noundef float @_ZN8geometry6volumeENS_5types14shapeCapsule_tE(<2 x float>) local_unnamed_addr #5

declare noundef float @_ZN8geometry6volumeENS_5types13shapeSphere_tE(float) local_unnamed_addr #5

declare noundef float @_ZN8geometry6volumeENS_5types15shapeCylinder_tE(<2 x float>) local_unnamed_addr #5

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { "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 #6 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass