#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 EXIT_FAILURE;
int EXIT_SUCCESS;
long atol(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char *namegenerator_generate_name_with_length(int, int);
int /*<<< orphan*/ namegenerator_load(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, long *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  srand(time(NULL));
  namegenerator_load("trigrams.txt");
  long N;
  if (argc <= 1) {
    printf("How many names would you like to generate? ");
    fflush(stdout);
    char s[256];
    scanf("%s", s);
    if (!sscanf(s, "%ld", &N)) {
      return EXIT_FAILURE;
    }
  } else {
    N = atol(argv[1]);
  }
  long i;
  for (i = 0; i < N; i++) {
    printf("%s\n", namegenerator_generate_name_with_length(5, 16));
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe40(%rip),%rdi
call   1040 <namegenerator_load@plt>
cmpl   $0x1,-0x8(%rbp)
jg     1234 <main+0xa4>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x120(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   10a0 <scanf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe30(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1090 <sscanf@plt>
cmp    $0x0,%eax
jne    122f <main+0x9f>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a4 <main+0x114>
jmp    1245 <main+0xb5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atol@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x128(%rbp)
mov    -0x128(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1298 <main+0x108>
mov    $0x5,%edi
mov    $0x10,%esi
call   1080 <namegenerator_generate_name_with_length@plt>
mov    %rax,%rsi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    1250 <main+0xc0>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe3d(%rip),%rdi
call   1050 <namegenerator_load@plt>
cmp    $0x1,%ebp
jg     1221 <main+0x81>
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
lea    0xe49(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   10b0 <scanf@plt>
lea    0xe38(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   10a0 <sscanf@plt>
test   %eax,%eax
je     126b <main+0xcb>
mov    0x8(%rsp),%rax
test   %rax,%rax
jg     1234 <main+0x94>
jmp    1262 <main+0xc2>
mov    0x8(%rbx),%rdi
call   10c0 <atol@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
jle    1262 <main+0xc2>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x5,%edi
mov    $0x10,%esi
call   1090 <namegenerator_generate_name_with_length@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
add    $0x1,%rbx
cmp    0x8(%rsp),%rbx
jl     1240 <main+0xa0>
mov    0x2d67(%rip),%rax
jmp    1272 <main+0xd2>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
add    $0x118,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"trigrams.txt\00"
@.str.1 = [44 x i8] c"How many names would you like to generate? \00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c"%ld\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [256 x i8]
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = call i32 @namegenerator_load(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %4
%13 = icmp sle i32 %12, 1
br i1 %13, label %14, label %26
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @stdout
%17 = call i32 @fflush(i32 %16)
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %6)
%22 = icmp ne i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %14
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %3
br label %44
25: ; preds = %14
br label %31
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i64 @atol(i8* %29)
store i64 %30, i64* %6
br label %31
31: ; preds = %26, %25
store i64 0, i64* %8
br label %32
32: ; preds = %39, %31
%33 = load i64, i64* %8
%34 = load i64, i64* %6
%35 = icmp slt i64 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = call i8* @namegenerator_generate_name_with_length(i32 5, i32 16)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36
%40 = load i64, i64* %8
%41 = add nsw i64 %40, 1
store i64 %41, i64* %8
br label %32
42: ; preds = %32
%43 = load i32, i32* @EXIT_SUCCESS
store i32 %43, i32* %3
br label %44
44: ; preds = %42, %23
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [13 x i8] c"trigrams.txt\00"
@.str.1 = [44 x i8] c"How many names would you like to generate? \00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c"%ld\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca [256 x i8]
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = tail call i32 @namegenerator_load(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = bitcast i64* %3 to i8*
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stdout
%13 = tail call i32 @fflush(i32 %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %3)
%17 = icmp eq i32 %16, 0
%18 = load i32, i32* @EXIT_FAILURE
br i1 %17, label %37, label %19
19: ; preds = %10
%20 = load i64, i64* %3
br label %25
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i64 @atol(i8* %23)
store i64 %24, i64* %3
br label %25
25: ; preds = %19, %21
%26 = phi i64 [ %20, %19 ], [ %24, %21 ]
%27 = icmp sgt i64 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %25, %28
%29 = phi i64 [ %32, %28 ], [ 0, %25 ]
%30 = call i8* @namegenerator_generate_name_with_length(i32 5, i32 16)
%31 = call i32 @puts(i8* dereferenceable(1) %30)
%32 = add nuw nsw i64 %29, 1
%33 = load i64, i64* %3
%34 = icmp slt i64 %32, %33
br i1 %34, label %28, label %35
35: ; preds = %28, %25
%36 = load i32, i32* @EXIT_SUCCESS
br label %37
37: ; preds = %10, %35
%38 = phi i32 [ %36, %35 ], [ %18, %10 ]
ret i32 %38
}