#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 */
unsigned int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void init(unsigned m[], unsigned n) {
  unsigned i;
  srand(time(NULL));
  m[0] = rand() % 5;
  for (i = 1; i < n; i++)
    m[i] = 1 + m[i - 1] + rand() % 5;
  for (i = 1; i < n; i++) {
    unsigned ind1, ind2;
    unsigned tmp;
    ind1 = rand() % n;
    ind2 = rand() % n;
    tmp = m[ind1];
    m[ind1] = m[ind2];
    m[ind2] = tmp;
  }
}


x86 assembly (clang, -O0):
<init>:
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    $0x0,%al
call   1050 <rand@plt>
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
mov    -0x8(%rbp),%rax
mov    %edx,(%rax)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11bc <init+0x8c>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%eax
mov    -0x20(%rbp),%edx
add    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116c <init+0x3c>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1229 <init+0xf9>
mov    $0x0,%al
call   1050 <rand@plt>
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c3 <init+0x93>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ebx
mov    %eax,%eax
mov    $0xcccccccd,%r12d
imul   %r12,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
mov    %ebx,(%r15)
cmp    $0x2,%r14d
jb     11ef <init+0xbf>
mov    %r14d,%r13d
mov    $0x1,%ebp
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ecx
imul   %r12,%rcx
shr    $0x22,%rcx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    %eax,%ebx
add    $0x1,%ebx
mov    %ebx,(%r15,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1180 <init+0x50>
cmp    $0x2,%r14d
jb     11ef <init+0xbf>
lea    -0x1(%r14),%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
xor    %edx,%edx
div    %r14d
mov    %edx,%ebx
xor    %eax,%eax
call   1050 <rand@plt>
xor    %edx,%edx
div    %r14d
mov    (%r15,%rbx,4),%eax
mov    (%r15,%rdx,4),%ecx
mov    %ecx,(%r15,%rbx,4)
mov    %eax,(%r15,%rdx,4)
add    $0xffffffff,%ebp
jne    11c0 <init+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @init(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = call i32 (...) @rand()
%12 = urem i32 %11, 5
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 %12, i32* %14
store i32 1, i32* %5
br label %15
15: ; preds = %34, %2
%16 = load i32, i32* %5
%17 = load i32, i32* %4
%18 = icmp ult i32 %16, %17
br i1 %18, label %19, label %37
19: ; preds = %15
%20 = load i32*, i32** %3
%21 = load i32, i32* %5
%22 = sub i32 %21, 1
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %20, i64 %23
%25 = load i32, i32* %24
%26 = add i32 1, %25
%27 = call i32 (...) @rand()
%28 = urem i32 %27, 5
%29 = add i32 %26, %28
%30 = load i32*, i32** %3
%31 = load i32, i32* %5
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %29, i32* %33
br label %34
34: ; preds = %19
%35 = load i32, i32* %5
%36 = add i32 %35, 1
store i32 %36, i32* %5
br label %15
37: ; preds = %15
store i32 1, i32* %5
br label %38
38: ; preds = %68, %37
%39 = load i32, i32* %5
%40 = load i32, i32* %4
%41 = icmp ult i32 %39, %40
br i1 %41, label %42, label %71
42: ; preds = %38
%43 = call i32 (...) @rand()
%44 = load i32, i32* %4
%45 = urem i32 %43, %44
store i32 %45, i32* %6
%46 = call i32 (...) @rand()
%47 = load i32, i32* %4
%48 = urem i32 %46, %47
store i32 %48, i32* %7
%49 = load i32*, i32** %3
%50 = load i32, i32* %6
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
store i32 %53, i32* %8
%54 = load i32*, i32** %3
%55 = load i32, i32* %7
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
%58 = load i32, i32* %57
%59 = load i32*, i32** %3
%60 = load i32, i32* %6
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
store i32 %58, i32* %62
%63 = load i32, i32* %8
%64 = load i32*, i32** %3
%65 = load i32, i32* %7
%66 = zext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
store i32 %63, i32* %67
br label %68
68: ; preds = %42
%69 = load i32, i32* %5
%70 = add i32 %69, 1
store i32 %70, i32* %5
br label %38
71: ; preds = %38
ret void
}

LLVM IR (-O2):
define void @init(i32* nocapture %0, i32 %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = urem i32 %5, 5
store i32 %6, i32* %0
%7 = icmp ugt i32 %1, 1
br i1 %7, label %8, label %35
8: ; preds = %2
%9 = zext i32 %1 to i64
br label %11
10: ; preds = %11
br i1 %7, label %21, label %35
11: ; preds = %8, %11
%12 = phi i32 [ %6, %8 ], [ %17, %11 ]
%13 = phi i64 [ 1, %8 ], [ %19, %11 ]
%14 = add i32 %12, 1
%15 = tail call i32 (...) @rand()
%16 = urem i32 %15, 5
%17 = add i32 %14, %16
%18 = getelementptr inbounds i32, i32* %0, i64 %13
store i32 %17, i32* %18
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %10, label %11
21: ; preds = %10, %21
%22 = phi i32 [ %33, %21 ], [ 1, %10 ]
%23 = tail call i32 (...) @rand()
%24 = urem i32 %23, %1
%25 = tail call i32 (...) @rand()
%26 = urem i32 %25, %1
%27 = zext i32 %24 to i64
%28 = getelementptr inbounds i32, i32* %0, i64 %27
%29 = load i32, i32* %28
%30 = zext i32 %26 to i64
%31 = getelementptr inbounds i32, i32* %0, i64 %30
%32 = load i32, i32* %31
store i32 %32, i32* %28
store i32 %29, i32* %31
%33 = add nuw i32 %22, 1
%34 = icmp eq i32 %33, %1
br i1 %34, label %35, label %21
35: ; preds = %21, %2, %10
ret void
}