#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*/ do_decode(char *, char *);
int /*<<< orphan*/ do_encode(char *, char *);
int /*<<< orphan*/ do_getver(char *);
int /*<<< orphan*/ print_banner();
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  printf("\n");
  print_banner();
  if (argc <= 1) {
    printf("Error: insufficient arguments.\n\n");
    print_usage();
    return 1;
  } else {
    if ((!strncmp(argv[1], "-d", strlen("-d")))) {
      if (argc == 4) {
        if (!do_decode(argv[2], argv[3]))
          return 2;
      } else {
        printf("Error: insufficient arguments.\n\n");
        return 1;
      }
    } else if ((!strncmp(argv[1], "-e", strlen("-e")))) {
      if (argc == 4) {
        if (!do_encode(argv[2], argv[3]))
          return 2;
      } else {
        printf("Error: insufficient arguments.\n\n");
        return 1;
      }
    } else if ((!strncmp(argv[1], "-v", strlen("-v")))) {
      if (argc == 3) {
        if (!do_getver(argv[2]))
          return 2;
      } else {
        printf("Error: insufficient arguments.\n\n");
        return 1;
      }
    } else {
      printf("Error: incorrect arguments.\n\n");
      print_usage();
      return 1;
    }
  }
}


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)
lea    0xea9(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1090 <print_banner@plt>
cmpl   $0x1,-0x8(%rbp)
jg     11d2 <main+0x52>
lea    0xe46(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x213>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    0xe3c(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xe2a(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    125b <main+0xdb>
cmpl   $0x4,-0x8(%rbp)
jne    123e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1070 <do_decode@plt>
cmp    $0x0,%eax
jne    1239 <main+0xb9>
movl   $0x2,-0x4(%rbp)
jmp    1393 <main+0x213>
jmp    1256 <main+0xd6>
lea    0xdbb(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x213>
jmp    138e <main+0x20e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xdb6(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xda4(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12e4 <main+0x164>
cmpl   $0x4,-0x8(%rbp)
jne    12c7 <main+0x147>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1080 <do_encode@plt>
cmp    $0x0,%eax
jne    12c2 <main+0x142>
movl   $0x2,-0x4(%rbp)
jmp    1393 <main+0x213>
jmp    12df <main+0x15f>
lea    0xd32(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x213>
jmp    1389 <main+0x209>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
lea    0xd30(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xd1e(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1365 <main+0x1e5>
cmpl   $0x3,-0x8(%rbp)
jne    1348 <main+0x1c8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <do_getver@plt>
cmp    $0x0,%eax
jne    1343 <main+0x1c3>
movl   $0x2,-0x4(%rbp)
jmp    1393 <main+0x213>
jmp    1360 <main+0x1e0>
lea    0xcb1(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x213>
jmp    1384 <main+0x204>
lea    0xcbe(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x213>
jmp    1389 <main+0x209>
jmp    138e <main+0x20e>
jmp    1393 <main+0x213>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   10a0 <print_banner@plt>
cmp    $0x1,%ebp
jg     11ca <main+0x3a>
lea    0xe6d(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10b0 <print_usage@plt>
jmp    1291 <main+0x101>
mov    0x8(%r14),%rbx
lea    0xe2b(%rip),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1242 <main+0xb2>
mov    0x8(%r14),%rbx
lea    0xe0a(%rip),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1256 <main+0xc6>
mov    0x8(%r14),%rbx
lea    0xde9(%rip),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     126a <main+0xda>
lea    0xdcc(%rip),%rdi
jmp    11b9 <main+0x29>
cmp    $0x4,%ebp
jne    1285 <main+0xf5>
mov    0x10(%r14),%rdi
mov    0x18(%r14),%rsi
call   1080 <do_decode@plt>
jmp    1278 <main+0xe8>
cmp    $0x4,%ebp
jne    1285 <main+0xf5>
mov    0x10(%r14),%rdi
mov    0x18(%r14),%rsi
call   1090 <do_encode@plt>
jmp    1278 <main+0xe8>
cmp    $0x3,%ebp
jne    1285 <main+0xf5>
mov    0x10(%r14),%rdi
call   1070 <do_getver@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
add    %eax,%eax
jmp    1296 <main+0x106>
lea    0xd9a(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [33 x i8] c"Error: insufficient arguments.\0A\0A\00"
@.str.2 = [3 x i8] c"-d\00"
@.str.3 = [3 x i8] c"-e\00"
@.str.4 = [3 x i8] c"-v\00"
@.str.5 = [30 x i8] c"Error: incorrect arguments.\0A\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 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @print_banner()
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (...) @print_usage()
store i32 1, i32* %3
br label %88
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %37, label %20
20: ; preds = %13
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 4
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = call i32 @do_decode(i8* %26, i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %23
store i32 2, i32* %3
br label %88
33: ; preds = %23
br label %36
34: ; preds = %20
%35 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %88
36: ; preds = %33
br label %87
37: ; preds = %13
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%42 = call i32 @strncmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %61, label %44
44: ; preds = %37
%45 = load i32, i32* %4
%46 = icmp eq i32 %45, 4
br i1 %46, label %47, label %58
47: ; preds = %44
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
%54 = call i32 @do_encode(i8* %50, i8* %53)
%55 = icmp ne i32 %54, 0
br i1 %55, label %57, label %56
56: ; preds = %47
store i32 2, i32* %3
br label %88
57: ; preds = %47
br label %60
58: ; preds = %44
%59 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %88
60: ; preds = %57
br label %86
61: ; preds = %37
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%66 = call i32 @strncmp(i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %65)
%67 = icmp ne i32 %66, 0
br i1 %67, label %82, label %68
68: ; preds = %61
%69 = load i32, i32* %4
%70 = icmp eq i32 %69, 3
br i1 %70, label %71, label %79
71: ; preds = %68
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 2
%74 = load i8*, i8** %73
%75 = call i32 @do_getver(i8* %74)
%76 = icmp ne i32 %75, 0
br i1 %76, label %78, label %77
77: ; preds = %71
store i32 2, i32* %3
br label %88
78: ; preds = %71
br label %81
79: ; preds = %68
%80 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %88
81: ; preds = %78
br label %85
82: ; preds = %61
%83 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%84 = call i32 (...) @print_usage()
store i32 1, i32* %3
br label %88
85: ; preds = %81
br label %86
86: ; preds = %85, %60
br label %87
87: ; preds = %86, %36
br label %88
88: ; preds = %10, %32, %34, %56, %58, %77, %79, %82, %87
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"-d\00"
@.str.3 = [3 x i8] c"-e\00"
@.str.4 = [3 x i8] c"-v\00"
@str.8 = [29 x i8] c"Error: incorrect arguments.\0A\00"
@str.9 = [32 x i8] c"Error: insufficient arguments.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 (...) @print_banner()
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%8 = tail call i32 (...) @print_usage()
br label %62
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @strncmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %9
%16 = icmp eq i32 %0, 4
br i1 %16, label %17, label %25
17: ; preds = %15
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = tail call i32 @do_decode(i8* %19, i8* %21)
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i32 2, i32 0
br label %62
25: ; preds = %15
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
br label %62
27: ; preds = %9
%28 = load i8*, i8** %10
%29 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%30 = tail call i32 @strncmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %44
32: ; preds = %27
%33 = icmp eq i32 %0, 4
br i1 %33, label %34, label %42
34: ; preds = %32
%35 = getelementptr inbounds i8*, i8** %1, i64 2
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8*, i8** %1, i64 3
%38 = load i8*, i8** %37
%39 = tail call i32 @do_encode(i8* %36, i8* %38)
%40 = icmp eq i32 %39, 0
%41 = select i1 %40, i32 2, i32 0
br label %62
42: ; preds = %32
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
br label %62
44: ; preds = %27
%45 = load i8*, i8** %10
%46 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%47 = tail call i32 @strncmp(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %46)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %59
49: ; preds = %44
%50 = icmp eq i32 %0, 3
br i1 %50, label %51, label %57
51: ; preds = %49
%52 = getelementptr inbounds i8*, i8** %1, i64 2
%53 = load i8*, i8** %52
%54 = tail call i32 @do_getver(i8* %53)
%55 = icmp eq i32 %54, 0
%56 = select i1 %55, i32 2, i32 0
br label %62
57: ; preds = %49
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
br label %62
59: ; preds = %44
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
%61 = tail call i32 (...) @print_usage()
br label %62
62: ; preds = %51, %34, %17, %6, %25, %42, %57, %59
%63 = phi i32 [ 1, %6 ], [ 1, %59 ], [ 1, %57 ], [ 1, %42 ], [ 1, %25 ], [ %24, %17 ], [ %41, %34 ], [ %56, %51 ]
ret i32 %63
}