#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 */
typedef enum func { ____Placeholder_func } func;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ decode_file(char *, char *, int, int);
int /*<<< orphan*/ encode_file(char *, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setup_tables(int);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int nativeBlockNum = 4;
  int parityBlockNum = 2;
  char *inFile = NULL;
  char *confFile = NULL;
  char *outFile = NULL;
  enum func { encode, decode };
  enum func op;
  nativeBlockNum = atoi(argv[1]);
  parityBlockNum = atoi(argv[2]);
  if (strcmp(argv[3], "-e") == 0) {
    op = encode;
  } else if (strcmp(argv[3], "-d") == 0) {
    op = decode;
  } else {
    printf("Invalid option!\n");
    exit(-1);
  }
  setup_tables(8);
  switch (op) {
  case encode:
    inFile = argv[4];
    encode_file(inFile, nativeBlockNum, parityBlockNum);
    break;
  case decode:
    if (argc == 5) {
      confFile = argv[4];
    } else if (argc == 7 && strcmp(argv[5], "-o") == 0) {
      confFile = argv[4];
      outFile = argv[6];
    } else {
      printf("Invalid command!\n");
      exit(-1);
    }
    decode_file(confFile, outFile, nativeBlockNum, parityBlockNum);
    break;
  }
  return 0;
}


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)
movl   $0x4,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe25(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11f6 <main+0x86>
movl   $0x0,-0x34(%rbp)
jmp    123b <main+0xcb>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdfe(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1220 <main+0xb0>
movl   $0x1,-0x34(%rbp)
jmp    1236 <main+0xc6>
lea    0xddf(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
jmp    123b <main+0xcb>
mov    $0x8,%edi
call   1040 <setup_tables@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
test   %eax,%eax
je     1269 <main+0xf9>
jmp    1258 <main+0xe8>
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
je     1289 <main+0x119>
jmp    1317 <main+0x1a7>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <encode_file@plt>
jmp    1317 <main+0x1a7>
cmpl   $0x5,-0x8(%rbp)
jne    12a4 <main+0x134>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1304 <main+0x194>
cmpl   $0x7,-0x8(%rbp)
jne    12e9 <main+0x179>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xd5a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12e9 <main+0x179>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    12ff <main+0x18f>
lea    0xd2a(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
jmp    1304 <main+0x194>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <decode_file@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%r15d
mov    0x18(%rbx),%rdi
lea    0xe61(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11ed <main+0x7d>
mov    0x18(%rbx),%rdi
lea    0xe4f(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1226 <main+0xb6>
mov    $0x8,%edi
call   1050 <setup_tables@plt>
cmp    $0x5,%ebp
je     1208 <main+0x98>
cmp    $0x7,%ebp
jne    122f <main+0xbf>
mov    0x28(%rbx),%rdi
lea    0xe29(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    122f <main+0xbf>
mov    0x30(%rbx),%rsi
jmp    120a <main+0x9a>
mov    $0x8,%edi
call   1050 <setup_tables@plt>
mov    0x20(%rbx),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
call   1060 <encode_file@plt>
jmp    1219 <main+0xa9>
xor    %esi,%esi
mov    0x20(%rbx),%rdi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1030 <decode_file@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xddc(%rip),%rdi
jmp    1236 <main+0xc6>
lea    0xde3(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-e\00"
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [17 x i8] c"Invalid option!\0A\00"
@.str.3 = [3 x i8] c"-o\00"
@.str.4 = [18 x i8] c"Invalid command!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 4, i32* %6
store i32 2, i32* %7
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %7
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %2
store i32 0, i32* %11
br label %37
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 1, i32* %11
br label %36
33: ; preds = %26
%34 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 -1)
unreachable
36: ; preds = %32
br label %37
37: ; preds = %36, %25
%38 = call i32 @setup_tables(i32 8)
%39 = load i32, i32* %11
switch i32 %39, label %81 [
i32 0, label %40
i32 1, label %48
]
40: ; preds = %37
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 4
%43 = load i8*, i8** %42
store i8* %43, i8** %8
%44 = load i8*, i8** %8
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = call i32 @encode_file(i8* %44, i32 %45, i32 %46)
br label %81
48: ; preds = %37
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 5
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 4
%54 = load i8*, i8** %53
store i8* %54, i8** %9
br label %75
55: ; preds = %48
%56 = load i32, i32* %4
%57 = icmp eq i32 %56, 7
br i1 %57, label %58, label %71
58: ; preds = %55
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 5
%61 = load i8*, i8** %60
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %71
64: ; preds = %58
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 4
%67 = load i8*, i8** %66
store i8* %67, i8** %9
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 6
%70 = load i8*, i8** %69
store i8* %70, i8** %10
br label %74
71: ; preds = %58, %55
%72 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%73 = call i32 @exit(i32 -1)
unreachable
74: ; preds = %64
br label %75
75: ; preds = %74, %51
%76 = load i8*, i8** %9
%77 = load i8*, i8** %10
%78 = load i32, i32* %6
%79 = load i32, i32* %7
%80 = call i32 @decode_file(i8* %76, i8* %77, i32 %78, i32 %79)
br label %81
81: ; preds = %37, %75, %40
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-e\00"
@.str.1 = [3 x i8] c"-d\00"
@.str.3 = [3 x i8] c"-o\00"
@str = [16 x i8] c"Invalid option!\00"
@str.5 = [17 x i8] c"Invalid command!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %2
%14 = load i8*, i8** %9
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %13
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @exit(i32 -1)
unreachable
20: ; preds = %2
%21 = tail call i32 @setup_tables(i32 8)
%22 = getelementptr inbounds i8*, i8** %1, i64 4
%23 = load i8*, i8** %22
%24 = tail call i32 @encode_file(i8* %23, i32 %5, i32 %8)
br label %43
25: ; preds = %13
%26 = tail call i32 @setup_tables(i32 8)
switch i32 %0, label %35 [
i32 5, label %38
i32 7, label %27
]
27: ; preds = %25
%28 = getelementptr inbounds i8*, i8** %1, i64 5
%29 = load i8*, i8** %28
%30 = tail call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = getelementptr inbounds i8*, i8** %1, i64 6
%34 = load i8*, i8** %33
br label %38
35: ; preds = %25, %27
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%37 = tail call i32 @exit(i32 -1)
unreachable
38: ; preds = %25, %32
%39 = phi i8* [ %34, %32 ], [ null, %25 ]
%40 = getelementptr inbounds i8*, i8** %1, i64 4
%41 = load i8*, i8** %40
%42 = tail call i32 @decode_file(i8* %41, i8* %39, i32 %5, i32 %8)
br label %43
43: ; preds = %38, %20
ret i32 0
}