#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*/ ConvertToDouble(unsigned char *, double *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int i;
  double val;
  unsigned char buf[8] = {0, 0, 0, 0, 0xff, 0xff, 0xe0, 0x3f};
  ConvertToDouble(buf, &val);
  fprintf(stdout, "buf=");
  for (i = 0; i < 8; i++)
    fprintf(stdout, "%.2x", buf[i]);
  fprintf(stdout, "\n");
  fprintf(stdout, "val=%g\n", val);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <ConvertToDouble@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11a4 <main+0x84>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rax
movzbl -0x28(%rbp,%rax,1),%edx
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <main+0x4c>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
movsd  -0x20(%rbp),%xmm0
lea    0xe42(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x3fe0ffff00000000,%rax
ff e0 3f
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <ConvertToDouble@plt>
mov    0x2e94(%rip),%rbx
mov    (%rbx),%edi
lea    0xeab(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0x8(%rsp),%edx
lea    0xe9b(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0x9(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0xa(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0xb(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0xc(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0xd(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0xe(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movzbl 0xf(%rsp),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe1c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movsd  0x10(%rsp),%xmm0
lea    0xe00(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.buf = [8 x i8] c"\00\00\00\00\FF\FF\E0?"
@stdout = global i32 0
@.str = [5 x i8] c"buf=\00"
@.str.1 = [5 x i8] c"%.2x\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [8 x i8] c"val=%g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca [8 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [8 x i8]* %8 to i8*
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%11 = call i32 @ConvertToDouble(i8* %10, double* %7)
%12 = load i32, i32* @stdout
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %14
14: ; preds = %25, %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 8
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i32, i32* @stdout
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %17
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %14
28: ; preds = %14
%29 = load i32, i32* @stdout
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @stdout
%32 = load double, double* %7
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %32)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [5 x i8] c"buf=\00"
@.str.1 = [5 x i8] c"%.2x\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [8 x i8] c"val=%g\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca double
%4 = alloca i64
%5 = bitcast i64* %4 to [8 x i8]*
%6 = bitcast double* %3 to i8*
%7 = bitcast i64* %4 to i8*
store i64 4602960289854390272, i64* %4
%8 = call i32 @ConvertToDouble(i8* %7, double* %3)
%9 = load i32, i32* @stdout
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stdout
%12 = bitcast i64* %4 to i8*
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @stdout
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @stdout
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 2
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @stdout
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 3
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @stdout
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 4
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* @stdout
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 5
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* @stdout
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 6
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* @stdout
%47 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 7
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = load i32, i32* @stdout
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32, i32* @stdout
%54 = load double, double* %3
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %54)
ret i32 0
}