#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 */
size_t randomRangeFast(size_t, size_t);
int /*<<< orphan*/ swapLongs(long *, long *);
void shuffleLongs(long *array, size_t len) {
  size_t n = len - 1;
  size_t i;
  size_t j;
  for (i = 0; i < n; ++i) {
    j = randomRangeFast(i, n);
    swapLongs(array + i, array + j);
  }
}


x86 assembly (clang, -O0):
<shuffleLongs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1197 <shuffleLongs+0x77>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <randomRangeFast@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1040 <swapLongs@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1144 <shuffleLongs+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffleLongs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
add    $0xffffffffffffffff,%r15
je     1164 <shuffleLongs+0x44>
mov    %rdi,%r14
xor    %ebx,%ebx
mov    %rdi,%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <randomRangeFast@plt>
lea    (%r14,%rax,8),%rsi
mov    %r12,%rdi
call   1040 <swapLongs@plt>
add    $0x1,%rbx
add    $0x8,%r12
cmp    %rbx,%r15
jne    1140 <shuffleLongs+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @shuffleLongs(i64* %0, i64 %1) {
%3 = alloca i64*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i64* %0, i64** %3
store i64 %1, i64* %4
%8 = load i64, i64* %4
%9 = sub i64 %8, 1
store i64 %9, i64* %5
store i64 0, i64* %6
br label %10
10: ; preds = %25, %2
%11 = load i64, i64* %6
%12 = load i64, i64* %5
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = load i64, i64* %6
%16 = load i64, i64* %5
%17 = call i64 @randomRangeFast(i64 %15, i64 %16)
store i64 %17, i64* %7
%18 = load i64*, i64** %3
%19 = load i64, i64* %6
%20 = getelementptr inbounds i64, i64* %18, i64 %19
%21 = load i64*, i64** %3
%22 = load i64, i64* %7
%23 = getelementptr inbounds i64, i64* %21, i64 %22
%24 = call i32 @swapLongs(i64* %20, i64* %23)
br label %25
25: ; preds = %14
%26 = load i64, i64* %6
%27 = add i64 %26, 1
store i64 %27, i64* %6
br label %10
28: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @shuffleLongs(i64* %0, i64 %1) {
%3 = add i64 %1, -1
%4 = icmp eq i64 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %11, %5 ], [ 0, %2 ]
%7 = tail call i64 @randomRangeFast(i64 %6, i64 %3)
%8 = getelementptr inbounds i64, i64* %0, i64 %6
%9 = getelementptr inbounds i64, i64* %0, i64 %7
%10 = tail call i32 @swapLongs(i64* %8, i64* %9)
%11 = add nuw i64 %6, 1
%12 = icmp eq i64 %11, %3
br i1 %12, label %13, label %5
13: ; preds = %5, %2
ret void
}