#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 /*<<< orphan*/ decode(char *, char *, char *);
int /*<<< orphan*/ encode(char *, char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char getopt(int, char *const *, char *);
char *optarg;
int /*<<< orphan*/ stderr;
int main(int argc, char *const argv[]) {
  char c;
  char *sourceFile = NULL;
  char *diffFile = NULL;
  char *targetFile = NULL;
  int action = 0;
  while ((c = getopt(argc, argv, "-ed")) != -1) {
    switch (c) {
    case 'e':
      action = 1;
      break;
    case 'd':
      action = 2;
      break;
    default:
      if (sourceFile == NULL)
        sourceFile = optarg;
      else if (diffFile == NULL)
        diffFile = optarg;
      else if (targetFile == NULL)
        targetFile = optarg;
      else {
        fprintf(stderr, "Invalid option '%s'\n", optarg);
        exit(-1);
      }
    }
  }
  switch (action) {
  case 1:
    if (targetFile == NULL) {
      fprintf(stderr, "Specify a source, target and diff file\n");
      exit(EXIT_FAILURE);
    }
    encode(sourceFile, diffFile, targetFile);
    break;
  case 2:
    if (targetFile == NULL) {
      fprintf(stderr, "Specify a source, diff and target file\n");
      exit(EXIT_FAILURE);
    }
    decode(sourceFile, diffFile, targetFile);
    break;
  default:
    fprintf(stderr, "Specify an action\n");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6d(%rip),%rdx
call   1060 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     127e <main+0x12e>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x64,%eax
je     11d9 <main+0x89>
jmp    11bc <main+0x6c>
mov    -0x38(%rbp),%eax
sub    $0x65,%eax
jne    11e5 <main+0x95>
jmp    11cd <main+0x7d>
movl   $0x1,-0x34(%rbp)
jmp    1279 <main+0x129>
movl   $0x2,-0x34(%rbp)
jmp    1279 <main+0x129>
cmpq   $0x0,-0x20(%rbp)
jne    1203 <main+0xb3>
mov    0x2e01(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1274 <main+0x124>
cmpq   $0x0,-0x28(%rbp)
jne    1221 <main+0xd1>
mov    0x2de3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    126f <main+0x11f>
cmpq   $0x0,-0x30(%rbp)
jne    123f <main+0xef>
mov    0x2dc5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    126a <main+0x11a>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
mov    0x2da9(%rip),%rax
mov    (%rax),%rdx
lea    0xdab(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
jmp    126f <main+0x11f>
jmp    1274 <main+0x124>
jmp    1279 <main+0x129>
jmp    1185 <main+0x35>
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x1,%eax
je     12a3 <main+0x153>
jmp    1292 <main+0x142>
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
je     12e9 <main+0x199>
jmp    132f <main+0x1df>
cmpq   $0x0,-0x30(%rbp)
jne    12d3 <main+0x183>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
lea    0xd5b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <encode@plt>
jmp    1354 <main+0x204>
cmpq   $0x0,-0x30(%rbp)
jne    1319 <main+0x1c9>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <decode@plt>
jmp    1354 <main+0x204>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
lea    0xd2a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe99(%rip),%rdx
call   1060 <getopt@plt>
cmp    $0xff,%al
je     126b <main+0x11b>
xor    %r15d,%r15d
lea    0xe82(%rip),%r13
xor    %r14d,%r14d
xor    %ecx,%ecx
mov    %rcx,(%rsp)
xor    %r12d,%r12d
jmp    11a7 <main+0x57>
nopl   0x0(%rax)
mov    $0x1,%r15d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1060 <getopt@plt>
cmp    $0xff,%al
je     11f9 <main+0xa9>
movsbl %al,%eax
cmp    $0x65,%eax
je     1190 <main+0x40>
cmp    $0x64,%eax
jne    11c0 <main+0x70>
mov    $0x2,%r15d
jmp    1196 <main+0x46>
nopl   0x0(%rax)
test   %r12,%r12
je     11dd <main+0x8d>
cmpq   $0x0,(%rsp)
je     11e9 <main+0x99>
test   %r14,%r14
jne    1240 <main+0xf0>
mov    0x2e20(%rip),%rax
mov    (%rax),%r14
jmp    1196 <main+0x46>
mov    0x2e14(%rip),%rax
mov    (%rax),%r12
jmp    1196 <main+0x46>
mov    0x2e08(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rsp)
jmp    1196 <main+0x46>
cmp    $0x2,%r15d
je     121b <main+0xcb>
cmp    $0x1,%r15d
jne    126b <main+0x11b>
test   %r14,%r14
je     127d <main+0x12d>
mov    %r12,%rdi
mov    (%rsp),%rsi
mov    %r14,%rdx
call   1030 <encode@plt>
jmp    122f <main+0xdf>
test   %r14,%r14
je     128f <main+0x13f>
mov    %r12,%rdi
mov    (%rsp),%rsi
mov    %r14,%rdx
call   1050 <decode@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    0x2da8(%rip),%rax
mov    (%rax),%rdx
lea    0xdaa(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
jmp    129f <main+0x14f>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xd8c(%rip),%rsi
jmp    129f <main+0x14f>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
lea    0xda2(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"-ed\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [21 x i8] c"Invalid option '%s'\0A\00"
@.str.2 = [40 x i8] c"Specify a source, target and diff file\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [40 x i8] c"Specify a source, diff and target file\0A\00"
@.str.4 = [19 x i8] c"Specify an action\0A\00"
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 i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
store i32 0, i32* %10
br label %11
11: ; preds = %45, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call signext i8 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8 %14, i8* %6
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %46
17: ; preds = %11
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
switch i32 %19, label %22 [
i32 101, label %20
i32 100, label %21
]
20: ; preds = %17
store i32 1, i32* %10
br label %45
21: ; preds = %17
store i32 2, i32* %10
br label %45
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = load i8*, i8** @optarg
store i8* %26, i8** %7
br label %44
27: ; preds = %22
%28 = load i8*, i8** %8
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = load i8*, i8** @optarg
store i8* %31, i8** %8
br label %43
32: ; preds = %27
%33 = load i8*, i8** %9
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = load i8*, i8** @optarg
store i8* %36, i8** %9
br label %42
37: ; preds = %32
%38 = load i32, i32* @stderr
%39 = load i8*, i8** @optarg
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = call i32 @exit(i32 -1)
unreachable
42: ; preds = %35
br label %43
43: ; preds = %42, %30
br label %44
44: ; preds = %43, %25
br label %45
45: ; preds = %44, %21, %20
br label %11
46: ; preds = %11
%47 = load i32, i32* %10
switch i32 %47, label %74 [
i32 1, label %48
i32 2, label %61
]
48: ; preds = %46
%49 = load i8*, i8** %9
%50 = icmp eq i8* %49, null
br i1 %50, label %51, label %56
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %48
%57 = load i8*, i8** %7
%58 = load i8*, i8** %8
%59 = load i8*, i8** %9
%60 = call i32 @encode(i8* %57, i8* %58, i8* %59)
br label %79
61: ; preds = %46
%62 = load i8*, i8** %9
%63 = icmp eq i8* %62, null
br i1 %63, label %64, label %69
64: ; preds = %61
%65 = load i32, i32* @stderr
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %61
%70 = load i8*, i8** %7
%71 = load i8*, i8** %8
%72 = load i8*, i8** %9
%73 = call i32 @decode(i8* %70, i8* %71, i8* %72)
br label %79
74: ; preds = %46
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%77 = load i32, i32* @EXIT_FAILURE
%78 = call i32 @exit(i32 %77)
unreachable
79: ; preds = %69, %56
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@.str = [4 x i8] c"-ed\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [21 x i8] c"Invalid option '%s'\0A\00"
@.str.2 = [40 x i8] c"Specify a source, target and diff file\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [40 x i8] c"Specify a source, diff and target file\0A\00"
@.str.4 = [19 x i8] c"Specify an action\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8 %3, -1
br i1 %4, label %56, label %5
5: ; preds = %2, %30
%6 = phi i8 [ %35, %30 ], [ %3, %2 ]
%7 = phi i32 [ %34, %30 ], [ 0, %2 ]
%8 = phi i8* [ %33, %30 ], [ null, %2 ]
%9 = phi i8* [ %32, %30 ], [ null, %2 ]
%10 = phi i8* [ %31, %30 ], [ null, %2 ]
%11 = sext i8 %6 to i32
switch i32 %11, label %13 [
i32 101, label %30
i32 100, label %12
]
12: ; preds = %5
br label %30
13: ; preds = %5
%14 = icmp eq i8* %10, null
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = load i8*, i8** @optarg
br label %30
17: ; preds = %13
%18 = icmp eq i8* %9, null
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = load i8*, i8** @optarg
br label %30
21: ; preds = %17
%22 = icmp eq i8* %8, null
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = load i8*, i8** @optarg
br label %30
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i8*, i8** @optarg
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = tail call i32 @exit(i32 -1)
unreachable
30: ; preds = %5, %15, %23, %19, %12
%31 = phi i8* [ %16, %15 ], [ %10, %19 ], [ %10, %23 ], [ %10, %12 ], [ %10, %5 ]
%32 = phi i8* [ %9, %15 ], [ %20, %19 ], [ %9, %23 ], [ %9, %12 ], [ %9, %5 ]
%33 = phi i8* [ %8, %15 ], [ %8, %19 ], [ %24, %23 ], [ %8, %12 ], [ %8, %5 ]
%34 = phi i32 [ %7, %15 ], [ %7, %19 ], [ %7, %23 ], [ 2, %12 ], [ 1, %5 ]
%35 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%36 = icmp eq i8 %35, -1
br i1 %36, label %37, label %5
37: ; preds = %30
switch i32 %34, label %56 [
i32 1, label %38
i32 2, label %47
]
38: ; preds = %37
%39 = icmp eq i8* %33, null
br i1 %39, label %40, label %45
40: ; preds = %38
%41 = load i32, i32* @stderr
%42 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
%44 = tail call i32 @exit(i32 %43)
unreachable
45: ; preds = %38
%46 = tail call i32 @encode(i8* %31, i8* %32, i8* %33)
br label %61
47: ; preds = %37
%48 = icmp eq i8* %33, null
br i1 %48, label %49, label %54
49: ; preds = %47
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = tail call i32 @exit(i32 %52)
unreachable
54: ; preds = %47
%55 = tail call i32 @decode(i8* %31, i8* %32, i8* %33)
br label %61
56: ; preds = %2, %37
%57 = load i32, i32* @stderr
%58 = tail call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%59 = load i32, i32* @EXIT_FAILURE
%60 = tail call i32 @exit(i32 %59)
unreachable
61: ; preds = %54, %45
ret i32 0
}