#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcasecmp(char *, char *);
int xed_decode(char const *);
int main(int argc, char *argv[]) {
  int ret = 0;
  char help = 0;
  int positional;
  int i;
  const char *infile = NULL;
  fprintf(stderr, "XED File Format Parser\n");
  fprintf(stderr, "2013, Dan Jackson\n");
  fprintf(stderr, "\n");
  positional = 0;
  for (i = 1; i < argc; i++) {
    if (!strcasecmp(argv[i], "--help")) {
      help = 1;
      break;
    } else if (argv[i][0] == '-') {
      fprintf(stderr, "ERROR: Unknown option: %s\n", argv[i]);
      help = 1;
      break;
    } else {
      positional++;
      if (positional == 1) {
        infile = argv[i];
      } else {
        fprintf(stderr, "ERROR: Unknown positional parameter: %s\n", argv[i]);
        help = 1;
        break;
      }
    }
  }
  if (infile == NULL) {
    fprintf(stderr, "ERROR: Input file not specified.\n");
    help = 1;
  }
  if (help) {
    fprintf(stderr, "\n");
    fprintf(stderr, "Usage: xed_decode <input.xed>\n");
    fprintf(stderr, "\n");
    ret = -1;
  } else {
    fprintf(stderr, "NOTE: Processing: %s\n", infile);
    ret = xed_decode(infile);
    fprintf(stderr, "NOTE: End processing\n");
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    0xeff(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1297 <main+0x167>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe60(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11e2 <main+0xb2>
movb   $0x1,-0x15(%rbp)
jmp    1297 <main+0x167>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1226 <main+0xf6>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movb   $0x1,-0x15(%rbp)
jmp    1297 <main+0x167>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    124e <main+0x11e>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
jmp    127a <main+0x14a>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movb   $0x1,-0x15(%rbp)
jmp    1297 <main+0x167>
jmp    127f <main+0x14f>
jmp    1284 <main+0x154>
jmp    1289 <main+0x159>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ac <main+0x7c>
cmpq   $0x0,-0x28(%rbp)
jne    12bd <main+0x18d>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movb   $0x1,-0x15(%rbp)
cmpb   $0x0,-0x15(%rbp)
je     1318 <main+0x1e8>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xd91(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1356 <main+0x226>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xd8b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <xed_decode@plt>
mov    %eax,-0x14(%rbp)
mov    0x2c9a(%rip),%rax
mov    (%rax),%edi
lea    0xd7e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e9c(%rip),%r12
mov    (%r12),%edi
lea    0xeb1(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r12),%edi
lea    0xeb7(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r12),%edi
lea    0xf23(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    $0x2,%ebp
jl     11b4 <main+0x84>
mov    0x8(%r14),%r15
lea    0xe9e(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11b4 <main+0x84>
cmpb   $0x2d,(%r15)
jne    1204 <main+0xd4>
mov    (%r12),%edi
lea    0xe88(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r12),%edi
lea    0xeb7(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r12),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r12),%edi
lea    0xeb9(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    (%r12),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x2,%ebp
jne    1231 <main+0x101>
mov    (%r12),%edi
lea    0xea3(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r15,%rdi
call   1040 <xed_decode@plt>
mov    %eax,%ebp
lea    0xe9e(%rip),%rbx
jmp    11eb <main+0xbb>
mov    0x10(%r14),%rbp
lea    0xdef(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11c6 <main+0x96>
cmpb   $0x2d,0x0(%rbp)
mov    (%r12),%edi
jne    125f <main+0x12f>
lea    0xdd5(%rip),%rsi
jmp    1266 <main+0x136>
lea    0xde7(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11c6 <main+0x96>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"XED File Format Parser\0A\00"
@.str.1 = [19 x i8] c"2013, Dan Jackson\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [7 x i8] c"--help\00"
@.str.4 = [27 x i8] c"ERROR: Unknown option: %s\0A\00"
@.str.5 = [41 x i8] c"ERROR: Unknown positional parameter: %s\0A\00"
@.str.6 = [34 x i8] c"ERROR: Input file not specified.\0A\00"
@.str.7 = [31 x i8] c"Usage: xed_decode <input.xed>\0A\00"
@.str.8 = [22 x i8] c"NOTE: Processing: %s\0A\00"
@.str.9 = [22 x i8] c"NOTE: End processing\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8 0, i8* %7
store i8* null, i8** %10
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
store i32 1, i32* %9
br label %17
17: ; preds = %70, %2
%18 = load i32, i32* %9
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %73
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @strcasecmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %21
store i8 1, i8* %7
br label %73
30: ; preds = %21
%31 = load i8**, i8*** %5
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 45
br i1 %39, label %40, label %48
40: ; preds = %30
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %46)
store i8 1, i8* %7
br label %73
48: ; preds = %30
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %59
53: ; preds = %48
%54 = load i8**, i8*** %5
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
store i8* %58, i8** %10
br label %67
59: ; preds = %48
%60 = load i32, i32* @stderr
%61 = load i8**, i8*** %5
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %65)
store i8 1, i8* %7
br label %73
67: ; preds = %53
br label %68
68: ; preds = %67
br label %69
69: ; preds = %68
br label %70
70: ; preds = %69
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
br label %17
73: ; preds = %59, %40, %29, %17
%74 = load i8*, i8** %10
%75 = icmp eq i8* %74, null
br i1 %75, label %76, label %79
76: ; preds = %73
%77 = load i32, i32* @stderr
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
store i8 1, i8* %7
br label %79
79: ; preds = %76, %73
%80 = load i8, i8* %7
%81 = icmp ne i8 %80, 0
br i1 %81, label %82, label %89
82: ; preds = %79
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %6
br label %97
89: ; preds = %79
%90 = load i32, i32* @stderr
%91 = load i8*, i8** %10
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %91)
%93 = load i8*, i8** %10
%94 = call i32 @xed_decode(i8* %93)
store i32 %94, i32* %6
%95 = load i32, i32* @stderr
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
br label %97
97: ; preds = %89, %82
%98 = load i32, i32* %6
ret i32 %98
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"XED File Format Parser\0A\00"
@.str.1 = [19 x i8] c"2013, Dan Jackson\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [7 x i8] c"--help\00"
@.str.4 = [27 x i8] c"ERROR: Unknown option: %s\0A\00"
@.str.5 = [41 x i8] c"ERROR: Unknown positional parameter: %s\0A\00"
@.str.6 = [34 x i8] c"ERROR: Input file not specified.\0A\00"
@.str.7 = [31 x i8] c"Usage: xed_decode <input.xed>\0A\00"
@.str.8 = [22 x i8] c"NOTE: Processing: %s\0A\00"
@.str.9 = [22 x i8] c"NOTE: End processing\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %36
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @strcasecmp(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %36, label %24
15: ; preds = %30
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @strcasecmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %39, label %20
20: ; preds = %15
%21 = load i8, i8* %17
%22 = icmp eq i8 %21, 45
%23 = load i32, i32* @stderr
br i1 %22, label %34, label %32
24: ; preds = %10
%25 = load i8, i8* %12
%26 = icmp eq i8 %25, 45
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %12)
br label %36
30: ; preds = %24
%31 = icmp eq i32 %0, 2
br i1 %31, label %44, label %15
32: ; preds = %20
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %17)
br label %39
34: ; preds = %20
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %17)
br label %39
36: ; preds = %10, %2, %27
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %39
39: ; preds = %32, %15, %34, %36
%40 = load i32, i32* @stderr
%41 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %48
44: ; preds = %30
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %12)
%47 = tail call i32 @xed_decode(i8* %12)
br label %48
48: ; preds = %44, %39
%49 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), %44 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %39 ]
%50 = phi i32 [ %47, %44 ], [ -1, %39 ]
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* %49)
ret i32 %50
}