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

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ abort();
int atoi(char *);
int /*<<< orphan*/ bitout_ui8(char);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int getopt(int, char **, char *);
scalar_t__ malloc(int);
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  uint16_t pidfilter = 0;
  char pidfilter_on = 'n';
  char pusifilter_on = 'n';
  int pusifilter;
  char wait = 'y';
  char *filename = NULL;
  int c;
  int verbose = 0;
  int width = 4;
  while ((c = getopt(argc, argv, "s:w:i:p:cv")) != -1) {
    switch (c) {
    case 'p':
      pidfilter = atoi(optarg);
      pidfilter_on = 'y';
      if (verbose > 0)
        printf("set pidfilter to: %u\n", pidfilter);
      break;
    case 'i':
      filename = optarg;
      if (verbose > 0)
        printf("set filename to: %s\n", filename);
      break;
    case 'c':
      wait = 'n';
      break;
    case 's':
      pusifilter = atoi(optarg);
      pusifilter_on = 'y';
      break;
    case 'v':
      verbose++;
      break;
    case 'w':
      width = atoi(optarg);
      break;
    default:
      printf("\n");
      usage(argv[0]);
      abort();
    }
  }
  if (filename == NULL) {
    usage(argv[0]);
    return 1;
  }
  FILE *f;
  char *data = (char *)malloc(188);
  int chk = 0;
  int i;
  printf("opening '%s'...\n", filename);
  if (!(f = fopen(filename, "r"))) {
    printf("couldn't open file.\n");
    return 2;
  }
  int oldsize = ftell(f);
  while (!feof(f) && chk != 0x47) {
    chk = fgetc(f);
  }
  int newsize = ftell(f);
  if (oldsize != newsize) {
    fseek(f, -1, SEEK_CUR);
    oldsize--;
  }
  if (feof(f)) {
    fclose(f);
    printf("EOF before hitting mainloop.\n");
    return 3;
  }
  while (!feof(f)) {
    fread(data, 188, 1, f);
    uint16_t PID = (data[1] & 0x1F) << 8 | (data[2] & 0xff);
    uint8_t PUSI = (data[1] & 0x40) >> 6;
    if ((pidfilter_on == 'y' && pidfilter != PID)) {
      if (verbose > 0) {
        printf("skipping PID 0x%04x packet.\n", PID);
      }
    } else if ((pusifilter_on == 'y' && pusifilter != PUSI)) {
      if (verbose > 0) {
        printf("skipping PUSI 0x%02x packet.\n", PUSI);
      }
    } else {
      printf("dumping a PID 0x%04x (%u) packet. PUSI is 0x%02X\n", PID, PID,
             PUSI);
      i = 0;
      while (i < 188) {
        printf("0x%04x ", i);
        int j = i;
        while (j < i + width && j < 188) {
          bitout_ui8(data[j]);
          printf(" ");
          j++;
        }
        i = j;
        printf("\n");
      }
      printf("\n\n");
      if (wait == 'y') {
        printf("\nPress enter to continue, or 'q' to quit.\n");
        if (fgetc(stdin) == 'q')
          return 0;
      }
    }
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x6e,-0x15(%rbp)
movb   $0x6e,-0x16(%rbp)
movb   $0x79,-0x1d(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x4,-0x34(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe24(%rip),%rdx
call   10f0 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     133e <main+0x15e>
mov    -0x2c(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x70(%rbp)
sub    $0x14,%eax
ja     1318 <main+0x138>
mov    -0x70(%rbp),%rax
lea    0xd9f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d87(%rip),%rax
mov    (%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x14(%rbp)
movb   $0x79,-0x15(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    129b <main+0xbb>
mov    -0x14(%rbp),%esi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1339 <main+0x159>
mov    0x2d51(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    12ca <main+0xea>
mov    -0x28(%rbp),%rsi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1339 <main+0x159>
movb   $0x6e,-0x1d(%rbp)
jmp    1339 <main+0x159>
mov    0x2d19(%rip),%rax
mov    (%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movb   $0x79,-0x16(%rbp)
jmp    1339 <main+0x159>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1339 <main+0x159>
mov    0x2cf0(%rip),%rax
mov    (%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x34(%rbp)
jmp    1339 <main+0x159>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <usage@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1222 <main+0x42>
cmpq   $0x0,-0x28(%rbp)
jne    1361 <main+0x181>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1691 <main+0x4b1>
mov    $0xbc,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd08(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    13c0 <main+0x1e0>
lea    0xcf0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1691 <main+0x4b1>
mov    -0x40(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%rdi
call   1090 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x71(%rbp)
jne    13f1 <main+0x211>
cmpl   $0x47,-0x4c(%rbp)
setne  %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    1401 <main+0x221>
jmp    1415 <main+0x235>
mov    -0x40(%rbp),%rdi
call   1070 <fgetc@plt>
movsbl %al,%eax
mov    %eax,-0x4c(%rbp)
jmp    13cc <main+0x1ec>
mov    -0x40(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x58(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x58(%rbp),%eax
je     144d <main+0x26d>
mov    -0x40(%rbp),%rdi
mov    0x2ba8(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   10c0 <fseek@plt>
mov    -0x54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     1483 <main+0x2a3>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xc42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1691 <main+0x4b1>
jmp    1488 <main+0x2a8>
mov    -0x40(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    14a7 <main+0x2c7>
jmp    1681 <main+0x4a1>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    $0xbc,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x48(%rbp),%rax
movsbl 0x1(%rax),%eax
and    $0x1f,%eax
shl    $0x8,%eax
mov    -0x48(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x48(%rbp),%rax
movsbl 0x1(%rax),%eax
and    $0x40,%eax
sar    $0x6,%eax
mov    %eax,-0x60(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x79,%eax
jne    1529 <main+0x349>
mov    -0x14(%rbp),%eax
cmp    -0x5c(%rbp),%eax
je     1529 <main+0x349>
cmpl   $0x0,-0x30(%rbp)
jle    1524 <main+0x344>
mov    -0x5c(%rbp),%esi
lea    0xbb3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    167c <main+0x49c>
movsbl -0x16(%rbp),%eax
cmp    $0x79,%eax
jne    1562 <main+0x382>
mov    -0x1c(%rbp),%eax
cmp    -0x60(%rbp),%eax
je     1562 <main+0x382>
cmpl   $0x0,-0x30(%rbp)
jle    155d <main+0x37d>
mov    -0x60(%rbp),%esi
lea    0xb97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1677 <main+0x497>
mov    -0x5c(%rbp),%esi
mov    -0x5c(%rbp),%edx
mov    -0x60(%rbp),%ecx
lea    0xb99(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x50(%rbp)
cmpl   $0xbc,-0x50(%rbp)
jge    161d <main+0x43d>
mov    -0x50(%rbp),%esi
lea    0xba6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%ecx
mov    -0x50(%rbp),%edx
add    -0x34(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x72(%rbp)
jge    15c7 <main+0x3e7>
cmpl   $0xbc,-0x64(%rbp)
setl   %al
mov    %al,-0x72(%rbp)
mov    -0x72(%rbp),%al
test   $0x1,%al
jne    15d7 <main+0x3f7>
jmp    1604 <main+0x424>
mov    -0x48(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10b0 <bitout_ui8@plt>
lea    0xb54(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    15a4 <main+0x3c4>
mov    -0x64(%rbp),%eax
mov    %eax,-0x50(%rbp)
lea    0xb35(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1580 <main+0x3a0>
lea    0xb21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0x79,%eax
jne    1672 <main+0x492>
lea    0xb09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x298b(%rip),%rax
mov    (%rax),%rdi
call   1070 <fgetc@plt>
movsbl %al,%eax
cmp    $0x71,%eax
jne    166d <main+0x48d>
movl   $0x0,-0x4(%rbp)
jmp    1691 <main+0x4b1>
jmp    1672 <main+0x492>
jmp    1677 <main+0x497>
jmp    167c <main+0x49c>
jmp    1488 <main+0x2a8>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movb   $0x6e,0xb(%rsp)
movl   $0x4,0x14(%rsp)
mov    $0x79,%al
lea    0xe2b(%rip),%r14
lea    0xdd0(%rip),%r12
mov    0x2dc1(%rip),%r15
xor    %ecx,%ecx
mov    %rcx,0x18(%rsp)
movl   $0x0,0xc(%rsp)
movb   $0x6e,0xa(%rsp)
movl   $0x0,0x10(%rsp)
jmp    1270 <main+0x70>
mov    (%r15),%rdi
call   1120 <atoi@plt>
mov    %eax,0x14(%rsp)
mov    %r13d,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%r13d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1110 <getopt@plt>
lea    -0x63(%rax),%ecx
cmp    $0x14,%ecx
ja     131c <main+0x11c>
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
mov    $0x6e,%al
jmp    *%rcx
mov    (%r15),%rax
mov    %rax,0x18(%rsp)
mov    %r13d,%eax
cmpl   $0x0,0xc(%rsp)
jle    1270 <main+0x70>
lea    0xdc5(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r13d,%eax
jmp    1270 <main+0x70>
mov    (%r15),%rdi
call   1120 <atoi@plt>
mov    %eax,0x10(%rsp)
movb   $0x79,0xa(%rsp)
mov    %r13d,%eax
cmpl   $0x0,0xc(%rsp)
jle    1270 <main+0x70>
lea    0xd7c(%rip),%rdi
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r13d,%eax
jmp    1270 <main+0x70>
mov    (%r15),%rdi
call   1120 <atoi@plt>
mov    %eax,0x24(%rsp)
movb   $0x79,0xb(%rsp)
mov    %r13d,%eax
jmp    1270 <main+0x70>
addl   $0x1,0xc(%rsp)
mov    %r13d,%eax
jmp    1270 <main+0x70>
cmp    $0xffffffff,%eax
jne    158b <main+0x38b>
mov    0x18(%rsp),%rbp
test   %rbp,%rbp
je     1550 <main+0x350>
mov    $0xbc,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
lea    0xd43(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd43(%rip),%rsi
mov    %rbp,%rdi
call   1100 <fopen@plt>
test   %rax,%rax
je     155f <main+0x35f>
mov    %rax,%r12
mov    %rax,%rdi
call   10a0 <ftell@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   10b0 <feof@plt>
xchg   %ax,%ax
test   %rax,%rax
jne    139e <main+0x19e>
mov    %r12,%rdi
call   1090 <fgetc@plt>
mov    %eax,%r14d
mov    %r12,%rdi
call   10b0 <feof@plt>
cmp    $0x47,%r14b
jne    1380 <main+0x180>
mov    %r12,%rdi
call   10a0 <ftell@plt>
cmp    %eax,%ebp
je     13c0 <main+0x1c0>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    $0xffffffff,%esi
call   10e0 <fseek@plt>
mov    %r12,%rdi
call   10b0 <feof@plt>
test   %rax,%rax
mov    0xa(%rsp),%bpl
je     13fe <main+0x1fe>
mov    %r12,%rdi
call   1070 <fclose@plt>
lea    0xd6f(%rip),%rdi
call   1050 <puts@plt>
mov    $0x3,%eax
jmp    157c <main+0x37c>
lea    0xca6(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12,%rdi
call   10b0 <feof@plt>
test   %rax,%rax
jne    1572 <main+0x372>
mov    %rbx,%rdi
mov    $0xbc,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1060 <fread@plt>
movsbl 0x1(%rbx),%ecx
mov    %ecx,%eax
and    $0x1f,%eax
shl    $0x8,%eax
movzbl 0x2(%rbx),%esi
or     %eax,%esi
cmp    $0x79,%bpl
jne    1450 <main+0x250>
cmp    %esi,0x10(%rsp)
je     1450 <main+0x250>
cmpl   $0x0,0xc(%rsp)
jg     13f0 <main+0x1f0>
jmp    13fe <main+0x1fe>
nopl   0x0(%rax,%rax,1)
shr    $0x6,%ecx
and    $0x1,%ecx
cmpb   $0x79,0xb(%rsp)
jne    1480 <main+0x280>
cmp    %ecx,0x24(%rsp)
je     1480 <main+0x280>
cmpl   $0x0,0xc(%rsp)
jle    13fe <main+0x1fe>
lea    0xc49(%rip),%rdi
mov    %ecx,%esi
jmp    13f7 <main+0x1f7>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %r14d,%r14d
lea    0xc4e(%rip),%rdi
mov    %esi,%edx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    14b3 <main+0x2b3>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0xbc,%r14d
jge    1510 <main+0x310>
lea    0xc50(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x14(%rsp),%eax
test   %eax,%eax
jle    14a0 <main+0x2a0>
movslq %r14d,%rbp
add    %eax,%r14d
movslq %r14d,%r15
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%rbx,%rbp,1),%edi
call   10d0 <bitout_ui8@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0x1(%rbp),%r14
cmp    %r15,%r14
jge    14a0 <main+0x2a0>
cmp    $0xbb,%rbp
mov    %r14,%rbp
jl     14e0 <main+0x2e0>
jmp    14a0 <main+0x2a0>
nopw   0x0(%rax,%rax,1)
lea    0xb82(%rip),%rdi
call   1050 <puts@plt>
cmp    $0x79,%r13b
mov    0xa(%rsp),%bpl
jne    13fe <main+0x1fe>
lea    0xbf4(%rip),%rdi
call   1050 <puts@plt>
mov    0x2a9a(%rip),%rax
mov    (%rax),%rdi
call   1090 <fgetc@plt>
cmp    $0x71,%al
jne    13fe <main+0x1fe>
jmp    157a <main+0x37a>
mov    (%rbx),%rdi
call   10f0 <usage@plt>
mov    $0x1,%eax
jmp    157c <main+0x37c>
lea    0xbac(%rip),%rdi
call   1050 <puts@plt>
mov    $0x2,%eax
jmp    157c <main+0x37c>
mov    %r12,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rbx),%rdi
call   10f0 <usage@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"s:w:i:p:cv\00"
@optarg = global i8* null
@.str.1 = [22 x i8] c"set pidfilter to: %u\0A\00"
@.str.2 = [21 x i8] c"set filename to: %s\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [17 x i8] c"opening '%s'...\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [21 x i8] c"couldn't open file.\0A\00"
@SEEK_CUR = global i32 0
@.str.7 = [30 x i8] c"EOF before hitting mainloop.\0A\00"
@.str.8 = [29 x i8] c"skipping PID 0x%04x packet.\0A\00"
@.str.9 = [30 x i8] c"skipping PUSI 0x%02x packet.\0A\00"
@.str.10 = [50 x i8] c"dumping a PID 0x%04x (%u) packet. PUSI is 0x%02X\0A\00"
@.str.11 = [8 x i8] c"0x%04x \00"
@.str.12 = [2 x i8] c" \00"
@.str.13 = [3 x i8] c"\0A\0A\00"
@.str.14 = [43 x i8] c"\0APress enter to continue, or 'q' to quit.\0A\00"
@stdin = global i32* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8 110, i8* %7
store i8 110, i8* %8
store i8 121, i8* %10
store i8* null, i8** %11
store i32 0, i32* %13
store i32 4, i32* %14
br label %24
24: ; preds = %65, %2
%25 = load i32, i32* %4
%26 = load i8**, i8*** %5
%27 = call i32 @getopt(i32 %25, i8** %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %27, i32* %12
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %66
29: ; preds = %24
%30 = load i32, i32* %12
switch i32 %30, label %58 [
i32 112, label %31
i32 105, label %40
i32 99, label %48
i32 115, label %49
i32 118, label %52
i32 119, label %55
]
31: ; preds = %29
%32 = load i8*, i8** @optarg
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %6
store i8 121, i8* %7
%34 = load i32, i32* %13
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load i32, i32* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %36, %31
br label %65
40: ; preds = %29
%41 = load i8*, i8** @optarg
store i8* %41, i8** %11
%42 = load i32, i32* %13
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i8*, i8** %11
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %44, %40
br label %65
48: ; preds = %29
store i8 110, i8* %10
br label %65
49: ; preds = %29
%50 = load i8*, i8** @optarg
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %9
store i8 121, i8* %8
br label %65
52: ; preds = %29
%53 = load i32, i32* %13
%54 = add nsw i32 %53, 1
store i32 %54, i32* %13
br label %65
55: ; preds = %29
%56 = load i8*, i8** @optarg
%57 = call i32 @atoi(i8* %56)
store i32 %57, i32* %14
br label %65
58: ; preds = %29
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 0
%62 = load i8*, i8** %61
%63 = call i32 @usage(i8* %62)
%64 = call i32 (...) @abort()
unreachable
65: ; preds = %55, %52, %49, %48, %47, %39
br label %24
66: ; preds = %24
%67 = load i8*, i8** %11
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %74
69: ; preds = %66
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 0
%72 = load i8*, i8** %71
%73 = call i32 @usage(i8* %72)
store i32 1, i32* %3
br label %232
74: ; preds = %66
%75 = call i64 @malloc(i32 188)
%76 = inttoptr i64 %75 to i8*
store i8* %76, i8** %16
store i32 0, i32* %17
%77 = load i8*, i8** %11
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %77)
%79 = load i8*, i8** %11
%80 = call i32* @fopen(i8* %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %80, i32** %15
%81 = icmp ne i32* %80, null
br i1 %81, label %84, label %82
82: ; preds = %74
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
store i32 2, i32* %3
br label %232
84: ; preds = %74
%85 = load i32*, i32** %15
%86 = call i32 @ftell(i32* %85)
store i32 %86, i32* %19
br label %87
87: ; preds = %96, %84
%88 = load i32*, i32** %15
%89 = call i64 @feof(i32* %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %94, label %91
91: ; preds = %87
%92 = load i32, i32* %17
%93 = icmp ne i32 %92, 71
br label %94
94: ; preds = %91, %87
%95 = phi i1 [ false, %87 ], [ %93, %91 ]
br i1 %95, label %96, label %100
96: ; preds = %94
%97 = load i32*, i32** %15
%98 = call signext i8 @fgetc(i32* %97)
%99 = sext i8 %98 to i32
store i32 %99, i32* %17
br label %87
100: ; preds = %94
%101 = load i32*, i32** %15
%102 = call i32 @ftell(i32* %101)
store i32 %102, i32* %20
%103 = load i32, i32* %19
%104 = load i32, i32* %20
%105 = icmp ne i32 %103, %104
br i1 %105, label %106, label %112
106: ; preds = %100
%107 = load i32*, i32** %15
%108 = load i32, i32* @SEEK_CUR
%109 = call i32 @fseek(i32* %107, i32 -1, i32 %108)
%110 = load i32, i32* %19
%111 = add nsw i32 %110, -1
store i32 %111, i32* %19
br label %112
112: ; preds = %106, %100
%113 = load i32*, i32** %15
%114 = call i64 @feof(i32* %113)
%115 = icmp ne i64 %114, 0
br i1 %115, label %116, label %120
116: ; preds = %112
%117 = load i32*, i32** %15
%118 = call i32 @fclose(i32* %117)
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
store i32 3, i32* %3
br label %232
120: ; preds = %112
br label %121
121: ; preds = %228, %120
%122 = load i32*, i32** %15
%123 = call i64 @feof(i32* %122)
%124 = icmp ne i64 %123, 0
%125 = xor i1 %124, true
br i1 %125, label %126, label %229
126: ; preds = %121
%127 = load i8*, i8** %16
%128 = load i32*, i32** %15
%129 = call i32 @fread(i8* %127, i32 188, i32 1, i32* %128)
%130 = load i8*, i8** %16
%131 = getelementptr inbounds i8, i8* %130, i64 1
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = and i32 %133, 31
%135 = shl i32 %134, 8
%136 = load i8*, i8** %16
%137 = getelementptr inbounds i8, i8* %136, i64 2
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = and i32 %139, 255
%141 = or i32 %135, %140
store i32 %141, i32* %21
%142 = load i8*, i8** %16
%143 = getelementptr inbounds i8, i8* %142, i64 1
%144 = load i8, i8* %143
%145 = sext i8 %144 to i32
%146 = and i32 %145, 64
%147 = ashr i32 %146, 6
store i32 %147, i32* %22
%148 = load i8, i8* %7
%149 = sext i8 %148 to i32
%150 = icmp eq i32 %149, 121
br i1 %150, label %151, label %162
151: ; preds = %126
%152 = load i32, i32* %6
%153 = load i32, i32* %21
%154 = icmp ne i32 %152, %153
br i1 %154, label %155, label %162
155: ; preds = %151
%156 = load i32, i32* %13
%157 = icmp sgt i32 %156, 0
br i1 %157, label %158, label %161
158: ; preds = %155
%159 = load i32, i32* %21
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %159)
br label %161
161: ; preds = %158, %155
br label %228
162: ; preds = %151, %126
%163 = load i8, i8* %8
%164 = sext i8 %163 to i32
%165 = icmp eq i32 %164, 121
br i1 %165, label %166, label %177
166: ; preds = %162
%167 = load i32, i32* %9
%168 = load i32, i32* %22
%169 = icmp ne i32 %167, %168
br i1 %169, label %170, label %177
170: ; preds = %166
%171 = load i32, i32* %13
%172 = icmp sgt i32 %171, 0
br i1 %172, label %173, label %176
173: ; preds = %170
%174 = load i32, i32* %22
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i32 %174)
br label %176
176: ; preds = %173, %170
br label %227
177: ; preds = %166, %162
%178 = load i32, i32* %21
%179 = load i32, i32* %21
%180 = load i32, i32* %22
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0), i32 %178, i32 %179, i32 %180)
store i32 0, i32* %18
br label %182
182: ; preds = %210, %177
%183 = load i32, i32* %18
%184 = icmp slt i32 %183, 188
br i1 %184, label %185, label %213
185: ; preds = %182
%186 = load i32, i32* %18
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i32 %186)
%188 = load i32, i32* %18
store i32 %188, i32* %23
br label %189
189: ; preds = %200, %185
%190 = load i32, i32* %23
%191 = load i32, i32* %18
%192 = load i32, i32* %14
%193 = add nsw i32 %191, %192
%194 = icmp slt i32 %190, %193
br i1 %194, label %195, label %198
195: ; preds = %189
%196 = load i32, i32* %23
%197 = icmp slt i32 %196, 188
br label %198
198: ; preds = %195, %189
%199 = phi i1 [ false, %189 ], [ %197, %195 ]
br i1 %199, label %200, label %210
200: ; preds = %198
%201 = load i8*, i8** %16
%202 = load i32, i32* %23
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds i8, i8* %201, i64 %203
%205 = load i8, i8* %204
%206 = call i32 @bitout_ui8(i8 signext %205)
%207 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%208 = load i32, i32* %23
%209 = add nsw i32 %208, 1
store i32 %209, i32* %23
br label %189
210: ; preds = %198
%211 = load i32, i32* %23
store i32 %211, i32* %18
%212 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %182
213: ; preds = %182
%214 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%215 = load i8, i8* %10
%216 = sext i8 %215 to i32
%217 = icmp eq i32 %216, 121
br i1 %217, label %218, label %226
218: ; preds = %213
%219 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.14, i64 0, i64 0))
%220 = load i32*, i32** @stdin
%221 = call signext i8 @fgetc(i32* %220)
%222 = sext i8 %221 to i32
%223 = icmp eq i32 %222, 113
br i1 %223, label %224, label %225
224: ; preds = %218
store i32 0, i32* %3
br label %232
225: ; preds = %218
br label %226
226: ; preds = %225, %213
br label %227
227: ; preds = %226, %176
br label %228
228: ; preds = %227, %161
br label %121
229: ; preds = %121
%230 = load i32*, i32** %15
%231 = call i32 @fclose(i32* %230)
store i32 0, i32* %3
br label %232
232: ; preds = %229, %224, %116, %82, %69
%233 = load i32, i32* %3
ret i32 %233
}

LLVM IR (-O2):
@.str = [11 x i8] c"s:w:i:p:cv\00"
@optarg = global i8* null
@.str.1 = [22 x i8] c"set pidfilter to: %u\0A\00"
@.str.2 = [21 x i8] c"set filename to: %s\0A\00"
@.str.4 = [17 x i8] c"opening '%s'...\0A\00"
@.str.5 = [2 x i8] c"r\00"
@SEEK_CUR = global i32 0
@.str.8 = [29 x i8] c"skipping PID 0x%04x packet.\0A\00"
@.str.9 = [30 x i8] c"skipping PUSI 0x%02x packet.\0A\00"
@.str.10 = [50 x i8] c"dumping a PID 0x%04x (%u) packet. PUSI is 0x%02X\0A\00"
@.str.11 = [8 x i8] c"0x%04x \00"
@stdin = global i32* null
@str = [20 x i8] c"couldn't open file.\00"
@str.15 = [2 x i8] c"\0A\00"
@str.16 = [42 x i8] c"\0APress enter to continue, or 'q' to quit.\00"
@str.17 = [29 x i8] c"EOF before hitting mainloop.\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %13, %2
%4 = phi i8* [ null, %2 ], [ %14, %13 ]
%5 = phi i8 [ 121, %2 ], [ %15, %13 ]
%6 = phi i32 [ 0, %2 ], [ %16, %13 ]
%7 = phi i32 [ 4, %2 ], [ %17, %13 ]
%8 = phi i32 [ undef, %2 ], [ %18, %13 ]
%9 = phi i8 [ 110, %2 ], [ %19, %13 ]
%10 = phi i8 [ 110, %2 ], [ %20, %13 ]
%11 = phi i32 [ 0, %2 ], [ %21, %13 ]
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %41 [
i32 -1, label %46
i32 112, label %22
i32 105, label %28
i32 99, label %13
i32 115, label %33
i32 118, label %36
i32 119, label %38
]
13: ; preds = %3, %28, %31, %22, %26, %38, %36, %33
%14 = phi i8* [ %4, %38 ], [ %4, %36 ], [ %4, %33 ], [ %29, %31 ], [ %29, %28 ], [ %4, %26 ], [ %4, %22 ], [ %4, %3 ]
%15 = phi i8 [ %5, %38 ], [ %5, %36 ], [ %5, %33 ], [ %5, %31 ], [ %5, %28 ], [ %5, %26 ], [ %5, %22 ], [ 110, %3 ]
%16 = phi i32 [ %6, %38 ], [ %37, %36 ], [ %6, %33 ], [ %6, %31 ], [ %6, %28 ], [ %6, %26 ], [ %6, %22 ], [ %6, %3 ]
%17 = phi i32 [ %40, %38 ], [ %7, %36 ], [ %7, %33 ], [ %7, %31 ], [ %7, %28 ], [ %7, %26 ], [ %7, %22 ], [ %7, %3 ]
%18 = phi i32 [ %8, %38 ], [ %8, %36 ], [ %35, %33 ], [ %8, %31 ], [ %8, %28 ], [ %8, %26 ], [ %8, %22 ], [ %8, %3 ]
%19 = phi i8 [ %9, %38 ], [ %9, %36 ], [ 121, %33 ], [ %9, %31 ], [ %9, %28 ], [ %9, %26 ], [ %9, %22 ], [ %9, %3 ]
%20 = phi i8 [ %10, %38 ], [ %10, %36 ], [ %10, %33 ], [ %10, %31 ], [ %10, %28 ], [ 121, %26 ], [ 121, %22 ], [ %10, %3 ]
%21 = phi i32 [ %11, %38 ], [ %11, %36 ], [ %11, %33 ], [ %11, %31 ], [ %11, %28 ], [ %24, %26 ], [ %24, %22 ], [ %11, %3 ]
br label %3
22: ; preds = %3
%23 = load i8*, i8** @optarg
%24 = tail call i32 @atoi(i8* %23)
%25 = icmp sgt i32 %6, 0
br i1 %25, label %26, label %13
26: ; preds = %22
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %13
28: ; preds = %3
%29 = load i8*, i8** @optarg
%30 = icmp sgt i32 %6, 0
br i1 %30, label %31, label %13
31: ; preds = %28
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %13
33: ; preds = %3
%34 = load i8*, i8** @optarg
%35 = tail call i32 @atoi(i8* %34)
br label %13
36: ; preds = %3
%37 = add nsw i32 %6, 1
br label %13
38: ; preds = %3
%39 = load i8*, i8** @optarg
%40 = tail call i32 @atoi(i8* %39)
br label %13
41: ; preds = %3
%42 = tail call i32 @putchar(i32 10)
%43 = load i8*, i8** %1
%44 = tail call i32 @usage(i8* %43)
%45 = tail call i32 (...) @abort()
unreachable
46: ; preds = %3
%47 = icmp eq i8* %4, null
br i1 %47, label %48, label %51
48: ; preds = %46
%49 = load i8*, i8** %1
%50 = tail call i32 @usage(i8* %49)
br label %151
51: ; preds = %46
%52 = tail call i64 @malloc(i32 188)
%53 = inttoptr i64 %52 to i8*
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%55 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %59
57: ; preds = %51
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %151
59: ; preds = %51
%60 = tail call i32 @ftell(i32* %55)
%61 = tail call i64 @feof(i32* %55)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %59, %63
%64 = tail call signext i8 @fgetc(i32* %55)
%65 = tail call i64 @feof(i32* %55)
%66 = icmp eq i64 %65, 0
%67 = icmp ne i8 %64, 71
%68 = and i1 %67, %66
br i1 %68, label %63, label %69
69: ; preds = %63, %59
%70 = tail call i32 @ftell(i32* %55)
%71 = icmp eq i32 %60, %70
br i1 %71, label %75, label %72
72: ; preds = %69
%73 = load i32, i32* @SEEK_CUR
%74 = tail call i32 @fseek(i32* %55, i32 -1, i32 %73)
br label %75
75: ; preds = %72, %69
%76 = tail call i64 @feof(i32* %55)
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %89
78: ; preds = %75
%79 = tail call i64 @feof(i32* %55)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %149
81: ; preds = %78
%82 = getelementptr inbounds i8, i8* %53, i64 1
%83 = getelementptr inbounds i8, i8* %53, i64 2
%84 = icmp ne i8 %10, 121
%85 = icmp sgt i32 %6, 0
%86 = icmp ne i8 %9, 121
%87 = icmp eq i8 %5, 121
%88 = icmp sgt i32 %7, 0
br label %92
89: ; preds = %75
%90 = tail call i32 @fclose(i32* %55)
%91 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.17, i64 0, i64 0))
br label %151
92: ; preds = %81, %146
%93 = tail call i32 @fread(i8* %53, i32 188, i32 1, i32* %55)
%94 = load i8, i8* %82
%95 = sext i8 %94 to i32
%96 = shl nsw i32 %95, 8
%97 = and i32 %96, 7936
%98 = load i8, i8* %83
%99 = zext i8 %98 to i32
%100 = or i32 %97, %99
%101 = lshr i32 %95, 6
%102 = and i32 %101, 1
%103 = icmp eq i32 %11, %100
%104 = select i1 %84, i1 true, i1 %103
br i1 %104, label %108, label %105
105: ; preds = %92
br i1 %85, label %106, label %146
106: ; preds = %105
%107 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %100)
br label %146
108: ; preds = %92
%109 = icmp eq i32 %8, %102
%110 = select i1 %86, i1 true, i1 %109
br i1 %110, label %114, label %111
111: ; preds = %108
br i1 %85, label %112, label %146
112: ; preds = %111
%113 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i32 %102)
br label %146
114: ; preds = %108
%115 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0), i32 %100, i32 %100, i32 %102)
br label %116
116: ; preds = %114, %135
%117 = phi i32 [ 0, %114 ], [ %136, %135 ]
%118 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i32 %117)
br i1 %88, label %119, label %135
119: ; preds = %116
%120 = add nsw i32 %117, %7
%121 = sext i32 %117 to i64
%122 = sext i32 %120 to i64
br label %123
123: ; preds = %119, %123
%124 = phi i64 [ %121, %119 ], [ %129, %123 ]
%125 = getelementptr inbounds i8, i8* %53, i64 %124
%126 = load i8, i8* %125
%127 = tail call i32 @bitout_ui8(i8 signext %126)
%128 = tail call i32 @putchar(i32 32)
%129 = add nsw i64 %124, 1
%130 = icmp slt i64 %129, %122
%131 = icmp slt i64 %124, 187
%132 = and i1 %130, %131
br i1 %132, label %123, label %133
133: ; preds = %123
%134 = trunc i64 %129 to i32
br label %135
135: ; preds = %133, %116
%136 = phi i32 [ %117, %116 ], [ %134, %133 ]
%137 = tail call i32 @putchar(i32 10)
%138 = icmp slt i32 %136, 188
br i1 %138, label %116, label %139
139: ; preds = %135
%140 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.15, i64 0, i64 0))
br i1 %87, label %141, label %146
141: ; preds = %139
%142 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.16, i64 0, i64 0))
%143 = load i32*, i32** @stdin
%144 = tail call signext i8 @fgetc(i32* %143)
%145 = icmp eq i8 %144, 113
br i1 %145, label %151, label %146
146: ; preds = %112, %111, %141, %139, %105, %106
%147 = tail call i64 @feof(i32* %55)
%148 = icmp eq i64 %147, 0
br i1 %148, label %92, label %149
149: ; preds = %146, %78
%150 = tail call i32 @fclose(i32* %55)
br label %151
151: ; preds = %141, %57, %149, %89, %48
%152 = phi i32 [ 1, %48 ], [ 2, %57 ], [ 3, %89 ], [ 0, %149 ], [ 0, %141 ]
ret i32 %152
}