#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 EXIT_SUCCESS;
int /*<<< orphan*/ decode(char *, char *, char *);
int /*<<< orphan*/ encode(char *, char *, char *);
int /*<<< orphan*/ print_use_demo();
int /*<<< orphan*/ simu_record(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char *input;
  char *output;
  char *option;
  char tmp[1024] = {0};
  char op = argv[1][0];
  if (argc < 4) {
    print_use_demo();
    return EXIT_FAILURE;
  } else if (argc > 4) {
    option = tmp;
    int i;
    char *p = tmp;
    for (i = 4; i < argc; i++) {
      strcpy(p, argv[i]);
      p += strlen(argv[i]) - 1;
    }
  }
  input = argv[2];
  output = argv[3];
  switch (op) {
  case 'e':
    encode(input, output, option);
    break;
  case 'd':
    decode(input, output, option);
    break;
  case 'r':
    simu_record(input, output, option);
    break;
  default:
    print_use_demo();
    break;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x431(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11ce <main+0x5e>
mov    $0x0,%al
call   1070 <print_use_demo@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1320 <main+0x1b0>
cmpl   $0x4,-0x8(%rbp)
jle    126b <main+0xfb>
lea    -0x430(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x440(%rbp)
movl   $0x4,-0x438(%rbp)
mov    -0x438(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1266 <main+0xf6>
mov    -0x440(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x438(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x438(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
sub    $0x1,%ecx
mov    -0x440(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x440(%rbp)
mov    -0x438(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x438(%rbp)
jmp    11fb <main+0x8b>
jmp    126b <main+0xfb>
jmp    1270 <main+0x100>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
movsbl -0x431(%rbp),%eax
mov    %eax,-0x444(%rbp)
sub    $0x64,%eax
je     12e1 <main+0x171>
jmp    12a3 <main+0x133>
mov    -0x444(%rbp),%eax
sub    $0x65,%eax
je     12cb <main+0x15b>
jmp    12b7 <main+0x147>
mov    -0x444(%rbp),%eax
sub    $0x72,%eax
je     12f7 <main+0x187>
jmp    130d <main+0x19d>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <encode@plt>
jmp    1314 <main+0x1a4>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1090 <decode@plt>
jmp    1314 <main+0x1a4>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1080 <simu_record@plt>
jmp    1314 <main+0x1a4>
mov    $0x0,%al
call   1070 <print_use_demo@plt>
mov    0x2cbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
cmp    $0x3,%ebp
jg     11ae <main+0x3e>
xor    %eax,%eax
call   1070 <print_use_demo@plt>
mov    0x2e37(%rip),%rax
jmp    123d <main+0xcd>
mov    0x8(%r14),%rax
movsbl (%rax),%r15d
cmp    $0x4,%ebp
je     11f7 <main+0x87>
mov    %ebp,%r12d
mov    $0x4,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%rbp,8),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    (%r14,%rbp,8),%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%rbx
add    $0xffffffffffffffff,%rbx
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11d0 <main+0x60>
mov    0x10(%r14),%rdi
mov    0x18(%r14),%rsi
cmp    $0x64,%r15d
je     121b <main+0xab>
cmp    $0x72,%r15d
je     1225 <main+0xb5>
cmp    $0x65,%r15d
jne    122f <main+0xbf>
mov    %rsp,%rdx
call   1030 <encode@plt>
jmp    1236 <main+0xc6>
mov    %rsp,%rdx
call   1090 <decode@plt>
jmp    1236 <main+0xc6>
mov    %rsp,%rdx
call   1080 <simu_record@plt>
jmp    1236 <main+0xc6>
xor    %eax,%eax
call   1070 <print_use_demo@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca i8
%11 = alloca i32
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [1024 x i8]* %9 to i8*
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
store i8 %18, i8* %10
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = call i32 (...) @print_use_demo()
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %85
24: ; preds = %2
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 4
br i1 %26, label %27, label %56
27: ; preds = %24
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
store i8* %28, i8** %8
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
store i8* %29, i8** %12
store i32 4, i32* %11
br label %30
30: ; preds = %52, %27
%31 = load i32, i32* %11
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %55
34: ; preds = %30
%35 = load i8*, i8** %12
%36 = load i8**, i8*** %5
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @strcpy(i8* %35, i8* %40)
%42 = load i8**, i8*** %5
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @strlen(i8* %46)
%48 = sub nsw i32 %47, 1
%49 = load i8*, i8** %12
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8* %51, i8** %12
br label %52
52: ; preds = %34
%53 = load i32, i32* %11
%54 = add nsw i32 %53, 1
store i32 %54, i32* %11
br label %30
55: ; preds = %30
br label %56
56: ; preds = %55, %24
br label %57
57: ; preds = %56
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 2
%60 = load i8*, i8** %59
store i8* %60, i8** %6
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 3
%63 = load i8*, i8** %62
store i8* %63, i8** %7
%64 = load i8, i8* %10
%65 = sext i8 %64 to i32
switch i32 %65, label %81 [
i32 101, label %66
i32 100, label %71
i32 114, label %76
]
66: ; preds = %57
%67 = load i8*, i8** %6
%68 = load i8*, i8** %7
%69 = load i8*, i8** %8
%70 = call i32 @encode(i8* %67, i8* %68, i8* %69)
br label %83
71: ; preds = %57
%72 = load i8*, i8** %6
%73 = load i8*, i8** %7
%74 = load i8*, i8** %8
%75 = call i32 @decode(i8* %72, i8* %73, i8* %74)
br label %83
76: ; preds = %57
%77 = load i8*, i8** %6
%78 = load i8*, i8** %7
%79 = load i8*, i8** %8
%80 = call i32 @simu_record(i8* %77, i8* %78, i8* %79)
br label %83
81: ; preds = %57
%82 = call i32 (...) @print_use_demo()
br label %83
83: ; preds = %81, %76, %71, %66
%84 = load i32, i32* @EXIT_SUCCESS
store i32 %84, i32* %3
br label %85
85: ; preds = %83, %21
%86 = load i32, i32* %3
ret i32 %86
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp slt i32 %0, 4
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 (...) @print_use_demo()
br label %42
11: ; preds = %2
%12 = icmp eq i32 %0, 4
br i1 %12, label %28, label %13
13: ; preds = %11
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 4, %13 ], [ %26, %15 ]
%17 = phi i8* [ %4, %13 ], [ %25, %15 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %16
%19 = load i8*, i8** %18
%20 = call i32 @strcpy(i8* %17, i8* %19)
%21 = load i8*, i8** %18
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %17, i64 %24
%26 = add nuw nsw i64 %16, 1
%27 = icmp eq i64 %26, %14
br i1 %27, label %28, label %15
28: ; preds = %15, %11
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8*, i8** %1, i64 3
%32 = load i8*, i8** %31
%33 = sext i8 %7 to i32
switch i32 %33, label %40 [
i32 101, label %34
i32 100, label %36
i32 114, label %38
]
34: ; preds = %28
%35 = call i32 @encode(i8* %30, i8* %32, i8* %4)
br label %42
36: ; preds = %28
%37 = call i32 @decode(i8* %30, i8* %32, i8* %4)
br label %42
38: ; preds = %28
%39 = call i32 @simu_record(i8* %30, i8* %32, i8* %4)
br label %42
40: ; preds = %28
%41 = call i32 (...) @print_use_demo()
br label %42
42: ; preds = %34, %36, %38, %40, %9
%43 = phi i32* [ @EXIT_FAILURE, %9 ], [ @EXIT_SUCCESS, %40 ], [ @EXIT_SUCCESS, %38 ], [ @EXIT_SUCCESS, %36 ], [ @EXIT_SUCCESS, %34 ]
%44 = load i32, i32* %43
ret i32 %44
}