#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 copy_file(char *, char *);
scalar_t__ decode(char **);
scalar_t__ encode(char **);
int /*<<< orphan*/ error(int);
int /*<<< orphan*/ printHelp(char **);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc < 3) {
    printHelp(argv);
    return EXIT_FAILURE;
  }
  if (strcmp(argv[1], "-e") == 0 && argc == 4) {
    if (copy_file(argv[2], argv[3]) == 10) {
      error(10);
      return 1;
    }
    return encode(argv) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
  } else if (strcmp(argv[1], "-d") == 0 && argc == 3) {
    return decode(argv) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
  } else {
    printHelp(argv);
    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    119a <main+0x3a>
mov    -0x10(%rbp),%rdi
call   1030 <printHelp@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a9 <main+0x149>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe57(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1231 <main+0xd1>
cmpl   $0x4,-0x8(%rbp)
jne    1231 <main+0xd1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <copy_file@plt>
cmp    $0xa,%eax
jne    11f6 <main+0x96>
mov    $0xa,%edi
call   1080 <error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a9 <main+0x149>
mov    -0x10(%rbp),%rdi
call   1050 <encode@plt>
cmp    $0x0,%rax
jne    121a <main+0xba>
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1226 <main+0xc6>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a9 <main+0x149>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc3(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1294 <main+0x134>
cmpl   $0x3,-0x8(%rbp)
jne    1294 <main+0x134>
mov    -0x10(%rbp),%rdi
call   1070 <decode@plt>
cmp    $0x0,%rax
jne    127d <main+0x11d>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    1289 <main+0x129>
mov    0x2d5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a9 <main+0x149>
mov    -0x10(%rbp),%rdi
call   1030 <printHelp@plt>
mov    0x2d3c(%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   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     1183 <main+0x23>
mov    %rbx,%rdi
call   1030 <printHelp@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %edi,%ebp
mov    0x8(%rbx),%rdi
lea    0xe70(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x4,%ebp
jne    11c2 <main+0x62>
test   %rax,%rax
jne    11c2 <main+0x62>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1040 <copy_file@plt>
cmp    $0xa,%eax
jne    11eb <main+0x8b>
mov    $0xa,%edi
call   1080 <error@plt>
mov    $0x1,%eax
jmp    117c <main+0x1c>
mov    0x8(%rbx),%rdi
lea    0xe36(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x3,%ebp
jne    116b <main+0xb>
test   %rax,%rax
jne    116b <main+0xb>
mov    %rbx,%rdi
call   1070 <decode@plt>
test   %rax,%rax
jne    1173 <main+0x13>
jmp    11fc <main+0x9c>
mov    %rbx,%rdi
call   1050 <encode@plt>
test   %rax,%rax
jne    1173 <main+0x13>
mov    0x2dd5(%rip),%rax
jmp    117a <main+0x1a>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"-e\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [3 x i8] c"-d\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 %12
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = call i32 @printHelp(i8** %9)
%11 = load i32, i32* @EXIT_FAILURE
store i32 %11, i32* %3
br label %65
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %42
18: ; preds = %12
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 4
br i1 %20, label %21, label %42
21: ; preds = %18
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call i32 @copy_file(i8* %24, i8* %27)
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %32
30: ; preds = %21
%31 = call i32 @error(i32 10)
store i32 1, i32* %3
br label %65
32: ; preds = %21
%33 = load i8**, i8*** %5
%34 = call i64 @encode(i8** %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* @EXIT_SUCCESS
br label %40
38: ; preds = %32
%39 = load i32, i32* @EXIT_FAILURE
br label %40
40: ; preds = %38, %36
%41 = phi i32 [ %37, %36 ], [ %39, %38 ]
store i32 %41, i32* %3
br label %65
42: ; preds = %18, %12
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %61
48: ; preds = %42
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 3
br i1 %50, label %51, label %61
51: ; preds = %48
%52 = load i8**, i8*** %5
%53 = call i64 @decode(i8** %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = load i32, i32* @EXIT_SUCCESS
br label %59
57: ; preds = %51
%58 = load i32, i32* @EXIT_FAILURE
br label %59
59: ; preds = %57, %55
%60 = phi i32 [ %56, %55 ], [ %58, %57 ]
store i32 %60, i32* %3
br label %65
61: ; preds = %48, %42
%62 = load i8**, i8*** %5
%63 = call i32 @printHelp(i8** %62)
%64 = load i32, i32* @EXIT_FAILURE
store i32 %64, i32* %3
br label %65
65: ; preds = %61, %59, %40, %30, %8
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"-e\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [3 x i8] c"-d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @printHelp(i8** %1)
%6 = load i32, i32* @EXIT_FAILURE
br label %44
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = icmp eq i32 %0, 4
%13 = and i1 %12, %11
br i1 %13, label %14, label %29
14: ; preds = %7
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @copy_file(i8* %16, i8* %18)
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = tail call i32 @error(i32 10)
br label %44
23: ; preds = %14
%24 = tail call i64 @encode(i8** %1)
%25 = icmp eq i64 %24, 0
%26 = load i32, i32* @EXIT_SUCCESS
%27 = load i32, i32* @EXIT_FAILURE
%28 = select i1 %25, i32 %26, i32 %27
br label %44
29: ; preds = %7
%30 = load i8*, i8** %8
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
%33 = icmp eq i32 %0, 3
%34 = and i1 %33, %32
br i1 %34, label %35, label %41
35: ; preds = %29
%36 = tail call i64 @decode(i8** %1)
%37 = icmp eq i64 %36, 0
%38 = load i32, i32* @EXIT_SUCCESS
%39 = load i32, i32* @EXIT_FAILURE
%40 = select i1 %37, i32 %38, i32 %39
br label %44
41: ; preds = %29
%42 = tail call i32 @printHelp(i8** %1)
%43 = load i32, i32* @EXIT_FAILURE
br label %44
44: ; preds = %41, %35, %23, %21, %4
%45 = phi i32 [ %6, %4 ], [ 1, %21 ], [ %28, %23 ], [ %40, %35 ], [ %43, %41 ]
ret i32 %45
}