#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 abs(int /*<<< orphan*/);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  int i, j;
  freopen("in", "w", stdout);
  srand(time(0));
  printf("%i\n", 10001);
  for (i = 0; i < 10001; ++i)
    printf("%i ", abs(rand()));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
lea    0xe7a(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1050 <freopen@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe5e(%rip),%rdi
mov    $0x2711,%esi
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2711,-0x14(%rbp)
jge    11ef <main+0x8f>
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b8 <main+0x58>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e86(%rip),%rax
mov    (%rax),%edx
lea    0xe9d(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1040 <freopen@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe81(%rip),%rdi
mov    $0x2711,%ebp
mov    $0x2711,%esi
call   1030 <printf@plt>
lea    0xe6f(%rip),%rbx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%esi
neg    %esi
cmovs  %eax,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0xffffffff,%ebp
jne    11a0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"in\00"
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%i\0A\00"
@.str.3 = [4 x i8] c"%i \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @stdout
%9 = call i32 @freopen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 @time(i32 0)
%11 = call i32 @srand(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 10001)
store i32 0, i32* %6
br label %13
13: ; preds = %20, %2
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 10001
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = call i32 (...) @rand()
%18 = call i32 @abs(i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %16
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %13
23: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"in\00"
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%i\0A\00"
@.str.3 = [4 x i8] c"%i \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdout
%4 = tail call i32 @freopen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @time(i32 0)
%6 = tail call i32 @srand(i32 %5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 10001)
br label %8
8: ; preds = %2, %8
%9 = phi i32 [ 0, %2 ], [ %13, %8 ]
%10 = tail call i32 (...) @rand()
%11 = tail call i32 @llvm.abs.i32(i32 %10, i1 true)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = add nuw nsw i32 %9, 1
%14 = icmp eq i32 %13, 10001
br i1 %14, label %15, label %8
15: ; preds = %8
ret i32 0
}