#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 /*<<< orphan*/ append_numbers(char *, char *);
int /*<<< orphan*/ append_symbols(char *, char *);
int /*<<< orphan*/ build_input(char *, char *);
int /*<<< orphan*/ concat_with_numbers(char *, char *);
int /*<<< orphan*/ concat_with_symbols(char *, char *);
int /*<<< orphan*/ file_exists(char *);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ prepend_numbers(char *, char *);
int /*<<< orphan*/ prepend_symbols(char *, char *);
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ replace_chars(char *, char *);
int main(int argc, char *argv[]) {
  int oflag = 0;
  char *ovalue = NULL;
  int iflag = 0;
  char *ivalue = NULL;
  int qflag = 0;
  char *qvalue = NULL;
  int opt = 0;
  while ((opt = getopt(argc, argv, "hioq:")) != -1) {
    switch (opt) {
    case 'i':
      iflag = 1;
      ivalue = optarg;
      break;
    case 'o':
      oflag = 1;
      ovalue = optarg;
      break;
    case 'q':
      qflag = 1;
      qvalue = optarg;
      break;
    case '?':
    case 'h':
      print_usage();
      return 1;
    default:
      print_usage();
      return 1;
    }
  }
  if (!oflag)
    ovalue = "myoutput";
  if (!qflag) {
    qvalue = "../share/pass_gen/questions";
    if (!file_exists(qvalue)) {
      printf("\nDefault questions file: %s\n", qvalue);
      printf("\nFile not found! Try using -q flag.\n\n");
      return -1;
    }
  }
  if (!iflag)
    ivalue = "custom_input";
  build_input(qvalue, ivalue);
  replace_chars(ivalue, ovalue);
  append_numbers(ovalue, "output_numbers1");
  prepend_numbers(ovalue, "output_numbers2");
  concat_with_numbers(ivalue, "output_numbers3");
  append_symbols(ivalue, "output_symbols1");
  prepend_symbols(ivalue, "output_symbols2");
  concat_with_symbols(ivalue, "output_symbols3");
  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   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xde8(%rip),%rdx
call   10d0 <getopt@plt>
mov    %eax,-0x44(%rbp)
cmp    $0xffffffff,%eax
je     12fa <main+0x13a>
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
sub    $0x3f,%eax
je     12cf <main+0x10f>
jmp    123d <main+0x7d>
mov    -0x48(%rbp),%eax
sub    $0x68,%eax
je     12cf <main+0x10f>
jmp    124e <main+0x8e>
mov    -0x48(%rbp),%eax
sub    $0x69,%eax
je     1281 <main+0xc1>
jmp    125f <main+0x9f>
mov    -0x48(%rbp),%eax
sub    $0x6f,%eax
je     129b <main+0xdb>
jmp    1270 <main+0xb0>
mov    -0x48(%rbp),%eax
sub    $0x71,%eax
je     12b5 <main+0xf5>
jmp    12e2 <main+0x122>
movl   $0x1,-0x24(%rbp)
mov    0x2d69(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    12f5 <main+0x135>
movl   $0x1,-0x14(%rbp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    12f5 <main+0x135>
movl   $0x1,-0x34(%rbp)
mov    0x2d35(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    12f5 <main+0x135>
mov    $0x0,%al
call   10e0 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    13fd <main+0x23d>
mov    $0x0,%al
call   10e0 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    13fd <main+0x23d>
jmp    120a <main+0x4a>
cmpl   $0x0,-0x14(%rbp)
jne    130f <main+0x14f>
lea    0xcfb(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    1367 <main+0x1a7>
lea    0xcef(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <file_exists@plt>
cmp    $0x0,%eax
jne    1362 <main+0x1a2>
mov    -0x40(%rbp),%rsi
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13fd <main+0x23d>
jmp    1367 <main+0x1a7>
cmpl   $0x0,-0x24(%rbp)
jne    137c <main+0x1bc>
lea    0xcf6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10a0 <build_input@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <replace_chars@plt>
mov    -0x20(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   1090 <append_numbers@plt>
mov    -0x20(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   10b0 <prepend_numbers@plt>
mov    -0x30(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   1030 <concat_with_numbers@plt>
mov    -0x30(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   10c0 <append_symbols@plt>
mov    -0x30(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   1050 <prepend_symbols@plt>
mov    -0x30(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   1060 <concat_with_symbols@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
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xe16(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xe04(%rip),%r13
mov    0x2df5(%rip),%r14
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    1229 <main+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14),%r12
mov    $0x1,%r15d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   10e0 <getopt@plt>
cmp    $0x71,%eax
je     1220 <main+0x50>
cmp    $0x67,%eax
jle    126c <main+0x9c>
cmp    $0x68,%eax
je     1274 <main+0xa4>
cmp    $0x6f,%eax
je     1262 <main+0x92>
cmp    $0x69,%eax
jne    1274 <main+0xa4>
mov    (%r14),%rax
mov    %rax,0x10(%rsp)
mov    $0x1,%eax
mov    %rax,(%rsp)
jmp    1229 <main+0x59>
mov    (%r14),%rax
mov    %rax,0x8(%rsp)
jmp    1229 <main+0x59>
cmp    $0xffffffff,%eax
je     1285 <main+0xb5>
cmp    $0x3f,%eax
xor    %eax,%eax
call   10f0 <print_usage@plt>
mov    $0x1,%eax
jmp    132c <main+0x15c>
test   %r15d,%r15d
jne    12a1 <main+0xd1>
lea    0xd7e(%rip),%r12
mov    %r12,%rdi
call   1040 <file_exists@plt>
test   %eax,%eax
je     133b <main+0x16b>
cmpl   $0x0,(%rsp)
lea    0xd9c(%rip),%rax
mov    0x10(%rsp),%rbx
cmove  %rax,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   10b0 <build_input@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%rbp
mov    %rbp,%rsi
call   1090 <replace_chars@plt>
lea    0xd7e(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <append_numbers@plt>
lea    0xd7f(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <prepend_numbers@plt>
lea    0xd80(%rip),%rsi
mov    %rbx,%rdi
call   1030 <concat_with_numbers@plt>
lea    0xd81(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <append_symbols@plt>
lea    0xd82(%rip),%rsi
mov    %rbx,%rdi
call   1060 <prepend_symbols@plt>
lea    0xd83(%rip),%rsi
mov    %rbx,%rdi
call   1070 <concat_with_symbols@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce9(%rip),%rdi
lea    0xcc6(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd5e(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%eax
jmp    132c <main+0x15c>

LLVM IR (-O0):
@.str = [6 x i8] c"hioq:\00"
@optarg = global i8* null
@.str.1 = [9 x i8] c"myoutput\00"
@.str.2 = [28 x i8] c"../share/pass_gen/questions\00"
@.str.3 = [29 x i8] c"\0ADefault questions file: %s\0A\00"
@.str.4 = [38 x i8] c"\0AFile not found! Try using -q flag.\0A\0A\00"
@.str.5 = [13 x i8] c"custom_input\00"
@.str.6 = [16 x i8] c"output_numbers1\00"
@.str.7 = [16 x i8] c"output_numbers2\00"
@.str.8 = [16 x i8] c"output_numbers3\00"
@.str.9 = [16 x i8] c"output_symbols1\00"
@.str.10 = [16 x i8] c"output_symbols2\00"
@.str.11 = [16 x i8] c"output_symbols3\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 i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* null, i8** %7
store i32 0, i32* %8
store i8* null, i8** %9
store i32 0, i32* %10
store i8* null, i8** %11
store i32 0, i32* %12
br label %13
13: ; preds = %30, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %12
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %31
18: ; preds = %13
%19 = load i32, i32* %12
switch i32 %19, label %28 [
i32 105, label %20
i32 111, label %22
i32 113, label %24
i32 63, label %26
i32 104, label %26
]
20: ; preds = %18
store i32 1, i32* %8
%21 = load i8*, i8** @optarg
store i8* %21, i8** %9
br label %30
22: ; preds = %18
store i32 1, i32* %6
%23 = load i8*, i8** @optarg
store i8* %23, i8** %7
br label %30
24: ; preds = %18
store i32 1, i32* %10
%25 = load i8*, i8** @optarg
store i8* %25, i8** %11
br label %30
26: ; preds = %18, %18
%27 = call i32 (...) @print_usage()
store i32 1, i32* %3
br label %70
28: ; preds = %18
%29 = call i32 (...) @print_usage()
store i32 1, i32* %3
br label %70
30: ; preds = %24, %22, %20
br label %13
31: ; preds = %13
%32 = load i32, i32* %6
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %31
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %35
35: ; preds = %34, %31
%36 = load i32, i32* %10
%37 = icmp ne i32 %36, 0
br i1 %37, label %47, label %38
38: ; preds = %35
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8** %11
%39 = load i8*, i8** %11
%40 = call i32 @file_exists(i8* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = load i8*, i8** %11
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %70
46: ; preds = %38
br label %47
47: ; preds = %46, %35
%48 = load i32, i32* %8
%49 = icmp ne i32 %48, 0
br i1 %49, label %51, label %50
50: ; preds = %47
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %9
br label %51
51: ; preds = %50, %47
%52 = load i8*, i8** %11
%53 = load i8*, i8** %9
%54 = call i32 @build_input(i8* %52, i8* %53)
%55 = load i8*, i8** %9
%56 = load i8*, i8** %7
%57 = call i32 @replace_chars(i8* %55, i8* %56)
%58 = load i8*, i8** %7
%59 = call i32 @append_numbers(i8* %58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%60 = load i8*, i8** %7
%61 = call i32 @prepend_numbers(i8* %60, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%62 = load i8*, i8** %9
%63 = call i32 @concat_with_numbers(i8* %62, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%64 = load i8*, i8** %9
%65 = call i32 @append_symbols(i8* %64, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%66 = load i8*, i8** %9
%67 = call i32 @prepend_symbols(i8* %66, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
%68 = load i8*, i8** %9
%69 = call i32 @concat_with_symbols(i8* %68, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %3
br label %70
70: ; preds = %51, %42, %28, %26
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [6 x i8] c"hioq:\00"
@optarg = global i8* null
@.str.1 = [9 x i8] c"myoutput\00"
@.str.2 = [28 x i8] c"../share/pass_gen/questions\00"
@.str.3 = [29 x i8] c"\0ADefault questions file: %s\0A\00"
@.str.5 = [13 x i8] c"custom_input\00"
@.str.6 = [16 x i8] c"output_numbers1\00"
@.str.7 = [16 x i8] c"output_numbers2\00"
@.str.8 = [16 x i8] c"output_numbers3\00"
@.str.9 = [16 x i8] c"output_symbols1\00"
@.str.10 = [16 x i8] c"output_symbols2\00"
@.str.11 = [16 x i8] c"output_symbols3\00"
@str = [37 x i8] c"\0AFile not found! Try using -q flag.\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %20, %2
%4 = phi i8* [ %21, %20 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %2 ]
%5 = phi i32 [ %10, %20 ], [ 0, %2 ]
%6 = phi i8* [ %11, %20 ], [ null, %2 ]
%7 = phi i32 [ %15, %20 ], [ 0, %2 ]
%8 = phi i8* [ %16, %20 ], [ null, %2 ]
br label %9
9: ; preds = %3, %18
%10 = phi i32 [ %5, %3 ], [ 1, %18 ]
%11 = phi i8* [ %6, %3 ], [ %19, %18 ]
%12 = phi i32 [ %7, %3 ], [ %15, %18 ]
%13 = phi i8* [ %8, %3 ], [ %16, %18 ]
br label %14
14: ; preds = %9, %22
%15 = phi i32 [ 1, %22 ], [ %12, %9 ]
%16 = phi i8* [ %23, %22 ], [ %13, %9 ]
%17 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %17, label %26 [
i32 -1, label %28
i32 105, label %18
i32 111, label %20
i32 113, label %22
i32 63, label %24
i32 104, label %24
]
18: ; preds = %14
%19 = load i8*, i8** @optarg
br label %9
20: ; preds = %14
%21 = load i8*, i8** @optarg
br label %3
22: ; preds = %14
%23 = load i8*, i8** @optarg
br label %14
24: ; preds = %14, %14
%25 = tail call i32 (...) @print_usage()
br label %48
26: ; preds = %14
%27 = tail call i32 (...) @print_usage()
br label %48
28: ; preds = %14
%29 = icmp eq i32 %15, 0
br i1 %29, label %30, label %36
30: ; preds = %28
%31 = tail call i32 @file_exists(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %48
36: ; preds = %30, %28
%37 = phi i8* [ %16, %28 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), %30 ]
%38 = icmp eq i32 %10, 0
%39 = select i1 %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %11
%40 = tail call i32 @build_input(i8* %37, i8* %39)
%41 = tail call i32 @replace_chars(i8* %39, i8* %4)
%42 = tail call i32 @append_numbers(i8* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%43 = tail call i32 @prepend_numbers(i8* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%44 = tail call i32 @concat_with_numbers(i8* %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%45 = tail call i32 @append_symbols(i8* %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%46 = tail call i32 @prepend_symbols(i8* %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
%47 = tail call i32 @concat_with_symbols(i8* %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
br label %48
48: ; preds = %36, %33, %26, %24
%49 = phi i32 [ 1, %26 ], [ 1, %24 ], [ 0, %36 ], [ -1, %33 ]
ret i32 %49
}