// File: mburhanpurkar[P]fast_xorshift_plus/example.cpp
// Function: time_xorshift_plus(float*, int, int, int, int)
static void time_xorshift_plus(float *out, int niter, int ny, int nx, int stride)
{
    assert(nx % 8 == 0);
    rng_helpers::xorshift_plus x;

    // Start timing
    struct timeval tv0 = rng_helpers::get_time();
    
    for (int iter = 0; iter < niter; iter++)
        for (int ifreq = 0; ifreq < ny; ifreq++)
            for (int it = 0; it < nx; it += 8)
	        x.gen_floats(out + ifreq * stride + it);

    // Stop timing
    struct timeval tv1 = rng_helpers::get_time();
    double dt = rng_helpers::time_diff(tv0, tv1);
    double noutputs = double(niter) * double(ny) * double(nx);
    double ns_per_output = 1.0e9 * dt / noutputs;

    cout << "time_xorshift_plus: ns_per_output = " << ns_per_output << endl;
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movl %esi, 0xac(%rsp)
movl %edx, 0xa8(%rsp)
movl %ecx, 0xa4(%rsp)
movl %r8d, 0xa0(%rsp)
movl 0xa4(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x2732
jmp 0x2751
leaq 0x293c(%rip), %rdi      # 0x5075
leaq 0x2941(%rip), %rsi      # 0x5081
movl $0x2d, %edx
leaq 0x2941(%rip), %rcx      # 0x508d
callq 0x20d0
leaq 0x88(%rsp), %rdi
callq 0x35f0
callq 0x2c50
movq %rdx, 0x28(%rsp)
movq %rax, 0x30(%rsp)
jmp 0x276f
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x78(%rsp)
movq %rax, 0x80(%rsp)
movl $0x0, 0x68(%rsp)
movl 0x68(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x2855
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0xa8(%rsp), %eax
jge 0x2843
movl $0x0, 0x60(%rsp)
movl 0x60(%rsp), %eax
cmpl 0xa4(%rsp), %eax
jge 0x2831
movq 0xb0(%rsp), %rax
movl 0x64(%rsp), %ecx
movl 0xa0(%rsp), %edx
imull %edx, %ecx
movslq %ecx, %rcx
leaq (%rax,%rcx,4), %rax
movslq 0x60(%rsp), %rcx
leaq (%rax,%rcx,4), %rsi
leaq 0x88(%rsp), %rdi
callq 0x3830
jmp 0x2802
jmp 0x2804
movl 0x60(%rsp), %eax
addl $0x8, %eax
movl %eax, 0x60(%rsp)
jmp 0x27c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x39b0
jmp 0x2933
jmp 0x2833
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x27a7
jmp 0x2845
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x278e
callq 0x2c50
movq %rdx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
jmp 0x2866
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x50(%rsp)
movq %rax, 0x58(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x2d10
vmovsd %xmm0, 0x48(%rsp)
vcvtsi2sdl 0xac(%rsp), %xmm0, %xmm0
vcvtsi2sdl 0xa8(%rsp), %xmm1, %xmm1
vmulsd %xmm1, %xmm0, %xmm0
vcvtsi2sdl 0xa4(%rsp), %xmm1, %xmm1
vmulsd %xmm1, %xmm0, %xmm0
vmovsd %xmm0, 0x40(%rsp)
vmovsd 0x48(%rsp), %xmm0
vmovsd 0x274a(%rip), %xmm1     # 0x5010
vmulsd %xmm1, %xmm0, %xmm0
vmovsd 0x40(%rsp), %xmm1
vdivsd %xmm1, %xmm0, %xmm0
vmovsd %xmm0, 0x38(%rsp)
movq 0x56ef(%rip), %rdi      # 0x7fd0
leaq 0x27da(%rip), %rsi      # 0x50c2
callq 0x2140
movq %rax, 0x10(%rsp)
jmp 0x28f4
movq 0x10(%rsp), %rdi
vmovsd 0x38(%rsp), %xmm0
callq 0x2230
movq %rax, 0x8(%rsp)
jmp 0x290b
movq 0x8(%rsp), %rdi
movq 0x56a1(%rip), %rsi      # 0x7fb8
callq 0x2160
jmp 0x291e
leaq 0x88(%rsp), %rdi
callq 0x39b0
addq $0xb8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0x2210
nopl (%rax)