#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_lim(size_t);
void shuffle_array(char **array, size_t arr_size) {
  size_t random;
  char *temp;
  for (size_t i = 0; i < arr_size; ++i) {
    random = rand_lim(arr_size);
    temp = array[i];
    array[i] = array[random];
    array[random] = temp;
  }
}


x86 assembly (clang, -O0):
<shuffle_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118c <shuffle_array+0x7c>
mov    -0x10(%rbp),%rdi
call   1030 <rand_lim@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1128 <shuffle_array+0x18>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle_array>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     1151 <shuffle_array+0x41>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <rand_lim@plt>
mov    (%r15,%rbx,8),%rcx
mov    (%r15,%rax,8),%rdx
mov    %rdx,(%r15,%rbx,8)
mov    %rcx,(%r15,%rax,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1130 <shuffle_array+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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