#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*/ uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int RAND_MAX;
int rand();
void shuffle_array(uint8_t *val) {
  for (size_t i = 0; i < 63; i++) {
    size_t j = i + rand() / (RAND_MAX / (64 - i) + 1);
    uint16_t t = val[j];
    val[j] = val[i];
    val[i] = t;
  }
}


x86 assembly (clang, -O0):
<shuffle_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x3f,-0x10(%rbp)
jae    11bd <shuffle_array+0xad>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    0x2e9d(%rip),%rax
movslq (%rax),%rax
mov    $0x40,%ecx
sub    -0x10(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    $0x1,%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <shuffle_array+0x14>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x40,%r12d
mov    0x2ec0(%rip),%r15
xor    %ebx,%ebx
jmp    1156 <shuffle_array+0x46>
nopl   0x0(%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,%r12
cmp    $0x1,%r12
je     11a2 <shuffle_array+0x92>
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ecx
movslq (%r15),%rax
mov    %rax,%rdx
or     %r12,%rdx
shr    $0x20,%rdx
je     1180 <shuffle_array+0x70>
xor    %edx,%edx
div    %r12
mov    %rax,%rsi
jmp    1187 <shuffle_array+0x77>
nopl   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %r12d
mov    %eax,%esi
movslq %ecx,%rax
add    $0x1,%rsi
mov    %rax,%rdx
or     %rsi,%rdx
shr    $0x20,%rdx
jne    1130 <shuffle_array+0x20>
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
jmp    1135 <shuffle_array+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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