#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*/ output_char(char);
int /*<<< orphan*/ output_q(long);
void output_double_binary(double d) {
  long exp;
  long exp_raw;
  long frac;
  long frac_raw;
  long sign;
  long lv;
  lv = *(long *)(&d);
  sign = 0x8000000000000000 & lv;
  frac_raw = (0x000FFFFFFFFFFFFF & lv);
  frac = frac_raw + 0x0010000000000000;
  exp_raw = 0x7FF0000000000000 & lv;
  exp_raw = exp_raw / 0x0010000000000000;
  exp = exp_raw - 1023 - 52;
  if (exp_raw == 0) {
    if (frac_raw == 0) {
      output_char('0');
      return;
    }
  }
  if (exp_raw == 0x7FF) {
    if (frac_raw == 0) {
      output_char('I');
      output_char('n');
      output_char('f');
      return;
    } else {
      output_char('N');
      output_char('a');
      output_char('N');
      output_char('s');
      return;
    }
  }
  if (sign == 0x8000000000000000) {
    output_char('-');
  }
  output_q(frac);
  output_char('L');
  output_char('*');
  output_char('2');
  output_char('*');
  output_char('*');
  output_q(exp);
  return;
}


x86 assembly (clang, -O0):
<output_double_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movabs $0x8000000000000000,%rax
and    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0xfffffffffffff,%rax
and    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
movabs $0x10000000000000,%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
movabs $0x7ff0000000000000,%rax
and    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movabs $0x10000000000000,%rcx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x3ff,%rax
sub    $0x34,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d0 <output_double_binary+0xb0>
cmpq   $0x0,-0x28(%rbp)
jne    11cb <output_double_binary+0xab>
mov    $0x30,%edi
call   1040 <output_char@plt>
jmp    129b <output_double_binary+0x17b>
jmp    11d0 <output_double_binary+0xb0>
cmpq   $0x7ff,-0x18(%rbp)
jne    1239 <output_double_binary+0x119>
cmpq   $0x0,-0x28(%rbp)
jne    120c <output_double_binary+0xec>
mov    $0x49,%edi
call   1040 <output_char@plt>
mov    $0x6e,%edi
call   1040 <output_char@plt>
mov    $0x66,%edi
call   1040 <output_char@plt>
jmp    129b <output_double_binary+0x17b>
mov    $0x4e,%edi
call   1040 <output_char@plt>
mov    $0x61,%edi
call   1040 <output_char@plt>
mov    $0x4e,%edi
call   1040 <output_char@plt>
mov    $0x73,%edi
call   1040 <output_char@plt>
jmp    129b <output_double_binary+0x17b>
movabs $0x8000000000000000,%rax
cmp    %rax,-0x30(%rbp)
jne    1257 <output_double_binary+0x137>
mov    $0x2d,%edi
call   1040 <output_char@plt>
mov    -0x20(%rbp),%rdi
call   1030 <output_q@plt>
mov    $0x4c,%edi
call   1040 <output_char@plt>
mov    $0x2a,%edi
call   1040 <output_char@plt>
mov    $0x32,%edi
call   1040 <output_char@plt>
mov    $0x2a,%edi
call   1040 <output_char@plt>
mov    $0x2a,%edi
call   1040 <output_char@plt>
mov    -0x10(%rbp),%rdi
call   1030 <output_q@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_double_binary>:
push   %r14
push   %rbx
push   %rax
movq   %xmm0,%rax
movabs $0xfffffffffffff,%rdx
mov    %rax,%rcx
and    %rdx,%rcx
mov    %rax,%rbx
shr    $0x34,%rbx
and    $0x7ff,%ebx
mov    %rbx,%rsi
or     %rcx,%rsi
je     1187 <output_double_binary+0x67>
cmp    $0x7ff,%ebx
jne    1191 <output_double_binary+0x71>
test   %rcx,%rcx
je     11f8 <output_double_binary+0xd8>
mov    $0x4e,%edi
call   1040 <output_char@plt>
mov    $0x61,%edi
call   1040 <output_char@plt>
mov    $0x4e,%edi
call   1040 <output_char@plt>
mov    $0x73,%edi
jmp    1211 <output_double_binary+0xf1>
mov    $0x30,%edi
jmp    1211 <output_double_binary+0xf1>
lea    (%rcx,%rdx,1),%r14
add    $0x1,%r14
add    $0xfffffffffffffbcd,%rbx
test   %rax,%rax
jns    11af <output_double_binary+0x8f>
mov    $0x2d,%edi
call   1040 <output_char@plt>
mov    %r14,%rdi
call   1030 <output_q@plt>
mov    $0x4c,%edi
call   1040 <output_char@plt>
mov    $0x2a,%edi
call   1040 <output_char@plt>
mov    $0x32,%edi
call   1040 <output_char@plt>
mov    $0x2a,%edi
call   1040 <output_char@plt>
mov    $0x2a,%edi
call   1040 <output_char@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <output_q@plt>
mov    $0x49,%edi
call   1040 <output_char@plt>
mov    $0x6e,%edi
call   1040 <output_char@plt>
mov    $0x66,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <output_char@plt>

LLVM IR (-O0):
define void @output_double_binary(double %0) {
%2 = alloca double
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store double %0, double* %2
%9 = bitcast double* %2 to i64*
%10 = load i64, i64* %9
store i64 %10, i64* %8
%11 = load i64, i64* %8
%12 = and i64 -9223372036854775808, %11
store i64 %12, i64* %7
%13 = load i64, i64* %8
%14 = and i64 4503599627370495, %13
store i64 %14, i64* %6
%15 = load i64, i64* %6
%16 = add nsw i64 %15, 4503599627370496
store i64 %16, i64* %5
%17 = load i64, i64* %8
%18 = and i64 9218868437227405312, %17
store i64 %18, i64* %4
%19 = load i64, i64* %4
%20 = sdiv i64 %19, 4503599627370496
store i64 %20, i64* %4
%21 = load i64, i64* %4
%22 = sub nsw i64 %21, 1023
%23 = sub nsw i64 %22, 52
store i64 %23, i64* %3
%24 = load i64, i64* %4
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %1
%27 = load i64, i64* %6
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @output_char(i8 signext 48)
br label %62
31: ; preds = %26
br label %32
32: ; preds = %31, %1
%33 = load i64, i64* %4
%34 = icmp eq i64 %33, 2047
br i1 %34, label %35, label %47
35: ; preds = %32
%36 = load i64, i64* %6
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = call i32 @output_char(i8 signext 73)
%40 = call i32 @output_char(i8 signext 110)
%41 = call i32 @output_char(i8 signext 102)
br label %62
42: ; preds = %35
%43 = call i32 @output_char(i8 signext 78)
%44 = call i32 @output_char(i8 signext 97)
%45 = call i32 @output_char(i8 signext 78)
%46 = call i32 @output_char(i8 signext 115)
br label %62
47: ; preds = %32
%48 = load i64, i64* %7
%49 = icmp eq i64 %48, -9223372036854775808
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @output_char(i8 signext 45)
br label %52
52: ; preds = %50, %47
%53 = load i64, i64* %5
%54 = call i32 @output_q(i64 %53)
%55 = call i32 @output_char(i8 signext 76)
%56 = call i32 @output_char(i8 signext 42)
%57 = call i32 @output_char(i8 signext 50)
%58 = call i32 @output_char(i8 signext 42)
%59 = call i32 @output_char(i8 signext 42)
%60 = load i64, i64* %3
%61 = call i32 @output_q(i64 %60)
br label %62
62: ; preds = %52, %42, %38, %29
ret void
}

LLVM IR (-O2):
define void @output_double_binary(double %0) {
%2 = bitcast double %0 to i64
%3 = and i64 %2, 4503599627370495
%4 = or i64 %3, 4503599627370496
%5 = lshr i64 %2, 52
%6 = and i64 %5, 2047
%7 = add nsw i64 %6, -1075
%8 = icmp eq i64 %3, 0
%9 = or i64 %6, %3
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = tail call i32 @output_char(i8 signext 48)
br label %37
13: ; preds = %1
%14 = icmp eq i64 %6, 2047
br i1 %14, label %15, label %25
15: ; preds = %13
br i1 %8, label %16, label %20
16: ; preds = %15
%17 = tail call i32 @output_char(i8 signext 73)
%18 = tail call i32 @output_char(i8 signext 110)
%19 = tail call i32 @output_char(i8 signext 102)
br label %37
20: ; preds = %15
%21 = tail call i32 @output_char(i8 signext 78)
%22 = tail call i32 @output_char(i8 signext 97)
%23 = tail call i32 @output_char(i8 signext 78)
%24 = tail call i32 @output_char(i8 signext 115)
br label %37
25: ; preds = %13
%26 = icmp slt i64 %2, 0
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = tail call i32 @output_char(i8 signext 45)
br label %29
29: ; preds = %27, %25
%30 = tail call i32 @output_q(i64 %4)
%31 = tail call i32 @output_char(i8 signext 76)
%32 = tail call i32 @output_char(i8 signext 42)
%33 = tail call i32 @output_char(i8 signext 50)
%34 = tail call i32 @output_char(i8 signext 42)
%35 = tail call i32 @output_char(i8 signext 42)
%36 = tail call i32 @output_q(i64 %7)
br label %37
37: ; preds = %29, %20, %16, %11
ret void
}