#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*/ const);
int /*<<< orphan*/ _mm_and_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_andnot_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_cmpeq_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_or_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ const _mm_set1_ps(float);
int /*<<< orphan*/ _mm_sub_ps(int /*<<< orphan*/, int /*<<< orphan*/ const);
__m128 floor_sse(__m128 v) {
  const __m128 round32 = _mm_set1_ps(12582912.0f);
  __m128 rounded = _mm_sub_ps(_mm_add_ps(v, round32), round32);
  __m128 mask = _mm_cmpeq_ps(v, rounded);
  __m128 floored = _mm_sub_ps(
      _mm_add_ps(_mm_sub_ps(v, _mm_set1_ps(0.5f)), round32), round32);
  return _mm_or_ps(_mm_and_ps(v, mask), _mm_andnot_ps(mask, floored));
}


x86 assembly (clang, -O0):
<floor_sse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movss  0xe81(%rip),%xmm0
call   1050 <_mm_set1_ps@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <_mm_add_ps@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1040 <_mm_sub_ps@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <_mm_cmpeq_ps@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movss  0xe41(%rip),%xmm0
call   1050 <_mm_set1_ps@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1040 <_mm_sub_ps@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1060 <_mm_add_ps@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1040 <_mm_sub_ps@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1090 <_mm_and_ps@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1080 <_mm_andnot_ps@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_or_ps@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floor_sse>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
movss  0xe82(%rip),%xmm0
call   1050 <_mm_set1_ps@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1060 <_mm_add_ps@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1040 <_mm_sub_ps@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <_mm_cmpeq_ps@plt>
mov    %eax,%r14d
movss  0xe59(%rip),%xmm0
call   1050 <_mm_set1_ps@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <_mm_sub_ps@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <_mm_add_ps@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1040 <_mm_sub_ps@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r14d,%esi
call   1090 <_mm_and_ps@plt>
mov    %eax,%ebx
mov    %r14d,%edi
mov    %ebp,%esi
call   1080 <_mm_andnot_ps@plt>
mov    %ebx,%edi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <_mm_or_ps@plt>

LLVM IR (-O0):
define i32 @floor_sse(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = call i32 @_mm_set1_ps(float 0x4168000000000000)
store i32 %7, i32* %3
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call i32 @_mm_add_ps(i32 %8, i32 %9)
%11 = load i32, i32* %3
%12 = call i32 @_mm_sub_ps(i32 %10, i32 %11)
store i32 %12, i32* %4
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = call i32 @_mm_cmpeq_ps(i32 %13, i32 %14)
store i32 %15, i32* %5
%16 = load i32, i32* %2
%17 = call i32 @_mm_set1_ps(float 5.000000e-01)
%18 = call i32 @_mm_sub_ps(i32 %16, i32 %17)
%19 = load i32, i32* %3
%20 = call i32 @_mm_add_ps(i32 %18, i32 %19)
%21 = load i32, i32* %3
%22 = call i32 @_mm_sub_ps(i32 %20, i32 %21)
store i32 %22, i32* %6
%23 = load i32, i32* %2
%24 = load i32, i32* %5
%25 = call i32 @_mm_and_ps(i32 %23, i32 %24)
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 @_mm_andnot_ps(i32 %26, i32 %27)
%29 = call i32 @_mm_or_ps(i32 %25, i32 %28)
ret i32 %29
}

LLVM IR (-O2):
define i32 @floor_sse(i32 %0) {
%2 = tail call i32 @_mm_set1_ps(float 0x4168000000000000)
%3 = tail call i32 @_mm_add_ps(i32 %0, i32 %2)
%4 = tail call i32 @_mm_sub_ps(i32 %3, i32 %2)
%5 = tail call i32 @_mm_cmpeq_ps(i32 %0, i32 %4)
%6 = tail call i32 @_mm_set1_ps(float 5.000000e-01)
%7 = tail call i32 @_mm_sub_ps(i32 %0, i32 %6)
%8 = tail call i32 @_mm_add_ps(i32 %7, i32 %2)
%9 = tail call i32 @_mm_sub_ps(i32 %8, i32 %2)
%10 = tail call i32 @_mm_and_ps(i32 %0, i32 %5)
%11 = tail call i32 @_mm_andnot_ps(i32 %5, i32 %9)
%12 = tail call i32 @_mm_or_ps(i32 %10, i32 %11)
ret i32 %12
}