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

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

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

; 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) #1

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_ZNK4math3tmp5_mat3mlERKNS0_5_vec3IfEE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 4 dereferenceable(12) %1) #2 align 2 {
  %3 = alloca %"class.math::tmp::_vec3", align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds [3 x [3 x float]], ptr %8, i64 0, i64 0
  %10 = getelementptr inbounds [3 x float], ptr %9, i64 0, i64 0
  %11 = load float, ptr %10, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.math::tmp::_vec3", ptr %12, i32 0, i32 0
  %14 = load float, ptr %13, align 4, !tbaa !11
  %15 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %7, i32 0, i32 0
  %16 = getelementptr inbounds [3 x [3 x float]], ptr %15, i64 0, i64 1
  %17 = getelementptr inbounds [3 x float], ptr %16, i64 0, i64 0
  %18 = load float, ptr %17, align 4, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.math::tmp::_vec3", ptr %19, i32 0, i32 1
  %21 = load float, ptr %20, align 4, !tbaa !13
  %22 = fmul float %18, %21
  %23 = call float @llvm.fmuladd.f32(float %11, float %14, float %22)
  %24 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %7, i32 0, i32 0
  %25 = getelementptr inbounds [3 x [3 x float]], ptr %24, i64 0, i64 2
  %26 = getelementptr inbounds [3 x float], ptr %25, i64 0, i64 0
  %27 = load float, ptr %26, align 4, !tbaa !9
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.math::tmp::_vec3", ptr %28, i32 0, i32 2
  %30 = load float, ptr %29, align 4, !tbaa !14
  %31 = call float @llvm.fmuladd.f32(float %27, float %30, float %23)
  %32 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %7, i32 0, i32 0
  %33 = getelementptr inbounds [3 x [3 x float]], ptr %32, i64 0, i64 0
  %34 = getelementptr inbounds [3 x float], ptr %33, i64 0, i64 1
  %35 = load float, ptr %34, align 4, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %"class.math::tmp::_vec3", ptr %36, i32 0, i32 0
  %38 = load float, ptr %37, align 4, !tbaa !11
  %39 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %7, i32 0, i32 0
  %40 = getelementptr inbounds [3 x [3 x float]], ptr %39, i64 0, i64 1
  %41 = getelementptr inbounds [3 x float], ptr %40, i64 0, i64 1
  %42 = load float, ptr %41, align 4, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %"class.math::tmp::_vec3", ptr %43, i32 0, i32 1
  %45 = load float, ptr %44, align 4, !tbaa !13
  %46 = fmul float %42, %45
  %47 = call float @llvm.fmuladd.f32(float %35, float %38, float %46)
  %48 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %7, i32 0, i32 0
  %49 = getelementptr inbounds [3 x [3 x float]], ptr %48, i64 0, i64 2
  %50 = getelementptr inbounds [3 x float], ptr %49, i64 0, i64 1
  %51 = load float, ptr %50, align 4, !tbaa !9
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.math::tmp::_vec3", ptr %52, i32 0, i32 2
  %54 = load float, ptr %53, align 4, !tbaa !14
  %55 = call float @llvm.fmuladd.f32(float %51, float %54, float %47)
  %56 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %7, i32 0, i32 0
  %57 = getelementptr inbounds [3 x [3 x float]], ptr %56, i64 0, i64 0
  %58 = getelementptr inbounds [3 x float], ptr %57, i64 0, i64 2
  %59 = load float, ptr %58, align 4, !tbaa !9
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %"class.math::tmp::_vec3", ptr %60, i32 0, i32 0
  %62 = load float, ptr %61, align 4, !tbaa !11
  %63 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %7, i32 0, i32 0
  %64 = getelementptr inbounds [3 x [3 x float]], ptr %63, i64 0, i64 1
  %65 = getelementptr inbounds [3 x float], ptr %64, i64 0, i64 2
  %66 = load float, ptr %65, align 4, !tbaa !9
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %"class.math::tmp::_vec3", ptr %67, i32 0, i32 1
  %69 = load float, ptr %68, align 4, !tbaa !13
  %70 = fmul float %66, %69
  %71 = call float @llvm.fmuladd.f32(float %59, float %62, float %70)
  %72 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %7, i32 0, i32 0
  %73 = getelementptr inbounds [3 x [3 x float]], ptr %72, i64 0, i64 2
  %74 = getelementptr inbounds [3 x float], ptr %73, i64 0, i64 2
  %75 = load float, ptr %74, align 4, !tbaa !9
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %"class.math::tmp::_vec3", ptr %76, i32 0, i32 2
  %78 = load float, ptr %77, align 4, !tbaa !14
  %79 = call float @llvm.fmuladd.f32(float %75, float %78, float %71)
  call void @_ZN4math3tmp5_vec3IfEC1Efff(ptr noundef nonnull align 4 dereferenceable(12) %3, float noundef %31, float noundef %55, float noundef %79)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 4 %3, i64 12, i1 false)
  %80 = load { <2 x float>, float }, ptr %6, align 8
  ret { <2 x float>, float } %80
}

declare void @_ZN4math3tmp5_vec3IfEC1Efff(ptr, float, float, float)

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

!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_vec3IfEE", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}


; 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::_vec3" = type { float, 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>, float } @_ZNK4math3tmp5_mat3mlERKNS0_5_vec3IfEE(ptr nocapture noundef nonnull readonly align 4 dereferenceable(36) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.math::tmp::_vec3", 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 12
  %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 24
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = load float, ptr %14, align 4, !tbaa !12
  %16 = tail call float @llvm.fmuladd.f32(float %13, float %15, float %11)
  %17 = getelementptr inbounds i8, ptr %0, i64 4
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = fmul float %9, %20
  %22 = tail call float @llvm.fmuladd.f32(float %18, float %5, float %21)
  %23 = getelementptr inbounds i8, ptr %0, i64 28
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = tail call float @llvm.fmuladd.f32(float %24, float %15, float %22)
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %0, i64 20
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = fmul float %9, %29
  %31 = tail call float @llvm.fmuladd.f32(float %27, float %5, float %30)
  %32 = getelementptr inbounds i8, ptr %0, i64 32
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = tail call float @llvm.fmuladd.f32(float %33, float %15, float %31)
  call void @_ZN4math3tmp5_vec3IfEC1Efff(ptr noundef nonnull align 4 dereferenceable(12) %3, float noundef %16, float noundef %25, float noundef %34)
  %.sroa.0.0.copyload = load <2 x float>, ptr %3, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  %.sroa.2.0.copyload = load float, ptr %.sroa.2.0..sroa_idx, align 8
  %.fca.0.insert = insertvalue { <2 x float>, float } poison, <2 x float> %.sroa.0.0.copyload, 0
  %.fca.1.insert = insertvalue { <2 x float>, float } %.fca.0.insert, float %.sroa.2.0.copyload, 1
  ret { <2 x float>, float } %.fca.1.insert
}

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

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

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


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