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

/* Variables and functions */
void *readUInt8(int /*<<< orphan*/ *);
double readDouble(FILE *f) {
  union {
    char c[8];
    double d;
  } data;
  data.c[3] = readUInt8(f);
  data.c[2] = readUInt8(f);
  data.c[1] = readUInt8(f);
  data.c[0] = readUInt8(f);
  data.c[7] = readUInt8(f);
  data.c[6] = readUInt8(f);
  data.c[5] = readUInt8(f);
  data.c[4] = readUInt8(f);
  return data.d;
}


x86 assembly (clang, -O0):
<readDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xe(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xf(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xb(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xc(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readDouble>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <readUInt8@plt>
mov    %rax,%r15
shl    $0x18,%r15d
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%ebx
shl    $0x10,%rbx
or     %r15,%rbx
mov    %r14,%rdi
call   1030 <readUInt8@plt>
shl    $0x8,%eax
movzwl %ax,%r15d
or     %rbx,%r15
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%r12d
or     %r15,%r12
mov    %r14,%rdi
call   1030 <readUInt8@plt>
mov    %rax,%rbx
shl    $0x38,%rbx
or     %r12,%rbx
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%r15d
shl    $0x30,%r15
or     %rbx,%r15
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%ebx
shl    $0x28,%rbx
or     %r15,%rbx
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%eax
shl    $0x20,%rax
or     %rbx,%rax
movq   %rax,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%union.anon = type { double }
define double @readDouble(i32* %0) {
%2 = alloca i32*
%3 = alloca %union.anon
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i8* @readUInt8(i32* %4)
%6 = ptrtoint i8* %5 to i8
%7 = bitcast %union.anon* %3 to [8 x i8]*
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 3
store i8 %6, i8* %8
%9 = load i32*, i32** %2
%10 = call i8* @readUInt8(i32* %9)
%11 = ptrtoint i8* %10 to i8
%12 = bitcast %union.anon* %3 to [8 x i8]*
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 2
store i8 %11, i8* %13
%14 = load i32*, i32** %2
%15 = call i8* @readUInt8(i32* %14)
%16 = ptrtoint i8* %15 to i8
%17 = bitcast %union.anon* %3 to [8 x i8]*
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %17, i64 0, i64 1
store i8 %16, i8* %18
%19 = load i32*, i32** %2
%20 = call i8* @readUInt8(i32* %19)
%21 = ptrtoint i8* %20 to i8
%22 = bitcast %union.anon* %3 to [8 x i8]*
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %22, i64 0, i64 0
store i8 %21, i8* %23
%24 = load i32*, i32** %2
%25 = call i8* @readUInt8(i32* %24)
%26 = ptrtoint i8* %25 to i8
%27 = bitcast %union.anon* %3 to [8 x i8]*
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %27, i64 0, i64 7
store i8 %26, i8* %28
%29 = load i32*, i32** %2
%30 = call i8* @readUInt8(i32* %29)
%31 = ptrtoint i8* %30 to i8
%32 = bitcast %union.anon* %3 to [8 x i8]*
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %32, i64 0, i64 6
store i8 %31, i8* %33
%34 = load i32*, i32** %2
%35 = call i8* @readUInt8(i32* %34)
%36 = ptrtoint i8* %35 to i8
%37 = bitcast %union.anon* %3 to [8 x i8]*
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %37, i64 0, i64 5
store i8 %36, i8* %38
%39 = load i32*, i32** %2
%40 = call i8* @readUInt8(i32* %39)
%41 = ptrtoint i8* %40 to i8
%42 = bitcast %union.anon* %3 to [8 x i8]*
%43 = getelementptr inbounds [8 x i8], [8 x i8]* %42, i64 0, i64 4
store i8 %41, i8* %43
%44 = bitcast %union.anon* %3 to double*
%45 = load double, double* %44
ret double %45
}

LLVM IR (-O2):
define double @readDouble(i32* %0) {
%2 = tail call i8* @readUInt8(i32* %0)
%3 = ptrtoint i8* %2 to i64
%4 = shl i64 %3, 24
%5 = and i64 %4, 4278190080
%6 = tail call i8* @readUInt8(i32* %0)
%7 = ptrtoint i8* %6 to i64
%8 = shl i64 %7, 16
%9 = and i64 %8, 16711680
%10 = or i64 %9, %5
%11 = tail call i8* @readUInt8(i32* %0)
%12 = ptrtoint i8* %11 to i64
%13 = shl i64 %12, 8
%14 = and i64 %13, 65280
%15 = or i64 %10, %14
%16 = tail call i8* @readUInt8(i32* %0)
%17 = ptrtoint i8* %16 to i64
%18 = and i64 %17, 255
%19 = or i64 %15, %18
%20 = tail call i8* @readUInt8(i32* %0)
%21 = ptrtoint i8* %20 to i64
%22 = shl i64 %21, 56
%23 = or i64 %19, %22
%24 = tail call i8* @readUInt8(i32* %0)
%25 = ptrtoint i8* %24 to i64
%26 = shl i64 %25, 48
%27 = and i64 %26, 71776119061217280
%28 = tail call i8* @readUInt8(i32* %0)
%29 = ptrtoint i8* %28 to i64
%30 = shl i64 %29, 40
%31 = and i64 %30, 280375465082880
%32 = or i64 %23, %27
%33 = tail call i8* @readUInt8(i32* %0)
%34 = ptrtoint i8* %33 to i64
%35 = shl i64 %34, 32
%36 = and i64 %35, 1095216660480
%37 = or i64 %32, %31
%38 = or i64 %37, %36
%39 = bitcast i64 %38 to double
ret double %39
}