#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 double uint64_t;

/* Variables and functions */
double rdtsc();
int /*<<< orphan*/ test(int, int);
double run(int size, int stride) {
  uint64_t start_cycles, end_cycles, diff;
  int elems = size / sizeof(int);
  test(elems, stride);
  start_cycles = rdtsc();
  test(elems, stride);
  end_cycles = rdtsc();
  diff = end_cycles - start_cycles;
  return (size / stride) / (diff / .9 * 1024.0 * 1024.0);
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shr    $0x2,%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <test@plt>
mov    $0x0,%al
call   1030 <rdtsc@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <test@plt>
mov    $0x0,%al
call   1030 <rdtsc@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cvtsi2sd %eax,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe7a(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xe66(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe5a(%rip),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%r14d
mov    %edi,%ebp
sar    $0x2,%ebp
mov    %ebp,%edi
call   1040 <test@plt>
xor    %eax,%eax
call   1030 <rdtsc@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <test@plt>
xor    %eax,%eax
call   1030 <rdtsc@plt>
subsd  0x8(%rsp),%xmm0
mov    %r14d,%eax
cltd
idiv   %ebx
cvtsi2sd %eax,%xmm1
divsd  0xe92(%rip),%xmm0
movsd  0xe92(%rip),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @run(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = udiv i64 %10, 4
%12 = trunc i64 %11 to i32
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = load i32, i32* %4
%15 = call i32 @test(i32 %13, i32 %14)
%16 = call double (...) @rdtsc()
store double %16, double* %5
%17 = load i32, i32* %8
%18 = load i32, i32* %4
%19 = call i32 @test(i32 %17, i32 %18)
%20 = call double (...) @rdtsc()
store double %20, double* %6
%21 = load double, double* %6
%22 = load double, double* %5
%23 = fsub double %21, %22
store double %23, double* %7
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = sdiv i32 %24, %25
%27 = sitofp i32 %26 to double
%28 = load double, double* %7
%29 = fdiv double %28, 9.000000e-01
%30 = fmul double %29, 1.024000e+03
%31 = fmul double %30, 1.024000e+03
%32 = fdiv double %27, %31
ret double %32
}

LLVM IR (-O2):
define double @run(i32 %0, i32 %1) {
%3 = ashr i32 %0, 2
%4 = tail call i32 @test(i32 %3, i32 %1)
%5 = tail call double (...) @rdtsc()
%6 = tail call i32 @test(i32 %3, i32 %1)
%7 = tail call double (...) @rdtsc()
%8 = fsub double %7, %5
%9 = sdiv i32 %0, %1
%10 = sitofp i32 %9 to double
%11 = fdiv double %8, 9.000000e-01
%12 = fmul double %11, 1.024000e+03
%13 = fmul double %12, 1.024000e+03
%14 = fdiv double %10, %13
ret double %14
}