#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int number;
  int maxnumber;
  int i, j;
  srand(time(NULL));
  maxnumber = 1 << 30;
  FILE *fp;
  fp = fopen("file01", "w");
  for (i = 0; i < 1000; i++) {
    for (j = 1; j < 10; j++) {
      number = rand() % maxnumber;
      fprintf(fp, "%d ", number);
    }
    fprintf(fp, "\n");
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x40000000,-0xc(%rbp)
lea    0xe73(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jge    1213 <main+0xb3>
movl   $0x1,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11f3 <main+0x93>
mov    $0x0,%al
call   1080 <rand@plt>
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x8(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b8 <main+0x58>
mov    -0x20(%rbp),%rdi
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a4 <main+0x44>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe77(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    $0x3e8,%ebp
lea    0xe65(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3fffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xc0000000,%ecx
sub    %ecx,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3fffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xc0000000,%ecx
sub    %ecx,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3fffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xc0000000,%ecx
sub    %ecx,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3fffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xc0000000,%ecx
sub    %ecx,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3fffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xc0000000,%ecx
sub    %ecx,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3fffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xc0000000,%ecx
sub    %ecx,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3fffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xc0000000,%ecx
sub    %ecx,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3fffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xc0000000,%ecx
sub    %ecx,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3fffffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xc0000000,%ecx
sub    %ecx,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"file01\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %34, %4 ]
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 1073741824
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 1073741824
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 1073741824
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 1073741824
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 1073741824
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 1073741824
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 1073741824
%26 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = tail call i32 (...) @rand()
%28 = srem i32 %27, 1073741824
%29 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = tail call i32 (...) @rand()
%31 = srem i32 %30, 1073741824
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = tail call i32 @fputc(i32 10, i32* %3)
%34 = add nuw nsw i32 %5, 1
%35 = icmp eq i32 %34, 1000
br i1 %35, label %36, label %4
36: ; preds = %4
%37 = tail call i32 @fclose(i32* %3)
ret i32 0
}