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

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, int /*<<< orphan*/, int,
                          int /*<<< orphan*/ *);
int pow(int, int);
int rand();
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  FILE *fp = fopen("numbers.txt", "w");
  srand(time(NULL));
  char n[20];
  int i;
  for (i = 0; i < 1000000; i++) {
    bzero(n, 20);
    uint64_t exp = pow(10, rand() % 11 + 3);
    snprintf(n, 20, "%lu\n", rand() % exp);
    fwrite(n, strlen(n), 1, fp);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe43(%rip),%rdi
lea    0xe48(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xf4240,-0x34(%rbp)
jge    127d <main+0xdd>
lea    -0x30(%rbp),%rdi
mov    $0x14,%esi
call   10a0 <bzero@plt>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x3,%esi
mov    $0xa,%edi
call   1090 <pow@plt>
mov    %eax,-0x38(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   10c0 <rand@plt>
mov    -0x48(%rbp),%rdi
cltd
idivl  -0x38(%rbp)
mov    %edx,%ecx
mov    $0x14,%esi
lea    0xdc9(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   10b0 <fwrite@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11e4 <main+0x44>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xe4d(%rip),%rdi
lea    0xe52(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0xf4240,%ebx
mov    %rsp,%r12
lea    0xe2f(%rip),%r15
nop
mov    %r12,%rdi
mov    $0x14,%esi
call   10a0 <bzero@plt>
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0x3,%esi
mov    $0xa,%edi
call   1090 <pow@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10c0 <rand@plt>
cltd
idiv   %ebp
mov    %edx,%ecx
mov    %r12,%rdi
mov    $0x14,%esi
mov    %r15,%rdx
call   1050 <snprintf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10b0 <fwrite@plt>
add    $0xffffffff,%ebx
jne    11e0 <main+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"numbers.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [20 x i8]
%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 ([12 x i8], [12 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** %6
%11 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
store i32 0, i32* %8
br label %13
13: ; preds = %33, %2
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 1000000
br i1 %15, label %16, label %36
16: ; preds = %13
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%18 = call i32 @bzero(i8* %17, i32 20)
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 11
%21 = add nsw i32 %20, 3
%22 = call i32 @pow(i32 10, i32 %21)
store i32 %22, i32* %9
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%24 = call i32 (...) @rand()
%25 = load i32, i32* %9
%26 = srem i32 %24, %25
%27 = call i32 @snprintf(i8* %23, i32 20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = load i32*, i32** %6
%32 = call i32 @fwrite(i8* %28, i32 %30, i32 1, i32* %31)
br label %33
33: ; preds = %16
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %13
36: ; preds = %13
%37 = load i32*, i32** %6
%38 = call i32 @fclose(i32* %37)
ret i32 0
}

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