#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(void *, void const *, size_t);
int /*<<< orphan*/ stderr;
double ephcom_indouble(FILE *infp) {
  double x;
  static double retval;
  unsigned char ch[8];
  unsigned char *gnulliver64c(unsigned char *);
  size_t nread = fread(ch, 1, 8, infp);
  if (nread != 8) {
    fprintf(stderr, "Failed to read 8 bytes.");
    return 0;
  }
  (void)gnulliver64c(ch);
  memcpy((void *)&retval, (const void *)ch, (size_t)8);
  return (retval);
}


x86 assembly (clang, -O0):
<ephcom_indouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x8,-0x28(%rbp)
je     1194 <ephcom_indouble+0x54>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1050 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11bf <ephcom_indouble+0x7f>
lea    -0x20(%rbp),%rdi
call   1040 <gnulliver64c@plt>
lea    -0x20(%rbp),%rsi
lea    0x2ea0(%rip),%rdi
mov    $0x8,%edx
call   1060 <memcpy@plt>
movsd  0x2e8e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ephcom_indouble>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rcx
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
cmp    $0x8,%rax
jne    118d <ephcom_indouble+0x4d>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <gnulliver64c@plt>
lea    0x2ed2(%rip),%rdi
mov    $0x8,%edx
mov    %rbx,%rsi
call   1060 <memcpy@plt>
movsd  0x2ebd(%rip),%xmm0
jmp    11a5 <ephcom_indouble+0x65>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1050 <fprintf@plt>
xorps  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@ephcom_indouble.retval = internal global double 0.000000e+00
@stderr = global i32 0
@.str = [24 x i8] c"Failed to read 8 bytes.\00"
define double @ephcom_indouble(i32* %0) {
%2 = alloca double
%3 = alloca i32*
%4 = alloca double
%5 = alloca [8 x i8]
%6 = alloca i64
store i32* %0, i32** %3
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%8 = load i32*, i32** %3
%9 = call i64 @fread(i8* %7, i32 1, i32 8, i32* %8)
store i64 %9, i64* %6
%10 = load i64, i64* %6
%11 = icmp ne i64 %10, 8
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %21
15: ; preds = %1
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%17 = call i8* @gnulliver64c(i8* %16)
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%19 = call i32 @memcpy(i8* bitcast (double* @ephcom_indouble.retval to i8*), i8* %18, i64 8)
%20 = load double, double* @ephcom_indouble.retval
store double %20, double* %2
br label %21
21: ; preds = %15, %12
%22 = load double, double* %2
ret double %22
}

LLVM IR (-O2):
@ephcom_indouble.retval = internal global double 0.000000e+00
@stderr = global i32 0
@.str = [24 x i8] c"Failed to read 8 bytes.\00"
define double @ephcom_indouble(i32* nocapture %0) {
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%4 = call i64 @fread(i8* %3, i32 1, i32 8, i32* %0)
%5 = icmp eq i64 %4, 8
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %13
9: ; preds = %1
%10 = call i8* @gnulliver64c(i8* %3)
%11 = call i32 @memcpy(i8* bitcast (double* @ephcom_indouble.retval to i8*), i8* %3, i64 8)
%12 = load double, double* @ephcom_indouble.retval
br label %13
13: ; preds = %9, %6
%14 = phi double [ 0.000000e+00, %6 ], [ %12, %9 ]
ret double %14
}