#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 */
int /*<<< orphan*/ abs(double);
double floor(int /*<<< orphan*/);
scalar_t__ isinf(double);
scalar_t__ isnan(double);
double jsV_numbertointeger(double n) {
  double sign = n < 0 ? -1 : 1;
  if (isnan(n))
    return 0;
  if (n == 0 || isinf(n))
    return n;
  return sign * floor(abs(n));
}


x86 assembly (clang, -O0):
<jsV_numbertointeger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
xorps  %xmm0,%xmm0
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1190 <jsV_numbertointeger+0x50>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fc <jsV_numbertointeger+0xbc>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ad <jsV_numbertointeger+0x6d>
jp     11ad <jsV_numbertointeger+0x6d>
jmp    11c1 <jsV_numbertointeger+0x81>
movsd  -0x10(%rbp),%xmm0
call   1060 <isinf@plt>
cmp    $0x0,%rax
je     11d0 <jsV_numbertointeger+0x90>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fc <jsV_numbertointeger+0xbc>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <abs@plt>
mov    %eax,%edi
call   1050 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jsV_numbertointeger>:
sub    $0x18,%rsp
movapd %xmm0,(%rsp)
call   1040 <isnan@plt>
xorpd  %xmm0,%xmm0
test   %rax,%rax
je     115c <jsV_numbertointeger+0x1c>
add    $0x18,%rsp
ret
xorpd  %xmm0,%xmm0
movapd (%rsp),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jne    1171 <jsV_numbertointeger+0x31>
jnp    1157 <jsV_numbertointeger+0x17>
call   1060 <isinf@plt>
test   %rax,%rax
je     1184 <jsV_numbertointeger+0x44>
movaps (%rsp),%xmm0
add    $0x18,%rsp
ret
movapd (%rsp),%xmm0
call   1030 <abs@plt>
mov    %eax,%edi
call   1050 <floor@plt>
movapd 0xe63(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd (%rsp),%xmm3
cmpltsd %xmm2,%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm3,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @jsV_numbertointeger(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
%5 = load double, double* %3
%6 = fcmp olt double %5, 0.000000e+00
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 -1, i32 1
%9 = sitofp i32 %8 to double
store double %9, double* %4
%10 = load double, double* %3
%11 = call i64 @isnan(double %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %1
store double 0.000000e+00, double* %2
br label %29
14: ; preds = %1
%15 = load double, double* %3
%16 = fcmp oeq double %15, 0.000000e+00
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load double, double* %3
%19 = call i64 @isinf(double %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17, %14
%22 = load double, double* %3
store double %22, double* %2
br label %29
23: ; preds = %17
%24 = load double, double* %4
%25 = load double, double* %3
%26 = call i32 @abs(double %25)
%27 = call double @floor(i32 %26)
%28 = fmul double %24, %27
store double %28, double* %2
br label %29
29: ; preds = %23, %21, %13
%30 = load double, double* %2
ret double %30
}

LLVM IR (-O2):
define double @jsV_numbertointeger(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = tail call i64 @isnan(double %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = fcmp oeq double %0, 0.000000e+00
br i1 %6, label %15, label %7
7: ; preds = %5
%8 = tail call i64 @isinf(double %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = tail call i32 @abs(double %0)
%12 = tail call double @floor(i32 %11)
%13 = fneg double %12
%14 = select i1 %2, double %13, double %12
br label %15
15: ; preds = %5, %7, %1, %10
%16 = phi double [ %14, %10 ], [ 0.000000e+00, %1 ], [ %0, %7 ], [ %0, %5 ]
ret double %16
}