; LLVM IR from DreamingInfraviolet/EstimateImageMatting :: Primatte/matrixd.ll (ZNK4math3tmp5_mat2mlERKNS0_5_vec2IfEE)

; 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.math::tmp::_vec2" = type { float, float }
%"class.math::tmp::_mat2" = type { [2 x [2 x float]] }

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

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZNK4math3tmp5_mat2mlERKNS0_5_vec2IfEE(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(8) %1) #1 align 2 {
  %3 = alloca %"class.math::tmp::_vec2", align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = getelementptr inbounds %"class.math::tmp::_mat2", ptr %6, i32 0, i32 0
  %8 = getelementptr inbounds [2 x [2 x float]], ptr %7, i64 0, i64 0
  %9 = getelementptr inbounds [2 x float], ptr %8, i64 0, i64 0
  %10 = load float, ptr %9, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.math::tmp::_vec2", ptr %11, i32 0, i32 0
  %13 = load float, ptr %12, align 4, !tbaa !11
  %14 = getelementptr inbounds %"class.math::tmp::_mat2", ptr %6, i32 0, i32 0
  %15 = getelementptr inbounds [2 x [2 x float]], ptr %14, i64 0, i64 1
  %16 = getelementptr inbounds [2 x float], ptr %15, i64 0, i64 0
  %17 = load float, ptr %16, align 4, !tbaa !9
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.math::tmp::_vec2", ptr %18, i32 0, i32 1
  %20 = load float, ptr %19, align 4, !tbaa !13
  %21 = fmul float %17, %20
  %22 = call float @llvm.fmuladd.f32(float %10, float %13, float %21)
  %23 = getelementptr inbounds %"class.math::tmp::_mat2", ptr %6, i32 0, i32 0
  %24 = getelementptr inbounds [2 x [2 x float]], ptr %23, i64 0, i64 0
  %25 = getelementptr inbounds [2 x float], ptr %24, i64 0, i64 1
  %26 = load float, ptr %25, align 4, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.math::tmp::_vec2", ptr %27, i32 0, i32 0
  %29 = load float, ptr %28, align 4, !tbaa !11
  %30 = getelementptr inbounds %"class.math::tmp::_mat2", ptr %6, i32 0, i32 0
  %31 = getelementptr inbounds [2 x [2 x float]], ptr %30, i64 0, i64 1
  %32 = getelementptr inbounds [2 x float], ptr %31, i64 0, i64 1
  %33 = load float, ptr %32, align 4, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.math::tmp::_vec2", ptr %34, i32 0, i32 1
  %36 = load float, ptr %35, align 4, !tbaa !13
  %37 = fmul float %33, %36
  %38 = call float @llvm.fmuladd.f32(float %26, float %29, float %37)
  call void @_ZN4math3tmp5_vec2IfEC1Eff(ptr noundef nonnull align 4 dereferenceable(8) %3, float noundef %22, float noundef %38)
  %39 = load <2 x float>, ptr %3, align 4
  ret <2 x float> %39
}

declare void @_ZN4math3tmp5_vec2IfEC1Eff(ptr, float, float)

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

!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, !10, i64 0}
!12 = !{!"_ZTSN4math3tmp5_vec2IfEE", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, 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.math::tmp::_vec2" = type { float, float }

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

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZNK4math3tmp5_mat2mlERKNS0_5_vec2IfEE(ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.math::tmp::_vec2", align 8
  %4 = load float, ptr %0, align 4, !tbaa !5
  %5 = load float, ptr %1, align 4, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 4
  %9 = load float, ptr %8, align 4, !tbaa !11
  %10 = fmul float %7, %9
  %11 = tail call float @llvm.fmuladd.f32(float %4, float %5, float %10)
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = fmul float %9, %15
  %17 = tail call float @llvm.fmuladd.f32(float %13, float %5, float %16)
  call void @_ZN4math3tmp5_vec2IfEC1Eff(ptr noundef nonnull align 4 dereferenceable(8) %3, float noundef %11, float noundef %17)
  %18 = load <2 x float>, ptr %3, align 8
  ret <2 x float> %18
}

declare void @_ZN4math3tmp5_vec2IfEC1Eff(ptr, float, float) local_unnamed_addr

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

!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"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN4math3tmp5_vec2IfEE", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}


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