; LLVM IR from Sopiro/Muli :: src/util/math.ll (ZN4muli4Mat49TranslateERKNS_4Vec3E)

; 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"

%"struct.muli::Mat4" = type { %"struct.muli::Vec4", %"struct.muli::Vec4", %"struct.muli::Vec4", %"struct.muli::Vec4" }
%"struct.muli::Vec4" = type { float, float, float, float }
%"struct.muli::Vec3" = type { float, float, 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4muli4Mat49TranslateERKNS_4Vec3E(ptr dead_on_unwind noalias writable sret(%"struct.muli::Mat4") align 4 %0, ptr noundef nonnull align 4 dereferenceable(64) %1, ptr noundef nonnull align 4 dereferenceable(12) %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 0
  %8 = getelementptr inbounds %"struct.muli::Mat4", ptr %0, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %7, i64 16, i1 false), !tbaa.struct !9
  %9 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 1
  %10 = getelementptr inbounds %"struct.muli::Mat4", ptr %0, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %9, i64 16, i1 false), !tbaa.struct !9
  %11 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 2
  %12 = getelementptr inbounds %"struct.muli::Mat4", ptr %0, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %11, i64 16, i1 false), !tbaa.struct !9
  %13 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 0
  %14 = getelementptr inbounds %"struct.muli::Vec4", ptr %13, i32 0, i32 0
  %15 = load float, ptr %14, align 4, !tbaa !12
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.muli::Vec3", ptr %16, i32 0, i32 0
  %18 = load float, ptr %17, align 4, !tbaa !15
  %19 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 1
  %20 = getelementptr inbounds %"struct.muli::Vec4", ptr %19, i32 0, i32 0
  %21 = load float, ptr %20, align 4, !tbaa !17
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.muli::Vec3", ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !18
  %25 = fmul float %21, %24
  %26 = call float @llvm.fmuladd.f32(float %15, float %18, float %25)
  %27 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 2
  %28 = getelementptr inbounds %"struct.muli::Vec4", ptr %27, i32 0, i32 0
  %29 = load float, ptr %28, align 4, !tbaa !19
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.muli::Vec3", ptr %30, i32 0, i32 2
  %32 = load float, ptr %31, align 4, !tbaa !20
  %33 = call float @llvm.fmuladd.f32(float %29, float %32, float %26)
  %34 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 3
  %35 = getelementptr inbounds %"struct.muli::Vec4", ptr %34, i32 0, i32 0
  %36 = load float, ptr %35, align 4, !tbaa !21
  %37 = fadd float %33, %36
  %38 = getelementptr inbounds %"struct.muli::Mat4", ptr %0, i32 0, i32 3
  %39 = getelementptr inbounds %"struct.muli::Vec4", ptr %38, i32 0, i32 0
  store float %37, ptr %39, align 4, !tbaa !21
  %40 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 0
  %41 = getelementptr inbounds %"struct.muli::Vec4", ptr %40, i32 0, i32 1
  %42 = load float, ptr %41, align 4, !tbaa !22
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.muli::Vec3", ptr %43, i32 0, i32 0
  %45 = load float, ptr %44, align 4, !tbaa !15
  %46 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 1
  %47 = getelementptr inbounds %"struct.muli::Vec4", ptr %46, i32 0, i32 1
  %48 = load float, ptr %47, align 4, !tbaa !23
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.muli::Vec3", ptr %49, i32 0, i32 1
  %51 = load float, ptr %50, align 4, !tbaa !18
  %52 = fmul float %48, %51
  %53 = call float @llvm.fmuladd.f32(float %42, float %45, float %52)
  %54 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 2
  %55 = getelementptr inbounds %"struct.muli::Vec4", ptr %54, i32 0, i32 1
  %56 = load float, ptr %55, align 4, !tbaa !24
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %"struct.muli::Vec3", ptr %57, i32 0, i32 2
  %59 = load float, ptr %58, align 4, !tbaa !20
  %60 = call float @llvm.fmuladd.f32(float %56, float %59, float %53)
  %61 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 3
  %62 = getelementptr inbounds %"struct.muli::Vec4", ptr %61, i32 0, i32 1
  %63 = load float, ptr %62, align 4, !tbaa !25
  %64 = fadd float %60, %63
  %65 = getelementptr inbounds %"struct.muli::Mat4", ptr %0, i32 0, i32 3
  %66 = getelementptr inbounds %"struct.muli::Vec4", ptr %65, i32 0, i32 1
  store float %64, ptr %66, align 4, !tbaa !25
  %67 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 0
  %68 = getelementptr inbounds %"struct.muli::Vec4", ptr %67, i32 0, i32 2
  %69 = load float, ptr %68, align 4, !tbaa !26
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.muli::Vec3", ptr %70, i32 0, i32 0
  %72 = load float, ptr %71, align 4, !tbaa !15
  %73 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 1
  %74 = getelementptr inbounds %"struct.muli::Vec4", ptr %73, i32 0, i32 2
  %75 = load float, ptr %74, align 4, !tbaa !27
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.muli::Vec3", ptr %76, i32 0, i32 1
  %78 = load float, ptr %77, align 4, !tbaa !18
  %79 = fmul float %75, %78
  %80 = call float @llvm.fmuladd.f32(float %69, float %72, float %79)
  %81 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 2
  %82 = getelementptr inbounds %"struct.muli::Vec4", ptr %81, i32 0, i32 2
  %83 = load float, ptr %82, align 4, !tbaa !28
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %"struct.muli::Vec3", ptr %84, i32 0, i32 2
  %86 = load float, ptr %85, align 4, !tbaa !20
  %87 = call float @llvm.fmuladd.f32(float %83, float %86, float %80)
  %88 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 3
  %89 = getelementptr inbounds %"struct.muli::Vec4", ptr %88, i32 0, i32 2
  %90 = load float, ptr %89, align 4, !tbaa !29
  %91 = fadd float %87, %90
  %92 = getelementptr inbounds %"struct.muli::Mat4", ptr %0, i32 0, i32 3
  %93 = getelementptr inbounds %"struct.muli::Vec4", ptr %92, i32 0, i32 2
  store float %91, ptr %93, align 4, !tbaa !29
  %94 = getelementptr inbounds %"struct.muli::Mat4", ptr %6, i32 0, i32 3
  %95 = getelementptr inbounds %"struct.muli::Vec4", ptr %94, i32 0, i32 3
  %96 = load float, ptr %95, align 4, !tbaa !30
  %97 = getelementptr inbounds %"struct.muli::Mat4", ptr %0, i32 0, i32 3
  %98 = getelementptr inbounds %"struct.muli::Vec4", ptr %97, i32 0, i32 3
  store float %96, ptr %98, align 4, !tbaa !30
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10, i64 12, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_ZTSN4muli4Mat4E", !14, i64 0, !14, i64 16, !14, i64 32, !14, i64 48}
!14 = !{!"_ZTSN4muli4Vec4E", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!15 = !{!16, !11, i64 0}
!16 = !{!"_ZTSN4muli4Vec3E", !11, i64 0, !11, i64 4, !11, i64 8}
!17 = !{!13, !11, i64 16}
!18 = !{!16, !11, i64 4}
!19 = !{!13, !11, i64 32}
!20 = !{!16, !11, i64 8}
!21 = !{!13, !11, i64 48}
!22 = !{!13, !11, i64 4}
!23 = !{!13, !11, i64 20}
!24 = !{!13, !11, i64 36}
!25 = !{!13, !11, i64 52}
!26 = !{!13, !11, i64 8}
!27 = !{!13, !11, i64 24}
!28 = !{!13, !11, i64 40}
!29 = !{!13, !11, i64 56}
!30 = !{!13, !11, i64 60}


; 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"

%"struct.muli::Mat4" = type { %"struct.muli::Vec4", %"struct.muli::Vec4", %"struct.muli::Vec4", %"struct.muli::Vec4" }
%"struct.muli::Vec4" = type { float, float, float, float }

; Function Attrs: mustprogress 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN4muli4Mat49TranslateERKNS_4Vec3E(ptr dead_on_unwind noalias nocapture writable writeonly sret(%"struct.muli::Mat4") align 4 %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(64) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %2) local_unnamed_addr #2 align 2 {
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1, i64 16, i1 false), !tbaa.struct !5
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(16) %4, i64 16, i1 false), !tbaa.struct !5
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %7, ptr noundef nonnull align 4 dereferenceable(16) %6, i64 16, i1 false), !tbaa.struct !5
  %8 = load float, ptr %2, align 4, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %2, i64 4
  %10 = load float, ptr %9, align 4, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %2, i64 8
  %12 = load float, ptr %11, align 4, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %1, i64 48
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %15 = load <2 x float>, ptr %1, align 4, !tbaa !6
  %16 = load <2 x float>, ptr %4, align 4, !tbaa !6
  %17 = insertelement <2 x float> poison, float %10, i64 0
  %18 = shufflevector <2 x float> %17, <2 x float> poison, <2 x i32> zeroinitializer
  %19 = fmul <2 x float> %18, %16
  %20 = insertelement <2 x float> poison, float %8, i64 0
  %21 = shufflevector <2 x float> %20, <2 x float> poison, <2 x i32> zeroinitializer
  %22 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %15, <2 x float> %21, <2 x float> %19)
  %23 = load <2 x float>, ptr %6, align 4, !tbaa !6
  %24 = insertelement <2 x float> poison, float %12, i64 0
  %25 = shufflevector <2 x float> %24, <2 x float> poison, <2 x i32> zeroinitializer
  %26 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %23, <2 x float> %25, <2 x float> %22)
  %27 = load <2 x float>, ptr %13, align 4, !tbaa !6
  %28 = fadd <2 x float> %26, %27
  store <2 x float> %28, ptr %14, align 4, !tbaa !6
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  %30 = load float, ptr %29, align 4, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %1, i64 24
  %32 = load float, ptr %31, align 4, !tbaa !17
  %33 = fmul float %10, %32
  %34 = tail call float @llvm.fmuladd.f32(float %30, float %8, float %33)
  %35 = getelementptr inbounds i8, ptr %1, i64 40
  %36 = load float, ptr %35, align 4, !tbaa !18
  %37 = tail call float @llvm.fmuladd.f32(float %36, float %12, float %34)
  %38 = getelementptr inbounds i8, ptr %1, i64 56
  %39 = load float, ptr %38, align 4, !tbaa !19
  %40 = fadd float %39, %37
  %41 = getelementptr inbounds i8, ptr %0, i64 56
  store float %40, ptr %41, align 4, !tbaa !19
  %42 = getelementptr inbounds i8, ptr %1, i64 60
  %43 = load float, ptr %42, align 4, !tbaa !20
  %44 = getelementptr inbounds i8, ptr %0, i64 60
  store float %43, ptr %44, align 4, !tbaa !20
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #3

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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) }

!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, i64 8, i64 4, !6, i64 12, 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 = !{!"_ZTSN4muli4Vec3E", !7, i64 0, !7, i64 4, !7, i64 8}
!12 = !{!11, !7, i64 4}
!13 = !{!11, !7, i64 8}
!14 = !{!15, !7, i64 8}
!15 = !{!"_ZTSN4muli4Mat4E", !16, i64 0, !16, i64 16, !16, i64 32, !16, i64 48}
!16 = !{!"_ZTSN4muli4Vec4E", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!17 = !{!15, !7, i64 24}
!18 = !{!15, !7, i64 40}
!19 = !{!15, !7, i64 56}
!20 = !{!15, !7, i64 60}


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