#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, ...);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  FILE *file;
  file = fopen("enormous_file.txt", "w");
  srand((unsigned)time(NULL));
  int max_lns = rand() % 1000000 + 1, i;
  fprintf(file, "%d %d\n", max_lns, rand() % 10000000 + 1);
  for (i = 0; i < max_lns; i++)
    fprintf(file, "%d\n", rand() % 1000000000 + 1);
  0, fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0xf4240,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    -0x28(%rbp),%rdi
mov    $0x989680,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x1c(%rbp),%edx
add    $0x1,%ecx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    -0x30(%rbp),%rdi
mov    $0x3b9aca00,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e9 <main+0x89>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xe95(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x431bde83,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x32,%rcx
add    %edx,%ecx
imul   $0xf4240,%ecx,%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x6b5fca6b,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x36,%rcx
add    %edx,%ecx
imul   $0x989680,%ecx,%ecx
neg    %ecx
add    %eax,%ecx
add    $0x1,%ecx
lea    0xe2c(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %ebp,%ebp
js     124d <main+0xed>
add    $0x1,%ebp
lea    0xe15(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x44b82fa1,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x3c,%rcx
add    %edx,%ecx
imul   $0x3b9aca00,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0xffffffff,%ebp
jne    1210 <main+0xb0>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"enormous_file.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 1000000
%7 = add nsw i32 %6, 1
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 10000000
%10 = add nsw i32 %9, 1
%11 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %10)
%12 = icmp slt i32 %6, 0
br i1 %12, label %21, label %13
13: ; preds = %0, %13
%14 = phi i32 [ %19, %13 ], [ 0, %0 ]
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 1000000000
%17 = add nsw i32 %16, 1
%18 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = add nuw nsw i32 %14, 1
%20 = icmp eq i32 %14, %6
br i1 %20, label %21, label %13
21: ; preds = %13, %0
%22 = tail call i32 @fclose(i32* %1)
ret i32 0
}