#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 */
typedef int uint64_t;
typedef scalar_t__ int32_t;

/* Variables and functions */
scalar_t__ DBL_MIN;
scalar_t__ fabsk(double);
scalar_t__ xisinf(double);
scalar_t__ xisnan(double);
__attribute__((visibility("default"))) const int xexpfrexp(double x) {
  union {
    double f;
    uint64_t u;
  } cx;
  int ret = 0;
  if (fabsk(x) < DBL_MIN) {
    x *= (1ULL << 63);
    ret = -63;
  }
  cx.f = x;
  ret += (int32_t)(((cx.u >> 52) & 0x7ff)) - 0x3fe;
  if (x == 0 || xisnan(x) || xisinf(x))
    ret = 0;
  return ret;
}


x86 assembly (clang, -O0):
<xexpfrexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <fabsk@plt>
mov    0x2e8b(%rip),%rcx
cmp    (%rcx),%rax
jge    1177 <xexpfrexp+0x47>
movsd  0xe9a(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0xffffffc1,-0x14(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x34,%ecx
sar    %cl,%eax
and    $0x7ff,%eax
movslq %eax,%rcx
sub    $0x3fe,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c1 <xexpfrexp+0x91>
jp     11c1 <xexpfrexp+0x91>
jmp    11e9 <xexpfrexp+0xb9>
movsd  -0x8(%rbp),%xmm0
call   1030 <xisnan@plt>
cmp    $0x0,%rax
jne    11e9 <xexpfrexp+0xb9>
movsd  -0x8(%rbp),%xmm0
call   1040 <xisinf@plt>
cmp    $0x0,%rax
je     11f0 <xexpfrexp+0xc0>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xexpfrexp>:
push   %rax
movsd  %xmm0,(%rsp)
call   1050 <fabsk@plt>
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
jl     114e <xexpfrexp+0x1e>
movsd  (%rsp),%xmm0
jmp    115b <xexpfrexp+0x2b>
movsd  (%rsp),%xmm0
mulsd  0xea5(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1167 <xexpfrexp+0x37>
jnp    1180 <xexpfrexp+0x50>
movsd  %xmm0,(%rsp)
call   1030 <xisnan@plt>
movsd  (%rsp),%xmm0
test   %rax,%rax
jne    1180 <xexpfrexp+0x50>
call   1040 <xisinf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%union.anon = type { double }
@DBL_MIN = global i64 0
define i32 @xexpfrexp(double %0) {
%2 = alloca double
%3 = alloca %union.anon
%4 = alloca i32
store double %0, double* %2
store i32 0, i32* %4
%5 = load double, double* %2
%6 = call i64 @fabsk(double %5)
%7 = load i64, i64* @DBL_MIN
%8 = icmp slt i64 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load double, double* %2
%11 = fmul double %10, 0x43E0000000000000
store double %11, double* %2
store i32 -63, i32* %4
br label %12
12: ; preds = %9, %1
%13 = load double, double* %2
%14 = bitcast %union.anon* %3 to double*
store double %13, double* %14
%15 = bitcast %union.anon* %3 to i32*
%16 = load i32, i32* %15
%17 = ashr i32 %16, 52
%18 = and i32 %17, 2047
%19 = sext i32 %18 to i64
%20 = sub nsw i64 %19, 1022
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = add nsw i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %4
%25 = load double, double* %2
%26 = fcmp oeq double %25, 0.000000e+00
br i1 %26, label %35, label %27
27: ; preds = %12
%28 = load double, double* %2
%29 = call i64 @xisnan(double %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load double, double* %2
%33 = call i64 @xisinf(double %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31, %27, %12
store i32 0, i32* %4
br label %36
36: ; preds = %35, %31
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@DBL_MIN = global i64 0
define i32 @xexpfrexp(double %0) {
%2 = tail call i64 @fabsk(double %0)
%3 = load i64, i64* @DBL_MIN
%4 = icmp slt i64 %2, %3
%5 = fmul double %0, 0x43E0000000000000
%6 = select i1 %4, double %5, double %0
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = tail call i64 @xisnan(double %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i64 @xisinf(double %6)
br label %13
13: ; preds = %11, %1, %8
ret i32 0
}