#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*/ double_to_binary(double, char *);
int /*<<< orphan*/ print_double_binary(double);
int /*<<< orphan*/ print_double_hex(double);
int /*<<< orphan*/ print_double_precision(double);
int /*<<< orphan*/ printf(char const *, ...);
void print_double(double d, const char *format) {
  char buf[65];
  buf[64] = 0;
  printf("%f\n", d);
  printf(format, d);
  printf("%.20f\n", d);
  print_double_hex(d);
  print_double_binary(d);
  double_to_binary(d, buf);
  printf("%s\n", buf);
  print_double_precision(d);
  printf("\n");
}


x86 assembly (clang, -O0):
<print_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movb   $0x0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    0xe8f(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
movsd  -0x8(%rbp),%xmm0
lea    0xe70(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  -0x8(%rbp),%xmm0
call   1040 <print_double_hex@plt>
movsd  -0x8(%rbp),%xmm0
call   1070 <print_double_binary@plt>
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rdi
call   1060 <double_to_binary@plt>
lea    -0x60(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x8(%rbp),%xmm0
call   1030 <print_double_precision@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_double>:
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
movsd  %xmm0,0x8(%rsp)
movb   $0x0,0x50(%rsp)
lea    0xe76(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xe5c(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x8(%rsp),%xmm0
call   1060 <print_double_hex@plt>
movsd  0x8(%rsp),%xmm0
call   1090 <print_double_binary@plt>
lea    0x10(%rsp),%rbx
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
call   1080 <double_to_binary@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
movsd  0x8(%rsp),%xmm0
call   1040 <print_double_precision@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [7 x i8] c"%.20f\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @print_double(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca [65 x i8]
store double %0, double* %3
store i8* %1, i8** %4
%6 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 64
store i8 0, i8* %6
%7 = load double, double* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %7)
%9 = load i8*, i8** %4
%10 = load double, double* %3
%11 = call i32 (i8*, ...) @printf(i8* %9, double %10)
%12 = load double, double* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %12)
%14 = load double, double* %3
%15 = call i32 @print_double_hex(double %14)
%16 = load double, double* %3
%17 = call i32 @print_double_binary(double %16)
%18 = load double, double* %3
%19 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%20 = call i32 @double_to_binary(double %18, i8* %19)
%21 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = load double, double* %3
%24 = call i32 @print_double_precision(double %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [7 x i8] c"%.20f\0A\00"
define void @print_double(double %0, i8* nocapture %1) {
%3 = alloca [65 x i8]
%4 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 64
store i8 0, i8* %5
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %0)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %1, double %0)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %0)
%9 = tail call i32 @print_double_hex(double %0)
%10 = tail call i32 @print_double_binary(double %0)
%11 = call i32 @double_to_binary(double %0, i8* %4)
%12 = call i32 @puts(i8* %4)
%13 = call i32 @print_double_precision(double %0)
%14 = call i32 @putchar(i32 10)
ret void
}