#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 __m128;

/* Variables and functions */
int _mm_load_ps1(float const *);
int _mm_loadu_ps(float const *);
int _mm_setzero_ps();
int /*<<< orphan*/ _mm_storeu_ps(float *, int);
void Toeplitz_mat4(const float *a, const float *f, float *b) {
  __m128 ax, fx, bx = _mm_setzero_ps();
  for (int x = 0; x < 4; x++) {
    ax = _mm_loadu_ps(a + 3 - x);
    fx = _mm_load_ps1(f + x);
    bx = bx + ax * fx;
  }
  _mm_storeu_ps(b, bx);
}


x86 assembly (clang, -O0):
<Toeplitz_mat4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1060 <_mm_setzero_ps@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    11c3 <Toeplitz_mat4+0x83>
mov    -0x8(%rbp),%rdi
add    $0xc,%rdi
movslq -0x28(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1050 <_mm_loadu_ps@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <_mm_load_ps1@plt>
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1165 <Toeplitz_mat4+0x25>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <_mm_storeu_ps@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Toeplitz_mat4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
xor    %eax,%eax
call   1060 <_mm_setzero_ps@plt>
mov    %eax,%r12d
lea    0xc(%r15),%rdi
call   1050 <_mm_loadu_ps@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1030 <_mm_load_ps1@plt>
imul   %eax,%ebp
add    %r12d,%ebp
lea    0x8(%r15),%rdi
call   1050 <_mm_loadu_ps@plt>
mov    %eax,%ebx
lea    0x4(%r13),%rdi
call   1030 <_mm_load_ps1@plt>
imul   %eax,%ebx
add    %ebp,%ebx
lea    0x4(%r15),%rdi
call   1050 <_mm_loadu_ps@plt>
mov    %eax,%ebp
lea    0x8(%r13),%rdi
call   1030 <_mm_load_ps1@plt>
imul   %eax,%ebp
add    %ebx,%ebp
mov    %r15,%rdi
call   1050 <_mm_loadu_ps@plt>
mov    %eax,%ebx
add    $0xc,%r13
mov    %r13,%rdi
call   1030 <_mm_load_ps1@plt>
imul   %eax,%ebx
add    %ebp,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <_mm_storeu_ps@plt>

LLVM IR (-O0):
define void @Toeplitz_mat4(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
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%11 = call i32 (...) @_mm_setzero_ps()
store i32 %11, i32* %9
store i32 0, i32* %10
br label %12
12: ; preds = %33, %3
%13 = load i32, i32* %10
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %36
15: ; preds = %12
%16 = load float*, float** %4
%17 = getelementptr inbounds float, float* %16, i64 3
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = sub i64 0, %19
%21 = getelementptr inbounds float, float* %17, i64 %20
%22 = call i32 @_mm_loadu_ps(float* %21)
store i32 %22, i32* %7
%23 = load float*, float** %5
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds float, float* %23, i64 %25
%27 = call i32 @_mm_load_ps1(float* %26)
store i32 %27, i32* %8
%28 = load i32, i32* %9
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = mul nsw i32 %29, %30
%32 = add nsw i32 %28, %31
store i32 %32, i32* %9
br label %33
33: ; preds = %15
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %12
36: ; preds = %12
%37 = load float*, float** %6
%38 = load i32, i32* %9
%39 = call i32 @_mm_storeu_ps(float* %37, i32 %38)
ret void
}

LLVM IR (-O2):
define void @Toeplitz_mat4(float* %0, float* %1, float* %2) {
%4 = tail call i32 (...) @_mm_setzero_ps()
%5 = getelementptr inbounds float, float* %0, i64 3
%6 = tail call i32 @_mm_loadu_ps(float* %5)
%7 = tail call i32 @_mm_load_ps1(float* %1)
%8 = mul nsw i32 %7, %6
%9 = add nsw i32 %8, %4
%10 = getelementptr inbounds float, float* %0, i64 2
%11 = tail call i32 @_mm_loadu_ps(float* %10)
%12 = getelementptr inbounds float, float* %1, i64 1
%13 = tail call i32 @_mm_load_ps1(float* %12)
%14 = mul nsw i32 %13, %11
%15 = add nsw i32 %14, %9
%16 = getelementptr inbounds float, float* %0, i64 1
%17 = tail call i32 @_mm_loadu_ps(float* %16)
%18 = getelementptr inbounds float, float* %1, i64 2
%19 = tail call i32 @_mm_load_ps1(float* %18)
%20 = mul nsw i32 %19, %17
%21 = add nsw i32 %20, %15
%22 = tail call i32 @_mm_loadu_ps(float* %0)
%23 = getelementptr inbounds float, float* %1, i64 3
%24 = tail call i32 @_mm_load_ps1(float* %23)
%25 = mul nsw i32 %24, %22
%26 = add nsw i32 %25, %21
%27 = tail call i32 @_mm_storeu_ps(float* %2, i32 %26)
ret void
}