#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 */
double modf(double, double *);
double floor(double d) {
  double fract;
  if (d < 0) {
    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
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11aa <floor+0x9a>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
lea    -0x8(%rbp),%rdi
call   1030 <modf@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1172 <floor+0x62>
jp     1172 <floor+0x62>
jmp    1184 <floor+0x74>
movsd  0xe86(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b8 <floor+0xa8>
movsd  -0x8(%rbp),%xmm0
lea    -0x8(%rbp),%rdi
call   1030 <modf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floor>:
push   %rax
movsd  %xmm0,(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1169 <floor+0x59>
xorpd  0xed8(%rip),%xmm0
mov    %rsp,%rdi
call   1030 <modf@plt>
movsd  (%rsp),%xmm1
movsd  0xed3(%rip),%xmm2
addsd  %xmm1,%xmm2
cmpneqsd 0xece(%rip),%xmm0
movapd %xmm0,%xmm3
andnpd %xmm1,%xmm3
andpd  %xmm2,%xmm0
orpd   %xmm3,%xmm0
xorpd  0xe9e(%rip),%xmm0
movlpd %xmm0,(%rsp)
pop    %rax
ret
mov    %rsp,%rdi
call   1030 <modf@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

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

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