#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(int, char **);
int /*<<< orphan*/ append_reg(int, char **);
int /*<<< orphan*/ delete (int, char **);
int /*<<< orphan*/ display_usage();
int /*<<< orphan*/ extract(int, char **);
char getopt(int, char **, char *);
int /*<<< orphan*/ printTable(int, char **, int);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  char flag, flagError;
  if (argc < 3) {
    display_usage();
  }
  flag = getopt(argc, argv, "Adqtvx");
  if (flag == -1) {
    display_usage();
  }
  flagError = getopt(argc, argv, "Adqtvx");
  if (flagError != -1) {
    printf("\nInvalid flag: %s\n\n", argv[1]);
    display_usage();
  }
  switch (flag) {
  case 'A':
    if (argc < 4) {
      display_usage();
    }
    append_reg(argc, argv);
    break;
  case 'd':
    if (argc < 4) {
      display_usage();
    }
    delete (argc, argv);
    break;
  case 'q':
    if (argc < 4) {
      display_usage();
    }
    append(argc, argv);
    break;
  case 't':
    printTable(argc, argv, !1);
    break;
  case 'v':
    printTable(argc, argv, 1);
    break;
  case 'x':
    if (argc < 4) {
      display_usage();
    }
    extract(argc, argv);
    break;
  default:
    display_usage();
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11a7 <main+0x27>
mov    $0x0,%al
call   1050 <display_usage@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf2b(%rip),%rdx
call   1070 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0xffffffff,%eax
jne    11d1 <main+0x51>
mov    $0x0,%al
call   1050 <display_usage@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf01(%rip),%rdx
call   1070 <getopt@plt>
mov    %al,-0x12(%rbp)
movsbl -0x12(%rbp),%eax
cmp    $0xffffffff,%eax
je     120f <main+0x8f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xee4(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <display_usage@plt>
movsbl -0x11(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x37,%eax
ja     12ea <main+0x16a>
mov    -0x20(%rbp),%rax
lea    0xdd0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x4,-0x8(%rbp)
jge    124a <main+0xca>
mov    $0x0,%al
call   1050 <display_usage@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10a0 <append_reg@plt>
jmp    12f1 <main+0x171>
cmpl   $0x4,-0x8(%rbp)
jge    126c <main+0xec>
mov    $0x0,%al
call   1050 <display_usage@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <delete@plt>
jmp    12f1 <main+0x171>
cmpl   $0x4,-0x8(%rbp)
jge    128e <main+0x10e>
mov    $0x0,%al
call   1050 <display_usage@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <append@plt>
jmp    12f1 <main+0x171>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1060 <printTable@plt>
jmp    12f1 <main+0x171>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1060 <printTable@plt>
jmp    12f1 <main+0x171>
cmpl   $0x4,-0x8(%rbp)
jge    12d9 <main+0x159>
mov    $0x0,%al
call   1050 <display_usage@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1080 <extract@plt>
jmp    12f1 <main+0x171>
mov    $0x0,%al
call   1050 <display_usage@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
cmp    $0x2,%edi
jg     1195 <main+0x15>
xor    %eax,%eax
call   1050 <display_usage@plt>
lea    0xf44(%rip),%rdx
mov    %ebp,%edi
mov    %r14,%rsi
call   1070 <getopt@plt>
mov    %eax,%ebx
cmp    $0xff,%al
jne    11b3 <main+0x33>
xor    %eax,%eax
call   1050 <display_usage@plt>
movsbl %bl,%ebx
lea    0xf23(%rip),%rdx
mov    %ebp,%edi
mov    %r14,%rsi
call   1070 <getopt@plt>
cmp    $0xff,%al
je     11e2 <main+0x62>
mov    0x8(%r14),%rsi
lea    0xf11(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <display_usage@plt>
add    $0xffffffbf,%ebx
cmp    $0x37,%ebx
ja     1212 <main+0x92>
lea    0xe0f(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
cmp    $0x3,%ebp
jg     1206 <main+0x86>
xor    %eax,%eax
call   1050 <display_usage@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   10a0 <append_reg@plt>
jmp    127b <main+0xfb>
xor    %eax,%eax
call   1050 <display_usage@plt>
jmp    127b <main+0xfb>
cmp    $0x3,%ebp
jg     1227 <main+0xa7>
xor    %eax,%eax
call   1050 <display_usage@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1090 <delete@plt>
jmp    127b <main+0xfb>
cmp    $0x3,%ebp
jg     123f <main+0xbf>
xor    %eax,%eax
call   1050 <display_usage@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <append@plt>
jmp    127b <main+0xfb>
cmp    $0x3,%ebp
jg     1257 <main+0xd7>
xor    %eax,%eax
call   1050 <display_usage@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1080 <extract@plt>
jmp    127b <main+0xfb>
mov    %ebp,%edi
mov    %r14,%rsi
xor    %edx,%edx
jmp    1276 <main+0xf6>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1060 <printTable@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Adqtvx\00"
@.str.1 = [20 x i8] c"\0AInvalid flag: %s\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @display_usage()
br label %12
12: ; preds = %10, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call signext i8 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8 %15, i8* %6
%16 = load i8, i8* %6
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 (...) @display_usage()
br label %21
21: ; preds = %19, %12
%22 = load i32, i32* %4
%23 = load i8**, i8*** %5
%24 = call signext i8 @getopt(i32 %22, i8** %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8 %24, i8* %7
%25 = load i8, i8* %7
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, -1
br i1 %27, label %28, label %34
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = call i32 (...) @display_usage()
br label %34
34: ; preds = %28, %21
%35 = load i8, i8* %6
%36 = sext i8 %35 to i32
switch i32 %36, label %81 [
i32 65, label %37
i32 100, label %46
i32 113, label %55
i32 116, label %64
i32 118, label %68
i32 120, label %72
]
37: ; preds = %34
%38 = load i32, i32* %4
%39 = icmp slt i32 %38, 4
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (...) @display_usage()
br label %42
42: ; preds = %40, %37
%43 = load i32, i32* %4
%44 = load i8**, i8*** %5
%45 = call i32 @append_reg(i32 %43, i8** %44)
br label %83
46: ; preds = %34
%47 = load i32, i32* %4
%48 = icmp slt i32 %47, 4
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (...) @display_usage()
br label %51
51: ; preds = %49, %46
%52 = load i32, i32* %4
%53 = load i8**, i8*** %5
%54 = call i32 @delete(i32 %52, i8** %53)
br label %83
55: ; preds = %34
%56 = load i32, i32* %4
%57 = icmp slt i32 %56, 4
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 (...) @display_usage()
br label %60
60: ; preds = %58, %55
%61 = load i32, i32* %4
%62 = load i8**, i8*** %5
%63 = call i32 @append(i32 %61, i8** %62)
br label %83
64: ; preds = %34
%65 = load i32, i32* %4
%66 = load i8**, i8*** %5
%67 = call i32 @printTable(i32 %65, i8** %66, i32 0)
br label %83
68: ; preds = %34
%69 = load i32, i32* %4
%70 = load i8**, i8*** %5
%71 = call i32 @printTable(i32 %69, i8** %70, i32 1)
br label %83
72: ; preds = %34
%73 = load i32, i32* %4
%74 = icmp slt i32 %73, 4
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = call i32 (...) @display_usage()
br label %77
77: ; preds = %75, %72
%78 = load i32, i32* %4
%79 = load i8**, i8*** %5
%80 = call i32 @extract(i32 %78, i8** %79)
br label %83
81: ; preds = %34
%82 = call i32 (...) @display_usage()
br label %83
83: ; preds = %81, %77, %68, %64, %60, %51, %42
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"Adqtvx\00"
@.str.1 = [20 x i8] c"\0AInvalid flag: %s\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @display_usage()
br label %6
6: ; preds = %4, %2
%7 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = sext i8 %7 to i32
%9 = icmp eq i8 %7, -1
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 (...) @display_usage()
br label %12
12: ; preds = %10, %6
%13 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8 %13, -1
br i1 %14, label %20, label %15
15: ; preds = %12
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = tail call i32 (...) @display_usage()
br label %20
20: ; preds = %15, %12
switch i32 %8, label %49 [
i32 65, label %21
i32 100, label %27
i32 113, label %33
i32 116, label %39
i32 118, label %41
i32 120, label %43
]
21: ; preds = %20
%22 = icmp slt i32 %0, 4
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = tail call i32 (...) @display_usage()
br label %25
25: ; preds = %23, %21
%26 = tail call i32 @append_reg(i32 %0, i8** %1)
br label %51
27: ; preds = %20
%28 = icmp slt i32 %0, 4
br i1 %28, label %29, label %31
29: ; preds = %27
%30 = tail call i32 (...) @display_usage()
br label %31
31: ; preds = %29, %27
%32 = tail call i32 @delete(i32 %0, i8** %1)
br label %51
33: ; preds = %20
%34 = icmp slt i32 %0, 4
br i1 %34, label %35, label %37
35: ; preds = %33
%36 = tail call i32 (...) @display_usage()
br label %37
37: ; preds = %35, %33
%38 = tail call i32 @append(i32 %0, i8** %1)
br label %51
39: ; preds = %20
%40 = tail call i32 @printTable(i32 %0, i8** %1, i32 0)
br label %51
41: ; preds = %20
%42 = tail call i32 @printTable(i32 %0, i8** %1, i32 1)
br label %51
43: ; preds = %20
%44 = icmp slt i32 %0, 4
br i1 %44, label %45, label %47
45: ; preds = %43
%46 = tail call i32 (...) @display_usage()
br label %47
47: ; preds = %45, %43
%48 = tail call i32 @extract(i32 %0, i8** %1)
br label %51
49: ; preds = %20
%50 = tail call i32 (...) @display_usage()
br label %51
51: ; preds = %49, %47, %41, %39, %37, %31, %25
ret i32 0
}