#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 */
int random_integer(int /*<<< orphan*/, size_t const);
int random_shuffle_array(void *array, const size_t length) {
  void *temp;
  if (length > 1) {
    int rand_index;
    for (int i = 0; i < length; ++i) {
      rand_index = random_integer(0, length - 1);
      temp = (&array)[i];
      (&array)[i] = (&array)[rand_index];
      (&array)[rand_index] = &(temp);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<random_shuffle_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jbe    1191 <random_shuffle_array+0x81>
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118c <random_shuffle_array+0x7c>
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
xor    %edi,%edi
call   1030 <random_integer@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x20(%rbp),%rax
mov    -0x8(%rbp,%rax,8),%rax
mov    %rax,-0x18(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x8(%rbp,%rax,8),%rcx
movslq -0x20(%rbp),%rax
mov    %rcx,-0x8(%rbp,%rax,8)
lea    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rax
mov    %rcx,-0x8(%rbp,%rax,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1132 <random_shuffle_array+0x22>
jmp    1191 <random_shuffle_array+0x81>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_shuffle_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%rsi
jb     1171 <random_shuffle_array+0x61>
mov    %rsi,%r15
mov    %rdi,%r14
add    $0xffffffffffffffff,%r15
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <random_integer@plt>
mov    %r14,0x8(%rsp)
cltq
lea    0x8(%rsp),%r14
mov    %r14,0x10(%rsp,%rax,8)
mov    %r15,%rbx
nopl   0x0(%rax)
mov    0x10(%rsp),%r12
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <random_integer@plt>
mov    %r12,0x8(%rsp)
cltq
mov    %r14,0x10(%rsp,%rax,8)
add    $0xffffffffffffffff,%rbx
jne    1150 <random_shuffle_array+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @random_shuffle_array(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = icmp ugt i64 %1, 1
br i1 %6, label %7, label %22
7: ; preds = %2
%8 = add i64 %1, -1
%9 = call i32 @random_integer(i32 0, i64 %8)
store i8* %0, i8** %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %3, i64 %10
%12 = bitcast i8** %11 to i8***
store i8** %4, i8*** %12
br label %13
13: ; preds = %7, %13
%14 = phi i64 [ 1, %7 ], [ %20, %13 ]
%15 = load i8*, i8** %3
%16 = call i32 @random_integer(i32 0, i64 %8)
store i8* %15, i8** %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %3, i64 %17
%19 = bitcast i8** %18 to i8***
store i8** %4, i8*** %19
%20 = add nuw i64 %14, 1
%21 = icmp eq i64 %20, %1
br i1 %21, label %22, label %13
22: ; preds = %13, %2
ret i32 0
}