#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*/ swap_integers(int *, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void shuffle(int *array) {
  int i, index1, index2;
  srand(time(NULL));
  for (i = 0; i < 4096 * 2; i++) {
    index1 = rand() % 4096;
    index2 = rand() % 4096;
    swap_integers(array, index1, index2);
  }
}


x86 assembly (clang, -O0):
<shuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x2000,-0xc(%rbp)
jge    11b1 <shuffle+0x71>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x1000,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x1000,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <swap_integers@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <shuffle+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    $0x2000,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebx
lea    0xfff(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffff000,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
lea    0xfff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffff000,%ecx
sub    %ecx,%eax
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1050 <swap_integers@plt>
add    $0xffffffff,%ebp
jne    1160 <shuffle+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @shuffle(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
store i32 0, i32* %3
br label %8
8: ; preds = %20, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 8192
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 4096
store i32 %13, i32* %4
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 4096
store i32 %15, i32* %5
%16 = load i32*, i32** %2
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i32 @swap_integers(i32* %16, i32 %17, i32 %18)
br label %20
20: ; preds = %11
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %8
23: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @shuffle(i32* %0) {
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
br label %4
4: ; preds = %1, %4
%5 = phi i32 [ 0, %1 ], [ %11, %4 ]
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 4096
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 4096
%10 = tail call i32 @swap_integers(i32* %0, i32 %7, i32 %9)
%11 = add nuw nsw i32 %5, 1
%12 = icmp eq i32 %11, 8192
br i1 %12, label %13, label %4
13: ; preds = %4
ret void
}