#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 benchRead(unsigned int, double *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int, double, double);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ threadedBench(unsigned int, double *, unsigned int);
void bench(unsigned int size, double *buffer, unsigned int nbThread) {
  double t, a;
  unsigned int rsize;
  if (buffer == NULL) {
    fprintf(stderr, "Can't run on NULL buffer\n");
    exit(1);
  }
  if (nbThread > 1) {
    threadedBench(size, buffer, nbThread);
  } else {
    t = benchRead(size, buffer);
    a = 0;
    rsize = sizeof(double) * size;
    printf("%i ko\t%i\t%g\t%g\n", rsize / 1024, size, t, a);
  }
}


x86 assembly (clang, -O0):
<bench>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118c <bench+0x3c>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x1,-0x14(%rbp)
jbe    11aa <bench+0x5a>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <threadedBench@plt>
jmp    11ec <bench+0x9c>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <benchRead@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
shr    $0xa,%esi
mov    -0x4(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bench>:
push   %rbx
test   %rsi,%rsi
je     1189 <bench+0x39>
mov    %edi,%ebx
cmp    $0x2,%edx
jb     1165 <bench+0x15>
mov    %ebx,%edi
pop    %rbx
jmp    1030 <threadedBench@plt>
mov    %ebx,%edi
call   1060 <benchRead@plt>
mov    %ebx,%esi
shr    $0x7,%esi
and    $0x3fffff,%esi
lea    0xe9c(%rip),%rdi
xorps  %xmm1,%xmm1
mov    %ebx,%edx
pop    %rbx
jmp    1040 <printf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Can't run on NULL buffer\0A\00"
@.str.1 = [16 x i8] c"%i ko\09%i\09%g\09%g\0A\00"
define void @bench(i32 %0, double* %1, i32 %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i32 %0, i32* %4
store double* %1, double** %5
store i32 %2, i32* %6
%10 = load double*, double** %5
%11 = icmp eq double* %10, null
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %3
%17 = load i32, i32* %6
%18 = icmp ugt i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32, i32* %4
%21 = load double*, double** %5
%22 = load i32, i32* %6
%23 = call i32 @threadedBench(i32 %20, double* %21, i32 %22)
br label %38
24: ; preds = %16
%25 = load i32, i32* %4
%26 = load double*, double** %5
%27 = call double @benchRead(i32 %25, double* %26)
store double %27, double* %7
store double 0.000000e+00, double* %8
%28 = load i32, i32* %4
%29 = zext i32 %28 to i64
%30 = mul i64 8, %29
%31 = trunc i64 %30 to i32
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = udiv i32 %32, 1024
%34 = load i32, i32* %4
%35 = load double, double* %7
%36 = load double, double* %8
%37 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %34, double %35, double %36)
br label %38
38: ; preds = %24, %19
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Can't run on NULL buffer\0A\00"
@.str.1 = [16 x i8] c"%i ko\09%i\09%g\09%g\0A\00"
define void @bench(i32 %0, double* %1, i32 %2) {
%4 = icmp eq double* %1, null
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %3
%10 = icmp ugt i32 %2, 1
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 @threadedBench(i32 %0, double* %1, i32 %2)
br label %18
13: ; preds = %9
%14 = tail call double @benchRead(i32 %0, double* %1)
%15 = lshr i32 %0, 7
%16 = and i32 %15, 4194303
%17 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %0, double %14, double 0.000000e+00)
br label %18
18: ; preds = %13, %11
ret void
}