#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*/ abort();
int /*<<< orphan*/ afs_extract_all(char *, char *);
int /*<<< orphan*/ afs_list_files(char *);
char *afs_load(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(char);
char *optarg;
scalar_t__ opterr;
int optind;
char optopt;
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *pstrBuffer;
  char *pstrDestPath = NULL;
  int iListOnly = 0;
  int i;
  opterr = 0;
  while ((i = getopt(argc, argv, "o:t")) != -1) {
    switch (i) {
    case 'o':
      pstrDestPath = optarg;
      break;
    case 't':
      iListOnly = 1;
      break;
    case '?':
      if (optopt == 'o')
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      else if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
    default:
      abort();
    }
  }
  i = optind;
  if (i + 1 != argc) {
    fprintf(stderr, "Usage: %s [-o destpath] file.afs\n", argv[0]);
    return 2;
  }
  pstrBuffer = afs_load(argv[i]);
  if (pstrBuffer == NULL)
    return -1;
  if (iListOnly == 1) {
    afs_list_files(pstrBuffer);
    goto main_ret;
  }
  afs_extract_all(pstrBuffer, pstrDestPath);
main_ret:
  free(pstrBuffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e14(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe3f(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     12dc <main+0x15c>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x3f,%eax
je     1227 <main+0xa7>
jmp    11e6 <main+0x66>
mov    -0x2c(%rbp),%eax
sub    $0x6f,%eax
je     1208 <main+0x88>
jmp    11f7 <main+0x77>
mov    -0x2c(%rbp),%eax
sub    $0x74,%eax
je     121b <main+0x9b>
jmp    12d0 <main+0x150>
mov    0x2de9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    12d7 <main+0x157>
movl   $0x1,-0x24(%rbp)
jmp    12d7 <main+0x157>
mov    0x2db2(%rip),%rax
movsbl (%rax),%eax
cmp    $0x6f,%eax
jne    1260 <main+0xe0>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    0x2d96(%rip),%rax
movsbl (%rax),%edx
lea    0xdb0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    12c4 <main+0x144>
mov    0x2d79(%rip),%rax
movsbl (%rax),%edi
call   1090 <isprint@plt>
cmp    $0x0,%eax
je     129e <main+0x11e>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
mov    0x2d58(%rip),%rax
movsbl (%rax),%edx
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    12bf <main+0x13f>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
mov    0x2d32(%rip),%rax
movsbl (%rax),%edx
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    12c4 <main+0x144>
movl   $0x1,-0x4(%rbp)
jmp    1382 <main+0x202>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    11b3 <main+0x33>
mov    0x2cf5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
je     1321 <main+0x1a1>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1382 <main+0x202>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <afs_load@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    134d <main+0x1cd>
movl   $0xffffffff,-0x4(%rbp)
jmp    1382 <main+0x202>
cmpl   $0x1,-0x24(%rbp)
jne    1365 <main+0x1e5>
mov    -0x18(%rbp),%rdi
call   1050 <afs_list_files@plt>
jmp    1372 <main+0x1f2>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <afs_extract_all@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x2e29(%rip),%rax
movq   $0x0,(%rax)
xor    %r14d,%r14d
lea    0xe58(%rip),%r15
mov    0x2e49(%rip),%r13
xor    %ebx,%ebx
mov    %ebx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   10a0 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x74,%eax
je     11c0 <main+0x40>
cmp    $0xffffffff,%eax
je     11f2 <main+0x72>
cmp    $0x3f,%eax
je     122e <main+0xae>
cmp    $0x6f,%eax
jne    12d2 <main+0x152>
mov    0x0(%r13),%r14
jmp    11b1 <main+0x31>
mov    0x2ddf(%rip),%rax
movslq (%rax),%rax
lea    0x1(%rax),%ecx
cmp    %ebp,%ecx
jne    1252 <main+0xd2>
mov    (%r12,%rax,8),%rdi
call   1060 <afs_load@plt>
test   %rax,%rax
je     1295 <main+0x115>
mov    %rax,%rbp
mov    %rax,%rdi
cmp    $0x1,%ebx
jne    12b1 <main+0x131>
call   1050 <afs_list_files@plt>
jmp    12b9 <main+0x139>
mov    0x2dab(%rip),%rbx
mov    (%rbx),%al
cmp    $0x6f,%al
jne    1274 <main+0xf4>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
lea    0xdb9(%rip),%rsi
mov    $0x6f,%edx
jmp    12a3 <main+0x123>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
lea    0xdf9(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x2,%eax
jmp    12c3 <main+0x143>
movsbl %al,%edi
call   1090 <isprint@plt>
mov    0x2d45(%rip),%rcx
mov    (%rcx),%edi
movsbl (%rbx),%edx
test   %eax,%eax
je     129c <main+0x11c>
lea    0xd93(%rip),%rsi
jmp    12a3 <main+0x123>
mov    $0xffffffff,%eax
jmp    12c3 <main+0x143>
lea    0xd9a(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    12c3 <main+0x143>
mov    %r14,%rsi
call   1080 <afs_extract_all@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@opterr = global i64 0
@.str = [4 x i8] c"o:t\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.4 = [34 x i8] c"Usage: %s [-o destpath] file.afs\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i32 0, i32* %8
store i64 0, i64* @opterr
br label %10
10: ; preds = %47, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %9
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %48
15: ; preds = %10
%16 = load i32, i32* %9
switch i32 %16, label %45 [
i32 111, label %17
i32 116, label %19
i32 63, label %20
]
17: ; preds = %15
%18 = load i8*, i8** @optarg
store i8* %18, i8** %7
br label %47
19: ; preds = %15
store i32 1, i32* %8
br label %47
20: ; preds = %15
%21 = load i8, i8* @optopt
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 111
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = load i8, i8* @optopt
%27 = sext i8 %26 to i32
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %44
29: ; preds = %20
%30 = load i8, i8* @optopt
%31 = call i32 @isprint(i8 signext %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i8, i8* @optopt
%36 = sext i8 %35 to i32
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %43
38: ; preds = %29
%39 = load i32, i32* @stderr
%40 = load i8, i8* @optopt
%41 = sext i8 %40 to i32
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %38, %33
br label %44
44: ; preds = %43, %24
store i32 1, i32* %3
br label %83
45: ; preds = %15
%46 = call i32 (...) @abort()
unreachable
47: ; preds = %19, %17
br label %10
48: ; preds = %10
%49 = load i32, i32* @optind
store i32 %49, i32* %9
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
%52 = load i32, i32* %4
%53 = icmp ne i32 %51, %52
br i1 %53, label %54, label %60
54: ; preds = %48
%55 = load i32, i32* @stderr
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 0
%58 = load i8*, i8** %57
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %58)
store i32 2, i32* %3
br label %83
60: ; preds = %48
%61 = load i8**, i8*** %5
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = call i8* @afs_load(i8* %65)
store i8* %66, i8** %6
%67 = load i8*, i8** %6
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %70
69: ; preds = %60
store i32 -1, i32* %3
br label %83
70: ; preds = %60
%71 = load i32, i32* %8
%72 = icmp eq i32 %71, 1
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i8*, i8** %6
%75 = call i32 @afs_list_files(i8* %74)
br label %80
76: ; preds = %70
%77 = load i8*, i8** %6
%78 = load i8*, i8** %7
%79 = call i32 @afs_extract_all(i8* %77, i8* %78)
br label %80
80: ; preds = %76, %73
%81 = load i8*, i8** %6
%82 = call i32 @free(i8* %81)
store i32 0, i32* %3
br label %83
83: ; preds = %80, %69, %54, %44
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [4 x i8] c"o:t\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.4 = [34 x i8] c"Usage: %s [-o destpath] file.afs\0A\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %9, %2
%4 = phi i8* [ %10, %9 ], [ null, %2 ]
%5 = phi i32 [ %7, %9 ], [ 0, %2 ]
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 1, %6 ], [ %5, %3 ]
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %27 [
i32 -1, label %29
i32 111, label %9
i32 116, label %6
i32 63, label %11
]
9: ; preds = %6
%10 = load i8*, i8** @optarg
br label %3
11: ; preds = %6
%12 = load i8, i8* @optopt
%13 = icmp eq i8 %12, 111
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 111)
br label %51
17: ; preds = %11
%18 = tail call i32 @isprint(i8 signext %12)
%19 = icmp eq i32 %18, 0
%20 = load i32, i32* @stderr
%21 = load i8, i8* @optopt
%22 = sext i8 %21 to i32
br i1 %19, label %25, label %23
23: ; preds = %17
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %51
25: ; preds = %17
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %51
27: ; preds = %6
%28 = tail call i32 (...) @abort()
unreachable
29: ; preds = %6
%30 = load i32, i32* @optind
%31 = add nsw i32 %30, 1
%32 = icmp eq i32 %31, %0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %1
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %35)
br label %51
37: ; preds = %29
%38 = sext i32 %30 to i64
%39 = getelementptr inbounds i8*, i8** %1, i64 %38
%40 = load i8*, i8** %39
%41 = tail call i8* @afs_load(i8* %40)
%42 = icmp eq i8* %41, null
br i1 %42, label %51, label %43
43: ; preds = %37
%44 = icmp eq i32 %7, 1
br i1 %44, label %45, label %47
45: ; preds = %43
%46 = tail call i32 @afs_list_files(i8* %41)
br label %49
47: ; preds = %43
%48 = tail call i32 @afs_extract_all(i8* %41, i8* %4)
br label %49
49: ; preds = %47, %45
%50 = tail call i32 @free(i8* %41)
br label %51
51: ; preds = %37, %14, %25, %23, %49, %33
%52 = phi i32 [ 2, %33 ], [ 0, %49 ], [ 1, %23 ], [ 1, %25 ], [ 1, %14 ], [ -1, %37 ]
ret i32 %52
}