#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 */
char readUInt8(int /*<<< orphan*/ *);
double readDouble(FILE *f) {
  char data[8];
  data[4] = readUInt8(f);
  data[5] = readUInt8(f);
  data[6] = readUInt8(f);
  data[7] = readUInt8(f);
  data[0] = readUInt8(f);
  data[1] = readUInt8(f);
  data[2] = readUInt8(f);
  data[3] = readUInt8(f);
  return *((double *)data);
}


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,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xb(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xf(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xe(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <readUInt8@plt>
mov    %al,-0xd(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readDouble>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <readUInt8@plt>
movzbl %al,%r15d
shl    $0x20,%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,%r15d
shl    $0x30,%r15
or     %rbx,%r15
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%ebx
shl    $0x38,%rbx
or     %r15,%rbx
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%r15d
or     %rbx,%r15
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%ebx
shl    $0x8,%rbx
or     %r15,%rbx
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%r15d
shl    $0x10,%r15
or     %rbx,%r15
mov    %r14,%rdi
call   1030 <readUInt8@plt>
movzbl %al,%eax
shl    $0x18,%rax
or     %r15,%rax
movq   %rax,%xmm0
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @readDouble(i32* %0) {
%2 = alloca i32*
%3 = alloca [8 x i8]
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call signext i8 @readUInt8(i32* %4)
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 4
store i8 %5, i8* %6
%7 = load i32*, i32** %2
%8 = call signext i8 @readUInt8(i32* %7)
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 5
store i8 %8, i8* %9
%10 = load i32*, i32** %2
%11 = call signext i8 @readUInt8(i32* %10)
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 6
store i8 %11, i8* %12
%13 = load i32*, i32** %2
%14 = call signext i8 @readUInt8(i32* %13)
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 7
store i8 %14, i8* %15
%16 = load i32*, i32** %2
%17 = call signext i8 @readUInt8(i32* %16)
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
store i8 %17, i8* %18
%19 = load i32*, i32** %2
%20 = call signext i8 @readUInt8(i32* %19)
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
store i8 %20, i8* %21
%22 = load i32*, i32** %2
%23 = call signext i8 @readUInt8(i32* %22)
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 2
store i8 %23, i8* %24
%25 = load i32*, i32** %2
%26 = call signext i8 @readUInt8(i32* %25)
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 3
store i8 %26, i8* %27
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%29 = bitcast i8* %28 to double*
%30 = load double, double* %29
ret double %30
}

LLVM IR (-O2):
define double @readDouble(i32* %0) {
%2 = tail call signext i8 @readUInt8(i32* %0)
%3 = zext i8 %2 to i64
%4 = shl nuw nsw i64 %3, 32
%5 = tail call signext i8 @readUInt8(i32* %0)
%6 = zext i8 %5 to i64
%7 = shl nuw nsw i64 %6, 40
%8 = or i64 %7, %4
%9 = tail call signext i8 @readUInt8(i32* %0)
%10 = zext i8 %9 to i64
%11 = shl nuw nsw i64 %10, 48
%12 = or i64 %8, %11
%13 = tail call signext i8 @readUInt8(i32* %0)
%14 = zext i8 %13 to i64
%15 = shl nuw i64 %14, 56
%16 = or i64 %12, %15
%17 = tail call signext i8 @readUInt8(i32* %0)
%18 = zext i8 %17 to i64
%19 = or i64 %16, %18
%20 = tail call signext i8 @readUInt8(i32* %0)
%21 = zext i8 %20 to i64
%22 = shl nuw nsw i64 %21, 8
%23 = tail call signext i8 @readUInt8(i32* %0)
%24 = zext i8 %23 to i64
%25 = shl nuw nsw i64 %24, 16
%26 = or i64 %19, %22
%27 = tail call signext i8 @readUInt8(i32* %0)
%28 = zext i8 %27 to i64
%29 = shl nuw nsw i64 %28, 24
%30 = or i64 %26, %25
%31 = or i64 %30, %29
%32 = bitcast i64 %31 to double
ret double %32
}