#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 scalar_t__ time_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fread(double *, int, int const, int /*<<< orphan*/ *);
scalar_t__ time(int /*<<< orphan*/ *);
int read_bin_onego(const char *fname, double *data, const int ndata) {
  FILE *fp;
  time_t start, end;
  fp = fopen(fname, "rb");
  assert(fp);
  start = time(NULL);
  fread(data, sizeof(double), ndata, fp);
  end = time(NULL);
  fclose(fp);
  return (int)(end - start);
}


x86 assembly (clang, -O0):
<read_bin_onego>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x8,%esi
call   1030 <fread@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_bin_onego>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r15
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <assert@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    $0x8,%esi
mov    %r14d,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <fclose@plt>
sub    %r12d,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
define i32 @read_bin_onego(i8* %0, double* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
store i8* %0, i8** %4
store double* %1, double** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = call i32 @assert(i32* %12)
%14 = call i64 @time(i32* null)
store i64 %14, i64* %8
%15 = load double*, double** %5
%16 = load i32, i32* %6
%17 = load i32*, i32** %7
%18 = call i32 @fread(double* %15, i32 8, i32 %16, i32* %17)
%19 = call i64 @time(i32* null)
store i64 %19, i64* %9
%20 = load i32*, i32** %7
%21 = call i32 @fclose(i32* %20)
%22 = load i64, i64* %9
%23 = load i64, i64* %8
%24 = sub nsw i64 %22, %23
%25 = trunc i64 %24 to i32
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define i32 @read_bin_onego(i8* nocapture %0, double* nocapture %1, i32 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @assert(i32* %4)
%6 = tail call i64 @time(i32* null)
%7 = tail call i32 @fread(double* %1, i32 8, i32 %2, i32* %4)
%8 = tail call i64 @time(i32* null)
%9 = tail call i32 @fclose(i32* %4)
%10 = sub nsw i64 %8, %6
%11 = trunc i64 %10 to i32
ret i32 %11
}