#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 fabs(double);
double floor(double);
double __dnint(double x) {
  if (fabs(x) >= 4503599627370496.0)
    return (x);
  else
    return (x >= 0.0 ? floor(x + .5) : -floor(.5 - x));
}


x86 assembly (clang, -O0):
<__dnint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xee7(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xecb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     114e <__dnint+0x3e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b4 <__dnint+0xa4>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     117c <__dnint+0x6c>
movsd  0xea0(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    11aa <__dnint+0x9a>
movsd  0xe84(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1030 <floor@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__dnint>:
push   %rax
movapd 0xee7(%rip),%xmm1
andpd  %xmm0,%xmm1
ucomisd 0xefb(%rip),%xmm1
jae    114e <__dnint+0x3e>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    1150 <__dnint+0x40>
movsd  0xeef(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <floor@plt>
xorpd  0xec2(%rip),%xmm0
pop    %rax
ret
addsd  0xed0(%rip),%xmm0
pop    %rax
jmp    1030 <floor@plt>

LLVM IR (-O0):
define double @__dnint(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = call double @llvm.fabs.f64(double %4)
%6 = fcmp oge double %5, 0x4330000000000000
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load double, double* %3
store double %8, double* %2
br label %23
9: ; preds = %1
%10 = load double, double* %3
%11 = fcmp oge double %10, 0.000000e+00
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load double, double* %3
%14 = fadd double %13, 5.000000e-01
%15 = call double @llvm.floor.f64(double %14)
br label %21
16: ; preds = %9
%17 = load double, double* %3
%18 = fsub double 5.000000e-01, %17
%19 = call double @llvm.floor.f64(double %18)
%20 = fneg double %19
br label %21
21: ; preds = %16, %12
%22 = phi double [ %15, %12 ], [ %20, %16 ]
store double %22, double* %2
br label %23
23: ; preds = %21, %7
%24 = load double, double* %2
ret double %24
}

LLVM IR (-O2):
define double @__dnint(double %0) {
%2 = tail call double @llvm.fabs.f64(double %0)
%3 = fcmp ult double %2, 0x4330000000000000
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = fcmp ult double %0, 0.000000e+00
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = fadd double %0, 5.000000e-01
%8 = tail call double @llvm.floor.f64(double %7)
br label %13
9: ; preds = %4
%10 = fsub double 5.000000e-01, %0
%11 = tail call double @llvm.floor.f64(double %10)
%12 = fneg double %11
br label %13
13: ; preds = %6, %9, %1
%14 = phi double [ %0, %1 ], [ %8, %6 ], [ %12, %9 ]
ret double %14
}