#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(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void random_app(unsigned int *sequence) {
  int i;
  srand((unsigned)time(NULL));
  for (i = 0; i < 16; i++) {
    sequence[i] = i;
  }
  for (i = 16 - 1; i >= 1; i--) {
    unsigned int temp;
    unsigned int ii = rand() % i;
    temp = sequence[i];
    sequence[i] = sequence[ii];
    sequence[ii] = temp;
  }
}


x86 assembly (clang, -O0):
<random_app>:
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   $0x10,-0xc(%rbp)
jge    1179 <random_app+0x49>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1153 <random_app+0x23>
movl   $0xf,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     11d6 <random_app+0xa6>
mov    $0x0,%al
call   1050 <rand@plt>
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1180 <random_app+0x50>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_app>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movaps 0xeb4(%rip),%xmm0
movups %xmm0,(%r14)
movaps 0xeb9(%rip),%xmm0
movups %xmm0,0x10(%r14)
movaps 0xebd(%rip),%xmm0
movups %xmm0,0x20(%r14)
movaps 0xec1(%rip),%xmm0
movups %xmm0,0x30(%r14)
mov    $0xf,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
cltd
idiv   %ebx
mov    (%r14,%rbx,4),%eax
mov    (%r14,%rdx,4),%ecx
mov    %ecx,(%r14,%rbx,4)
mov    %eax,(%r14,%rdx,4)
lea    -0x1(%rbx),%rax
cmp    $0x1,%rbx
mov    %rax,%rbx
ja     1180 <random_app+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @random_app(i32* nocapture %0) {
%2 = tail call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @srand(i32 %3)
%5 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %5
%6 = getelementptr inbounds i32, i32* %0, i64 4
%7 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %7
%8 = getelementptr inbounds i32, i32* %0, i64 8
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %0, i64 12
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, <4 x i32>* %11
br label %12
12: ; preds = %1, %12
%13 = phi i64 [ 15, %1 ], [ %22, %12 ]
%14 = tail call i32 (...) @rand()
%15 = trunc i64 %13 to i32
%16 = srem i32 %14, %15
%17 = getelementptr inbounds i32, i32* %0, i64 %13
%18 = load i32, i32* %17
%19 = zext i32 %16 to i64
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
store i32 %21, i32* %17
store i32 %18, i32* %20
%22 = add nsw i64 %13, -1
%23 = icmp ugt i64 %13, 1
br i1 %23, label %12, label %24
24: ; preds = %12
ret void
}