#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int rand();
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(int argc, char *argv[]) {
  int nwords;
  int seed;
  switch (argc) {
  case 2:
    nwords = atoi(argv[1]);
    seed = 42;
    break;
  case 3:
    nwords = atoi(argv[1]);
    seed = atoi(argv[2]);
    break;
  default:
    fprintf(stderr, "Usage: %s #words Seed\n", argv[0]);
    return 1;
  }
  srand(seed);
  char *letters = "aaaabccdeeeeeefghhiiijkllmmnnoooopqrrssttuuvwxyz";
  int nletters = strlen(letters);
  int i, j, len;
  char word[17];
  for (i = 0; i < nwords; i++) {
    len = rand() % 14 + 2;
    for (j = 0; j < len; j++)
      word[j] = letters[rand() % nletters];
    word[j] = '\n';
    word[j + 1] = '\0';
    fputs(word, stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x2,%eax
je     119b <main+0x3b>
jmp    118a <main+0x2a>
mov    -0x54(%rbp),%eax
sub    $0x3,%eax
je     11b7 <main+0x57>
jmp    11dc <main+0x7c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x2a,-0x18(%rbp)
jmp    1204 <main+0xa4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    1204 <main+0xa4>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe0d(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ce <main+0x16e>
mov    -0x18(%rbp),%edi
call   1050 <srand@plt>
lea    0xe04(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12c7 <main+0x167>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0xe,%ecx
cltd
idiv   %ecx
add    $0x2,%edx
mov    %edx,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1291 <main+0x131>
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
cltd
idivl  -0x24(%rbp)
mov    -0x60(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x2c(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1252 <main+0xf2>
movslq -0x2c(%rbp),%rax
movb   $0xa,-0x50(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
mov    0x2d26(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    122a <main+0xca>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1192 <main+0x32>
cmp    $0x2,%edi
jne    1283 <main+0x123>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    $0x2a,%edi
jmp    11a9 <main+0x49>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe62(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %r14d,%r14d
jle    127f <main+0x11f>
mov    %eax,%ebp
mov    0x2e09(%rip),%r15
xor    %r13d,%r13d
mov    %r14d,0xc(%rsp)
jmp    1203 <main+0xa3>
nopl   0x0(%rax)
mov    %eax,%eax
movw   $0xa,0x10(%rsp,%rax,1)
mov    (%r15),%esi
lea    0x10(%rsp),%rdi
call   1040 <fputs@plt>
add    $0x1,%r13d
cmp    %r14d,%r13d
je     127f <main+0x11f>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x3,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x4,%edx
mov    %ecx,%r12d
sub    %edx,%r12d
add    %ecx,%r12d
add    %eax,%r12d
mov    $0x0,%eax
cmp    $0xffffffff,%r12d
jl     11e0 <main+0x80>
mov    %r15,%r14
add    $0x2,%r12d
xor    %r15d,%r15d
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <rand@plt>
cltd
idiv   %ebp
movslq %edx,%rax
movzbl (%rax,%rbx,1),%eax
mov    %al,0x10(%rsp,%r15,1)
add    $0x1,%r15
cmp    %r15,%r12
jne    1250 <main+0xf0>
mov    %r12d,%eax
mov    %r14,%r15
mov    0xc(%rsp),%r14d
jmp    11e0 <main+0x80>
xor    %eax,%eax
jmp    12a0 <main+0x140>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd6a(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"Usage: %s #words Seed\0A\00"
@.str.1 = [49 x i8] c"aaaabccdeeeeeefghhiiijkllmmnnoooopqrrssttuuvwxyz\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [17 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
switch i32 %14, label %29 [
i32 2, label %15
i32 3, label %20
]
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %6
store i32 42, i32* %7
br label %35
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
br label %35
29: ; preds = %2
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %33)
store i32 1, i32* %3
br label %81
35: ; preds = %20, %15
%36 = load i32, i32* %7
%37 = call i32 @srand(i32 %36)
store i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8** %8
%38 = load i8*, i8** %8
%39 = call i32 @strlen(i8* %38)
store i32 %39, i32* %9
store i32 0, i32* %10
br label %40
40: ; preds = %77, %35
%41 = load i32, i32* %10
%42 = load i32, i32* %6
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %80
44: ; preds = %40
%45 = call i32 (...) @rand()
%46 = srem i32 %45, 14
%47 = add nsw i32 %46, 2
store i32 %47, i32* %12
store i32 0, i32* %11
br label %48
48: ; preds = %63, %44
%49 = load i32, i32* %11
%50 = load i32, i32* %12
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %66
52: ; preds = %48
%53 = load i8*, i8** %8
%54 = call i32 (...) @rand()
%55 = load i32, i32* %9
%56 = srem i32 %54, %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %53, i64 %57
%59 = load i8, i8* %58
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [17 x i8], [17 x i8]* %13, i64 0, i64 %61
store i8 %59, i8* %62
br label %63
63: ; preds = %52
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 1
store i32 %65, i32* %11
br label %48
66: ; preds = %48
%67 = load i32, i32* %11
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [17 x i8], [17 x i8]* %13, i64 0, i64 %68
store i8 10, i8* %69
%70 = load i32, i32* %11
%71 = add nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [17 x i8], [17 x i8]* %13, i64 0, i64 %72
store i8 0, i8* %73
%74 = getelementptr inbounds [17 x i8], [17 x i8]* %13, i64 0, i64 0
%75 = load i32, i32* @stdout
%76 = call i32 @fputs(i8* %74, i32 %75)
br label %77
77: ; preds = %66
%78 = load i32, i32* %10
%79 = add nsw i32 %78, 1
store i32 %79, i32* %10
br label %40
80: ; preds = %40
store i32 0, i32* %3
br label %81
81: ; preds = %80, %29
%82 = load i32, i32* %3
ret i32 %82
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"Usage: %s #words Seed\0A\00"
@.str.1 = [49 x i8] c"aaaabccdeeeeeefghhiiijkllmmnnoooopqrrssttuuvwxyz\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [17 x i8]
switch i32 %0, label %15 [
i32 2, label %4
i32 3, label %8
]
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %19
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
br label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %1
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %56
19: ; preds = %8, %4
%20 = phi i32 [ %14, %8 ], [ 42, %4 ]
%21 = phi i32 [ %11, %8 ], [ %7, %4 ]
%22 = tail call i32 @srand(i32 %20)
%23 = tail call i32 @strlen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%25 = icmp sgt i32 %21, 0
br i1 %25, label %26, label %55
26: ; preds = %19, %44
%27 = phi i32 [ %53, %44 ], [ 0, %19 ]
%28 = call i32 (...) @rand()
%29 = srem i32 %28, 14
%30 = icmp sgt i32 %29, -2
br i1 %30, label %31, label %44
31: ; preds = %26
%32 = add nsw i32 %29, 2
%33 = zext i32 %32 to i64
br label %34
34: ; preds = %31, %34
%35 = phi i64 [ 0, %31 ], [ %42, %34 ]
%36 = call i32 (...) @rand()
%37 = srem i32 %36, %23
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [49 x i8], [49 x i8]* @.str.1, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %35
store i8 %40, i8* %41
%42 = add nuw nsw i64 %35, 1
%43 = icmp eq i64 %42, %33
br i1 %43, label %44, label %34
44: ; preds = %34, %26
%45 = phi i32 [ 0, %26 ], [ %32, %34 ]
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %46
store i8 10, i8* %47
%48 = add nuw nsw i32 %45, 1
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %49
store i8 0, i8* %50
%51 = load i32, i32* @stdout
%52 = call i32 @fputs(i8* %24, i32 %51)
%53 = add nuw nsw i32 %27, 1
%54 = icmp eq i32 %53, %21
br i1 %54, label %55, label %26
55: ; preds = %44, %19
br label %56
56: ; preds = %55, %15
%57 = phi i32 [ 1, %15 ], [ 0, %55 ]
ret i32 %57
}