#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*/ FILE;

/* Variables and functions */
int atoi(char *);
int countlines(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ is_numeric(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
char *remove_newline(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int numnames = 3;
  int argnum;
  for (argnum = 1; argnum < argc; argnum++) {
    if (strncmp(argv[argnum], "-h", 2) == 0 ||
        strncmp(argv[argnum], "--help", 6) == 0) {
      printf("usage: %s [number of names]\n", argv[0]);
      printf("Name Generator\nPlace First Names in firstname.txt and surnames "
             "in surname.txt\nA numerical parameter can specify the number of "
             "names to generate.\nThe default number of names is 3.\n");
      return 1;
    }
    if (argc > 2 || !(is_numeric(argv[argnum]))) {
      printf("usage: %s [number of names]\n", argv[0]);
      return 1;
    }
    numnames = atoi(argv[argnum]);
  }
  FILE *firstnamep = fopen("firstname.txt", "r");
  if (firstnamep == NULL) {
    perror("Error opening firstname.txt");
    return 1;
  }
  FILE *surnamep = fopen("surname.txt", "r");
  if (surnamep == NULL) {
    perror("Error opening surname.txt");
    return 1;
  }
  int firstnametotal = 0, surnametotal = 0;
  firstnametotal = countlines(firstnamep);
  surnametotal = countlines(surnamep);
  rewind(firstnamep);
  rewind(surnamep);
  srand(time(NULL));
  char *firstnameresult = NULL;
  char *surnameresult = NULL;
  firstnameresult = (char *)malloc(255 * sizeof(char));
  surnameresult = (char *)malloc(255 * sizeof(char));
  int name;
  for (name = 0; name < numnames; name++) {
    int surnum = 0, firstnum = 0;
    firstnum = rand() % firstnametotal;
    surnum = rand() % surnametotal;
    int i;
    for (i = 0; i < firstnum; i++) {
      fgets(firstnameresult, 255, firstnamep);
    }
    for (i = 0; i < surnum; i++) {
      fgets(surnameresult, 255, surnamep);
    }
    firstnameresult = remove_newline(firstnameresult);
    surnameresult = remove_newline(surnameresult);
    printf("%s %s\n", firstnameresult, surnameresult);
    rewind(firstnamep);
    rewind(surnamep);
  }
  printf("\n Returned %d names out of %d firstnames and %d surnames\n",
         numnames, firstnametotal, surnametotal);
  fclose(firstnamep);
  fclose(surnamep);
  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)
movl   $0x3,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1304 <main+0x114>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdcd(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     126e <main+0x7e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xda9(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    129d <main+0xad>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    150f <main+0x31f>
cmpl   $0x2,-0x8(%rbp)
jg     12c1 <main+0xd1>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <is_numeric@plt>
cmp    $0x0,%eax
jne    12e2 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    150f <main+0x31f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1214 <main+0x24>
lea    0xde0(%rip),%rdi
lea    0xdc9(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    133e <main+0x14e>
lea    0xdb0(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    150f <main+0x31f>
lea    0xdc2(%rip),%rdi
lea    0xd8f(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1378 <main+0x188>
lea    0xd92(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    150f <main+0x31f>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <countlines@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <countlines@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <rewind@plt>
mov    -0x28(%rbp),%rdi
call   1080 <rewind@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,%edi
call   10a0 <srand@plt>
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    $0xff,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0xff,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    14df <main+0x2ef>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    $0x0,%al
call   1110 <rand@plt>
cltd
idivl  -0x2c(%rbp)
mov    %edx,-0x4c(%rbp)
mov    $0x0,%al
call   1110 <rand@plt>
cltd
idivl  -0x30(%rbp)
mov    %edx,-0x48(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    145c <main+0x26c>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xff,%esi
call   10b0 <fgets@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1430 <main+0x240>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    148f <main+0x29f>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0xff,%esi
call   10b0 <fgets@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1463 <main+0x273>
mov    -0x38(%rbp),%rdi
call   1040 <remove_newline@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <remove_newline@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1080 <rewind@plt>
mov    -0x28(%rbp),%rdi
call   1080 <rewind@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    13f3 <main+0x203>
mov    -0x14(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
lea    0xc2b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x3,0x8(%rsp)
cmp    $0x2,%edi
jl     1283 <main+0x83>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xdd5(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13f9 <main+0x1f9>
mov    0x8(%rbx),%rdi
lea    0xdba(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13f9 <main+0x1f9>
cmp    $0x2,%ebp
jne    1418 <main+0x218>
mov    0x8(%rbx),%rdi
call   1070 <is_numeric@plt>
test   %eax,%eax
je     1418 <main+0x218>
mov    0x8(%rbx),%rdi
call   1110 <atoi@plt>
mov    %eax,0x8(%rsp)
lea    0xdad(%rip),%rdi
lea    0xd96(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     142b <main+0x22b>
mov    %rax,%rbx
lea    0xdaa(%rip),%rdi
lea    0xd77(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1434 <main+0x234>
mov    %rax,%rbp
mov    %rbx,%rdi
call   10a0 <countlines@plt>
mov    %eax,0x10(%rsp)
mov    %rbp,%rdi
call   10a0 <countlines@plt>
mov    %eax,0xc(%rsp)
mov    %rbx,%rdi
call   1090 <rewind@plt>
mov    %rbp,%rdi
call   1090 <rewind@plt>
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,%edi
call   10b0 <srand@plt>
mov    $0xff,%edi
call   10e0 <malloc@plt>
mov    %rax,%r15
mov    $0xff,%edi
call   10e0 <malloc@plt>
cmpl   $0x0,0x8(%rsp)
jle    13cb <main+0x1cb>
mov    %rax,%r14
xor    %eax,%eax
jmp    1367 <main+0x167>
mov    %r15,%rdi
call   1050 <remove_newline@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1050 <remove_newline@plt>
mov    %rax,%r14
lea    0xd22(%rip),%rdi
mov    %r15,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1090 <rewind@plt>
mov    %rbp,%rdi
call   1090 <rewind@plt>
mov    0x14(%rsp),%eax
add    $0x1,%eax
cmp    0x8(%rsp),%eax
je     13cb <main+0x1cb>
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1120 <rand@plt>
cltd
idivl  0x10(%rsp)
mov    %edx,%r13d
xor    %eax,%eax
call   1120 <rand@plt>
cltd
idivl  0xc(%rsp)
mov    %edx,%r12d
test   %r13d,%r13d
jle    13a6 <main+0x1a6>
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   10c0 <fgets@plt>
add    $0xffffffff,%r13d
jne    1390 <main+0x190>
test   %r12d,%r12d
jle    1320 <main+0x120>
nop
mov    %r14,%rdi
mov    $0xff,%esi
mov    %rbp,%rdx
call   10c0 <fgets@plt>
add    $0xffffffff,%r12d
jne    13b0 <main+0x1b0>
jmp    1320 <main+0x120>
lea    0xc94(%rip),%rdi
mov    0x8(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
jmp    1445 <main+0x245>
mov    (%rbx),%rsi
lea    0xc07(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc8f(%rip),%rdi
call   1040 <puts@plt>
jmp    1440 <main+0x240>
mov    (%rbx),%rsi
lea    0xbe8(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1440 <main+0x240>
lea    0xbf7(%rip),%rdi
jmp    143b <main+0x23b>
lea    0xc0a(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [29 x i8] c"usage: %s [number of names]\0A\00"
@.str.3 = [180 x i8] c"Name Generator\0APlace First Names in firstname.txt and surnames in surname.txt\0AA numerical parameter can specify the number of names to generate.\0AThe default number of names is 3.\0A\00"
@.str.4 = [14 x i8] c"firstname.txt\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [28 x i8] c"Error opening firstname.txt\00"
@.str.7 = [12 x i8] c"surname.txt\00"
@.str.8 = [26 x i8] c"Error opening surname.txt\00"
@.str.9 = [7 x i8] c"%s %s\0A\00"
@.str.10 = [58 x i8] c"\0A Returned %d names out of %d firstnames and %d surnames\0A\00"
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 i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %6
store i32 1, i32* %7
br label %18
18: ; preds = %67, %2
%19 = load i32, i32* %7
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %70
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%29 = icmp eq i64 %28, 0
br i1 %29, label %38, label %30
30: ; preds = %22
%31 = load i8**, i8*** %5
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i64 @strncmp(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %30, %22
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %155
44: ; preds = %30
%45 = load i32, i32* %4
%46 = icmp sgt i32 %45, 2
br i1 %46, label %55, label %47
47: ; preds = %44
%48 = load i8**, i8*** %5
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 @is_numeric(i8* %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %60, label %55
55: ; preds = %47, %44
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 0
%58 = load i8*, i8** %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %58)
store i32 1, i32* %3
br label %155
60: ; preds = %47
%61 = load i8**, i8*** %5
%62 = load i32, i32* %7
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = call i32 @atoi(i8* %65)
store i32 %66, i32* %6
br label %67
67: ; preds = %60
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %18
70: ; preds = %18
%71 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %71, i32** %8
%72 = load i32*, i32** %8
%73 = icmp eq i32* %72, null
br i1 %73, label %74, label %76
74: ; preds = %70
%75 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %155
76: ; preds = %70
%77 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %77, i32** %9
%78 = load i32*, i32** %9
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %82
80: ; preds = %76
%81 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %155
82: ; preds = %76
store i32 0, i32* %10
store i32 0, i32* %11
%83 = load i32*, i32** %8
%84 = call i32 @countlines(i32* %83)
store i32 %84, i32* %10
%85 = load i32*, i32** %9
%86 = call i32 @countlines(i32* %85)
store i32 %86, i32* %11
%87 = load i32*, i32** %8
%88 = call i32 @rewind(i32* %87)
%89 = load i32*, i32** %9
%90 = call i32 @rewind(i32* %89)
%91 = call i32 @time(i32* null)
%92 = call i32 @srand(i32 %91)
store i8* null, i8** %12
store i8* null, i8** %13
%93 = call i64 @malloc(i32 255)
%94 = inttoptr i64 %93 to i8*
store i8* %94, i8** %12
%95 = call i64 @malloc(i32 255)
%96 = inttoptr i64 %95 to i8*
store i8* %96, i8** %13
store i32 0, i32* %14
br label %97
97: ; preds = %143, %82
%98 = load i32, i32* %14
%99 = load i32, i32* %6
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %146
101: ; preds = %97
store i32 0, i32* %15
store i32 0, i32* %16
%102 = call i32 (...) @rand()
%103 = load i32, i32* %10
%104 = srem i32 %102, %103
store i32 %104, i32* %16
%105 = call i32 (...) @rand()
%106 = load i32, i32* %11
%107 = srem i32 %105, %106
store i32 %107, i32* %15
store i32 0, i32* %17
br label %108
108: ; preds = %116, %101
%109 = load i32, i32* %17
%110 = load i32, i32* %16
%111 = icmp slt i32 %109, %110
br i1 %111, label %112, label %119
112: ; preds = %108
%113 = load i8*, i8** %12
%114 = load i32*, i32** %8
%115 = call i32 @fgets(i8* %113, i32 255, i32* %114)
br label %116
116: ; preds = %112
%117 = load i32, i32* %17
%118 = add nsw i32 %117, 1
store i32 %118, i32* %17
br label %108
119: ; preds = %108
store i32 0, i32* %17
br label %120
120: ; preds = %128, %119
%121 = load i32, i32* %17
%122 = load i32, i32* %15
%123 = icmp slt i32 %121, %122
br i1 %123, label %124, label %131
124: ; preds = %120
%125 = load i8*, i8** %13
%126 = load i32*, i32** %9
%127 = call i32 @fgets(i8* %125, i32 255, i32* %126)
br label %128
128: ; preds = %124
%129 = load i32, i32* %17
%130 = add nsw i32 %129, 1
store i32 %130, i32* %17
br label %120
131: ; preds = %120
%132 = load i8*, i8** %12
%133 = call i8* @remove_newline(i8* %132)
store i8* %133, i8** %12
%134 = load i8*, i8** %13
%135 = call i8* @remove_newline(i8* %134)
store i8* %135, i8** %13
%136 = load i8*, i8** %12
%137 = load i8*, i8** %13
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %136, i8* %137)
%139 = load i32*, i32** %8
%140 = call i32 @rewind(i32* %139)
%141 = load i32*, i32** %9
%142 = call i32 @rewind(i32* %141)
br label %143
143: ; preds = %131
%144 = load i32, i32* %14
%145 = add nsw i32 %144, 1
store i32 %145, i32* %14
br label %97
146: ; preds = %97
%147 = load i32, i32* %6
%148 = load i32, i32* %10
%149 = load i32, i32* %11
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.10, i64 0, i64 0), i32 %147, i32 %148, i32 %149)
%151 = load i32*, i32** %8
%152 = call i32 @fclose(i32* %151)
%153 = load i32*, i32** %9
%154 = call i32 @fclose(i32* %153)
store i32 0, i32* %3
br label %155
155: ; preds = %146, %80, %74, %55, %38
%156 = load i32, i32* %3
ret i32 %156
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [29 x i8] c"usage: %s [number of names]\0A\00"
@.str.4 = [14 x i8] c"firstname.txt\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [28 x i8] c"Error opening firstname.txt\00"
@.str.7 = [12 x i8] c"surname.txt\00"
@.str.8 = [26 x i8] c"Error opening surname.txt\00"
@.str.9 = [7 x i8] c"%s %s\0A\00"
@.str.10 = [58 x i8] c"\0A Returned %d names out of %d firstnames and %d surnames\0A\00"
@str = [179 x i8] c"Name Generator\0APlace First Names in firstname.txt and surnames in surname.txt\0AA numerical parameter can specify the number of names to generate.\0AThe default number of names is 3.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %29
4: ; preds = %2
%5 = icmp eq i32 %0, 2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %4
%11 = load i8*, i8** %6
%12 = tail call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10, %4
%15 = load i8*, i8** %1
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([179 x i8], [179 x i8]* @str, i64 0, i64 0))
br label %86
18: ; preds = %10
br i1 %5, label %19, label %23
19: ; preds = %18
%20 = load i8*, i8** %6
%21 = tail call i32 @is_numeric(i8* %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19, %18
%24 = load i8*, i8** %1
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %86
26: ; preds = %19
%27 = load i8*, i8** %6
%28 = tail call i32 @atoi(i8* %27)
br label %29
29: ; preds = %26, %2
%30 = phi i32 [ 3, %2 ], [ %28, %26 ]
%31 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %86
35: ; preds = %29
%36 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
br label %86
40: ; preds = %35
%41 = tail call i32 @countlines(i32* %31)
%42 = tail call i32 @countlines(i32* %36)
%43 = tail call i32 @rewind(i32* %31)
%44 = tail call i32 @rewind(i32* %36)
%45 = tail call i32 @time(i32* null)
%46 = tail call i32 @srand(i32 %45)
%47 = tail call i64 @malloc(i32 255)
%48 = tail call i64 @malloc(i32 255)
%49 = icmp sgt i32 %30, 0
br i1 %49, label %50, label %82
50: ; preds = %40
%51 = inttoptr i64 %48 to i8*
%52 = inttoptr i64 %47 to i8*
br label %53
53: ; preds = %50, %74
%54 = phi i32 [ %80, %74 ], [ 0, %50 ]
%55 = phi i8* [ %76, %74 ], [ %51, %50 ]
%56 = phi i8* [ %75, %74 ], [ %52, %50 ]
%57 = tail call i32 (...) @rand()
%58 = srem i32 %57, %41
%59 = tail call i32 (...) @rand()
%60 = srem i32 %59, %42
%61 = icmp sgt i32 %58, 0
br i1 %61, label %64, label %62
62: ; preds = %64, %53
%63 = icmp sgt i32 %60, 0
br i1 %63, label %69, label %74
64: ; preds = %53, %64
%65 = phi i32 [ %67, %64 ], [ 0, %53 ]
%66 = tail call i32 @fgets(i8* %56, i32 255, i32* %31)
%67 = add nuw nsw i32 %65, 1
%68 = icmp eq i32 %67, %58
br i1 %68, label %62, label %64
69: ; preds = %62, %69
%70 = phi i32 [ %72, %69 ], [ 0, %62 ]
%71 = tail call i32 @fgets(i8* %55, i32 255, i32* %36)
%72 = add nuw nsw i32 %70, 1
%73 = icmp eq i32 %72, %60
br i1 %73, label %74, label %69
74: ; preds = %69, %62
%75 = tail call i8* @remove_newline(i8* %56)
%76 = tail call i8* @remove_newline(i8* %55)
%77 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %75, i8* %76)
%78 = tail call i32 @rewind(i32* %31)
%79 = tail call i32 @rewind(i32* %36)
%80 = add nuw nsw i32 %54, 1
%81 = icmp eq i32 %80, %30
br i1 %81, label %82, label %53
82: ; preds = %74, %40
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.10, i64 0, i64 0), i32 %30, i32 %41, i32 %42)
%84 = tail call i32 @fclose(i32* %31)
%85 = tail call i32 @fclose(i32* %36)
br label %86
86: ; preds = %33, %82, %38, %23, %14
%87 = phi i32 [ 1, %14 ], [ 1, %23 ], [ 1, %33 ], [ 1, %38 ], [ 0, %82 ]
ret i32 %87
}