#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 u_int;

/* Variables and functions */
double frexp(double value, int *eptr) {
  union {
    double v;
    struct {
      u_int u_mant1 : 7;
      u_int u_exp : 8;
      u_int u_sign : 1;
      u_int u_mant2 : 16;
      u_int u_mant3 : 32;
    } s;
  } u;
  if (value) {
    u.v = value;
    *eptr = u.s.u_exp - 128;
    u.s.u_exp = 128;
    return (u.v);
  } else {
    *eptr = 0;
    return (0.0);
  }
}


x86 assembly (clang, -O0):
<frexp>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    112a <frexp+0x2a>
jp     112a <frexp+0x2a>
jmp    1171 <frexp+0x71>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x31,%rax
sar    $0x38,%rax
mov    %eax,%ecx
sub    $0x80,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
and    $0xffffffffffff807f,%rax
or     $0x4000,%rax
mov    %rax,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1183 <frexp+0x83>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<frexp>:
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1110 <frexp+0x10>
jnp    1134 <frexp+0x34>
movq   %xmm1,%rax
mov    %eax,%ecx
shr    $0x7,%ecx
movsbl %cl,%ecx
add    $0xffffff80,%ecx
mov    %ecx,(%rdi)
and    $0xffffffffffff807f,%rax
or     $0x4000,%rax
movq   %rax,%xmm0
ret
movl   $0x0,(%rdi)
ret

LLVM IR (-O0):
%union.anon = type { double }
%struct.anon = type { i64 }
define double @frexp(double %0, i32* %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32*
%6 = alloca %union.anon
store double %0, double* %4
store i32* %1, i32** %5
%7 = load double, double* %4
%8 = fcmp une double %7, 0.000000e+00
br i1 %8, label %9, label %27
9: ; preds = %2
%10 = load double, double* %4
%11 = bitcast %union.anon* %6 to double*
store double %10, double* %11
%12 = bitcast %union.anon* %6 to %struct.anon*
%13 = bitcast %struct.anon* %12 to i64*
%14 = load i64, i64* %13
%15 = shl i64 %14, 49
%16 = ashr i64 %15, 56
%17 = trunc i64 %16 to i32
%18 = sub nsw i32 %17, 128
%19 = load i32*, i32** %5
store i32 %18, i32* %19
%20 = bitcast %union.anon* %6 to %struct.anon*
%21 = bitcast %struct.anon* %20 to i64*
%22 = load i64, i64* %21
%23 = and i64 %22, -32641
%24 = or i64 %23, 16384
store i64 %24, i64* %21
%25 = bitcast %union.anon* %6 to double*
%26 = load double, double* %25
store double %26, double* %3
br label %29
27: ; preds = %2
%28 = load i32*, i32** %5
store i32 0, i32* %28
store double 0.000000e+00, double* %3
br label %29
29: ; preds = %27, %9
%30 = load double, double* %3
ret double %30
}

LLVM IR (-O2):
define double @frexp(double %0, i32* nocapture writeonly %1) {
%3 = fcmp une double %0, 0.000000e+00
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = bitcast double %0 to i64
%6 = shl i64 %5, 49
%7 = ashr i64 %6, 56
%8 = trunc i64 %7 to i32
%9 = add nsw i32 %8, -128
store i32 %9, i32* %1
%10 = and i64 %5, -32641
%11 = or i64 %10, 16384
%12 = bitcast i64 %11 to double
br label %14
13: ; preds = %2
store i32 0, i32* %1
br label %14
14: ; preds = %13, %4
%15 = phi double [ %12, %4 ], [ 0.000000e+00, %13 ]
ret double %15
}