#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 /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ bit_array_to_byte_array(int /*<<< orphan*/ *, int,
                                           int /*<<< orphan*/ *);
int /*<<< orphan*/ byte_array_to_string(int /*<<< orphan*/ *, int, char *);
int /*<<< orphan*/ double_to_bit_array_diy_big(double, int /*<<< orphan*/ *);
int /*<<< orphan*/ double_to_bit_array_native(double, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
void show(double f, const char *str) {
  char s[100];
  uint8_t bit[64], byte[8];
  printf("Bit representation of %.20lf (%s):\n", f, str);
  double_to_bit_array_native(f, bit);
  bit_array_to_byte_array(bit, 8, byte);
  byte_array_to_string(byte, 8, s);
  printf("Native (current computer structure):\n%s\n", s);
  double_to_bit_array_diy_big(f, bit);
  bit_array_to_byte_array(bit, 8, byte);
  byte_array_to_string(byte, 8, s);
  printf("DIY in big endian: \n%s\n", s);
  puts("");
}


x86 assembly (clang, -O0):
<show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
lea    -0x180(%rbp),%rdi
call   1080 <double_to_bit_array_native@plt>
lea    -0x180(%rbp),%rdi
lea    -0x1a0(%rbp),%rdx
mov    $0x8,%esi
call   1050 <bit_array_to_byte_array@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x80(%rbp),%rdx
mov    $0x8,%esi
call   1070 <byte_array_to_string@plt>
lea    -0x80(%rbp),%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
lea    -0x180(%rbp),%rdi
call   1060 <double_to_bit_array_diy_big@plt>
lea    -0x180(%rbp),%rdi
lea    -0x1a0(%rbp),%rdx
mov    $0x8,%esi
call   1050 <bit_array_to_byte_array@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x80(%rbp),%rdx
mov    $0x8,%esi
call   1070 <byte_array_to_string@plt>
lea    -0x80(%rbp),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf1(%rip),%rdi
call   1030 <puts@plt>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
mov    %rdi,%rsi
movsd  %xmm0,0x8(%rsp)
lea    0xe84(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xa0(%rsp),%r15
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
call   1080 <double_to_bit_array_native@plt>
lea    0x10(%rsp),%rbx
mov    %r15,%rdi
mov    $0x8,%esi
mov    %rbx,%rdx
call   1050 <bit_array_to_byte_array@plt>
lea    0x30(%rsp),%r14
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %r14,%rdx
call   1070 <byte_array_to_string@plt>
lea    0xe5a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
call   1060 <double_to_bit_array_diy_big@plt>
mov    %r15,%rdi
mov    $0x8,%esi
mov    %rbx,%rdx
call   1050 <bit_array_to_byte_array@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %r14,%rdx
call   1070 <byte_array_to_string@plt>
lea    0xe44(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Bit representation of %.20lf (%s):\0A\00"
@.str.1 = [41 x i8] c"Native (current computer structure):\0A%s\0A\00"
@.str.2 = [24 x i8] c"DIY in big endian: \0A%s\0A\00"
@.str.3 = [1 x i8] zeroinitializer
define void @show(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca [100 x i8]
%6 = alloca [64 x i32]
%7 = alloca [8 x i32]
store double %0, double* %3
store i8* %1, i8** %4
%8 = load double, double* %3
%9 = load i8*, i8** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), double %8, i8* %9)
%11 = load double, double* %3
%12 = getelementptr inbounds [64 x i32], [64 x i32]* %6, i64 0, i64 0
%13 = call i32 @double_to_bit_array_native(double %11, i32* %12)
%14 = getelementptr inbounds [64 x i32], [64 x i32]* %6, i64 0, i64 0
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%16 = call i32 @bit_array_to_byte_array(i32* %14, i32 8, i32* %15)
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%19 = call i32 @byte_array_to_string(i32* %17, i32 8, i8* %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load double, double* %3
%23 = getelementptr inbounds [64 x i32], [64 x i32]* %6, i64 0, i64 0
%24 = call i32 @double_to_bit_array_diy_big(double %22, i32* %23)
%25 = getelementptr inbounds [64 x i32], [64 x i32]* %6, i64 0, i64 0
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%27 = call i32 @bit_array_to_byte_array(i32* %25, i32 8, i32* %26)
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%30 = call i32 @byte_array_to_string(i32* %28, i32 8, i8* %29)
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Bit representation of %.20lf (%s):\0A\00"
@.str.1 = [41 x i8] c"Native (current computer structure):\0A%s\0A\00"
@.str.2 = [24 x i8] c"DIY in big endian: \0A%s\0A\00"
define void @show(double %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = alloca [64 x i32]
%5 = alloca [8 x i32]
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = bitcast [64 x i32]* %4 to i8*
%8 = bitcast [8 x i32]* %5 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), double %0, i8* %1)
%10 = getelementptr inbounds [64 x i32], [64 x i32]* %4, i64 0, i64 0
%11 = call i32 @double_to_bit_array_native(double %0, i32* %10)
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 0
%13 = call i32 @bit_array_to_byte_array(i32* %10, i32 8, i32* %12)
%14 = call i32 @byte_array_to_string(i32* %12, i32 8, i8* %6)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%16 = call i32 @double_to_bit_array_diy_big(double %0, i32* %10)
%17 = call i32 @bit_array_to_byte_array(i32* %10, i32 8, i32* %12)
%18 = call i32 @byte_array_to_string(i32* %12, i32 8, i8* %6)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%20 = call i32 @putchar(i32 10)
ret void
}