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

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

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


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef float @_ZNK4math3tmp5_mat33detEv(ptr nocapture noundef nonnull readonly align 4 dereferenceable(36) %0) local_unnamed_addr #0 align 2 {
  %2 = load float, ptr %0, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load <4 x float>, ptr %4, align 4
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load float, ptr %7, align 4, !tbaa !5
  %9 = load float, ptr %3, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 28
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = load float, ptr %6, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 20
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = shufflevector <4 x float> %5, <4 x float> poison, <2 x i32> zeroinitializer
  %20 = insertelement <2 x float> poison, float %2, i64 0
  %21 = insertelement <2 x float> %20, float %14, i64 1
  %22 = fmul <2 x float> %19, %21
  %23 = insertelement <2 x float> poison, float %9, i64 0
  %24 = insertelement <2 x float> %23, float %2, i64 1
  %25 = insertelement <2 x float> poison, float %11, i64 0
  %26 = shufflevector <2 x float> %25, <2 x float> poison, <2 x i32> zeroinitializer
  %27 = fmul <2 x float> %24, %26
  %28 = insertelement <2 x float> poison, float %13, i64 0
  %29 = insertelement <2 x float> %28, float %18, i64 1
  %30 = fmul <2 x float> %27, %29
  %31 = insertelement <2 x float> poison, float %8, i64 0
  %32 = insertelement <2 x float> %31, float %13, i64 1
  %33 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %22, <2 x float> %32, <2 x float> %30)
  %34 = insertelement <2 x float> poison, float %16, i64 0
  %35 = insertelement <2 x float> %34, float %9, i64 1
  %36 = insertelement <2 x float> poison, float %14, i64 0
  %37 = insertelement <2 x float> %36, float %16, i64 1
  %38 = fmul <2 x float> %35, %37
  %39 = insertelement <2 x float> poison, float %18, i64 0
  %40 = insertelement <2 x float> %39, float %8, i64 1
  %41 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %38, <2 x float> %40, <2 x float> %33)
  %shift = shufflevector <2 x float> %41, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %42 = fsub <2 x float> %41, %shift
  %43 = extractelement <2 x float> %42, i64 0
  ret float %43
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 #1 = { 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 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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