#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 NAN;
scalar_t__ isnan(float);
int /*<<< orphan*/ modff(float, float *);
float floorf(float x) {
  if (isnan(x)) {
    return NAN;
  }
  modff(x, &x);
  if (x < 0.0) {
    x -= 1.0;
  }
  return x;
}


x86 assembly (clang, -O0):
<floorf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1156 <floorf+0x36>
mov    0x2eb0(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11a2 <floorf+0x82>
movss  -0x8(%rbp),%xmm0
lea    -0x8(%rbp),%rdi
call   1030 <modff@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1198 <floorf+0x78>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe75(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floorf>:
push   %rax
movss  %xmm0,(%rsp)
movss  %xmm0,0x4(%rsp)
call   1040 <isnan@plt>
test   %rax,%rax
je     1143 <floorf+0x23>
mov    0x2ebb(%rip),%rax
movss  (%rax),%xmm0
pop    %rax
ret
mov    %rsp,%rdi
movss  0x4(%rsp),%xmm0
call   1030 <modff@plt>
movss  (%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jbe    116b <floorf+0x4b>
addss  0xe9a(%rip),%xmm0
movss  %xmm0,(%rsp)
pop    %rax
ret

LLVM IR (-O0):
@NAN = global float 0.000000e+00
define float @floorf(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %3
%4 = load float, float* %3
%5 = call i64 @isnan(float %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load float, float* @NAN
store float %8, float* %2
br label %22
9: ; preds = %1
%10 = load float, float* %3
%11 = call i32 @modff(float %10, float* %3)
%12 = load float, float* %3
%13 = fpext float %12 to double
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = load float, float* %3
%17 = fpext float %16 to double
%18 = fsub double %17, 1.000000e+00
%19 = fptrunc double %18 to float
store float %19, float* %3
br label %20
20: ; preds = %15, %9
%21 = load float, float* %3
store float %21, float* %2
br label %22
22: ; preds = %20, %7
%23 = load float, float* %2
ret float %23
}

LLVM IR (-O2):
@NAN = global float 0.000000e+00
define float @floorf(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = tail call i64 @isnan(float %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = load float, float* @NAN
br label %13
7: ; preds = %1
%8 = call i32 @modff(float %0, float* %2)
%9 = load float, float* %2
%10 = fcmp olt float %9, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = fadd float %9, -1.000000e+00
store float %12, float* %2
br label %13
13: ; preds = %5, %7, %11
%14 = phi float [ %6, %5 ], [ %12, %11 ], [ %9, %7 ]
ret float %14
}