#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_MAX;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ shuffle(int *, int);
int main(int argc, char *argv[]) {
  int A[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
  int i, k, N;
  printf("RAND_MAX: %ld\n", RAND_MAX);
  for (k = 0; k < 100; k++) {
    shuffle(A, 16);
    for (i = 0; i < 16; i++)
      printf(" %d", A[i]);
    putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x40,%edx
call   1060 <memcpy@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%esi
lea    0xec5(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x58(%rbp)
cmpl   $0x64,-0x58(%rbp)
jge    11ea <main+0xaa>
lea    -0x50(%rbp),%rdi
mov    $0x10,%esi
call   1040 <shuffle@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jge    11d2 <main+0x92>
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%esi
lea    0xe90(%rip),%rdi
call   1050 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11a6 <main+0x66>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1187 <main+0x47>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
movaps 0xef1(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
lea    0xec9(%rip),%rdi
call   1050 <printf@plt>
mov    $0x64,%ebp
mov    %rsp,%r14
lea    0xec4(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x10,%esi
call   1040 <shuffle@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.main.A = [16 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15]
@.str = [15 x i8] c"RAND_MAX: %ld\0A\00"
@RAND_MAX = global i32 0
@.str.1 = [4 x i8] c" %d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [16 x i32]
%4 = bitcast [16 x i32]* %3 to i8*
%5 = load i32, i32* @RAND_MAX
%6 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%8 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 1
%9 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 2
%10 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 3
%11 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 4
%12 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 5
%13 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 6
%14 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 7
%15 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 8
%16 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 9
%17 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 10
%18 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 11
%19 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 12
%20 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 13
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 14
%22 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 15
br label %23
23: ; preds = %2, %23
%24 = phi i32 [ 0, %2 ], [ %59, %23 ]
%25 = call i32 @shuffle(i32* %7, i32 16)
%26 = load i32, i32* %7
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %8
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %9
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %10
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %11
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %12
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %13
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %14
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %15
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %16
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %17
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %18
%49 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %19
%51 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %20
%53 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %21
%55 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %22
%57 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%58 = call i32 @putchar(i8 signext 10)
%59 = add nuw nsw i32 %24, 1
%60 = icmp eq i32 %59, 100
br i1 %60, label %61, label %23
61: ; preds = %23
ret i32 0
}