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

; 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::Mat3" = type { %"struct.muli::Vec3", %"struct.muli::Vec3", %"struct.muli::Vec3" }
%"struct.muli::Vec3" = type { float, float, float }
%"struct.muli::Vec2" = type { 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 @_ZN4muli4Mat39TranslateERKNS_4Vec2E(ptr dead_on_unwind noalias writable sret(%"struct.muli::Mat3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %1, ptr noundef nonnull align 4 dereferenceable(8) %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::Mat3", ptr %6, i32 0, i32 0
  %8 = getelementptr inbounds %"struct.muli::Mat3", ptr %0, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %7, i64 12, i1 false), !tbaa.struct !9
  %9 = getelementptr inbounds %"struct.muli::Mat3", ptr %6, i32 0, i32 1
  %10 = getelementptr inbounds %"struct.muli::Mat3", ptr %0, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %9, i64 12, i1 false), !tbaa.struct !9
  %11 = getelementptr inbounds %"struct.muli::Mat3", ptr %6, i32 0, i32 0
  %12 = getelementptr inbounds %"struct.muli::Vec3", ptr %11, i32 0, i32 0
  %13 = load float, ptr %12, align 4, !tbaa !12
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.muli::Vec2", ptr %14, i32 0, i32 0
  %16 = load float, ptr %15, align 4, !tbaa !15
  %17 = getelementptr inbounds %"struct.muli::Mat3", ptr %6, i32 0, i32 1
  %18 = getelementptr inbounds %"struct.muli::Vec3", ptr %17, i32 0, i32 0
  %19 = load float, ptr %18, align 4, !tbaa !17
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.muli::Vec2", ptr %20, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !18
  %23 = fmul float %19, %22
  %24 = call float @llvm.fmuladd.f32(float %13, float %16, float %23)
  %25 = getelementptr inbounds %"struct.muli::Mat3", ptr %6, i32 0, i32 2
  %26 = getelementptr inbounds %"struct.muli::Vec3", ptr %25, i32 0, i32 0
  %27 = load float, ptr %26, align 4, !tbaa !19
  %28 = fadd float %24, %27
  %29 = getelementptr inbounds %"struct.muli::Mat3", ptr %0, i32 0, i32 2
  %30 = getelementptr inbounds %"struct.muli::Vec3", ptr %29, i32 0, i32 0
  store float %28, ptr %30, align 4, !tbaa !19
  %31 = getelementptr inbounds %"struct.muli::Mat3", ptr %6, i32 0, i32 0
  %32 = getelementptr inbounds %"struct.muli::Vec3", ptr %31, i32 0, i32 1
  %33 = load float, ptr %32, align 4, !tbaa !20
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.muli::Vec2", ptr %34, i32 0, i32 0
  %36 = load float, ptr %35, align 4, !tbaa !15
  %37 = getelementptr inbounds %"struct.muli::Mat3", ptr %6, i32 0, i32 1
  %38 = getelementptr inbounds %"struct.muli::Vec3", ptr %37, i32 0, i32 1
  %39 = load float, ptr %38, align 4, !tbaa !21
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.muli::Vec2", ptr %40, i32 0, i32 1
  %42 = load float, ptr %41, align 4, !tbaa !18
  %43 = fmul float %39, %42
  %44 = call float @llvm.fmuladd.f32(float %33, float %36, float %43)
  %45 = getelementptr inbounds %"struct.muli::Mat3", ptr %6, i32 0, i32 2
  %46 = getelementptr inbounds %"struct.muli::Vec3", ptr %45, i32 0, i32 1
  %47 = load float, ptr %46, align 4, !tbaa !22
  %48 = fadd float %44, %47
  %49 = getelementptr inbounds %"struct.muli::Mat3", ptr %0, i32 0, i32 2
  %50 = getelementptr inbounds %"struct.muli::Vec3", ptr %49, i32 0, i32 1
  store float %48, ptr %50, align 4, !tbaa !22
  %51 = getelementptr inbounds %"struct.muli::Mat3", ptr %6, i32 0, i32 2
  %52 = getelementptr inbounds %"struct.muli::Vec3", ptr %51, i32 0, i32 2
  %53 = load float, ptr %52, align 4, !tbaa !23
  %54 = getelementptr inbounds %"struct.muli::Mat3", ptr %0, i32 0, i32 2
  %55 = getelementptr inbounds %"struct.muli::Vec3", ptr %54, i32 0, i32 2
  store float %53, ptr %55, align 4, !tbaa !23
  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}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_ZTSN4muli4Mat3E", !14, i64 0, !14, i64 12, !14, i64 24}
!14 = !{!"_ZTSN4muli4Vec3E", !11, i64 0, !11, i64 4, !11, i64 8}
!15 = !{!16, !11, i64 0}
!16 = !{!"_ZTSN4muli4Vec2E", !11, i64 0, !11, i64 4}
!17 = !{!13, !11, i64 12}
!18 = !{!16, !11, i64 4}
!19 = !{!13, !11, i64 24}
!20 = !{!13, !11, i64 4}
!21 = !{!13, !11, i64 16}
!22 = !{!13, !11, i64 28}
!23 = !{!13, !11, i64 32}


; 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::Mat3" = type { %"struct.muli::Vec3", %"struct.muli::Vec3", %"struct.muli::Vec3" }
%"struct.muli::Vec3" = type { 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN4muli4Mat39TranslateERKNS_4Vec2E(ptr dead_on_unwind noalias nocapture writable writeonly sret(%"struct.muli::Mat3") align 4 %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(36) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %2) local_unnamed_addr #1 align 2 {
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, i64 12, i1 false), !tbaa.struct !5
  %4 = getelementptr inbounds i8, ptr %1, i64 12
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %4, i64 12, i1 false), !tbaa.struct !5
  %6 = load float, ptr %2, align 4, !tbaa !10
  %7 = getelementptr inbounds i8, ptr %2, i64 4
  %8 = load float, ptr %7, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %1, i64 24
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load <2 x float>, ptr %1, align 4, !tbaa !6
  %12 = load <2 x float>, ptr %4, align 4, !tbaa !6
  %13 = insertelement <2 x float> poison, float %8, i64 0
  %14 = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> zeroinitializer
  %15 = fmul <2 x float> %14, %12
  %16 = insertelement <2 x float> poison, float %6, i64 0
  %17 = shufflevector <2 x float> %16, <2 x float> poison, <2 x i32> zeroinitializer
  %18 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %11, <2 x float> %17, <2 x float> %15)
  %19 = load <2 x float>, ptr %9, align 4, !tbaa !6
  %20 = fadd <2 x float> %19, %18
  store <2 x float> %20, ptr %10, align 4, !tbaa !6
  %21 = getelementptr inbounds i8, ptr %1, i64 32
  %22 = load float, ptr %21, align 4, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  store float %22, ptr %23, align 4, !tbaa !13
  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>) #2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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}
!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 = !{!"_ZTSN4muli4Vec2E", !7, i64 0, !7, i64 4}
!12 = !{!11, !7, i64 4}
!13 = !{!14, !7, i64 32}
!14 = !{!"_ZTSN4muli4Mat3E", !15, i64 0, !15, i64 12, !15, i64 24}
!15 = !{!"_ZTSN4muli4Vec3E", !7, i64 0, !7, i64 4, !7, i64 8}


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