#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 EXIT_FAILURE;
int decode(int, char **);
int encode(int, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 3) {
    fprintf(stderr, "ERROR: %s expects at least two arguments.", argv[0]);
    return EXIT_FAILURE;
  }
  switch (argv[1][1]) {
  case 'e':
    return encode(argc, argv);
    break;
  case 'd':
    return decode(argc, argv);
    break;
  }
  fprintf(stderr, "ERROR: Failed to parse input.\n");
  return EXIT_FAILURE;
}


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    117f <main+0x4f>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f8 <main+0xc8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x64,%eax
je     11c1 <main+0x91>
jmp    119c <main+0x6c>
mov    -0x14(%rbp),%eax
sub    $0x65,%eax
jne    11d5 <main+0xa5>
jmp    11ad <main+0x7d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <encode@plt>
mov    %eax,-0x4(%rbp)
jmp    11f8 <main+0xc8>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <decode@plt>
mov    %eax,-0x4(%rbp)
jmp    11f8 <main+0xc8>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jg     1152 <main+0x22>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xeb7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1187 <main+0x57>
mov    0x8(%rsi),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
je     116a <main+0x3a>
cmp    $0x65,%eax
jne    1170 <main+0x40>
pop    %rax
jmp    1030 <encode@plt>
pop    %rax
jmp    1050 <decode@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [42 x i8] c"ERROR: %s expects at least two arguments.\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"ERROR: Failed to parse input.\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, 3
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
store i32 %14, i32* %3
br label %34
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %30 [
i32 101, label %22
i32 100, label %26
]
22: ; preds = %15
%23 = load i32, i32* %4
%24 = load i8**, i8*** %5
%25 = call i32 @encode(i32 %23, i8** %24)
store i32 %25, i32* %3
br label %34
26: ; preds = %15
%27 = load i32, i32* %4
%28 = load i8**, i8*** %5
%29 = call i32 @decode(i32 %27, i8** %28)
store i32 %29, i32* %3
br label %34
30: ; preds = %15
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
store i32 %33, i32* %3
br label %34
34: ; preds = %30, %26, %22, %8
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [42 x i8] c"ERROR: %s expects at least two arguments.\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"ERROR: Failed to parse input.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
br label %23
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
switch i32 %14, label %19 [
i32 101, label %15
i32 100, label %17
]
15: ; preds = %9
%16 = tail call i32 @encode(i32 %0, i8** %1)
br label %23
17: ; preds = %9
%18 = tail call i32 @decode(i32 %0, i8** %1)
br label %23
19: ; preds = %9
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
br label %23
23: ; preds = %19, %17, %15, %4
%24 = phi i32 [ %8, %4 ], [ %22, %19 ], [ %18, %17 ], [ %16, %15 ]
ret i32 %24
}