#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ NESGetTitle(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ NESRemoveTitle(int /*<<< orphan*/ *);
int /*<<< orphan*/ NESSetTitle(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *lastPathComponent(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void parse_cli_title(char **argv) {
  char title_command[10] = "print";
  char *current_arg = *(argv++);
  if (!current_arg || current_arg == 0) {
    fprintf(stderr, "Argument error: %s\n\n",
            "Expected a sub-action (set, remove or print)!");
    exit(EXIT_FAILURE);
  };
  strcpy(title_command, current_arg);
  current_arg = *(argv++);
#pragma mark **Print Title
  if (strcmp(title_command, "print") == 0) {
    for (; (current_arg != NULL); current_arg = *(argv++)) {
      FILE *ifile = NULL;
      if (!(ifile = fopen(current_arg, "r"))) {
        perror(current_arg);
        continue;
      }
      char *title = (char *)malloc(128);
      NESGetTitle(title, ifile, 1);
      if (title[0] == 0) {
        strcpy(title, "[n/a]");
      }
      printf("%s: %s\n", lastPathComponent(current_arg), title);
      fclose(ifile);
    }
#pragma mark **Set Title
  } else if (strcmp(title_command, "set") == 0) {
    char *new_title = current_arg;
    current_arg = *(argv++);
    for (; (current_arg != NULL); current_arg = *(argv++)) {
      FILE *ifile = NULL;
      if (!(ifile = fopen(current_arg, "r+"))) {
        perror(current_arg);
        continue;
      }
      if (!NESSetTitle(ifile, new_title)) {
        printf("An error occurred while setting the title\n");
      }
      fclose(ifile);
    }
#pragma mark **Remove Title
  } else if (strcmp(title_command, "remove") == 0) {
    for (; (current_arg != NULL); current_arg = *(argv++)) {
      FILE *ifile = NULL;
      if (!(ifile = fopen(current_arg, "r+"))) {
        perror(current_arg);
        continue;
      }
      NESRemoveTitle(ifile);
      fclose(ifile);
    }
  } else {
    printf("Unknown command %s\n", title_command);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<parse_cli_title>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xe1d(%rip),%rax
mov    %rax,-0x12(%rbp)
mov    0xe1a(%rip),%ax
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     121e <parse_cli_title+0x4e>
cmpq   $0x0,-0x20(%rbp)
jne    1248 <parse_cli_title+0x78>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
lea    0xdea(%rip),%rdx
call   1080 <fprintf@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    -0x12(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    -0x12(%rbp),%rdi
lea    0xdd7(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1350 <parse_cli_title+0x180>
jmp    128a <parse_cli_title+0xba>
cmpq   $0x0,-0x20(%rbp)
je     134b <parse_cli_title+0x17b>
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdab(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12c9 <parse_cli_title+0xf9>
mov    -0x20(%rbp),%rdi
call   10d0 <perror@plt>
jmp    1330 <parse_cli_title+0x160>
mov    $0x80,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   1060 <NESGetTitle@plt>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1309 <parse_cli_title+0x139>
mov    -0x30(%rbp),%rdi
lea    0xd51(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
call   1090 <lastPathComponent@plt>
mov    %rax,%rsi
mov    -0x30(%rbp),%rdx
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    128a <parse_cli_title+0xba>
jmp    14ce <parse_cli_title+0x2fe>
lea    -0x12(%rbp),%rdi
lea    0xd08(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1414 <parse_cli_title+0x244>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     140f <parse_cli_title+0x23f>
movq   $0x0,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xcc1(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    13c7 <parse_cli_title+0x1f7>
mov    -0x20(%rbp),%rdi
call   10d0 <perror@plt>
jmp    13f4 <parse_cli_title+0x224>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10e0 <NESSetTitle@plt>
cmp    $0x0,%eax
jne    13eb <parse_cli_title+0x21b>
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1388 <parse_cli_title+0x1b8>
jmp    14c9 <parse_cli_title+0x2f9>
lea    -0x12(%rbp),%rdi
lea    0xc76(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    14a4 <parse_cli_title+0x2d4>
jmp    1433 <parse_cli_title+0x263>
cmpq   $0x0,-0x20(%rbp)
je     149f <parse_cli_title+0x2cf>
movq   $0x0,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xc16(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1472 <parse_cli_title+0x2a2>
mov    -0x20(%rbp),%rdi
call   10d0 <perror@plt>
jmp    1484 <parse_cli_title+0x2b4>
mov    -0x48(%rbp),%rdi
call   10b0 <NESRemoveTitle@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1433 <parse_cli_title+0x263>
jmp    14c4 <parse_cli_title+0x2f4>
lea    -0x12(%rbp),%rsi
lea    0xbed(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b1b(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    14c9 <parse_cli_title+0x2f9>
jmp    14ce <parse_cli_title+0x2fe>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cli_title>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movabs $0x746e697270,%rax
mov    %rax,0x8(%rsp)
movw   $0x0,0x10(%rsp)
mov    (%rdi),%rsi
test   %rsi,%rsi
je     13e9 <parse_cli_title+0x209>
mov    %rdi,%r14
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x10(%r14),%r15
mov    0x8(%r14),%r13
lea    0xe1e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12ce <parse_cli_title+0xee>
lea    0xe1c(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     136d <parse_cli_title+0x18d>
lea    0xe09(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1407 <parse_cli_title+0x227>
test   %r13,%r13
je     13da <parse_cli_title+0x1fa>
lea    0xde3(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
mov    %rbx,%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12c4 <parse_cli_title+0xe4>
mov    %rax,%rbp
mov    %rax,%rdi
call   10c0 <NESRemoveTitle@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    (%r15),%r13
add    $0x8,%r15
test   %r13,%r13
jne    1290 <parse_cli_title+0xb0>
jmp    13da <parse_cli_title+0x1fa>
mov    %r13,%rdi
call   10e0 <perror@plt>
jmp    12b3 <parse_cli_title+0xd3>
test   %r13,%r13
je     13da <parse_cli_title+0x1fa>
lea    0xd75(%rip),%r14
lea    0xd76(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %r14,%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1363 <parse_cli_title+0x183>
mov    %rax,%rbx
mov    $0x80,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1070 <NESGetTitle@plt>
cmpb   $0x0,0x0(%rbp)
jne    1335 <parse_cli_title+0x155>
mov    %rbp,%rdi
lea    0xd25(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
call   10a0 <lastPathComponent@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    (%r15),%r13
add    $0x8,%r15
test   %r13,%r13
jne    12f0 <parse_cli_title+0x110>
jmp    13da <parse_cli_title+0x1fa>
mov    %r13,%rdi
call   10e0 <perror@plt>
jmp    1355 <parse_cli_title+0x175>
mov    (%r15),%rbx
test   %rbx,%rbx
je     13da <parse_cli_title+0x1fa>
add    $0x18,%r14
lea    0xce7(%rip),%r15
lea    0xcfe(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13d0 <parse_cli_title+0x1f0>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r13,%rsi
call   10f0 <NESSetTitle@plt>
test   %eax,%eax
jne    13ba <parse_cli_title+0x1da>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    (%r14),%rbx
add    $0x8,%r14
test   %rbx,%rbx
jne    1390 <parse_cli_title+0x1b0>
jmp    13da <parse_cli_title+0x1fa>
mov    %rbx,%rdi
call   10e0 <perror@plt>
jmp    13c2 <parse_cli_title+0x1e2>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bf0(%rip),%rax
mov    (%rax),%edi
lea    0xc11(%rip),%rsi
lea    0xc1f(%rip),%rdx
call   1090 <fprintf@plt>
jmp    141a <parse_cli_title+0x23a>
lea    0xc63(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2bb7(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@__const.parse_cli_title.title_command = [10 x i8] c"print\00\00\00\00\00"
@stderr = global i32 0
@.str = [21 x i8] c"Argument error: %s\0A\0A\00"
@.str.1 = [46 x i8] c"Expected a sub-action (set, remove or print)!\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [6 x i8] c"print\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"[n/a]\00"
@.str.5 = [8 x i8] c"%s: %s\0A\00"
@.str.6 = [4 x i8] c"set\00"
@.str.7 = [3 x i8] c"r+\00"
@.str.8 = [43 x i8] c"An error occurred while setting the title\0A\00"
@.str.9 = [7 x i8] c"remove\00"
@.str.10 = [20 x i8] c"Unknown command %s\0A\00"
define void @parse_cli_title(i8** %0) {
%2 = alloca i8**
%3 = alloca [10 x i8]
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
store i8** %0, i8*** %2
%10 = bitcast [10 x i8]* %3 to i8*
%11 = load i8**, i8*** %2
%12 = getelementptr inbounds i8*, i8** %11, i32 1
store i8** %12, i8*** %2
%13 = load i8*, i8** %11
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i8*, i8** %4
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %24
19: ; preds = %16, %1
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %16
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%26 = load i8*, i8** %4
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = load i8**, i8*** %2
%29 = getelementptr inbounds i8*, i8** %28, i32 1
store i8** %29, i8*** %2
%30 = load i8*, i8** %28
store i8* %30, i8** %4
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %71
34: ; preds = %24
br label %35
35: ; preds = %66, %34
%36 = load i8*, i8** %4
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %70
38: ; preds = %35
store i32* null, i32** %5
%39 = load i8*, i8** %4
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %40, i32** %5
%41 = icmp ne i32* %40, null
br i1 %41, label %45, label %42
42: ; preds = %38
%43 = load i8*, i8** %4
%44 = call i32 @perror(i8* %43)
br label %66
45: ; preds = %38
%46 = call i64 @malloc(i32 128)
%47 = inttoptr i64 %46 to i8*
store i8* %47, i8** %6
%48 = load i8*, i8** %6
%49 = load i32*, i32** %5
%50 = call i32 @NESGetTitle(i8* %48, i32* %49, i32 1)
%51 = load i8*, i8** %6
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %45
%57 = load i8*, i8** %6
%58 = call i32 @strcpy(i8* %57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %59
59: ; preds = %56, %45
%60 = load i8*, i8** %4
%61 = call i8* @lastPathComponent(i8* %60)
%62 = load i8*, i8** %6
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %61, i8* %62)
%64 = load i32*, i32** %5
%65 = call i32 @fclose(i32* %64)
br label %66
66: ; preds = %59, %42
%67 = load i8**, i8*** %2
%68 = getelementptr inbounds i8*, i8** %67, i32 1
store i8** %68, i8*** %2
%69 = load i8*, i8** %67
store i8* %69, i8** %4
br label %35
70: ; preds = %35
br label %137
71: ; preds = %24
%72 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %105
75: ; preds = %71
%76 = load i8*, i8** %4
store i8* %76, i8** %7
%77 = load i8**, i8*** %2
%78 = getelementptr inbounds i8*, i8** %77, i32 1
store i8** %78, i8*** %2
%79 = load i8*, i8** %77
store i8* %79, i8** %4
br label %80
80: ; preds = %100, %75
%81 = load i8*, i8** %4
%82 = icmp ne i8* %81, null
br i1 %82, label %83, label %104
83: ; preds = %80
store i32* null, i32** %8
%84 = load i8*, i8** %4
%85 = call i32* @fopen(i8* %84, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32* %85, i32** %8
%86 = icmp ne i32* %85, null
br i1 %86, label %90, label %87
87: ; preds = %83
%88 = load i8*, i8** %4
%89 = call i32 @perror(i8* %88)
br label %100
90: ; preds = %83
%91 = load i32*, i32** %8
%92 = load i8*, i8** %7
%93 = call i32 @NESSetTitle(i32* %91, i8* %92)
%94 = icmp ne i32 %93, 0
br i1 %94, label %97, label %95
95: ; preds = %90
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0))
br label %97
97: ; preds = %95, %90
%98 = load i32*, i32** %8
%99 = call i32 @fclose(i32* %98)
br label %100
100: ; preds = %97, %87
%101 = load i8**, i8*** %2
%102 = getelementptr inbounds i8*, i8** %101, i32 1
store i8** %102, i8*** %2
%103 = load i8*, i8** %101
store i8* %103, i8** %4
br label %80
104: ; preds = %80
br label %136
105: ; preds = %71
%106 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%107 = call i64 @strcmp(i8* %106, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %130
109: ; preds = %105
br label %110
110: ; preds = %125, %109
%111 = load i8*, i8** %4
%112 = icmp ne i8* %111, null
br i1 %112, label %113, label %129
113: ; preds = %110
store i32* null, i32** %9
%114 = load i8*, i8** %4
%115 = call i32* @fopen(i8* %114, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32* %115, i32** %9
%116 = icmp ne i32* %115, null
br i1 %116, label %120, label %117
117: ; preds = %113
%118 = load i8*, i8** %4
%119 = call i32 @perror(i8* %118)
br label %125
120: ; preds = %113
%121 = load i32*, i32** %9
%122 = call i32 @NESRemoveTitle(i32* %121)
%123 = load i32*, i32** %9
%124 = call i32 @fclose(i32* %123)
br label %125
125: ; preds = %120, %117
%126 = load i8**, i8*** %2
%127 = getelementptr inbounds i8*, i8** %126, i32 1
store i8** %127, i8*** %2
%128 = load i8*, i8** %126
store i8* %128, i8** %4
br label %110
129: ; preds = %110
br label %135
130: ; preds = %105
%131 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* %131)
%133 = load i32, i32* @EXIT_FAILURE
%134 = call i32 @exit(i32 %133)
unreachable
135: ; preds = %129
br label %136
136: ; preds = %135, %104
br label %137
137: ; preds = %136, %70
ret void
}

LLVM IR (-O2):
@__const.parse_cli_title.title_command = [10 x i8] c"print\00\00\00\00\00"
@stderr = global i32 0
@.str = [21 x i8] c"Argument error: %s\0A\0A\00"
@.str.1 = [46 x i8] c"Expected a sub-action (set, remove or print)!\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [6 x i8] c"print\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"[n/a]\00"
@.str.5 = [8 x i8] c"%s: %s\0A\00"
@.str.6 = [4 x i8] c"set\00"
@.str.7 = [3 x i8] c"r+\00"
@.str.9 = [7 x i8] c"remove\00"
@.str.10 = [20 x i8] c"Unknown command %s\0A\00"
@str = [42 x i8] c"An error occurred while setting the title\00"
define void @parse_cli_title(i8** nocapture %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = load i8*, i8** %0
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
%12 = getelementptr inbounds i8*, i8** %0, i64 1
%13 = call i32 @strcpy(i8* %3, i8* %4)
%14 = getelementptr inbounds i8*, i8** %0, i64 2
%15 = load i8*, i8** %12
%16 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %43
18: ; preds = %11
%19 = icmp eq i8* %15, null
br i1 %19, label %92, label %20
20: ; preds = %18, %39
%21 = phi i8** [ %40, %39 ], [ %14, %18 ]
%22 = phi i8* [ %41, %39 ], [ %15, %18 ]
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @perror(i8* %22)
br label %39
27: ; preds = %20
%28 = call i64 @malloc(i32 128)
%29 = inttoptr i64 %28 to i8*
%30 = call i32 @NESGetTitle(i8* %29, i32* %23, i32 1)
%31 = load i8, i8* %29
%32 = icmp eq i8 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %27
%36 = call i8* @lastPathComponent(i8* %22)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %36, i8* %29)
%38 = call i32 @fclose(i32* %23)
br label %39
39: ; preds = %35, %25
%40 = getelementptr inbounds i8*, i8** %21, i64 1
%41 = load i8*, i8** %21
%42 = icmp eq i8* %41, null
br i1 %42, label %92, label %20
43: ; preds = %11
%44 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %69
46: ; preds = %43
%47 = load i8*, i8** %14
%48 = icmp eq i8* %47, null
br i1 %48, label %92, label %49
49: ; preds = %46
%50 = getelementptr inbounds i8*, i8** %0, i64 3
br label %51
51: ; preds = %49, %65
%52 = phi i8* [ %67, %65 ], [ %47, %49 ]
%53 = phi i8** [ %66, %65 ], [ %50, %49 ]
%54 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 @perror(i8* %52)
br label %65
58: ; preds = %51
%59 = call i32 @NESSetTitle(i32* %54, i8* %15)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %63
63: ; preds = %61, %58
%64 = call i32 @fclose(i32* %54)
br label %65
65: ; preds = %63, %56
%66 = getelementptr inbounds i8*, i8** %53, i64 1
%67 = load i8*, i8** %53
%68 = icmp eq i8* %67, null
br i1 %68, label %92, label %51
69: ; preds = %43
%70 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %88
72: ; preds = %69
%73 = icmp eq i8* %15, null
br i1 %73, label %92, label %74
74: ; preds = %72, %84
%75 = phi i8** [ %85, %84 ], [ %14, %72 ]
%76 = phi i8* [ %86, %84 ], [ %15, %72 ]
%77 = call i32* @fopen(i8* %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%78 = icmp eq i32* %77, null
br i1 %78, label %79, label %81
79: ; preds = %74
%80 = call i32 @perror(i8* %76)
br label %84
81: ; preds = %74
%82 = call i32 @NESRemoveTitle(i32* %77)
%83 = call i32 @fclose(i32* %77)
br label %84
84: ; preds = %81, %79
%85 = getelementptr inbounds i8*, i8** %75, i64 1
%86 = load i8*, i8** %75
%87 = icmp eq i8* %86, null
br i1 %87, label %92, label %74
88: ; preds = %69
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* %3)
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %84, %65, %39, %72, %46, %18
ret void
}