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

/* Variables and functions */
scalar_t__ malloc(unsigned long);
char *bits_of_double(double d) {
  unsigned long byte_count = sizeof(d);
  unsigned char *bytes = (unsigned char *)&d;
  char *bits_of_double = (char *)malloc(byte_count * 8 + 1);
  bits_of_double[byte_count * 8] = 0;
  unsigned char byte;
  int i, j, k;
  for (i = byte_count, j = 0; i > 0; i--) {
    byte = bytes[i - 1];
    for (k = j + 8; j < k; j++) {
      if (byte & 0x80) {
        bits_of_double[j] = '1';
      } else {
        bits_of_double[j] = '0';
      }
      byte = byte << 1;
    }
  }
  return bits_of_double;
}


x86 assembly (clang, -O0):
<bits_of_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movq   $0x8,-0x10(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
shl    $0x3,%rdi
add    $0x1,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x3,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    11ec <bits_of_double+0xdc>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    11d9 <bits_of_double+0xc9>
movzbl -0x21(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11b5 <bits_of_double+0xa5>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    11c1 <bits_of_double+0xb1>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
movzbl -0x21(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x21(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1186 <bits_of_double+0x76>
jmp    11de <bits_of_double+0xce>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1160 <bits_of_double+0x50>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bits_of_double>:
push   %rax
movsd  %xmm0,(%rsp)
mov    $0x41,%edi
call   1030 <malloc@plt>
movb   $0x0,0x40(%rax)
movq   (%rsp),%xmm0
pxor   %xmm5,%xmm5
punpcklbw %xmm5,%xmm0
pshufd $0x4e,%xmm0,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm4
packuswb %xmm4,%xmm4
pcmpeqd %xmm1,%xmm1
movdqa %xmm4,%xmm9
pcmpgtb %xmm1,%xmm9
movdqa 0xea6(%rip),%xmm6
paddb  %xmm6,%xmm9
movdqa 0xea9(%rip),%xmm1
pand   %xmm4,%xmm1
pcmpeqb %xmm5,%xmm1
paddb  %xmm6,%xmm1
punpcklbw %xmm1,%xmm9
movdqa 0xe9f(%rip),%xmm10
pand   %xmm4,%xmm10
pcmpeqb %xmm5,%xmm10
paddb  %xmm6,%xmm10
movdqa 0xe98(%rip),%xmm2
pand   %xmm4,%xmm2
pcmpeqb %xmm5,%xmm2
paddb  %xmm6,%xmm2
punpcklbw %xmm2,%xmm10
movdqa 0xe8e(%rip),%xmm11
pand   %xmm4,%xmm11
pcmpeqb %xmm5,%xmm11
paddb  %xmm6,%xmm11
movdqa 0xe87(%rip),%xmm3
pand   %xmm4,%xmm3
pcmpeqb %xmm5,%xmm3
paddb  %xmm6,%xmm3
punpcklbw %xmm3,%xmm11
movdqa 0xe7e(%rip),%xmm3
pand   %xmm4,%xmm3
pcmpeqb %xmm5,%xmm3
pand   0xe7e(%rip),%xmm4
por    0xe86(%rip),%xmm4
paddb  %xmm6,%xmm3
punpcklbw %xmm4,%xmm3
pshufhw $0xe8,%xmm3,%xmm4
pshufd $0xe8,%xmm4,%xmm5
movdqa 0xe7c(%rip),%xmm0
movdqa %xmm0,%xmm6
pandn  %xmm5,%xmm6
pshufhw $0xf6,%xmm11,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pand   %xmm0,%xmm5
por    %xmm6,%xmm5
pshufd $0xed,%xmm5,%xmm8
pshufhw $0xe8,%xmm10,%xmm5
pshufd $0xf6,%xmm5,%xmm6
movdqa 0xe58(%rip),%xmm2
movdqa %xmm2,%xmm5
pandn  %xmm6,%xmm5
pshufd $0xff,%xmm9,%xmm6
pshufhw $0x55,%xmm6,%xmm6
pand   %xmm2,%xmm6
por    %xmm5,%xmm6
pshufd $0xe8,%xmm6,%xmm6
punpckldq %xmm8,%xmm6
pshufhw $0x60,%xmm3,%xmm5
pshufd $0xe8,%xmm5,%xmm5
movdqa %xmm0,%xmm4
pandn  %xmm5,%xmm4
pshufhw $0xd4,%xmm11,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pand   %xmm0,%xmm5
por    %xmm4,%xmm5
pshufd $0xed,%xmm5,%xmm4
pshufhw $0x60,%xmm10,%xmm5
pshufd $0xf6,%xmm5,%xmm5
movdqa %xmm2,%xmm7
pandn  %xmm5,%xmm7
pshufd $0xaa,%xmm9,%xmm5
pshufhw $0x55,%xmm5,%xmm5
pand   %xmm2,%xmm5
por    %xmm7,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm4,%xmm5
pshuflw $0xe8,%xmm3,%xmm4
pshufd $0x60,%xmm4,%xmm4
movdqa %xmm0,%xmm7
pandn  %xmm4,%xmm7
pshuflw $0xf6,%xmm11,%xmm4
pshufd $0x60,%xmm4,%xmm4
pand   %xmm0,%xmm4
por    %xmm7,%xmm4
pshufd $0xed,%xmm4,%xmm4
pshuflw $0xe8,%xmm10,%xmm7
pshufd $0xd4,%xmm7,%xmm7
movdqa %xmm2,%xmm1
pandn  %xmm7,%xmm1
pshufd $0x55,%xmm9,%xmm7
pshufhw $0x55,%xmm7,%xmm7
pand   %xmm2,%xmm7
por    %xmm1,%xmm7
pshufd $0xe8,%xmm7,%xmm1
punpckldq %xmm4,%xmm1
pshuflw $0x60,%xmm3,%xmm3
pshufd $0x60,%xmm3,%xmm3
pshuflw $0xd4,%xmm11,%xmm4
pshufd $0x60,%xmm4,%xmm4
pand   %xmm0,%xmm4
pandn  %xmm3,%xmm0
por    %xmm4,%xmm0
pshufd $0xed,%xmm0,%xmm0
pshuflw $0x60,%xmm10,%xmm3
pshufd $0xd4,%xmm3,%xmm3
pshufd $0x0,%xmm9,%xmm4
pshufhw $0x55,%xmm4,%xmm4
pand   %xmm2,%xmm4
pandn  %xmm3,%xmm2
por    %xmm4,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm0,%xmm2
movdqu %xmm2,(%rax)
movdqu %xmm1,0x10(%rax)
movdqu %xmm5,0x20(%rax)
movdqu %xmm6,0x30(%rax)
pop    %rcx
ret

LLVM IR (-O0):
define i8* @bits_of_double(double %0) {
%2 = alloca double
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store double %0, double* %2
store i64 8, i64* %3
%10 = bitcast double* %2 to i8*
store i8* %10, i8** %4
%11 = load i64, i64* %3
%12 = mul i64 %11, 8
%13 = add i64 %12, 1
%14 = call i64 @malloc(i64 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = load i64, i64* %3
%18 = mul i64 %17, 8
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 0, i8* %19
%20 = load i64, i64* %3
%21 = trunc i64 %20 to i32
store i32 %21, i32* %7
store i32 0, i32* %8
br label %22
22: ; preds = %62, %1
%23 = load i32, i32* %7
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %65
25: ; preds = %22
%26 = load i8*, i8** %4
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
%31 = load i8, i8* %30
store i8 %31, i8* %6
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 8
store i32 %33, i32* %9
br label %34
34: ; preds = %58, %25
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %61
38: ; preds = %34
%39 = load i8, i8* %6
%40 = zext i8 %39 to i32
%41 = and i32 %40, 128
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %38
%44 = load i8*, i8** %5
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
store i8 49, i8* %47
br label %53
48: ; preds = %38
%49 = load i8*, i8** %5
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
store i8 48, i8* %52
br label %53
53: ; preds = %48, %43
%54 = load i8, i8* %6
%55 = zext i8 %54 to i32
%56 = shl i32 %55, 1
%57 = trunc i32 %56 to i8
store i8 %57, i8* %6
br label %58
58: ; preds = %53
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %34
61: ; preds = %34
br label %62
62: ; preds = %61
%63 = load i32, i32* %7
%64 = add nsw i32 %63, -1
store i32 %64, i32* %7
br label %22
65: ; preds = %22
%66 = load i8*, i8** %5
ret i8* %66
}

LLVM IR (-O2):
define i8* @bits_of_double(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = tail call i64 @malloc(i64 65)
%4 = inttoptr i64 %3 to i8*
%5 = getelementptr inbounds i8, i8* %4, i64 64
store i8 0, i8* %5
%6 = bitcast double* %2 to <8 x i8>*
%7 = load <8 x i8>, <8 x i8>* %6
%8 = shufflevector <8 x i8> %7, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%9 = icmp sgt <8 x i8> %8, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
%10 = select <8 x i1> %9, <8 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <8 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%11 = and <8 x i8> %8, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
%12 = icmp eq <8 x i8> %11, zeroinitializer
%13 = select <8 x i1> %12, <8 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <8 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%14 = and <8 x i8> %8, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%15 = icmp eq <8 x i8> %14, zeroinitializer
%16 = select <8 x i1> %15, <8 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <8 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%17 = and <8 x i8> %8, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%18 = icmp eq <8 x i8> %17, zeroinitializer
%19 = select <8 x i1> %18, <8 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <8 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%20 = and <8 x i8> %8, <i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8>
%21 = icmp eq <8 x i8> %20, zeroinitializer
%22 = select <8 x i1> %21, <8 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <8 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%23 = and <8 x i8> %8, <i8 4, i8 4, i8 4, i8 4, i8 4, i8 4, i8 4, i8 4>
%24 = icmp eq <8 x i8> %23, zeroinitializer
%25 = select <8 x i1> %24, <8 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <8 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%26 = and <8 x i8> %8, <i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2>
%27 = icmp eq <8 x i8> %26, zeroinitializer
%28 = select <8 x i1> %27, <8 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <8 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%29 = and <8 x i8> %8, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%30 = or <8 x i8> %29, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%31 = inttoptr i64 %3 to <64 x i8>*
%32 = shufflevector <8 x i8> %10, <8 x i8> %13, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
%33 = shufflevector <8 x i8> %16, <8 x i8> %19, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
%34 = shufflevector <8 x i8> %22, <8 x i8> %25, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
%35 = shufflevector <8 x i8> %28, <8 x i8> %30, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
%36 = shufflevector <16 x i8> %32, <16 x i8> %33, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
%37 = shufflevector <16 x i8> %34, <16 x i8> %35, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
%38 = shufflevector <32 x i8> %36, <32 x i8> %37, <64 x i32> <i32 0, i32 8, i32 16, i32 24, i32 32, i32 40, i32 48, i32 56, i32 1, i32 9, i32 17, i32 25, i32 33, i32 41, i32 49, i32 57, i32 2, i32 10, i32 18, i32 26, i32 34, i32 42, i32 50, i32 58, i32 3, i32 11, i32 19, i32 27, i32 35, i32 43, i32 51, i32 59, i32 4, i32 12, i32 20, i32 28, i32 36, i32 44, i32 52, i32 60, i32 5, i32 13, i32 21, i32 29, i32 37, i32 45, i32 53, i32 61, i32 6, i32 14, i32 22, i32 30, i32 38, i32 46, i32 54, i32 62, i32 7, i32 15, i32 23, i32 31, i32 39, i32 47, i32 55, i32 63>
store <64 x i8> %38, <64 x i8>* %31
ret i8* %4
}