void babl_matrix_mul_vectorff_buf3(const float *mat, const float *v_in,
                                   float *v_out, int samples) {
  int i;
  const float m_0_0 = mat[0 * 3 + 0];
  const float m_0_1 = mat[0 * 3 + 1];
  const float m_0_2 = mat[0 * 3 + 2];
  const float m_1_0 = mat[1 * 3 + 0];
  const float m_1_1 = mat[1 * 3 + 1];
  const float m_1_2 = mat[1 * 3 + 2];
  const float m_2_0 = mat[2 * 3 + 0];
  const float m_2_1 = mat[2 * 3 + 1];
  const float m_2_2 = mat[2 * 3 + 2];
  for (i = 0; i < samples; i++) {
    const float a = v_in[0], b = v_in[1], c = v_in[2];
    v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
    v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
    v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
    v_in += 3;
    v_out += 3;
  }
}


x86 assembly (clang, -O0):
<babl_matrix_mul_vectorff_buf3>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movss  0x10(%rax),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movss  0x14(%rax),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movss  0x18(%rax),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
movss  0x1c(%rax),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movss  0x20(%rax),%xmm0
movss  %xmm0,-0x44(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1296 <babl_matrix_mul_vectorff_buf3+0x196>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x24(%rbp),%xmm1
movss  -0x48(%rbp),%xmm2
movss  -0x28(%rbp),%xmm0
mulss  -0x4c(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
movss  -0x50(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm1
movss  -0x48(%rbp),%xmm2
movss  -0x34(%rbp),%xmm0
mulss  -0x4c(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x38(%rbp),%xmm0
movss  -0x50(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x3c(%rbp),%xmm1
movss  -0x48(%rbp),%xmm2
movss  -0x40(%rbp),%xmm0
mulss  -0x4c(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x44(%rbp),%xmm0
movss  -0x50(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1197 <babl_matrix_mul_vectorff_buf3+0x97>
pop    %rbp
ret

x86 assembly (clang, -O2):
<babl_matrix_mul_vectorff_buf3>:
sub    $0x18,%rsp
test   %ecx,%ecx
jle    1209 <babl_matrix_mul_vectorff_buf3+0x109>
movss  (%rdi),%xmm8
movss  0x4(%rdi),%xmm13
movss  0x8(%rdi),%xmm14
movss  0xc(%rdi),%xmm15
movss  0x10(%rdi),%xmm9
movss  0x14(%rdi),%xmm10
movss  0x18(%rdi),%xmm6
movss  0x1c(%rdi),%xmm7
movss  0x20(%rdi),%xmm0
lea    -0x1(%rcx),%r9d
xor    %r8d,%r8d
cmp    $0x3,%r9d
jb     1171 <babl_matrix_mul_vectorff_buf3+0x71>
lea    (%r9,%r9,2),%rax
lea    (%rsi,%rax,4),%rdi
add    $0xc,%rdi
cmp    %rdx,%rdi
jbe    120e <babl_matrix_mul_vectorff_buf3+0x10e>
lea    (%rdx,%rax,4),%rax
add    $0xc,%rax
cmp    %rsi,%rax
jbe    120e <babl_matrix_mul_vectorff_buf3+0x10e>
mov    %rsi,%r10
mov    %rdx,%r11
sub    %r8d,%ecx
xor    %eax,%eax
nopl   0x0(%rax)
movss  (%r10,%rax,1),%xmm1
movss  0x4(%r10,%rax,1),%xmm3
movss  0x8(%r10,%rax,1),%xmm2
movaps %xmm13,%xmm4
mulss  %xmm3,%xmm4
movaps %xmm8,%xmm5
mulss  %xmm1,%xmm5
addss  %xmm4,%xmm5
movaps %xmm14,%xmm4
mulss  %xmm2,%xmm4
addss  %xmm5,%xmm4
movss  %xmm4,(%r11,%rax,1)
movaps %xmm9,%xmm4
mulss  %xmm3,%xmm4
movaps %xmm15,%xmm5
mulss  %xmm1,%xmm5
addss  %xmm4,%xmm5
movaps %xmm10,%xmm4
mulss  %xmm2,%xmm4
addss  %xmm5,%xmm4
movss  %xmm4,0x4(%r11,%rax,1)
mulss  %xmm7,%xmm3
mulss  %xmm6,%xmm1
addss  %xmm3,%xmm1
mulss  %xmm0,%xmm2
addss  %xmm1,%xmm2
movss  %xmm2,0x8(%r11,%rax,1)
add    $0xc,%rax
add    $0xffffffff,%ecx
jne    1180 <babl_matrix_mul_vectorff_buf3+0x80>
add    $0x18,%rsp
ret
add    $0x1,%r9
mov    %r9,%r8
and    $0xfffffffffffffffc,%r8
lea    0x0(,%r8,4),%rax
lea    (%rax,%rax,2),%r11
lea    (%rsi,%r11,1),%r10
add    %rdx,%r11
movaps %xmm13,%xmm1
shufps $0x0,%xmm13,%xmm1
movaps %xmm1,(%rsp)
movaps %xmm8,%xmm1
shufps $0x0,%xmm8,%xmm1
movaps %xmm1,-0x10(%rsp)
movaps %xmm14,%xmm1
shufps $0x0,%xmm14,%xmm1
movaps %xmm1,-0x20(%rsp)
movaps %xmm9,%xmm1
shufps $0x0,%xmm9,%xmm1
movaps %xmm1,-0x30(%rsp)
movaps %xmm15,%xmm1
shufps $0x0,%xmm15,%xmm1
movaps %xmm1,-0x40(%rsp)
movaps %xmm10,%xmm1
shufps $0x0,%xmm10,%xmm1
movaps %xmm1,-0x50(%rsp)
movaps %xmm7,%xmm1
shufps $0x0,%xmm7,%xmm1
movaps %xmm1,-0x60(%rsp)
movaps %xmm6,%xmm1
shufps $0x0,%xmm6,%xmm1
movaps %xmm1,-0x70(%rsp)
movaps %xmm0,%xmm1
shufps $0x0,%xmm0,%xmm1
movaps %xmm1,-0x80(%rsp)
xor    %eax,%eax
mov    %r8,%rdi
nopl   0x0(%rax,%rax,1)
movups (%rsi,%rax,1),%xmm2
movups 0x10(%rsi,%rax,1),%xmm11
movups 0x20(%rsi,%rax,1),%xmm5
movaps %xmm5,%xmm3
shufps $0xe5,%xmm11,%xmm3
movaps %xmm5,%xmm4
shufps $0xf6,%xmm11,%xmm4
movaps %xmm2,%xmm1
shufps $0x1,%xmm11,%xmm1
shufps $0x21,%xmm2,%xmm11
shufps $0x2c,%xmm3,%xmm2
shufps $0x28,%xmm4,%xmm1
shufps $0xc2,%xmm5,%xmm11
movaps (%rsp),%xmm3
mulps  %xmm1,%xmm3
movaps -0x10(%rsp),%xmm4
mulps  %xmm2,%xmm4
addps  %xmm3,%xmm4
movaps -0x20(%rsp),%xmm12
mulps  %xmm11,%xmm12
addps  %xmm4,%xmm12
movaps -0x30(%rsp),%xmm3
mulps  %xmm1,%xmm3
movaps -0x40(%rsp),%xmm4
mulps  %xmm2,%xmm4
addps  %xmm3,%xmm4
movaps -0x50(%rsp),%xmm3
mulps  %xmm11,%xmm3
addps  %xmm4,%xmm3
mulps  -0x60(%rsp),%xmm1
mulps  -0x70(%rsp),%xmm2
addps  %xmm1,%xmm2
mulps  -0x80(%rsp),%xmm11
addps  %xmm2,%xmm11
movaps %xmm11,%xmm1
shufps $0xd4,%xmm12,%xmm1
movaps %xmm3,%xmm2
movlhps %xmm12,%xmm2
shufps $0x82,%xmm1,%xmm2
movaps %xmm12,%xmm1
unpckhpd %xmm3,%xmm1
movaps %xmm11,%xmm4
shufps $0x11,%xmm3,%xmm4
shufps $0x82,%xmm1,%xmm4
shufps $0xff,%xmm11,%xmm3
shufps $0x23,%xmm11,%xmm12
shufps $0x82,%xmm3,%xmm12
movups %xmm12,0x20(%rdx,%rax,1)
movups %xmm4,0x10(%rdx,%rax,1)
movups %xmm2,(%rdx,%rax,1)
add    $0x30,%rax
add    $0xfffffffffffffffc,%rdi
jne    12b0 <babl_matrix_mul_vectorff_buf3+0x1b0>
cmp    %r8,%r9
jne    1177 <babl_matrix_mul_vectorff_buf3+0x77>
jmp    1209 <babl_matrix_mul_vectorff_buf3+0x109>

LLVM IR (-O0):
define void @babl_matrix_mul_vectorff_buf3(float* %0, float* %1, float* %2, i32 %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store i32 %3, i32* %8
%22 = load float*, float** %5
%23 = getelementptr inbounds float, float* %22, i64 0
%24 = load float, float* %23
store float %24, float* %10
%25 = load float*, float** %5
%26 = getelementptr inbounds float, float* %25, i64 1
%27 = load float, float* %26
store float %27, float* %11
%28 = load float*, float** %5
%29 = getelementptr inbounds float, float* %28, i64 2
%30 = load float, float* %29
store float %30, float* %12
%31 = load float*, float** %5
%32 = getelementptr inbounds float, float* %31, i64 3
%33 = load float, float* %32
store float %33, float* %13
%34 = load float*, float** %5
%35 = getelementptr inbounds float, float* %34, i64 4
%36 = load float, float* %35
store float %36, float* %14
%37 = load float*, float** %5
%38 = getelementptr inbounds float, float* %37, i64 5
%39 = load float, float* %38
store float %39, float* %15
%40 = load float*, float** %5
%41 = getelementptr inbounds float, float* %40, i64 6
%42 = load float, float* %41
store float %42, float* %16
%43 = load float*, float** %5
%44 = getelementptr inbounds float, float* %43, i64 7
%45 = load float, float* %44
store float %45, float* %17
%46 = load float*, float** %5
%47 = getelementptr inbounds float, float* %46, i64 8
%48 = load float, float* %47
store float %48, float* %18
store i32 0, i32* %9
br label %49
49: ; preds = %100, %4
%50 = load i32, i32* %9
%51 = load i32, i32* %8
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %103
53: ; preds = %49
%54 = load float*, float** %6
%55 = getelementptr inbounds float, float* %54, i64 0
%56 = load float, float* %55
store float %56, float* %19
%57 = load float*, float** %6
%58 = getelementptr inbounds float, float* %57, i64 1
%59 = load float, float* %58
store float %59, float* %20
%60 = load float*, float** %6
%61 = getelementptr inbounds float, float* %60, i64 2
%62 = load float, float* %61
store float %62, float* %21
%63 = load float, float* %10
%64 = load float, float* %19
%65 = load float, float* %11
%66 = load float, float* %20
%67 = fmul float %65, %66
%68 = call float @llvm.fmuladd.f32(float %63, float %64, float %67)
%69 = load float, float* %12
%70 = load float, float* %21
%71 = call float @llvm.fmuladd.f32(float %69, float %70, float %68)
%72 = load float*, float** %7
%73 = getelementptr inbounds float, float* %72, i64 0
store float %71, float* %73
%74 = load float, float* %13
%75 = load float, float* %19
%76 = load float, float* %14
%77 = load float, float* %20
%78 = fmul float %76, %77
%79 = call float @llvm.fmuladd.f32(float %74, float %75, float %78)
%80 = load float, float* %15
%81 = load float, float* %21
%82 = call float @llvm.fmuladd.f32(float %80, float %81, float %79)
%83 = load float*, float** %7
%84 = getelementptr inbounds float, float* %83, i64 1
store float %82, float* %84
%85 = load float, float* %16
%86 = load float, float* %19
%87 = load float, float* %17
%88 = load float, float* %20
%89 = fmul float %87, %88
%90 = call float @llvm.fmuladd.f32(float %85, float %86, float %89)
%91 = load float, float* %18
%92 = load float, float* %21
%93 = call float @llvm.fmuladd.f32(float %91, float %92, float %90)
%94 = load float*, float** %7
%95 = getelementptr inbounds float, float* %94, i64 2
store float %93, float* %95
%96 = load float*, float** %6
%97 = getelementptr inbounds float, float* %96, i64 3
store float* %97, float** %6
%98 = load float*, float** %7
%99 = getelementptr inbounds float, float* %98, i64 3
store float* %99, float** %7
br label %100
100: ; preds = %53
%101 = load i32, i32* %9
%102 = add nsw i32 %101, 1
store i32 %102, i32* %9
br label %49
103: ; preds = %49
ret void
}

LLVM IR (-O2):
define void @babl_matrix_mul_vectorff_buf3(float* nocapture %0, float* nocapture %1, float* nocapture writeonly %2, i32 %3) {
%5 = load float, float* %0
%6 = getelementptr inbounds float, float* %0, i64 1
%7 = load float, float* %6
%8 = getelementptr inbounds float, float* %0, i64 2
%9 = load float, float* %8
%10 = getelementptr inbounds float, float* %0, i64 3
%11 = load float, float* %10
%12 = getelementptr inbounds float, float* %0, i64 4
%13 = load float, float* %12
%14 = getelementptr inbounds float, float* %0, i64 5
%15 = load float, float* %14
%16 = getelementptr inbounds float, float* %0, i64 6
%17 = load float, float* %16
%18 = getelementptr inbounds float, float* %0, i64 7
%19 = load float, float* %18
%20 = getelementptr inbounds float, float* %0, i64 8
%21 = load float, float* %20
%22 = icmp sgt i32 %3, 0
br i1 %22, label %23, label %119
23: ; preds = %4
%24 = add i32 %3, -1
%25 = zext i32 %24 to i64
%26 = add nuw nsw i64 %25, 1
%27 = icmp ult i32 %24, 3
br i1 %27, label %91, label %28
28: ; preds = %23
%29 = add i32 %3, -1
%30 = zext i32 %29 to i64
%31 = mul nuw nsw i64 %30, 3
%32 = add nuw nsw i64 %31, 3
%33 = getelementptr float, float* %2, i64 %32
%34 = getelementptr float, float* %1, i64 %32
%35 = icmp ugt float* %34, %2
%36 = icmp ugt float* %33, %1
%37 = and i1 %35, %36
br i1 %37, label %91, label %38
38: ; preds = %28
%39 = and i64 %26, 8589934588
%40 = mul nuw nsw i64 %39, 3
%41 = getelementptr float, float* %1, i64 %40
%42 = mul nuw nsw i64 %39, 3
%43 = getelementptr float, float* %2, i64 %42
%44 = trunc i64 %39 to i32
%45 = insertelement <4 x float> poison, float %7, i64 0
%46 = shufflevector <4 x float> %45, <4 x float> poison, <4 x i32> zeroinitializer
%47 = insertelement <4 x float> poison, float %5, i64 0
%48 = shufflevector <4 x float> %47, <4 x float> poison, <4 x i32> zeroinitializer
%49 = insertelement <4 x float> poison, float %9, i64 0
%50 = shufflevector <4 x float> %49, <4 x float> poison, <4 x i32> zeroinitializer
%51 = insertelement <4 x float> poison, float %13, i64 0
%52 = shufflevector <4 x float> %51, <4 x float> poison, <4 x i32> zeroinitializer
%53 = insertelement <4 x float> poison, float %11, i64 0
%54 = shufflevector <4 x float> %53, <4 x float> poison, <4 x i32> zeroinitializer
%55 = insertelement <4 x float> poison, float %15, i64 0
%56 = shufflevector <4 x float> %55, <4 x float> poison, <4 x i32> zeroinitializer
%57 = insertelement <4 x float> poison, float %19, i64 0
%58 = shufflevector <4 x float> %57, <4 x float> poison, <4 x i32> zeroinitializer
%59 = insertelement <4 x float> poison, float %17, i64 0
%60 = shufflevector <4 x float> %59, <4 x float> poison, <4 x i32> zeroinitializer
%61 = insertelement <4 x float> poison, float %21, i64 0
%62 = shufflevector <4 x float> %61, <4 x float> poison, <4 x i32> zeroinitializer
br label %63
63: ; preds = %63, %38
%64 = phi i64 [ 0, %38 ], [ %87, %63 ]
%65 = mul i64 %64, 3
%66 = getelementptr float, float* %1, i64 %65
%67 = mul i64 %64, 3
%68 = bitcast float* %66 to <12 x float>*
%69 = load <12 x float>, <12 x float>* %68
%70 = shufflevector <12 x float> %69, <12 x float> poison, <4 x i32> <i32 0, i32 3, i32 6, i32 9>
%71 = shufflevector <12 x float> %69, <12 x float> poison, <4 x i32> <i32 1, i32 4, i32 7, i32 10>
%72 = shufflevector <12 x float> %69, <12 x float> poison, <4 x i32> <i32 2, i32 5, i32 8, i32 11>
%73 = fmul <4 x float> %46, %71
%74 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %48, <4 x float> %70, <4 x float> %73)
%75 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %50, <4 x float> %72, <4 x float> %74)
%76 = fmul <4 x float> %52, %71
%77 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %54, <4 x float> %70, <4 x float> %76)
%78 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %56, <4 x float> %72, <4 x float> %77)
%79 = fmul <4 x float> %58, %71
%80 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %60, <4 x float> %70, <4 x float> %79)
%81 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %62, <4 x float> %72, <4 x float> %80)
%82 = getelementptr inbounds float, float* %2, i64 %67
%83 = bitcast float* %82 to <12 x float>*
%84 = shufflevector <4 x float> %75, <4 x float> %78, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
%85 = shufflevector <4 x float> %81, <4 x float> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
%86 = shufflevector <8 x float> %84, <8 x float> %85, <12 x i32> <i32 0, i32 4, i32 8, i32 1, i32 5, i32 9, i32 2, i32 6, i32 10, i32 3, i32 7, i32 11>
store <12 x float> %86, <12 x float>* %83
%87 = add nuw i64 %64, 4
%88 = icmp eq i64 %87, %39
br i1 %88, label %89, label %63
89: ; preds = %63
%90 = icmp eq i64 %26, %39
br i1 %90, label %119, label %91
91: ; preds = %28, %23, %89
%92 = phi float* [ %1, %28 ], [ %1, %23 ], [ %41, %89 ]
%93 = phi float* [ %2, %28 ], [ %2, %23 ], [ %43, %89 ]
%94 = phi i32 [ 0, %28 ], [ 0, %23 ], [ %44, %89 ]
br label %95
95: ; preds = %91, %95
%96 = phi float* [ %115, %95 ], [ %92, %91 ]
%97 = phi float* [ %116, %95 ], [ %93, %91 ]
%98 = phi i32 [ %117, %95 ], [ %94, %91 ]
%99 = load float, float* %96
%100 = getelementptr inbounds float, float* %96, i64 1
%101 = load float, float* %100
%102 = getelementptr inbounds float, float* %96, i64 2
%103 = load float, float* %102
%104 = fmul float %7, %101
%105 = tail call float @llvm.fmuladd.f32(float %5, float %99, float %104)
%106 = tail call float @llvm.fmuladd.f32(float %9, float %103, float %105)
store float %106, float* %97
%107 = fmul float %13, %101
%108 = tail call float @llvm.fmuladd.f32(float %11, float %99, float %107)
%109 = tail call float @llvm.fmuladd.f32(float %15, float %103, float %108)
%110 = getelementptr inbounds float, float* %97, i64 1
store float %109, float* %110
%111 = fmul float %19, %101
%112 = tail call float @llvm.fmuladd.f32(float %17, float %99, float %111)
%113 = tail call float @llvm.fmuladd.f32(float %21, float %103, float %112)
%114 = getelementptr inbounds float, float* %97, i64 2
store float %113, float* %114
%115 = getelementptr inbounds float, float* %96, i64 3
%116 = getelementptr inbounds float, float* %97, i64 3
%117 = add nuw nsw i32 %98, 1
%118 = icmp eq i32 %117, %3
br i1 %118, label %119, label %95
119: ; preds = %95, %89, %4
ret void
}