#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 rand();
void shuffle(size_t *array, size_t size) {
  for (size_t i = size - 1; i > 0; --i) {
    size_t j = rand() % (i + 1);
    size_t tmp = array[i];
    array[i] = array[j];
    array[j] = tmp;
  }
}


x86 assembly (clang, -O0):
<shuffle>:
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)
cmpq   $0x0,-0x18(%rbp)
jbe    1198 <shuffle+0x88>
mov    $0x0,%al
call   1030 <rand@plt>
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <shuffle+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%rsi
je     116a <shuffle+0x5a>
mov    %rsi,%rbx
mov    %rdi,%r14
jmp    1151 <shuffle+0x41>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %edx,%edx
div    %rbx
mov    -0x8(%r14,%rbx,8),%rax
mov    (%r14,%rdx,8),%rcx
mov    %rcx,-0x8(%r14,%rbx,8)
mov    %rax,(%r14,%rdx,8)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
je     116a <shuffle+0x5a>
xor    %eax,%eax
call   1030 <rand@plt>
mov    %rax,%rcx
or     %rbx,%rcx
shr    $0x20,%rcx
jne    1130 <shuffle+0x20>
xor    %edx,%edx
div    %ebx
jmp    1135 <shuffle+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @shuffle(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
br label %10
10: ; preds = %33, %2
%11 = load i64, i64* %5
%12 = icmp ugt i64 %11, 0
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = call i64 (...) @rand()
%15 = load i64, i64* %5
%16 = add i64 %15, 1
%17 = urem i64 %14, %16
store i64 %17, i64* %6
%18 = load i64*, i64** %3
%19 = load i64, i64* %5
%20 = getelementptr inbounds i64, i64* %18, i64 %19
%21 = load i64, i64* %20
store i64 %21, i64* %7
%22 = load i64*, i64** %3
%23 = load i64, i64* %6
%24 = getelementptr inbounds i64, i64* %22, i64 %23
%25 = load i64, i64* %24
%26 = load i64*, i64** %3
%27 = load i64, i64* %5
%28 = getelementptr inbounds i64, i64* %26, i64 %27
store i64 %25, i64* %28
%29 = load i64, i64* %7
%30 = load i64*, i64** %3
%31 = load i64, i64* %6
%32 = getelementptr inbounds i64, i64* %30, i64 %31
store i64 %29, i64* %32
br label %33
33: ; preds = %13
%34 = load i64, i64* %5
%35 = add i64 %34, -1
store i64 %35, i64* %5
br label %10
36: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @shuffle(i64* nocapture %0, i64 %1) {
%3 = add i64 %1, -1
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %6, %2
ret void
6: ; preds = %2, %6
%7 = phi i64 [ %15, %6 ], [ %3, %2 ]
%8 = phi i64 [ %7, %6 ], [ %1, %2 ]
%9 = tail call i64 (...) @rand()
%10 = urem i64 %9, %8
%11 = getelementptr inbounds i64, i64* %0, i64 %7
%12 = load i64, i64* %11
%13 = getelementptr inbounds i64, i64* %0, i64 %10
%14 = load i64, i64* %13
store i64 %14, i64* %11
store i64 %12, i64* %13
%15 = add i64 %7, -1
%16 = icmp eq i64 %15, 0
br i1 %16, label %5, label %6
}