#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 int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ Cell;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
void main(int argc, char **argv) {
  FILE *File;
  unsigned char Cell[5];
  int CellCount;
  char AuxString[33];
  if (argc != 2) {
    printf("Usage: %s <AerochopperCaptureBin>\n", argv[0]);
    return;
  }
  File = fopen(argv[1], "rb");
  if (!File) {
    printf("Unable to open file %s\n", argv[1]);
    return;
  }
  CellCount = 0;
  memset(AuxString, '-', 32);
  AuxString[32] = 0;
  while (fread(Cell, sizeof(Cell), 1, File)) {
    if (!(Cell[0] & 0x0F)) {
      printf("Invalid cell header %02X - value not xF\n", Cell[0]);
      break;
    }
    if (!(CellCount & 0x03)) {
      if ((Cell[0] >> 4) != (CellCount >> 1)) {
        printf("Invalid cell header %02X - supercell counter mismatch\n",
               Cell[0]);
        break;
      }
    }
    if (((Cell[0] >> 4) & 0x01) != (CellCount & 0x01)) {
      printf("Invalid cell header %02X - even/odd sequence error\n", Cell[0]);
      break;
    }
    if (CellCount & 0x03)
      AuxString[CellCount] = (Cell[0] >> 5) + '0';
    printf("%02d: %02X %02X %02X %02X %s\n", CellCount + 1, Cell[1], Cell[2],
           Cell[3], Cell[4], AuxString);
    CellCount = (CellCount + 1) % 32;
  }
  if (!feof(File))
    printf("Error reading file!\n");
  fclose(File);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
je     1193 <main+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1336 <main+0x1d6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d1 <main+0x71>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1336 <main+0x1d6>
movl   $0x0,-0x24(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x2d,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
movb   $0x0,-0x30(%rbp)
lea    -0x1d(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x5,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
je     130d <main+0x1ad>
movzbl -0x1d(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    1237 <main+0xd7>
movzbl -0x1d(%rbp),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    130d <main+0x1ad>
mov    -0x24(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
jne    1277 <main+0x117>
movzbl -0x1d(%rbp),%eax
sar    $0x4,%eax
mov    -0x24(%rbp),%ecx
sar    $0x1,%ecx
cmp    %ecx,%eax
je     1272 <main+0x112>
movzbl -0x1d(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    130d <main+0x1ad>
jmp    1277 <main+0x117>
movzbl -0x1d(%rbp),%eax
sar    $0x4,%eax
and    $0x1,%eax
mov    -0x24(%rbp),%ecx
and    $0x1,%ecx
cmp    %ecx,%eax
je     12a6 <main+0x146>
movzbl -0x1d(%rbp),%esi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    130d <main+0x1ad>
mov    -0x24(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
je     12c9 <main+0x169>
movzbl -0x1d(%rbp),%eax
sar    $0x5,%eax
add    $0x30,%eax
mov    %al,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x24(%rbp),%esi
add    $0x1,%esi
movzbl -0x1c(%rbp),%edx
movzbl -0x1b(%rbp),%ecx
movzbl -0x1a(%rbp),%r8d
movzbl -0x19(%rbp),%r9d
lea    -0x50(%rbp),%rax
lea    0xde6(%rip),%rdi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
jmp    11ef <main+0x8f>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
jne    132d <main+0x1cd>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    12ad <main+0x13d>
mov    0x8(%rbx),%rdi
lea    0xe8e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12b9 <main+0x149>
mov    %rax,%rbp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x2d,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
movb   $0x0,0x30(%rsp)
lea    0xb(%rsp),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     12f0 <main+0x180>
lea    0xee9(%rip),%r12
lea    0xb(%rsp),%r13
xor    %r15d,%r15d
jmp    125d <main+0xed>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%r15),%ebx
movzbl 0xc(%rsp),%edx
movzbl 0xd(%rsp),%ecx
movzbl 0xe(%rsp),%r8d
movzbl 0xf(%rsp),%r9d
mov    %r14,(%rsp)
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%r15),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xffffffe0,%eax
neg    %eax
add    %eax,%r15d
add    $0x1,%r15d
mov    %r13,%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     12f0 <main+0x180>
movzbl 0xb(%rsp),%esi
test   $0xf,%sil
je     12d9 <main+0x169>
mov    %esi,%eax
shr    $0x4,%eax
test   $0x3,%r15b
je     1290 <main+0x120>
xor    %r15d,%eax
test   $0x1,%al
jne    12a4 <main+0x134>
shr    $0x5,%sil
or     $0x30,%sil
movslq %r15d,%rax
mov    %sil,0x10(%rsp,%rax,1)
jmp    1200 <main+0x90>
nop
mov    %r15d,%ecx
sar    %ecx
cmp    %ecx,%eax
jne    12e2 <main+0x172>
xor    %r15d,%eax
test   $0x1,%al
je     1200 <main+0x90>
lea    0xdf3(%rip),%rdi
jmp    12e9 <main+0x179>
mov    (%rbx),%rsi
lea    0xd49(%rip),%rdi
jmp    12c4 <main+0x154>
mov    0x8(%rbx),%rsi
lea    0xd62(%rip),%rdi
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <printf@plt>
lea    0xd5e(%rip),%rdi
jmp    12e9 <main+0x179>
lea    0xd7e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1308 <main+0x198>
lea    0xded(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Usage: %s <AerochopperCaptureBin>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [24 x i8] c"Unable to open file %s\0A\00"
@.str.3 = [41 x i8] c"Invalid cell header %02X - value not xF\0A\00"
@.str.4 = [55 x i8] c"Invalid cell header %02X - supercell counter mismatch\0A\00"
@.str.5 = [52 x i8] c"Invalid cell header %02X - even/odd sequence error\0A\00"
@.str.6 = [30 x i8] c"%02d: %02X %02X %02X %02X %s\0A\00"
@.str.7 = [21 x i8] c"Error reading file!\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca [5 x i8]
%7 = alloca i32
%8 = alloca [33 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %123
16: ; preds = %2
%17 = load i8**, i8*** %4
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %5
%21 = load i32*, i32** %5
%22 = icmp ne i32* %21, null
br i1 %22, label %28, label %23
23: ; preds = %16
%24 = load i8**, i8*** %4
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %123
28: ; preds = %16
store i32 0, i32* %7
%29 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%30 = call i32 @memset(i8* %29, i8 signext 45, i32 32)
%31 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 32
store i8 0, i8* %31
br label %32
32: ; preds = %94, %28
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%34 = load i32*, i32** %5
%35 = call i64 @fread(i8* %33, i32 5, i32 1, i32* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %114
37: ; preds = %32
%38 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = and i32 %40, 15
%42 = icmp ne i32 %41, 0
br i1 %42, label %48, label %43
43: ; preds = %37
%44 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %46)
br label %114
48: ; preds = %37
%49 = load i32, i32* %7
%50 = and i32 %49, 3
%51 = icmp ne i32 %50, 0
br i1 %51, label %66, label %52
52: ; preds = %48
%53 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = ashr i32 %55, 4
%57 = load i32, i32* %7
%58 = ashr i32 %57, 1
%59 = icmp ne i32 %56, %58
br i1 %59, label %60, label %65
60: ; preds = %52
%61 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %63)
br label %114
65: ; preds = %52
br label %66
66: ; preds = %65, %48
%67 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = ashr i32 %69, 4
%71 = and i32 %70, 1
%72 = load i32, i32* %7
%73 = and i32 %72, 1
%74 = icmp ne i32 %71, %73
br i1 %74, label %75, label %80
75: ; preds = %66
%76 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%77 = load i8, i8* %76
%78 = zext i8 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %78)
br label %114
80: ; preds = %66
%81 = load i32, i32* %7
%82 = and i32 %81, 3
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %94
84: ; preds = %80
%85 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%86 = load i8, i8* %85
%87 = zext i8 %86 to i32
%88 = ashr i32 %87, 5
%89 = add nsw i32 %88, 48
%90 = trunc i32 %89 to i8
%91 = load i32, i32* %7
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 %92
store i8 %90, i8* %93
br label %94
94: ; preds = %84, %80
%95 = load i32, i32* %7
%96 = add nsw i32 %95, 1
%97 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 1
%98 = load i8, i8* %97
%99 = zext i8 %98 to i32
%100 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 2
%101 = load i8, i8* %100
%102 = zext i8 %101 to i32
%103 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 3
%104 = load i8, i8* %103
%105 = zext i8 %104 to i32
%106 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 4
%107 = load i8, i8* %106
%108 = zext i8 %107 to i32
%109 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %96, i32 %99, i32 %102, i32 %105, i32 %108, i8* %109)
%111 = load i32, i32* %7
%112 = add nsw i32 %111, 1
%113 = srem i32 %112, 32
store i32 %113, i32* %7
br label %32
114: ; preds = %75, %60, %43, %32
%115 = load i32*, i32** %5
%116 = call i32 @feof(i32* %115)
%117 = icmp ne i32 %116, 0
br i1 %117, label %120, label %118
118: ; preds = %114
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %120
120: ; preds = %118, %114
%121 = load i32*, i32** %5
%122 = call i32 @fclose(i32* %121)
br label %123
123: ; preds = %120, %23, %11
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"Usage: %s <AerochopperCaptureBin>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [24 x i8] c"Unable to open file %s\0A\00"
@.str.3 = [41 x i8] c"Invalid cell header %02X - value not xF\0A\00"
@.str.4 = [55 x i8] c"Invalid cell header %02X - supercell counter mismatch\0A\00"
@.str.5 = [52 x i8] c"Invalid cell header %02X - even/odd sequence error\0A\00"
@.str.6 = [30 x i8] c"%02d: %02X %02X %02X %02X %s\0A\00"
@str = [20 x i8] c"Error reading file!\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca [5 x i8]
%4 = alloca [33 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %80
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %80
19: ; preds = %11
%20 = call i32 @memset(i8* %6, i8 signext 45, i32 32)
%21 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 32
store i8 0, i8* %21
%22 = call i64 @fread(i8* %5, i32 5, i32 1, i32* %14)
%23 = icmp eq i64 %22, 0
br i1 %23, label %73, label %24
24: ; preds = %19
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 1
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 2
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 3
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 4
br label %29
29: ; preds = %24, %55
%30 = phi i32 [ 0, %24 ], [ %66, %55 ]
%31 = load i8, i8* %5
%32 = zext i8 %31 to i32
%33 = and i32 %32, 15
%34 = icmp eq i32 %33, 0
br i1 %34, label %69, label %35
35: ; preds = %29
%36 = and i32 %30, 3
%37 = icmp eq i32 %36, 0
%38 = lshr i32 %32, 4
br i1 %37, label %39, label %46
39: ; preds = %35
%40 = ashr i32 %30, 1
%41 = icmp eq i32 %38, %40
br i1 %41, label %42, label %69
42: ; preds = %39
%43 = xor i32 %38, %30
%44 = and i32 %43, 1
%45 = icmp eq i32 %44, 0
br i1 %45, label %55, label %69
46: ; preds = %35
%47 = xor i32 %38, %30
%48 = and i32 %47, 1
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %69
50: ; preds = %46
%51 = lshr i8 %31, 5
%52 = or i8 %51, 48
%53 = sext i32 %30 to i64
%54 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 %53
store i8 %52, i8* %54
br label %55
55: ; preds = %42, %50
%56 = add nsw i32 %30, 1
%57 = load i8, i8* %25
%58 = zext i8 %57 to i32
%59 = load i8, i8* %26
%60 = zext i8 %59 to i32
%61 = load i8, i8* %27
%62 = zext i8 %61 to i32
%63 = load i8, i8* %28
%64 = zext i8 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %56, i32 %58, i32 %60, i32 %62, i32 %64, i8* %6)
%66 = srem i32 %56, 32
%67 = call i64 @fread(i8* %5, i32 5, i32 1, i32* %14)
%68 = icmp eq i64 %67, 0
br i1 %68, label %73, label %29
69: ; preds = %42, %46, %39, %29
%70 = phi i8* [ getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), %29 ], [ getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), %39 ], [ getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), %46 ], [ getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), %42 ]
%71 = zext i8 %31 to i32
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %70, i32 %71)
br label %73
73: ; preds = %55, %69, %19
%74 = call i32 @feof(i32* %14)
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %78
78: ; preds = %76, %73
%79 = call i32 @fclose(i32* %14)
br label %80
80: ; preds = %78, %16, %8
ret void
}