#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 atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: gen <number of lines>\n");
    exit(0);
  }
  int number = atoi(argv[1]);
  srand(time(NULL));
  char *buffer;
  for (int i = 0; i < number; i++) {
    int length = rand() % 10 + 5;
    buffer = (char *)malloc(sizeof(char) * (length + 1));
    for (int j = 0; j < length; j++) {
      buffer[j] = 'a' + (rand() % 26);
    }
    buffer[length] = 0;
    printf("%s\n", buffer);
    free(buffer);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11cc <main+0x3c>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    129c <main+0x10c>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x5,%edx
mov    %edx,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1269 <main+0xd9>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1232 <main+0xa2>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rsi
lea    0xd9e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f3 <main+0x63>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    129c <main+0x10c>
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%r15d
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
test   %r15d,%r15d
jle    128b <main+0xfb>
xor    %r13d,%r13d
jmp    11f9 <main+0x69>
nopl   0x0(%rax)
movb   $0x0,(%rbx,%r12,1)
lea    0xe42(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x1,%r13d
cmp    %r15d,%r13d
je     128b <main+0xfb>
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%edx
sub    %ecx,%edx
movslq %edx,%rbp
lea    0x5(%rbp),%r12
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x6,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
cmp    $0xfffffffc,%ebp
jl     11d0 <main+0x40>
mov    %r12d,%ebp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x61,%al
mov    %al,(%rbx,%r14,1)
add    $0x1,%r14
cmp    %r14,%rbp
jne    1250 <main+0xc0>
jmp    11d0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
lea    0xd54(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: gen <number of lines>\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = call i32 @time(i32* null)
%23 = call i32 @srand(i32 %22)
store i32 0, i32* %8
br label %24
24: ; preds = %64, %17
%25 = load i32, i32* %8
%26 = load i32, i32* %6
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %67
28: ; preds = %24
%29 = call i32 (...) @rand()
%30 = srem i32 %29, 10
%31 = add nsw i32 %30, 5
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = mul i64 1, %34
%36 = trunc i64 %35 to i32
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to i8*
store i8* %38, i8** %7
store i32 0, i32* %10
br label %39
39: ; preds = %52, %28
%40 = load i32, i32* %10
%41 = load i32, i32* %9
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %55
43: ; preds = %39
%44 = call i32 (...) @rand()
%45 = srem i32 %44, 26
%46 = add nsw i32 97, %45
%47 = trunc i32 %46 to i8
%48 = load i8*, i8** %7
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 %47, i8* %51
br label %52
52: ; preds = %43
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %10
br label %39
55: ; preds = %39
%56 = load i8*, i8** %7
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 0, i8* %59
%60 = load i8*, i8** %7
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %60)
%62 = load i8*, i8** %7
%63 = call i32 @free(i8* %62)
br label %64
64: ; preds = %55
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
store i32 %66, i32* %8
br label %24
67: ; preds = %24
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: gen <number of lines>\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = tail call i32 @time(i32* null)
%13 = tail call i32 @srand(i32 %12)
%14 = icmp sgt i32 %11, 0
br i1 %14, label %16, label %15
15: ; preds = %27, %8
ret i32 0
16: ; preds = %8, %27
%17 = phi i32 [ %32, %27 ], [ 0, %8 ]
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 10
%20 = add nsw i32 %19, 5
%21 = add nsw i32 %19, 6
%22 = tail call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
%24 = icmp sgt i32 %19, -5
br i1 %24, label %25, label %27
25: ; preds = %16
%26 = zext i32 %20 to i64
br label %34
27: ; preds = %34, %16
%28 = sext i32 %20 to i64
%29 = getelementptr inbounds i8, i8* %23, i64 %28
store i8 0, i8* %29
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%31 = tail call i32 @free(i8* %23)
%32 = add nuw nsw i32 %17, 1
%33 = icmp eq i32 %32, %11
br i1 %33, label %15, label %16
34: ; preds = %25, %34
%35 = phi i64 [ 0, %25 ], [ %41, %34 ]
%36 = tail call i32 (...) @rand()
%37 = srem i32 %36, 26
%38 = trunc i32 %37 to i8
%39 = add nsw i8 %38, 97
%40 = getelementptr inbounds i8, i8* %23, i64 %35
store i8 %39, i8* %40
%41 = add nuw nsw i64 %35, 1
%42 = icmp eq i64 %41, %26
br i1 %42, label %27, label %34
}