#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ __m128;

/* Variables and functions */
int /*<<< orphan*/ _mm_add_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_loadu_ps(float const *);
int /*<<< orphan*/ _mm_mul_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_set1_ps(float const);
int /*<<< orphan*/ _mm_storeu_ps(float *, int /*<<< orphan*/);
void fast_matrix_mul_4x4_sse(float *dest, const float *a, const float *b) {
  int i;
  __m128 a_col_1 = _mm_loadu_ps(a);
  __m128 a_col_2 = _mm_loadu_ps(&a[4]);
  __m128 a_col_3 = _mm_loadu_ps(&a[8]);
  __m128 a_col_4 = _mm_loadu_ps(&a[12]);
  for (i = 0; i < 16; i += 4) {
    __m128 r_col = _mm_mul_ps(a_col_1, _mm_set1_ps(b[i]));
    r_col = _mm_add_ps(r_col, _mm_mul_ps(a_col_2, _mm_set1_ps(b[i + 1])));
    r_col = _mm_add_ps(r_col, _mm_mul_ps(a_col_3, _mm_set1_ps(b[i + 2])));
    r_col = _mm_add_ps(r_col, _mm_mul_ps(a_col_4, _mm_set1_ps(b[i + 3])));
    _mm_storeu_ps(&dest[i], r_col);
  }
}


x86 assembly (clang, -O0):
<fast_matrix_mul_4x4_sse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <_mm_loadu_ps@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x10,%rdi
call   1040 <_mm_loadu_ps@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x20,%rdi
call   1040 <_mm_loadu_ps@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x30,%rdi
call   1040 <_mm_loadu_ps@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    12a9 <fast_matrix_mul_4x4_sse+0x159>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1060 <_mm_set1_ps@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_mul_ps@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
call   1060 <_mm_set1_ps@plt>
mov    -0x48(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_mul_ps@plt>
mov    -0x44(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_add_ps@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
call   1060 <_mm_set1_ps@plt>
mov    -0x40(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_mul_ps@plt>
mov    -0x3c(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_add_ps@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
call   1060 <_mm_set1_ps@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_mul_ps@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_add_ps@plt>
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x30(%rbp),%esi
call   1030 <_mm_storeu_ps@plt>
mov    -0x1c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a7 <fast_matrix_mul_4x4_sse+0x57>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fast_matrix_mul_4x4_sse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <_mm_loadu_ps@plt>
mov    %eax,0x14(%rsp)
lea    0x10(%rbp),%rdi
call   1040 <_mm_loadu_ps@plt>
mov    %eax,0x10(%rsp)
lea    0x20(%rbp),%rdi
call   1040 <_mm_loadu_ps@plt>
mov    %eax,0xc(%rsp)
add    $0x30,%rbp
mov    %rbp,%rdi
call   1040 <_mm_loadu_ps@plt>
mov    %eax,%r12d
mov    $0xfffffffffffffffc,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0x10(%r14,%r13,4),%xmm0
call   1060 <_mm_set1_ps@plt>
mov    0x14(%rsp),%edi
mov    %eax,%esi
call   1050 <_mm_mul_ps@plt>
mov    %eax,%r15d
movss  0x14(%r14,%r13,4),%xmm0
call   1060 <_mm_set1_ps@plt>
mov    0x10(%rsp),%edi
mov    %eax,%esi
call   1050 <_mm_mul_ps@plt>
mov    %r15d,%edi
mov    %eax,%esi
call   1070 <_mm_add_ps@plt>
mov    %eax,%ebp
movss  0x18(%r14,%r13,4),%xmm0
call   1060 <_mm_set1_ps@plt>
mov    0xc(%rsp),%edi
mov    %eax,%esi
call   1050 <_mm_mul_ps@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1070 <_mm_add_ps@plt>
mov    %eax,%ebp
movss  0x1c(%r14,%r13,4),%xmm0
call   1060 <_mm_set1_ps@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1050 <_mm_mul_ps@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1070 <_mm_add_ps@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <_mm_storeu_ps@plt>
add    $0x4,%r13
add    $0x10,%rbx
cmp    $0xc,%r13
jb     11b0 <fast_matrix_mul_4x4_sse+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fast_matrix_mul_4x4_sse(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%13 = load float*, float** %5
%14 = call i32 @_mm_loadu_ps(float* %13)
store i32 %14, i32* %8
%15 = load float*, float** %5
%16 = getelementptr inbounds float, float* %15, i64 4
%17 = call i32 @_mm_loadu_ps(float* %16)
store i32 %17, i32* %9
%18 = load float*, float** %5
%19 = getelementptr inbounds float, float* %18, i64 8
%20 = call i32 @_mm_loadu_ps(float* %19)
store i32 %20, i32* %10
%21 = load float*, float** %5
%22 = getelementptr inbounds float, float* %21, i64 12
%23 = call i32 @_mm_loadu_ps(float* %22)
store i32 %23, i32* %11
store i32 0, i32* %7
br label %24
24: ; preds = %75, %3
%25 = load i32, i32* %7
%26 = icmp slt i32 %25, 16
br i1 %26, label %27, label %78
27: ; preds = %24
%28 = load i32, i32* %8
%29 = load float*, float** %6
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
%33 = load float, float* %32
%34 = call i32 @_mm_set1_ps(float %33)
%35 = call i32 @_mm_mul_ps(i32 %28, i32 %34)
store i32 %35, i32* %12
%36 = load i32, i32* %12
%37 = load i32, i32* %9
%38 = load float*, float** %6
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %38, i64 %41
%43 = load float, float* %42
%44 = call i32 @_mm_set1_ps(float %43)
%45 = call i32 @_mm_mul_ps(i32 %37, i32 %44)
%46 = call i32 @_mm_add_ps(i32 %36, i32 %45)
store i32 %46, i32* %12
%47 = load i32, i32* %12
%48 = load i32, i32* %10
%49 = load float*, float** %6
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 2
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float, float* %49, i64 %52
%54 = load float, float* %53
%55 = call i32 @_mm_set1_ps(float %54)
%56 = call i32 @_mm_mul_ps(i32 %48, i32 %55)
%57 = call i32 @_mm_add_ps(i32 %47, i32 %56)
store i32 %57, i32* %12
%58 = load i32, i32* %12
%59 = load i32, i32* %11
%60 = load float*, float** %6
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 3
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds float, float* %60, i64 %63
%65 = load float, float* %64
%66 = call i32 @_mm_set1_ps(float %65)
%67 = call i32 @_mm_mul_ps(i32 %59, i32 %66)
%68 = call i32 @_mm_add_ps(i32 %58, i32 %67)
store i32 %68, i32* %12
%69 = load float*, float** %4
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds float, float* %69, i64 %71
%73 = load i32, i32* %12
%74 = call i32 @_mm_storeu_ps(float* %72, i32 %73)
br label %75
75: ; preds = %27
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 4
store i32 %77, i32* %7
br label %24
78: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @fast_matrix_mul_4x4_sse(float* %0, float* %1, float* nocapture %2) {
%4 = tail call i32 @_mm_loadu_ps(float* %1)
%5 = getelementptr inbounds float, float* %1, i64 4
%6 = tail call i32 @_mm_loadu_ps(float* %5)
%7 = getelementptr inbounds float, float* %1, i64 8
%8 = tail call i32 @_mm_loadu_ps(float* %7)
%9 = getelementptr inbounds float, float* %1, i64 12
%10 = tail call i32 @_mm_loadu_ps(float* %9)
br label %11
11: ; preds = %3, %11
%12 = phi i64 [ 0, %3 ], [ %37, %11 ]
%13 = getelementptr inbounds float, float* %2, i64 %12
%14 = load float, float* %13
%15 = tail call i32 @_mm_set1_ps(float %14)
%16 = tail call i32 @_mm_mul_ps(i32 %4, i32 %15)
%17 = or i64 %12, 1
%18 = getelementptr inbounds float, float* %2, i64 %17
%19 = load float, float* %18
%20 = tail call i32 @_mm_set1_ps(float %19)
%21 = tail call i32 @_mm_mul_ps(i32 %6, i32 %20)
%22 = tail call i32 @_mm_add_ps(i32 %16, i32 %21)
%23 = or i64 %12, 2
%24 = getelementptr inbounds float, float* %2, i64 %23
%25 = load float, float* %24
%26 = tail call i32 @_mm_set1_ps(float %25)
%27 = tail call i32 @_mm_mul_ps(i32 %8, i32 %26)
%28 = tail call i32 @_mm_add_ps(i32 %22, i32 %27)
%29 = or i64 %12, 3
%30 = getelementptr inbounds float, float* %2, i64 %29
%31 = load float, float* %30
%32 = tail call i32 @_mm_set1_ps(float %31)
%33 = tail call i32 @_mm_mul_ps(i32 %10, i32 %32)
%34 = tail call i32 @_mm_add_ps(i32 %28, i32 %33)
%35 = getelementptr inbounds float, float* %0, i64 %12
%36 = tail call i32 @_mm_storeu_ps(float* %35, i32 %34)
%37 = add nuw nsw i64 %12, 4
%38 = icmp ult i64 %12, 12
br i1 %38, label %11, label %39
39: ; preds = %11
ret void
}