#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 rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char **shuffle(char *a[], int n) {
  int i, j;
  char *temp;
  srand(time(NULL));
  for (i = n - 1; i > 0; i--) {
    j = rand() % i;
    temp = a[j];
    a[j] = a[i];
    a[i] = temp;
  }
  return a;
}


x86 assembly (clang, -O0):
<shuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11b6 <shuffle+0x86>
mov    $0x0,%al
call   1050 <rand@plt>
cltd
idivl  -0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <shuffle+0x28>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
cmp    $0x2,%ebp
jl     117c <shuffle+0x4c>
mov    %ebp,%ebp
xchg   %ax,%ax
lea    -0x1(%rbp),%rbx
xor    %eax,%eax
call   1050 <rand@plt>
cltd
idiv   %ebx
movslq %edx,%rax
mov    (%r14,%rax,8),%rcx
mov    %ebx,%edx
mov    (%r14,%rdx,8),%rsi
mov    %rsi,(%r14,%rax,8)
mov    %rcx,(%r14,%rdx,8)
cmp    $0x2,%rbp
mov    %rbx,%rbp
ja     1150 <shuffle+0x20>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i8** @shuffle(i8** returned %0, i32 %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = icmp sgt i32 %1, 1
br i1 %5, label %6, label %21
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ %7, %6 ], [ %10, %8 ]
%10 = add nsw i64 %9, -1
%11 = trunc i64 %10 to i32
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, %11
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %0, i64 %14
%16 = load i8*, i8** %15
%17 = and i64 %10, 4294967295
%18 = getelementptr inbounds i8*, i8** %0, i64 %17
%19 = load i8*, i8** %18
store i8* %19, i8** %15
store i8* %16, i8** %18
%20 = icmp ugt i64 %9, 2
br i1 %20, label %8, label %21
21: ; preds = %8, %2
ret i8** %0
}