#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 */
scalar_t__ commandCat(int, char **);
scalar_t__ commandCreate(int, char **);
int /*<<< orphan*/ commandHelp(char *);
scalar_t__ commandList(int, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    commandHelp(NULL);
    return 0;
  } else if (!strcmp("help", argv[1])) {
    commandHelp(argc >= 3 ? argv[2] : argv[1]);
    return 0;
  } else if (!strcmp("create", argv[1]) || !strcmp("c", argv[1])) {
    if (commandCreate(argc, argv) < 0) {
      commandHelp("create");
      return 1;
    }
  } else if (!strcmp("list", argv[1]) || !strcmp("l", argv[1])) {
    if (commandList(argc, argv) < 0) {
      commandHelp("list");
      return 1;
    }
  } else if (!strcmp("cat", argv[1])) {
    if (commandCat(argc, argv) < 0) {
      commandHelp("cat");
      return 1;
    }
  } else {
    fprintf(stderr, "Unknown filearchive command.\n");
    commandHelp(NULL);
    return 1;
  }
  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   $0x2,-0x8(%rbp)
jge    1195 <main+0x35>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <commandHelp@plt>
movl   $0x0,-0x4(%rbp)
jmp    135d <main+0x1fd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5c(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11ee <main+0x8e>
cmpl   $0x3,-0x8(%rbp)
jl     11cd <main+0x6d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11d9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <commandHelp@plt>
movl   $0x0,-0x4(%rbp)
jmp    135d <main+0x1fd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe08(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1228 <main+0xc8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdf2(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    125b <main+0xfb>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <commandCreate@plt>
cmp    $0x0,%rax
jge    1256 <main+0xf6>
lea    0xdc0(%rip),%rdi
call   1060 <commandHelp@plt>
movl   $0x1,-0x4(%rbp)
jmp    135d <main+0x1fd>
jmp    134c <main+0x1ec>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xda4(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1295 <main+0x135>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd8c(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12c8 <main+0x168>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <commandList@plt>
cmp    $0x0,%rax
jge    12c3 <main+0x163>
lea    0xd5c(%rip),%rdi
call   1060 <commandHelp@plt>
movl   $0x1,-0x4(%rbp)
jmp    135d <main+0x1fd>
jmp    1347 <main+0x1e7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd3e(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1318 <main+0x1b8>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <commandCat@plt>
cmp    $0x0,%rax
jge    1313 <main+0x1b3>
lea    0xd13(%rip),%rdi
call   1060 <commandHelp@plt>
movl   $0x1,-0x4(%rbp)
jmp    135d <main+0x1fd>
jmp    1342 <main+0x1e2>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
lea    0xcf1(%rip),%rsi
call   1080 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <commandHelp@plt>
movl   $0x1,-0x4(%rbp)
jmp    135d <main+0x1fd>
jmp    1347 <main+0x1e7>
jmp    134c <main+0x1ec>
jmp    1351 <main+0x1f1>
jmp    1356 <main+0x1f6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebx,%ebx
cmp    $0x2,%edi
jge    1185 <main+0x25>
xor    %r15d,%r15d
mov    %r15,%rdi
call   1060 <commandHelp@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%r12
lea    0xe6b(%rip),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1238 <main+0xd8>
lea    0xe59(%rip),%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     122c <main+0xcc>
lea    0xe4a(%rip),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     122c <main+0xcc>
lea    0xe39(%rip),%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     124e <main+0xee>
lea    0xe28(%rip),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     124e <main+0xee>
lea    0xe17(%rip),%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     126d <main+0x10d>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%ebx
jmp    116f <main+0xf>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <commandCreate@plt>
jmp    1258 <main+0xf8>
cmp    $0x3,%ebp
jb     1246 <main+0xe6>
mov    0x10(%r14),%r15
jmp    1172 <main+0x12>
mov    %r12,%r15
jmp    1172 <main+0x12>
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <commandList@plt>
xor    %ebx,%ebx
test   %rax,%rax
jns    117a <main+0x1a>
mov    $0x1,%ebx
jmp    1172 <main+0x12>
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <commandCat@plt>
jmp    1258 <main+0xf8>

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@.str.1 = [7 x i8] c"create\00"
@.str.2 = [2 x i8] c"c\00"
@.str.3 = [5 x i8] c"list\00"
@.str.4 = [2 x i8] c"l\00"
@.str.5 = [4 x i8] c"cat\00"
@stderr = global i32 0
@.str.6 = [30 x i8] c"Unknown filearchive command.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @commandHelp(i8* null)
store i32 0, i32* %3
br label %93
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %30, label %16
16: ; preds = %10
%17 = load i32, i32* %4
%18 = icmp sge i32 %17, 3
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
br label %27
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
br label %27
27: ; preds = %23, %19
%28 = phi i8* [ %22, %19 ], [ %26, %23 ]
%29 = call i32 @commandHelp(i8* %28)
store i32 0, i32* %3
br label %93
30: ; preds = %10
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %30
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %50, label %42
42: ; preds = %36, %30
%43 = load i32, i32* %4
%44 = load i8**, i8*** %5
%45 = call i64 @commandCreate(i32 %43, i8** %44)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @commandHelp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %93
49: ; preds = %42
br label %90
50: ; preds = %36
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %53)
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %50
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = call i32 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %59)
%61 = icmp ne i32 %60, 0
br i1 %61, label %70, label %62
62: ; preds = %56, %50
%63 = load i32, i32* %4
%64 = load i8**, i8*** %5
%65 = call i64 @commandList(i32 %63, i8** %64)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %62
%68 = call i32 @commandHelp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %93
69: ; preds = %62
br label %89
70: ; preds = %56
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 1
%73 = load i8*, i8** %72
%74 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %73)
%75 = icmp ne i32 %74, 0
br i1 %75, label %84, label %76
76: ; preds = %70
%77 = load i32, i32* %4
%78 = load i8**, i8*** %5
%79 = call i64 @commandCat(i32 %77, i8** %78)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %76
%82 = call i32 @commandHelp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %93
83: ; preds = %76
br label %88
84: ; preds = %70
%85 = load i32, i32* @stderr
%86 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%87 = call i32 @commandHelp(i8* null)
store i32 1, i32* %3
br label %93
88: ; preds = %83
br label %89
89: ; preds = %88, %69
br label %90
90: ; preds = %89, %49
br label %91
91: ; preds = %90
br label %92
92: ; preds = %91
store i32 0, i32* %3
br label %93
93: ; preds = %92, %84, %81, %67, %47, %27, %8
%94 = load i32, i32* %3
ret i32 %94
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [7 x i8] c"create\00"
@.str.2 = [2 x i8] c"c\00"
@.str.3 = [5 x i8] c"list\00"
@.str.4 = [2 x i8] c"l\00"
@.str.5 = [4 x i8] c"cat\00"
@stderr = global i32 0
@.str.6 = [30 x i8] c"Unknown filearchive command.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %41, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = icmp ugt i32 %0, 2
br i1 %10, label %11, label %41
11: ; preds = %9
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
br label %41
14: ; preds = %4
%15 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %6)
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %6)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17, %14
%21 = tail call i64 @commandCreate(i32 %0, i8** %1)
%22 = icmp slt i64 %21, 0
br i1 %22, label %41, label %45
23: ; preds = %17
%24 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(1) %6)
%25 = icmp eq i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(1) %6)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26, %23
%30 = tail call i64 @commandList(i32 %0, i8** %1)
%31 = icmp slt i64 %30, 0
br i1 %31, label %41, label %45
32: ; preds = %26
%33 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* dereferenceable(1) %6)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = tail call i64 @commandCat(i32 %0, i8** %1)
%37 = icmp slt i64 %36, 0
br i1 %37, label %41, label %45
38: ; preds = %32
%39 = load i32, i32* @stderr
%40 = tail call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
br label %41
41: ; preds = %35, %29, %20, %11, %9, %2, %38
%42 = phi i8* [ null, %38 ], [ null, %2 ], [ %13, %11 ], [ %6, %9 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %20 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %29 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %35 ]
%43 = phi i32 [ 1, %38 ], [ 0, %2 ], [ 0, %11 ], [ 0, %9 ], [ 1, %20 ], [ 1, %29 ], [ 1, %35 ]
%44 = tail call i32 @commandHelp(i8* %42)
br label %45
45: ; preds = %41, %20, %35, %29
%46 = phi i32 [ 0, %29 ], [ 0, %35 ], [ 0, %20 ], [ %43, %41 ]
ret i32 %46
}