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

/* Variables and functions */
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
long pow(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  long int i, n;
  FILE *fp;
  fp = fopen("data.in", "w");
  time_t t;
  n = pow(10, atoi(argv[1]));
  srand((unsigned)time(&t));
  for (i = 0; i < n; i++) {
    fprintf(fp, "%d ", rand() % 10000);
  }
  printf("\nCount %ld", i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe63(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,%esi
mov    $0xa,%edi
call   1080 <pow@plt>
mov    %rax,-0x20(%rbp)
lea    -0x2c(%rbp),%rdi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1228 <main+0xa8>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    -0x38(%rbp),%rdi
mov    $0x2710,%ecx
cltd
idiv   %ecx
lea    0xdf8(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11e2 <main+0x62>
mov    -0x18(%rbp),%rsi
lea    0xddb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xe6e(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
mov    0x8(%r14),%rdi
call   1090 <atoi@plt>
mov    $0xa,%edi
mov    %eax,%esi
call   1080 <pow@plt>
mov    %rax,%r14
lea    0x4(%rsp),%rdi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
test   %r14,%r14
jle    1219 <main+0x99>
lea    0xe34(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rdx
imul   $0x68db8bad,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <fprintf@plt>
add    $0xffffffffffffffff,%rbx
jne    11e0 <main+0x60>
jmp    121c <main+0x9c>
xor    %r14d,%r14d
lea    0xdeb(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"data.in\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [11 x i8] c"\0ACount %ld\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %8
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
%15 = call i64 @pow(i32 10, i32 %14)
store i64 %15, i64* %7
%16 = call i64 @time(i32* %9)
%17 = trunc i64 %16 to i32
%18 = call i32 @srand(i32 %17)
store i64 0, i64* %6
br label %19
19: ; preds = %28, %2
%20 = load i64, i64* %6
%21 = load i64, i64* %7
%22 = icmp slt i64 %20, %21
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = load i32*, i32** %8
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 10000
%27 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %23
%29 = load i64, i64* %6
%30 = add nsw i64 %29, 1
store i64 %30, i64* %6
br label %19
31: ; preds = %19
%32 = load i64, i64* %6
%33 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"data.in\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [11 x i8] c"\0ACount %ld\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = tail call i64 @pow(i32 10, i32 %8)
%10 = call i64 @time(i32* %3)
%11 = trunc i64 %10 to i32
%12 = call i32 @srand(i32 %11)
%13 = icmp sgt i64 %9, 0
br i1 %13, label %14, label %21
14: ; preds = %2, %14
%15 = phi i64 [ %19, %14 ], [ 0, %2 ]
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 10000
%18 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %14
21: ; preds = %14, %2
%22 = phi i64 [ 0, %2 ], [ %9, %14 ]
%23 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 %22)
ret i32 0
}