#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 /*<<< orphan*/ printf(char *, ...);
int rand();
void shuffle(char **arr, int len) {
  printf("Array Count: %d\n", len);
  printf("===================\n");
  for (int i = 0; i < len; i++) {
    int pick_index = rand() % (len - i);
    printf("%s\n", arr[pick_index]);
    arr[pick_index] = arr[len - i - 1];
  }
}


x86 assembly (clang, -O0):
<shuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bc <shuffle+0x9c>
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1155 <shuffle+0x35>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
jle    1185 <shuffle+0x55>
mov    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
cltd
idiv   %ebp
movslq %edx,%rbx
mov    (%r14,%rbx,8),%rdi
call   1030 <puts@plt>
mov    -0x8(%r14,%rbp,8),%rax
mov    %rax,(%r14,%rbx,8)
add    $0xffffffffffffffff,%rbp
jne    1160 <shuffle+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Array Count: %d\0A\00"
@.str.1 = [21 x i8] c"===================\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @shuffle(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %10
10: ; preds = %38, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %41
14: ; preds = %10
%15 = call i32 (...) @rand()
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = sub nsw i32 %16, %17
%19 = srem i32 %15, %18
store i32 %19, i32* %6
%20 = load i8**, i8*** %3
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load i8**, i8*** %3
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = sub nsw i32 %27, %28
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %26, i64 %31
%33 = load i8*, i8** %32
%34 = load i8**, i8*** %3
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
store i8* %33, i8** %37
br label %38
38: ; preds = %14
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %10
41: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"Array Count: %d\0A\00"
@str = [20 x i8] c"===================\00"
define void @shuffle(i8** nocapture %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %1)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = zext i32 %1 to i64
%8 = zext i32 %1 to i64
br label %10
9: ; preds = %10, %2
ret void
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %23, %10 ]
%12 = tail call i32 (...) @rand()
%13 = sub nsw i64 %7, %11
%14 = trunc i64 %13 to i32
%15 = srem i32 %12, %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %0, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i32 @puts(i8* dereferenceable(1) %18)
%20 = add nsw i64 %13, -1
%21 = getelementptr inbounds i8*, i8** %0, i64 %20
%22 = load i8*, i8** %21
store i8* %22, i8** %17
%23 = add nuw nsw i64 %11, 1
%24 = icmp eq i64 %23, %8
br i1 %24, label %9, label %10
}