#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
scalar_t__ time(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  FILE *in;
  if (argc == 1)
    in = stdin;
  else {
    if ((in = fopen(argv[1], "r")) == NULL) {
      fprintf(stderr, "Can't open file '%s'\n", argv[1]);
      exit(1);
    }
  }
  int vals[100000], i = 0;
  while (fscanf(in, "%d", &vals[i]) != EOF) {
    i++;
  }
  srand((unsigned)time(0));
  for (int j = 0; j < i; j++) {
    int tmp = vals[j];
    int swap_index = rand() % i;
    vals[j] = vals[swap_index];
    vals[swap_index] = tmp;
  }
  for (int j = 0; j < i; j++) {
    printf("%d\n", vals[j]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ac0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11b6 <main+0x36>
mov    0x2e3e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1204 <main+0x84>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ff <main+0x7f>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe12(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    1204 <main+0x84>
movl   $0x0,-0x61aa4(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x61aa4(%rbp),%rax
lea    -0x61aa0(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdea(%rip),%rsi
call   1040 <fscanf@plt>
mov    0x2da6(%rip),%rcx
cmp    (%rcx),%rax
je     1257 <main+0xd7>
mov    -0x61aa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61aa4(%rbp)
jmp    120e <main+0x8e>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x61aa8(%rbp)
mov    -0x61aa8(%rbp),%eax
cmp    -0x61aa4(%rbp),%eax
jge    12ed <main+0x16d>
movslq -0x61aa8(%rbp),%rax
mov    -0x61aa0(%rbp,%rax,4),%eax
mov    %eax,-0x61aac(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
cltd
idivl  -0x61aa4(%rbp)
mov    %edx,-0x61ab0(%rbp)
movslq -0x61ab0(%rbp),%rax
mov    -0x61aa0(%rbp,%rax,4),%ecx
movslq -0x61aa8(%rbp),%rax
mov    %ecx,-0x61aa0(%rbp,%rax,4)
mov    -0x61aac(%rbp),%ecx
movslq -0x61ab0(%rbp),%rax
mov    %ecx,-0x61aa0(%rbp,%rax,4)
mov    -0x61aa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61aa8(%rbp)
jmp    126f <main+0xef>
movl   $0x0,-0x61ab4(%rbp)
mov    -0x61ab4(%rbp),%eax
cmp    -0x61aa4(%rbp),%eax
jge    1337 <main+0x1b7>
movslq -0x61ab4(%rbp),%rax
mov    -0x61aa0(%rbp,%rax,4),%esi
lea    0xcfd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x61ab4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61ab4(%rbp)
jmp    12f7 <main+0x177>
xor    %eax,%eax
add    $0x61ac0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x61a80,%rsp
cmp    $0x1,%edi
jne    11a0 <main+0x20>
mov    0x2e4d(%rip),%rax
mov    (%rax),%r14
jmp    11bf <main+0x3f>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe52(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     1286 <main+0x106>
mov    $0xffffffff,%ebp
mov    %rsp,%rbx
lea    0xe4a(%rip),%r15
mov    0x2e0b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
add    $0x1,%ebp
add    $0x4,%rbx
cmp    (%r12),%rax
jne    11e0 <main+0x60>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
test   %ebp,%ebp
je     1274 <main+0xf4>
mov    %ebp,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp,%rbx,4),%r15d
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idiv   %ebp
movslq %edx,%rax
mov    (%rsp,%rax,4),%ecx
mov    %ecx,(%rsp,%rbx,4)
mov    %r15d,(%rsp,%rax,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1220 <main+0xa0>
test   %ebp,%ebp
je     1274 <main+0xf4>
xor    %ebx,%ebx
lea    0xdca(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1260 <main+0xe0>
xor    %eax,%eax
add    $0x61a80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xd68(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"Can't open file '%s'\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [100000 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32*, i32** @stdin
store i32* %16, i32** %6
br label %31
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %30
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %17
br label %31
31: ; preds = %30, %15
store i32 0, i32* %8
br label %32
32: ; preds = %40, %31
%33 = load i32*, i32** %6
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100000 x i32], [100000 x i32]* %7, i64 0, i64 %35
%37 = call i64 @fscanf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %36)
%38 = load i64, i64* @EOF
%39 = icmp ne i64 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %32
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %32
43: ; preds = %32
%44 = call i64 @time(i32 0)
%45 = trunc i64 %44 to i32
%46 = call i32 @srand(i32 %45)
store i32 0, i32* %9
br label %47
47: ; preds = %70, %43
%48 = load i32, i32* %9
%49 = load i32, i32* %8
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %73
51: ; preds = %47
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100000 x i32], [100000 x i32]* %7, i64 0, i64 %53
%55 = load i32, i32* %54
store i32 %55, i32* %10
%56 = call i32 (...) @rand()
%57 = load i32, i32* %8
%58 = srem i32 %56, %57
store i32 %58, i32* %11
%59 = load i32, i32* %11
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [100000 x i32], [100000 x i32]* %7, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [100000 x i32], [100000 x i32]* %7, i64 0, i64 %64
store i32 %62, i32* %65
%66 = load i32, i32* %10
%67 = load i32, i32* %11
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [100000 x i32], [100000 x i32]* %7, i64 0, i64 %68
store i32 %66, i32* %69
br label %70
70: ; preds = %51
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
br label %47
73: ; preds = %47
store i32 0, i32* %12
br label %74
74: ; preds = %84, %73
%75 = load i32, i32* %12
%76 = load i32, i32* %8
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %87
78: ; preds = %74
%79 = load i32, i32* %12
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [100000 x i32], [100000 x i32]* %7, i64 0, i64 %80
%82 = load i32, i32* %81
%83 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %78
%85 = load i32, i32* %12
%86 = add nsw i32 %85, 1
store i32 %86, i32* %12
br label %74
87: ; preds = %74
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"Can't open file '%s'\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100000 x i32]
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = load i32*, i32** @stdin
br label %17
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %8
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %7, %5
%18 = phi i32* [ %6, %5 ], [ %10, %7 ]
%19 = bitcast [100000 x i32]* %3 to i8*
br label %20
20: ; preds = %20, %17
%21 = phi i64 [ %26, %20 ], [ 0, %17 ]
%22 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 %21
%23 = call i64 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %22)
%24 = load i64, i64* @EOF
%25 = icmp eq i64 %23, %24
%26 = add nuw i64 %21, 1
br i1 %25, label %27, label %20
27: ; preds = %20
%28 = trunc i64 %21 to i32
%29 = call i64 @time(i32 0)
%30 = trunc i64 %29 to i32
%31 = call i32 @srand(i32 %30)
%32 = icmp eq i32 %28, 0
br i1 %32, label %49, label %33
33: ; preds = %27
%34 = and i64 %21, 4294967295
br label %38
35: ; preds = %38
br i1 %32, label %49, label %36
36: ; preds = %35
%37 = and i64 %21, 4294967295
br label %50
38: ; preds = %33, %38
%39 = phi i64 [ 0, %33 ], [ %47, %38 ]
%40 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (...) @rand()
%43 = srem i32 %42, %28
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 %44
%46 = load i32, i32* %45
store i32 %46, i32* %40
store i32 %41, i32* %45
%47 = add nuw nsw i64 %39, 1
%48 = icmp eq i64 %47, %34
br i1 %48, label %35, label %38
49: ; preds = %50, %27, %35
ret i32 0
50: ; preds = %36, %50
%51 = phi i64 [ 0, %36 ], [ %55, %50 ]
%52 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = add nuw nsw i64 %51, 1
%56 = icmp eq i64 %55, %37
br i1 %56, label %49, label %50
}