#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 */
double now();
int /*<<< orphan*/ printf(char *, ...);
void do_test(int (*fun)(const char *fileName), const char *fileName,
             const char *testName) {
  double total_time;
  double start_time = now();
  int value = fun(fileName);
  total_time = now() - start_time;
  printf("-- %-3s %-5s -- ", "gcc", testName, value);
  printf("It took %7.6f seconds to read %d GiB. That's %10.2f MiB/s.\n",
         total_time, 10, (10 * 1024) / total_time);
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1040 <now@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdi
call   *%rax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <now@plt>
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
lea    0xe9c(%rip),%rdi
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe79(%rip),%xmm1
divsd  -0x20(%rbp),%xmm1
lea    0xe8a(%rip),%rdi
mov    $0xa,%esi
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1040 <now@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   *%r15
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <now@plt>
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xea7(%rip),%rdi
lea    0xeb1(%rip),%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0xe84(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
divsd  %xmm0,%xmm1
lea    0xe90(%rip),%rdi
mov    $0xa,%esi
mov    $0x2,%al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"-- %-3s %-5s -- \00"
@.str.1 = [4 x i8] c"gcc\00"
@.str.2 = [60 x i8] c"It took %7.6f seconds to read %d GiB. That's %10.2f MiB/s.\0A\00"
define void @do_test(i32 (i8*)* %0, i8* %1, i8* %2) {
%4 = alloca i32 (i8*)*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i32 (i8*)* %0, i32 (i8*)** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = call double (...) @now()
store double %10, double* %8
%11 = load i32 (i8*)*, i32 (i8*)** %4
%12 = load i8*, i8** %5
%13 = call i32 %11(i8* %12)
store i32 %13, i32* %9
%14 = call double (...) @now()
%15 = load double, double* %8
%16 = fsub double %14, %15
store double %16, double* %7
%17 = load i8*, i8** %6
%18 = load i32, i32* %9
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %18)
%20 = load double, double* %7
%21 = load double, double* %7
%22 = fdiv double 1.024000e+04, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), double %20, i32 10, double %22)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"-- %-3s %-5s -- \00"
@.str.1 = [4 x i8] c"gcc\00"
@.str.2 = [60 x i8] c"It took %7.6f seconds to read %d GiB. That's %10.2f MiB/s.\0A\00"
define void @do_test(i32 (i8*)* nocapture %0, i8* %1, i8* %2) {
%4 = tail call double (...) @now()
%5 = tail call i32 %0(i8* %1)
%6 = tail call double (...) @now()
%7 = fsub double %6, %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %5)
%9 = fdiv double 1.024000e+04, %7
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), double %7, i32 10, double %9)
ret void
}