#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 */

/* Variables and functions */
float modf(float, float *);
float floor(float d) {
  float fract;
  if (d < 0.0) {
    d = -d;
    fract = modf(d, &d);
    if (fract != 0.0)
      d += 1;
    d = -d;
  } else
    modf(d, &d);
  return (d);
}


x86 assembly (clang, -O0):
<floor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11ac <floor+0x9c>
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
lea    -0x4(%rbp),%rdi
call   1030 <modf@plt>
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117e <floor+0x6e>
jp     117e <floor+0x6e>
jmp    1190 <floor+0x80>
movss  0xe7a(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11ba <floor+0xaa>
movss  -0x4(%rbp),%xmm0
lea    -0x4(%rbp),%rdi
call   1030 <modf@plt>
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floor>:
push   %rax
movss  %xmm0,0x4(%rsp)
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jbe    116c <floor+0x5c>
xorps  0xeda(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <modf@plt>
movss  0x4(%rsp),%xmm1
movss  0xecc(%rip),%xmm2
addss  %xmm1,%xmm2
cmpneqss 0xec3(%rip),%xmm0
movaps %xmm0,%xmm3
andnps %xmm1,%xmm3
andps  %xmm2,%xmm0
orps   %xmm3,%xmm0
xorps  0xe9c(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
pop    %rax
ret
lea    0x4(%rsp),%rdi
call   1030 <modf@plt>
movss  0x4(%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @floor(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %2
%4 = load float, float* %2
%5 = fpext float %4 to double
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %21
7: ; preds = %1
%8 = load float, float* %2
%9 = fneg float %8
store float %9, float* %2
%10 = load float, float* %2
%11 = call float @modf(float %10, float* %2)
store float %11, float* %3
%12 = load float, float* %3
%13 = fpext float %12 to double
%14 = fcmp une double %13, 0.000000e+00
br i1 %14, label %15, label %18
15: ; preds = %7
%16 = load float, float* %2
%17 = fadd float %16, 1.000000e+00
store float %17, float* %2
br label %18
18: ; preds = %15, %7
%19 = load float, float* %2
%20 = fneg float %19
store float %20, float* %2
br label %24
21: ; preds = %1
%22 = load float, float* %2
%23 = call float @modf(float %22, float* %2)
br label %24
24: ; preds = %21, %18
%25 = load float, float* %2
ret float %25
}

LLVM IR (-O2):
define float @floor(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = fcmp olt float %0, 0.000000e+00
br i1 %3, label %4, label %12
4: ; preds = %1
%5 = fneg float %0
store float %5, float* %2
%6 = call float @modf(float %5, float* %2)
%7 = fcmp une float %6, 0.000000e+00
%8 = load float, float* %2
%9 = fadd float %8, 1.000000e+00
%10 = select i1 %7, float %9, float %8
%11 = fneg float %10
store float %11, float* %2
br label %15
12: ; preds = %1
%13 = call float @modf(float %0, float* %2)
%14 = load float, float* %2
br label %15
15: ; preds = %12, %4
%16 = phi float [ %14, %12 ], [ %11, %4 ]
ret float %16
}