#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 int /*<<< orphan*/ off_t;

/* Variables and functions */
unsigned long long RAND_MAX;
unsigned long long random();
void shuffle(off_t *offsets, long long unsigned int n) {
  long long unsigned int i;
  if (n <= 1)
    return;
  for (i = 0; i < n - 1; i++) {
    long long unsigned int j = i + random() / (RAND_MAX / (n - i) + 1);
    off_t t = offsets[j];
    offsets[j] = offsets[i];
    offsets[i] = t;
  }
}


x86 assembly (clang, -O0):
<shuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
ja     1130 <shuffle+0x20>
jmp    11d8 <shuffle+0xc8>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    11d8 <shuffle+0xc8>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
mov    %rax,-0x38(%rbp)
mov    0x2e81(%rip),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
sub    -0x18(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    $0x1,%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <shuffle+0x28>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%rsi
jae    112a <shuffle+0x1a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
mov    0x2eaf(%rip),%r12
jmp    1169 <shuffle+0x59>
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rax
xor    %edx,%edx
div    %rsi
add    %rbx,%rax
mov    (%r14,%rax,4),%ecx
mov    (%r14,%rbx,4),%edx
mov    %edx,(%r14,%rax,4)
mov    %ecx,(%r14,%rbx,4)
add    $0x1,%rbx
add    $0xffffffffffffffff,%r15
cmp    $0x1,%r15
je     111e <shuffle+0xe>
xor    %eax,%eax
call   1030 <random@plt>
mov    %rax,%rcx
mov    (%r12),%rax
mov    %rax,%rdx
or     %r15,%rdx
shr    $0x20,%rdx
je     1190 <shuffle+0x80>
xor    %edx,%edx
div    %r15
mov    %rax,%rsi
jmp    1197 <shuffle+0x87>
nopl   (%rax)
xor    %edx,%edx
div    %r15d
mov    %eax,%esi
add    $0x1,%rsi
mov    %rcx,%rax
or     %rsi,%rax
shr    $0x20,%rax
jne    1140 <shuffle+0x30>
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
jmp    1148 <shuffle+0x38>

LLVM IR (-O0):
@RAND_MAX = global i64 0
define void @shuffle(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
store i32* %0, i32** %3
store i64 %1, i64* %4
%8 = load i64, i64* %4
%9 = icmp ule i64 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %2
br label %46
11: ; preds = %2
store i64 0, i64* %5
br label %12
12: ; preds = %43, %11
%13 = load i64, i64* %5
%14 = load i64, i64* %4
%15 = sub i64 %14, 1
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %46
17: ; preds = %12
%18 = load i64, i64* %5
%19 = call i64 (...) @random()
%20 = load i64, i64* @RAND_MAX
%21 = load i64, i64* %4
%22 = load i64, i64* %5
%23 = sub i64 %21, %22
%24 = udiv i64 %20, %23
%25 = add i64 %24, 1
%26 = udiv i64 %19, %25
%27 = add i64 %18, %26
store i64 %27, i64* %6
%28 = load i32*, i32** %3
%29 = load i64, i64* %6
%30 = getelementptr inbounds i32, i32* %28, i64 %29
%31 = load i32, i32* %30
store i32 %31, i32* %7
%32 = load i32*, i32** %3
%33 = load i64, i64* %5
%34 = getelementptr inbounds i32, i32* %32, i64 %33
%35 = load i32, i32* %34
%36 = load i32*, i32** %3
%37 = load i64, i64* %6
%38 = getelementptr inbounds i32, i32* %36, i64 %37
store i32 %35, i32* %38
%39 = load i32, i32* %7
%40 = load i32*, i32** %3
%41 = load i64, i64* %5
%42 = getelementptr inbounds i32, i32* %40, i64 %41
store i32 %39, i32* %42
br label %43
43: ; preds = %17
%44 = load i64, i64* %5
%45 = add i64 %44, 1
store i64 %45, i64* %5
br label %12
46: ; preds = %10, %12
ret void
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define void @shuffle(i32* nocapture %0, i64 %1) {
%3 = icmp ult i64 %1, 2
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = add i64 %1, -1
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ %19, %6 ], [ 0, %4 ]
%8 = tail call i64 (...) @random()
%9 = load i64, i64* @RAND_MAX
%10 = sub i64 %1, %7
%11 = udiv i64 %9, %10
%12 = add i64 %11, 1
%13 = udiv i64 %8, %12
%14 = add i64 %13, %7
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = getelementptr inbounds i32, i32* %0, i64 %7
%18 = load i32, i32* %17
store i32 %18, i32* %15
store i32 %16, i32* %17
%19 = add nuw i64 %7, 1
%20 = icmp eq i64 %19, %5
br i1 %20, label %21, label %6
21: ; preds = %6, %2
ret void
}