#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 FP_INFINITE;
int FP_NAN;
int FP_NORMAL;
int FP_SUBNORMAL;
int FP_ZERO;
scalar_t__ __ESBMC_isinf(double);
scalar_t__ __ESBMC_isnan(double);
scalar_t__ __ESBMC_isnormal(double);
int __fpclassifyd(double d) {
  if (__ESBMC_isnan(d))
    return FP_NAN;
  if (__ESBMC_isinf(d))
    return FP_INFINITE;
  if (d == 0)
    return FP_ZERO;
  if (__ESBMC_isnormal(d))
    return FP_NORMAL;
  return FP_SUBNORMAL;
}


x86 assembly (clang, -O0):
<__fpclassifyd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <__ESBMC_isnan@plt>
cmp    $0x0,%rax
je     1162 <__fpclassifyd+0x32>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e1 <__fpclassifyd+0xb1>
movsd  -0x10(%rbp),%xmm0
call   1030 <__ESBMC_isinf@plt>
cmp    $0x0,%rax
je     1187 <__fpclassifyd+0x57>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e1 <__fpclassifyd+0xb1>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b0 <__fpclassifyd+0x80>
jp     11b0 <__fpclassifyd+0x80>
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e1 <__fpclassifyd+0xb1>
movsd  -0x10(%rbp),%xmm0
call   1040 <__ESBMC_isnormal@plt>
cmp    $0x0,%rax
je     11d5 <__fpclassifyd+0xa5>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e1 <__fpclassifyd+0xb1>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__fpclassifyd>:
push   %rax
movsd  %xmm0,(%rsp)
call   1050 <__ESBMC_isnan@plt>
test   %rax,%rax
je     1149 <__fpclassifyd+0x19>
mov    0x2e99(%rip),%rax
jmp    119a <__fpclassifyd+0x6a>
movsd  (%rsp),%xmm0
call   1030 <__ESBMC_isinf@plt>
test   %rax,%rax
je     1161 <__fpclassifyd+0x31>
mov    0x2e79(%rip),%rax
jmp    119a <__fpclassifyd+0x6a>
xorpd  %xmm0,%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    117b <__fpclassifyd+0x4b>
jp     117b <__fpclassifyd+0x4b>
mov    0x2e57(%rip),%rax
jmp    119a <__fpclassifyd+0x6a>
movsd  (%rsp),%xmm0
call   1040 <__ESBMC_isnormal@plt>
test   %rax,%rax
jne    1193 <__fpclassifyd+0x63>
mov    0x2e2f(%rip),%rax
jmp    119a <__fpclassifyd+0x6a>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@FP_NAN = global i32 0
@FP_INFINITE = global i32 0
@FP_ZERO = global i32 0
@FP_NORMAL = global i32 0
@FP_SUBNORMAL = global i32 0
define i32 @__fpclassifyd(double %0) {
%2 = alloca i32
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = call i64 @__ESBMC_isnan(double %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32, i32* @FP_NAN
store i32 %8, i32* %2
br label %28
9: ; preds = %1
%10 = load double, double* %3
%11 = call i64 @__ESBMC_isinf(double %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i32, i32* @FP_INFINITE
store i32 %14, i32* %2
br label %28
15: ; preds = %9
%16 = load double, double* %3
%17 = fcmp oeq double %16, 0.000000e+00
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i32, i32* @FP_ZERO
store i32 %19, i32* %2
br label %28
20: ; preds = %15
%21 = load double, double* %3
%22 = call i64 @__ESBMC_isnormal(double %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i32, i32* @FP_NORMAL
store i32 %25, i32* %2
br label %28
26: ; preds = %20
%27 = load i32, i32* @FP_SUBNORMAL
store i32 %27, i32* %2
br label %28
28: ; preds = %26, %24, %18, %13, %7
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@FP_NAN = global i32 0
@FP_INFINITE = global i32 0
@FP_ZERO = global i32 0
@FP_NORMAL = global i32 0
@FP_SUBNORMAL = global i32 0
define i32 @__fpclassifyd(double %0) {
%2 = tail call i64 @__ESBMC_isnan(double %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = tail call i64 @__ESBMC_isinf(double %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = fcmp oeq double %0, 0.000000e+00
br i1 %8, label %13, label %9
9: ; preds = %7
%10 = tail call i64 @__ESBMC_isnormal(double %0)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32* @FP_SUBNORMAL, i32* @FP_NORMAL
br label %13
13: ; preds = %9, %7, %4, %1
%14 = phi i32* [ @FP_NAN, %1 ], [ @FP_INFINITE, %4 ], [ @FP_ZERO, %7 ], [ %12, %9 ]
%15 = load i32, i32* %14
ret i32 %15
}