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

/* Variables and functions */
int atoi(char const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int fread(char *, int, int, int /*<<< orphan*/ *);
int rand();
int /*<<< orphan*/ showusage();
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strsep(char **, char *);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, const char **argv) {
  if (argc < 2)
    showusage();
  int num_columns = atoi(argv[1]);
  time_t t;
  int i, j, num_words, add_delimiter;
  char *words[1024 * 128];
  char buffer[1024 * 1024];
  char *word;
  char *buffer_ptr;
  FILE *dict = fopen("/usr/share/dict/words", "rb");
  int num_read = fread(buffer, sizeof(char), sizeof(buffer), dict);
  if (!num_read) {
    fprintf(stderr, "error: didnt read any bytes\n");
    exit(1);
  }
  buffer_ptr = buffer;
  i = 0;
  while ((word = strsep(&buffer_ptr, "\n")))
    words[i++] = word;
  num_words = i;
  srand((unsigned)time(&t));
  while (1) {
    add_delimiter = 0;
    for (j = 0; j < num_columns; j++) {
      if (add_delimiter)
        fputs(",", stdout);
      fputs(words[rand() % num_words], stdout);
      add_delimiter = 1;
    }
    fputs("\n", stdout);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11da <main+0x2a>
mov    $0x0,%al
call   10c0 <showusage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    0xe0f(%rip),%rdi
lea    0xe1e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x200048(%rbp)
lea    -0x200030(%rbp),%rdi
mov    -0x200048(%rbp),%rcx
mov    $0x1,%esi
mov    $0x100000,%edx
call   1030 <fread@plt>
mov    %eax,-0x20004c(%rbp)
cmpl   $0x0,-0x20004c(%rbp)
jne    1253 <main+0xa3>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
lea    0xdd5(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    -0x200030(%rbp),%rax
mov    %rax,-0x200040(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x200040(%rbp),%rdi
lea    0xdbe(%rip),%rsi
call   1080 <strsep@plt>
mov    %rax,-0x200038(%rbp)
cmp    $0x0,%rax
je     12ad <main+0xfd>
mov    -0x200038(%rbp),%rcx
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %rcx,-0x100030(%rbp,%rax,8)
ff
jmp    1268 <main+0xb8>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1335 <main+0x185>
cmpl   $0x0,-0x28(%rbp)
je     12fc <main+0x14c>
mov    0x2cea(%rip),%rax
mov    (%rax),%esi
lea    0xd3f(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x0,%al
call   10d0 <rand@plt>
cltd
idivl  -0x24(%rbp)
movslq %edx,%rax
mov    -0x100030(%rbp,%rax,8),%rdi
ff
mov    0x2cbf(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
movl   $0x1,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12d1 <main+0x121>
mov    0x2c9c(%rip),%rax
mov    (%rax),%esi
lea    0xcef(%rip),%rdi
call   1040 <fputs@plt>
jmp    12c3 <main+0x113>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x200028,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11d0 <main+0x20>
xor    %eax,%eax
call   10c0 <showusage@plt>
mov    0x8(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
lea    0xe1d(%rip),%rdi
lea    0xe2c(%rip),%rsi
call   1090 <fopen@plt>
lea    0x100020(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x100000,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
test   %eax,%eax
je     12fd <main+0x14d>
mov    %rbx,0x10(%rsp)
lea    0xe14(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strsep@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1259 <main+0xa9>
lea    0xdfc(%rip),%r15
lea    0x10(%rsp),%r12
nopl   (%rax)
mov    %rax,0x20(%rsp,%rbx,8)
add    $0x1,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
call   1080 <strsep@plt>
test   %rax,%rax
jne    1240 <main+0x90>
lea    0x1c(%rsp),%rdi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    -0x1(%r14),%eax
mov    %eax,0xc(%rsp)
mov    0x2d5f(%rip),%rbp
lea    0xdb6(%rip),%r12
lea    0xdad(%rip),%r15
jmp    129b <main+0xeb>
nopl   0x0(%rax)
mov    0x0(%rbp),%esi
mov    %r15,%rdi
call   1040 <fputs@plt>
test   %r14d,%r14d
jle    1290 <main+0xe0>
xor    %eax,%eax
call   10d0 <rand@plt>
cltd
idiv   %ebx
movslq %edx,%rax
mov    0x20(%rsp,%rax,8),%rdi
mov    0x0(%rbp),%esi
call   1040 <fputs@plt>
cmp    $0x1,%r14d
je     1290 <main+0xe0>
mov    0xc(%rsp),%r13d
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%rbp),%esi
mov    %r12,%rdi
call   1040 <fputs@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
cltd
idiv   %ebx
movslq %edx,%rax
mov    0x20(%rsp,%rax,8),%rdi
mov    0x0(%rbp),%esi
call   1040 <fputs@plt>
add    $0xffffffff,%r13d
jne    12d0 <main+0x120>
jmp    1290 <main+0xe0>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
lea    0xd0c(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"/usr/share/dict/words\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"error: didnt read any bytes\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [2 x i8] c",\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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [131072 x i8*]
%13 = alloca [1048576 x i8]
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32*
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 (...) @showusage()
br label %22
22: ; preds = %20, %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %6
%27 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %16
%28 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %13, i64 0, i64 0
%29 = load i32*, i32** %16
%30 = call i32 @fread(i8* %28, i32 1, i32 1048576, i32* %29)
store i32 %30, i32* %17
%31 = load i32, i32* %17
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %22
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %22
%38 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %13, i64 0, i64 0
store i8* %38, i8** %15
store i32 0, i32* %8
br label %39
39: ; preds = %42, %37
%40 = call i8* @strsep(i8** %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %40, i8** %14
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i8*, i8** %14
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds [131072 x i8*], [131072 x i8*]* %12, i64 0, i64 %46
store i8* %43, i8** %47
br label %39
48: ; preds = %39
%49 = load i32, i32* %8
store i32 %49, i32* %10
%50 = call i64 @time(i32* %7)
%51 = trunc i64 %50 to i32
%52 = call i32 @srand(i32 %51)
br label %53
53: ; preds = %48, %76
store i32 0, i32* %11
store i32 0, i32* %9
br label %54
54: ; preds = %73, %53
%55 = load i32, i32* %9
%56 = load i32, i32* %6
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %76
58: ; preds = %54
%59 = load i32, i32* %11
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load i32, i32* @stdout
%63 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %61, %58
%65 = call i32 (...) @rand()
%66 = load i32, i32* %10
%67 = srem i32 %65, %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [131072 x i8*], [131072 x i8*]* %12, i64 0, i64 %68
%70 = load i8*, i8** %69
%71 = load i32, i32* @stdout
%72 = call i32 @fputs(i8* %70, i32 %71)
store i32 1, i32* %11
br label %73
73: ; preds = %64
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
br label %54
76: ; preds = %54
%77 = load i32, i32* @stdout
%78 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %77)
br label %53
}

LLVM IR (-O2):
@.str = [22 x i8] c"/usr/share/dict/words\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"error: didnt read any bytes\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [2 x i8] c",\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [131072 x i8*]
%5 = alloca [1048576 x i8]
%6 = alloca i8*
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 (...) @showusage()
br label %10
10: ; preds = %8, %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = bitcast i32* %3 to i8*
%15 = bitcast [131072 x i8*]* %4 to i8*
%16 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %5, i64 0, i64 0
%17 = bitcast i8** %6 to i8*
%18 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @fread(i8* %16, i32 1, i32 1048576, i32* %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %10
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %10
store i8* %16, i8** %6
%26 = call i8* @strsep(i8** %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i8* %26, null
br i1 %27, label %37, label %28
28: ; preds = %25, %28
%29 = phi i64 [ %31, %28 ], [ 0, %25 ]
%30 = phi i8* [ %33, %28 ], [ %26, %25 ]
%31 = add nuw i64 %29, 1
%32 = getelementptr inbounds [131072 x i8*], [131072 x i8*]* %4, i64 0, i64 %29
store i8* %30, i8** %32
%33 = call i8* @strsep(i8** %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %28
35: ; preds = %28
%36 = trunc i64 %31 to i32
br label %37
37: ; preds = %35, %25
%38 = phi i32 [ 0, %25 ], [ %36, %35 ]
%39 = call i64 @time(i32* %3)
%40 = trunc i64 %39 to i32
%41 = call i32 @srand(i32 %40)
%42 = icmp sgt i32 %13, 0
%43 = icmp eq i32 %13, 1
br label %44
44: ; preds = %66, %37
br i1 %42, label %45, label %66
45: ; preds = %44
%46 = call i32 (...) @rand()
%47 = srem i32 %46, %38
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [131072 x i8*], [131072 x i8*]* %4, i64 0, i64 %48
%50 = load i8*, i8** %49
%51 = load i32, i32* @stdout
%52 = call i32 @fputs(i8* %50, i32 %51)
br i1 %43, label %66, label %53
53: ; preds = %45, %53
%54 = phi i32 [ %64, %53 ], [ 1, %45 ]
%55 = load i32, i32* @stdout
%56 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %55)
%57 = call i32 (...) @rand()
%58 = srem i32 %57, %38
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [131072 x i8*], [131072 x i8*]* %4, i64 0, i64 %59
%61 = load i8*, i8** %60
%62 = load i32, i32* @stdout
%63 = call i32 @fputs(i8* %61, i32 %62)
%64 = add nuw nsw i32 %54, 1
%65 = icmp eq i32 %64, %13
br i1 %65, label %66, label %53
66: ; preds = %53, %45, %44
%67 = load i32, i32* @stdout
%68 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %67)
br label %44
}