#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;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
scalar_t__ feof(int /*<<< orphan*/ *);
unsigned int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, unsigned int,
                         int /*<<< orphan*/);
unsigned int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned int *, int, int, int /*<<< orphan*/ *);
unsigned int getid(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int xx(unsigned int);
int main(int argc, char *argv[]) {
  unsigned int lastgood = 0;
  unsigned int fixat = 0;
  unsigned int offset = 0;
  int fix_flag = 0;
  FILE *f;
  if (argc <= 1) {
    printf("Usage: %s [-fix] badfile.avi\n", argv[0]);
    exit(1);
  }
  if (!strcmp(argv[1], "-fix")) {
    fix_flag = 1;
    f = fopen(argv[argc - 1], "rb+");
  } else
    f = fopen(argv[argc - 1], "rb");
  if (!f) {
    perror("error");
    printf("couldnt open '%s'\n", argv[argc - 1]);
    exit(2);
  }
  while (1) {
    unsigned int id, len;
  again:
    id = fgetc(f);
    id = (id << 8) | fgetc(f);
    id = (id << 8) | fgetc(f);
  faszom:
    if (feof(f))
      break;
    id = (id << 8) | fgetc(f);
    printf("%08X: %c%c%c%c\n", (int)ftell(f) - 4, xx(id >> 24), xx(id >> 16),
           xx(id >> 8), xx(id));
    switch (id) {
    case ((('R') << 24) | (('I') << 16) | (('F') << 8) | ('F')):
      fread(&len, 4, 1, f);
      id = getid(f);
      printf("RIFF header, filesize=0x%X  format=%c%c%c%c\n", len, xx(id >> 24),
             xx(id >> 16), xx(id >> 8), xx(id));
      break;
    case ((('L') << 24) | (('I') << 16) | (('S') << 8) | ('T')):
      fread(&len, 4, 1, f);
      id = getid(f);
      printf("LIST size=0x%X  format=%c%c%c%c\n", len, xx(id >> 24),
             xx(id >> 16), xx(id >> 8), xx(id));
      break;
    case ((('a') << 24) | (('v') << 16) | (('i') << 8) | ('h')):
    case ((('s') << 24) | (('t') << 16) | (('r') << 8) | ('h')):
    case ((('s') << 24) | (('t') << 16) | (('r') << 8) | ('f')):
    case ((('J') << 24) | (('U') << 16) | (('N') << 8) | ('K')):
    case ((('i') << 24) | (('d') << 16) | (('x') << 8) | ('1')):
    case ((('d') << 24) | (('m') << 16) | (('l') << 8) | ('h')):
    case ((('i') << 24) | (('n') << 16) | (('d') << 8) | ('x')):
    case ((('i') << 24) | (('x') << 16) | (('0') << 8) | ('0')):
    case ((('i') << 24) | (('x') << 16) | (('0') << 8) | ('1')):
    case ((('0') << 24) | (('1') << 16) | (('w') << 8) | ('b')):
    case ((('0') << 24) | (('2') << 16) | (('w') << 8) | ('b')):
    case ((('0') << 24) | (('3') << 16) | (('w') << 8) | ('b')):
    case ((('0') << 24) | (('0') << 16) | (('d') << 8) | ('b')):
    case ((('0') << 24) | (('0') << 16) | (('d') << 8) | ('c')):
    case ((('0') << 24) | (('0') << 16) | (('_') << 8) | ('_')):
    case ((('I') << 24) | (('S') << 16) | (('F') << 8) | ('T')):
    case ((('I') << 24) | (('S') << 16) | (('R') << 8) | ('C')):
    case ((('I') << 24) | (('N') << 16) | (('A') << 8) | ('M')):
    case ((('I') << 24) | (('S') << 16) | (('B') << 8) | ('J')):
    case ((('I') << 24) | (('A') << 16) | (('R') << 8) | ('T')):
    case ((('I') << 24) | (('C') << 16) | (('O') << 8) | ('P')):
    case ((('I') << 24) | (('C') << 16) | (('M') << 8) | ('T')):
      lastgood = ftell(f);
      if (fixat && fix_flag) {
        fseek(f, fixat, SEEK_SET);
        len = lastgood - fixat - 8;
        printf("Correct len to 0x%X\n", len);
        fwrite(&len, 4, 1, f);
        fseek(f, lastgood, SEEK_SET);
        fixat = 0;
      }
      fread(&len, 4, 1, f);
      printf("ID ok, chunk len=0x%X\n", len);
      len += len & 1;
      fseek(f, len, SEEK_CUR);
      break;
    default:
      if (!lastgood) {
        ++offset;
        printf("invalid ID, trying %d byte offset\n", offset);
        goto faszom;
      }
      printf("invalid ID, parsing next chunk's data at 0x%X\n", lastgood);
      fseek(f, lastgood, SEEK_SET);
      fixat = lastgood;
      lastgood = 0;
      goto again;
    }
    offset = 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     122b <main+0x5b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde4(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1275 <main+0xa5>
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdbc(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
jmp    1296 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd9a(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12d6 <main+0x106>
lea    0xd82(%rip),%rdi
call   10d0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>
jmp    12db <main+0x10b>
jmp    12e0 <main+0x110>
mov    -0x28(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%rax
je     133c <main+0x16c>
jmp    179a <main+0x5ca>
mov    -0x2c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <ftell@plt>
add    $0xfffffffc,%eax
mov    %eax,-0x4c(%rbp)
movzbl -0x29(%rbp),%edi
call   1060 <xx@plt>
mov    %eax,-0x48(%rbp)
movzwl -0x2a(%rbp),%edi
call   1060 <xx@plt>
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
shr    $0x8,%edi
call   1060 <xx@plt>
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <xx@plt>
mov    -0x4c(%rbp),%esi
mov    -0x48(%rbp),%edx
mov    -0x44(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    %eax,%r9d
lea    0xc97(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x30305f5f,%eax
je     165a <main+0x48a>
jmp    13c9 <main+0x1f9>
mov    -0x3c(%rbp),%eax
add    $0xcfcf9b9e,%eax
sub    $0x2,%eax
jb     165a <main+0x48a>
jmp    13df <main+0x20f>
mov    -0x3c(%rbp),%eax
sub    $0x30317762,%eax
je     165a <main+0x48a>
jmp    13f2 <main+0x222>
mov    -0x3c(%rbp),%eax
sub    $0x30327762,%eax
je     165a <main+0x48a>
jmp    1405 <main+0x235>
mov    -0x3c(%rbp),%eax
sub    $0x30337762,%eax
je     165a <main+0x48a>
jmp    1418 <main+0x248>
mov    -0x3c(%rbp),%eax
sub    $0x49415254,%eax
je     165a <main+0x48a>
jmp    142b <main+0x25b>
mov    -0x3c(%rbp),%eax
sub    $0x49434d54,%eax
je     165a <main+0x48a>
jmp    143e <main+0x26e>
mov    -0x3c(%rbp),%eax
sub    $0x49434f50,%eax
je     165a <main+0x48a>
jmp    1451 <main+0x281>
mov    -0x3c(%rbp),%eax
sub    $0x494e414d,%eax
je     165a <main+0x48a>
jmp    1464 <main+0x294>
mov    -0x3c(%rbp),%eax
sub    $0x4953424a,%eax
je     165a <main+0x48a>
jmp    1477 <main+0x2a7>
mov    -0x3c(%rbp),%eax
sub    $0x49534654,%eax
je     165a <main+0x48a>
jmp    148a <main+0x2ba>
mov    -0x3c(%rbp),%eax
sub    $0x49535243,%eax
je     165a <main+0x48a>
jmp    149d <main+0x2cd>
mov    -0x3c(%rbp),%eax
sub    $0x4a554e4b,%eax
je     165a <main+0x48a>
jmp    14b0 <main+0x2e0>
mov    -0x3c(%rbp),%eax
sub    $0x4c495354,%eax
je     15dc <main+0x40c>
jmp    14c3 <main+0x2f3>
mov    -0x3c(%rbp),%eax
sub    $0x52494646,%eax
je     155e <main+0x38e>
jmp    14d6 <main+0x306>
mov    -0x3c(%rbp),%eax
sub    $0x61766968,%eax
je     165a <main+0x48a>
jmp    14e9 <main+0x319>
mov    -0x3c(%rbp),%eax
sub    $0x646d6c68,%eax
je     165a <main+0x48a>
jmp    14fc <main+0x32c>
mov    -0x3c(%rbp),%eax
sub    $0x69647831,%eax
je     165a <main+0x48a>
jmp    150f <main+0x33f>
mov    -0x3c(%rbp),%eax
sub    $0x696e6478,%eax
je     165a <main+0x48a>
jmp    1522 <main+0x352>
mov    -0x3c(%rbp),%eax
add    $0x9687cfd0,%eax
sub    $0x2,%eax
jb     165a <main+0x48a>
jmp    1538 <main+0x368>
mov    -0x3c(%rbp),%eax
sub    $0x73747266,%eax
je     165a <main+0x48a>
jmp    154b <main+0x37b>
mov    -0x3c(%rbp),%eax
sub    $0x73747268,%eax
je     165a <main+0x48a>
jmp    172d <main+0x55d>
mov    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x28(%rbp),%rdi
call   1050 <getid@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x2c(%rbp),%edi
shr    $0x18,%edi
call   1060 <xx@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x2c(%rbp),%edi
shr    $0x10,%edi
call   1060 <xx@plt>
mov    %eax,-0x58(%rbp)
mov    -0x2c(%rbp),%edi
shr    $0x8,%edi
call   1060 <xx@plt>
mov    %eax,-0x54(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <xx@plt>
mov    -0x60(%rbp),%esi
mov    -0x5c(%rbp),%edx
mov    -0x58(%rbp),%ecx
mov    -0x54(%rbp),%r8d
mov    %eax,%r9d
lea    0xa83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    178e <main+0x5be>
mov    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x28(%rbp),%rdi
call   1050 <getid@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x2c(%rbp),%edi
shr    $0x18,%edi
call   1060 <xx@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x2c(%rbp),%edi
shr    $0x10,%edi
call   1060 <xx@plt>
mov    %eax,-0x68(%rbp)
mov    -0x2c(%rbp),%edi
shr    $0x8,%edi
call   1060 <xx@plt>
mov    %eax,-0x64(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <xx@plt>
mov    -0x70(%rbp),%esi
mov    -0x6c(%rbp),%edx
mov    -0x68(%rbp),%ecx
mov    -0x64(%rbp),%r8d
mov    %eax,%r9d
lea    0xa32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    178e <main+0x5be>
mov    -0x28(%rbp),%rdi
call   1090 <ftell@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     16df <main+0x50f>
cmpl   $0x0,-0x20(%rbp)
je     16df <main+0x50f>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2950(%rip),%rax
mov    (%rax),%edx
call   10b0 <fseek@plt>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0x9fc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10f0 <fwrite@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2907(%rip),%rax
mov    (%rax),%edx
call   10b0 <fseek@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x30(%rbp),%esi
lea    0x9b6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
and    $0x1,%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    0x28c7(%rip),%rax
mov    (%rax),%edx
call   10b0 <fseek@plt>
jmp    178e <main+0x5be>
cmpl   $0x0,-0x14(%rbp)
jne    1756 <main+0x586>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0x983(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1324 <main+0x154>
mov    -0x14(%rbp),%esi
lea    0x990(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2863(%rip),%rax
mov    (%rax),%edx
call   10b0 <fseek@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    12e0 <main+0x110>
movl   $0x0,-0x1c(%rbp)
jmp    12db <main+0x10b>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
cmp    $0x1,%edi
jle    172e <main+0x55e>
mov    %edi,%ebp
mov    0x8(%r14),%rdi
lea    0xe27(%rip),%rsi
call   1080 <strcmp@plt>
add    $0xffffffff,%ebp
mov    %eax,0x14(%rsp)
test   %eax,%eax
mov    (%r14,%rbp,8),%rdi
lea    0xe13(%rip),%rax
lea    0xe10(%rip),%rsi
cmove  %rax,%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1749 <main+0x579>
mov    %rax,%r13
mov    %rax,%rdi
call   1070 <fgetc@plt>
mov    %eax,%r12d
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%r14d
mov    %r13,%rdi
call   10a0 <feof@plt>
test   %rax,%rax
je     126a <main+0x9a>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
shl    $0x8,%ebp
shl    $0x10,%r12d
or     %ebp,%r12d
or     %r14d,%r12d
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movl   $0x1,0x10(%rsp)
mov    %r12d,%ebx
shl    $0x8,%ebx
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%r12d
or     %ebx,%r12d
mov    %r13,%r14
mov    %r13,%rdi
call   1090 <ftell@plt>
lea    -0x4(%rax),%ebp
mov    %r12d,%edi
shr    $0x18,%edi
call   1060 <xx@plt>
mov    %eax,%r15d
mov    %r12d,%edi
shr    $0x10,%edi
call   1060 <xx@plt>
mov    %eax,%r13d
mov    %r12d,%edi
shr    $0x8,%edi
call   1060 <xx@plt>
mov    %eax,%ebx
mov    %r12d,%edi
call   1060 <xx@plt>
lea    0xd51(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r13d,%ecx
mov    %ebx,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x49535242,%r12d
jg     1350 <main+0x180>
cmp    $0x49415253,%r12d
jg     13a0 <main+0x1d0>
cmp    $0x30317761,%r12d
mov    %r14,%r13
jg     1420 <main+0x250>
lea    -0x30306462(%r12),%eax
cf
cmp    $0x2,%eax
jb     14e0 <main+0x310>
cmp    $0x30305f5f,%r12d
jne    14a0 <main+0x2d0>
jmp    14e0 <main+0x310>
cmp    $0x69647830,%r12d
jg     13e0 <main+0x210>
cmp    $0x52494645,%r12d
mov    %r14,%r13
jg     1448 <main+0x278>
cmp    $0x49535243,%r12d
je     14e0 <main+0x310>
cmp    $0x4a554e4b,%r12d
je     14e0 <main+0x310>
cmp    $0x4c495354,%r12d
jne    14a0 <main+0x2d0>
jmp    15e6 <main+0x416>
nopl   0x0(%rax)
cmp    $0x494e414c,%r12d
mov    %r14,%r13
jg     146d <main+0x29d>
cmp    $0x49415254,%r12d
je     14e0 <main+0x310>
cmp    $0x49434d54,%r12d
je     14e0 <main+0x310>
cmp    $0x49434f50,%r12d
jne    14a0 <main+0x2d0>
jmp    14e0 <main+0x310>
nopl   0x0(%rax)
cmp    $0x6978302f,%r12d
mov    %r14,%r13
jle    148a <main+0x2ba>
lea    -0x69783030(%r12),%eax
96
cmp    $0x2,%eax
jb     14e0 <main+0x310>
cmp    $0x73747266,%r12d
je     14e0 <main+0x310>
cmp    $0x73747268,%r12d
jne    14a0 <main+0x2d0>
jmp    14e0 <main+0x310>
cmp    $0x30317762,%r12d
je     14e0 <main+0x310>
cmp    $0x30327762,%r12d
je     14e0 <main+0x310>
cmp    $0x30337762,%r12d
jne    14a0 <main+0x2d0>
jmp    14e0 <main+0x310>
cmp    $0x52494646,%r12d
je     1642 <main+0x472>
cmp    $0x61766968,%r12d
je     14e0 <main+0x310>
cmp    $0x646d6c68,%r12d
jne    14a0 <main+0x2d0>
jmp    14e0 <main+0x310>
cmp    $0x494e414d,%r12d
je     14e0 <main+0x310>
cmp    $0x4953424a,%r12d
je     14e0 <main+0x310>
cmp    $0x49534654,%r12d
jne    14a0 <main+0x2d0>
jmp    14e0 <main+0x310>
cmp    $0x69647831,%r12d
je     14e0 <main+0x310>
cmp    $0x696e6478,%r12d
je     14e0 <main+0x310>
nopl   0x0(%rax)
cmpl   $0x0,0x8(%rsp)
jne    16b7 <main+0x4e7>
lea    0xc1b(%rip),%rdi
mov    0x10(%rsp),%ebx
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
call   10a0 <feof@plt>
add    $0x1,%ebx
mov    %ebx,0x10(%rsp)
test   %rax,%rax
je     1298 <main+0xc8>
jmp    1259 <main+0x89>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1090 <ftell@plt>
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     1560 <main+0x390>
cmpl   $0x0,0x14(%rsp)
lea    0x4(%rsp),%rbp
jne    1565 <main+0x395>
mov    0x2ad1(%rip),%r14
mov    (%r14),%edx
mov    %r13,%rdi
mov    %ebx,%esi
call   10b0 <fseek@plt>
mov    0x8(%rsp),%r15d
mov    %r15d,%esi
sub    %ebx,%esi
add    $0xfffffff8,%esi
mov    %esi,0x4(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xb6d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   10f0 <fwrite@plt>
mov    (%r14),%edx
mov    %r13,%rdi
mov    %r15d,%esi
call   10b0 <fseek@plt>
jmp    1565 <main+0x395>
lea    0x4(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
mov    0x4(%rsp),%ebx
lea    0xb31(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
and    $0x1,%esi
add    %ebx,%esi
mov    0x2a4c(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
call   10b0 <fseek@plt>
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
shl    $0x10,%ebx
shl    $0x8,%ebp
or     %ebx,%ebp
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%r12d
or     %ebp,%r12d
mov    %r13,%rdi
call   10a0 <feof@plt>
test   %rax,%rax
je     1290 <main+0xc0>
jmp    1259 <main+0x89>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
mov    %r13,%rdi
call   1050 <getid@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%r14d
mov    %eax,%edi
shr    $0x18,%edi
call   1060 <xx@plt>
mov    %eax,%r15d
mov    %ebx,%edi
shr    $0x10,%edi
call   1060 <xx@plt>
mov    %eax,%r12d
mov    %ebx,%edi
shr    $0x8,%edi
call   1060 <xx@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1060 <xx@plt>
lea    0xa40(%rip),%rdi
jmp    169c <main+0x4cc>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
mov    %r13,%rdi
call   1050 <getid@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%r14d
mov    %eax,%edi
shr    $0x18,%edi
call   1060 <xx@plt>
mov    %eax,%r15d
mov    %ebx,%edi
shr    $0x10,%edi
call   1060 <xx@plt>
mov    %eax,%r12d
mov    %ebx,%edi
shr    $0x8,%edi
call   1060 <xx@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1060 <xx@plt>
lea    0x9b7(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
jmp    15a6 <main+0x3d6>
lea    0xa32(%rip),%rdi
mov    0x8(%rsp),%r14d
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2904(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r14d,%esi
call   10b0 <fseek@plt>
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
shl    $0x10,%ebx
shl    $0x8,%ebp
or     %ebx,%ebp
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%r12d
or     %ebp,%r12d
mov    %r13,%rdi
call   10a0 <feof@plt>
mov    %r14d,0xc(%rsp)
movl   $0x0,0x8(%rsp)
test   %rax,%rax
je     1290 <main+0xc0>
jmp    1259 <main+0x89>
mov    (%r14),%rsi
lea    0x8c8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0x8da(%rip),%rdi
call   10d0 <perror@plt>
mov    (%r14,%rbp,8),%rsi
lea    0x8d0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Usage: %s [-fix] badfile.avi\0A\00"
@.str.1 = [5 x i8] c"-fix\00"
@.str.2 = [4 x i8] c"rb+\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [6 x i8] c"error\00"
@.str.5 = [19 x i8] c"couldnt open '%s'\0A\00"
@.str.6 = [16 x i8] c"%08X: %c%c%c%c\0A\00"
@.str.7 = [45 x i8] c"RIFF header, filesize=0x%X format=%c%c%c%c\0A\00"
@.str.8 = [33 x i8] c"LIST size=0x%X format=%c%c%c%c\0A\00"
@SEEK_SET = global i32 0
@.str.9 = [21 x i8] c"Correct len to 0x%X\0A\00"
@.str.10 = [23 x i8] c"ID ok, chunk len=0x%X\0A\00"
@SEEK_CUR = global i32 0
@.str.11 = [35 x i8] c"invalid ID, trying %d byte offset\0A\00"
@.str.12 = [47 x i8] c"invalid ID, parsing next chunk's data at 0x%X\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 i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 1
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %35, label %27
27: ; preds = %21
store i32 1, i32* %9
%28 = load i8**, i8*** %5
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %28, i64 %31
%33 = load i8*, i8** %32
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32* %34, i32** %10
br label %43
35: ; preds = %21
%36 = load i8**, i8*** %5
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %36, i64 %39
%41 = load i8*, i8** %40
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %42, i32** %10
br label %43
43: ; preds = %35, %27
%44 = load i32*, i32** %10
%45 = icmp ne i32* %44, null
br i1 %45, label %56, label %46
46: ; preds = %43
%47 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%48 = load i8**, i8*** %5
%49 = load i32, i32* %4
%50 = sub nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %48, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %53)
%55 = call i32 @exit(i32 2)
unreachable
56: ; preds = %43
br label %57
57: ; preds = %56, %188
br label %58
58: ; preds = %180, %57
%59 = load i32*, i32** %10
%60 = call i32 @fgetc(i32* %59)
store i32 %60, i32* %11
%61 = load i32, i32* %11
%62 = shl i32 %61, 8
%63 = load i32*, i32** %10
%64 = call i32 @fgetc(i32* %63)
%65 = or i32 %62, %64
store i32 %65, i32* %11
%66 = load i32, i32* %11
%67 = shl i32 %66, 8
%68 = load i32*, i32** %10
%69 = call i32 @fgetc(i32* %68)
%70 = or i32 %67, %69
store i32 %70, i32* %11
br label %71
71: ; preds = %175, %58
%72 = load i32*, i32** %10
%73 = call i64 @feof(i32* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %71
br label %189
76: ; preds = %71
%77 = load i32, i32* %11
%78 = shl i32 %77, 8
%79 = load i32*, i32** %10
%80 = call i32 @fgetc(i32* %79)
%81 = or i32 %78, %80
store i32 %81, i32* %11
%82 = load i32*, i32** %10
%83 = call i32 @ftell(i32* %82)
%84 = sub nsw i32 %83, 4
%85 = load i32, i32* %11
%86 = lshr i32 %85, 24
%87 = call i32 @xx(i32 %86)
%88 = load i32, i32* %11
%89 = lshr i32 %88, 16
%90 = call i32 @xx(i32 %89)
%91 = load i32, i32* %11
%92 = lshr i32 %91, 8
%93 = call i32 @xx(i32 %92)
%94 = load i32, i32* %11
%95 = call i32 @xx(i32 %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %84, i32 %87, i32 %90, i32 %93, i32 %95)
%97 = load i32, i32* %11
switch i32 %97, label %172 [
i32 1380533830, label %98
i32 1279873876, label %116
i32 1635150184, label %134
i32 1937011304, label %134
i32 1937011302, label %134
i32 1247104587, label %134
i32 1768192049, label %134
i32 1684892776, label %134
i32 1768842360, label %134
i32 1769484336, label %134
i32 1769484337, label %134
i32 808548194, label %134
i32 808613730, label %134
i32 808679266, label %134
i32 808477794, label %134
i32 808477795, label %134
i32 808476511, label %134
i32 1230194260, label %134
i32 1230197315, label %134
i32 1229865293, label %134
i32 1230193226, label %134
i32 1229017684, label %134
i32 1229147984, label %134
i32 1229147476, label %134
]
98: ; preds = %76
%99 = load i32*, i32** %10
%100 = call i32 @fread(i32* %12, i32 4, i32 1, i32* %99)
%101 = load i32*, i32** %10
%102 = call i32 @getid(i32* %101)
store i32 %102, i32* %11
%103 = load i32, i32* %12
%104 = load i32, i32* %11
%105 = lshr i32 %104, 24
%106 = call i32 @xx(i32 %105)
%107 = load i32, i32* %11
%108 = lshr i32 %107, 16
%109 = call i32 @xx(i32 %108)
%110 = load i32, i32* %11
%111 = lshr i32 %110, 8
%112 = call i32 @xx(i32 %111)
%113 = load i32, i32* %11
%114 = call i32 @xx(i32 %113)
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i32 %103, i32 %106, i32 %109, i32 %112, i32 %114)
br label %188
116: ; preds = %76
%117 = load i32*, i32** %10
%118 = call i32 @fread(i32* %12, i32 4, i32 1, i32* %117)
%119 = load i32*, i32** %10
%120 = call i32 @getid(i32* %119)
store i32 %120, i32* %11
%121 = load i32, i32* %12
%122 = load i32, i32* %11
%123 = lshr i32 %122, 24
%124 = call i32 @xx(i32 %123)
%125 = load i32, i32* %11
%126 = lshr i32 %125, 16
%127 = call i32 @xx(i32 %126)
%128 = load i32, i32* %11
%129 = lshr i32 %128, 8
%130 = call i32 @xx(i32 %129)
%131 = load i32, i32* %11
%132 = call i32 @xx(i32 %131)
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %121, i32 %124, i32 %127, i32 %130, i32 %132)
br label %188
134: ; preds = %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76
%135 = load i32*, i32** %10
%136 = call i32 @ftell(i32* %135)
store i32 %136, i32* %6
%137 = load i32, i32* %7
%138 = icmp ne i32 %137, 0
br i1 %138, label %139, label %159
139: ; preds = %134
%140 = load i32, i32* %9
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %159
142: ; preds = %139
%143 = load i32*, i32** %10
%144 = load i32, i32* %7
%145 = load i32, i32* @SEEK_SET
%146 = call i32 @fseek(i32* %143, i32 %144, i32 %145)
%147 = load i32, i32* %6
%148 = load i32, i32* %7
%149 = sub i32 %147, %148
%150 = sub i32 %149, 8
store i32 %150, i32* %12
%151 = load i32, i32* %12
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i32 %151)
%153 = load i32*, i32** %10
%154 = call i32 @fwrite(i32* %12, i32 4, i32 1, i32* %153)
%155 = load i32*, i32** %10
%156 = load i32, i32* %6
%157 = load i32, i32* @SEEK_SET
%158 = call i32 @fseek(i32* %155, i32 %156, i32 %157)
store i32 0, i32* %7
br label %159
159: ; preds = %142, %139, %134
%160 = load i32*, i32** %10
%161 = call i32 @fread(i32* %12, i32 4, i32 1, i32* %160)
%162 = load i32, i32* %12
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i32 %162)
%164 = load i32, i32* %12
%165 = and i32 %164, 1
%166 = load i32, i32* %12
%167 = add i32 %166, %165
store i32 %167, i32* %12
%168 = load i32*, i32** %10
%169 = load i32, i32* %12
%170 = load i32, i32* @SEEK_CUR
%171 = call i32 @fseek(i32* %168, i32 %169, i32 %170)
br label %188
172: ; preds = %76
%173 = load i32, i32* %6
%174 = icmp ne i32 %173, 0
br i1 %174, label %180, label %175
175: ; preds = %172
%176 = load i32, i32* %8
%177 = add i32 %176, 1
store i32 %177, i32* %8
%178 = load i32, i32* %8
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0), i32 %178)
br label %71
180: ; preds = %172
%181 = load i32, i32* %6
%182 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.12, i64 0, i64 0), i32 %181)
%183 = load i32*, i32** %10
%184 = load i32, i32* %6
%185 = load i32, i32* @SEEK_SET
%186 = call i32 @fseek(i32* %183, i32 %184, i32 %185)
%187 = load i32, i32* %6
store i32 %187, i32* %7
store i32 0, i32* %6
br label %58
188: ; preds = %159, %116, %98
store i32 0, i32* %8
br label %57
189: ; preds = %75
%190 = load i32, i32* %3
ret i32 %190
}

LLVM IR (-O2):
@.str = [30 x i8] c"Usage: %s [-fix] badfile.avi\0A\00"
@.str.1 = [5 x i8] c"-fix\00"
@.str.2 = [4 x i8] c"rb+\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [6 x i8] c"error\00"
@.str.5 = [19 x i8] c"couldnt open '%s'\0A\00"
@.str.6 = [16 x i8] c"%08X: %c%c%c%c\0A\00"
@.str.7 = [45 x i8] c"RIFF header, filesize=0x%X format=%c%c%c%c\0A\00"
@.str.8 = [33 x i8] c"LIST size=0x%X format=%c%c%c%c\0A\00"
@SEEK_SET = global i32 0
@.str.9 = [21 x i8] c"Correct len to 0x%X\0A\00"
@.str.10 = [23 x i8] c"ID ok, chunk len=0x%X\0A\00"
@SEEK_CUR = global i32 0
@.str.11 = [35 x i8] c"invalid ID, trying %d byte offset\0A\00"
@.str.12 = [47 x i8] c"invalid ID, parsing next chunk's data at 0x%X\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = add nsw i32 %0, -1
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = select i1 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%19 = tail call i32* @fopen(i8* %17, i8* %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %33, label %21
21: ; preds = %9
%22 = bitcast i32* %3 to i8*
%23 = tail call i32 @fgetc(i32* %19)
%24 = tail call i32 @fgetc(i32* %19)
%25 = tail call i32 @fgetc(i32* %19)
%26 = tail call i64 @feof(i32* %19)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %143
28: ; preds = %21
%29 = shl i32 %24, 8
%30 = shl i32 %23, 16
%31 = or i32 %29, %30
%32 = or i32 %31, %25
br label %41
33: ; preds = %9
%34 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%35 = add nsw i32 %0, -1
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %1, i64 %36
%38 = load i8*, i8** %37
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %38)
%40 = tail call i32 @exit(i32 2)
unreachable
41: ; preds = %127, %28
%42 = phi i32 [ %32, %28 ], [ %128, %127 ]
%43 = phi i32 [ 0, %28 ], [ %129, %127 ]
%44 = phi i32 [ 0, %28 ], [ %130, %127 ]
%45 = icmp eq i32 %44, 0
br label %46
46: ; preds = %41, %109
%47 = phi i32 [ %42, %41 ], [ %51, %109 ]
%48 = phi i32 [ 0, %41 ], [ %110, %109 ]
%49 = shl i32 %47, 8
%50 = tail call i32 @fgetc(i32* %19)
%51 = or i32 %50, %49
%52 = tail call i32 @ftell(i32* %19)
%53 = add nsw i32 %52, -4
%54 = lshr i32 %51, 24
%55 = tail call i32 @xx(i32 %54)
%56 = lshr i32 %51, 16
%57 = tail call i32 @xx(i32 %56)
%58 = lshr i32 %51, 8
%59 = tail call i32 @xx(i32 %58)
%60 = tail call i32 @xx(i32 %51)
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %53, i32 %55, i32 %57, i32 %59, i32 %60)
switch i32 %51, label %108 [
i32 1380533830, label %62
i32 1279873876, label %74
i32 1635150184, label %86
i32 1937011304, label %86
i32 1937011302, label %86
i32 1247104587, label %86
i32 1768192049, label %86
i32 1684892776, label %86
i32 1768842360, label %86
i32 1769484336, label %86
i32 1769484337, label %86
i32 808548194, label %86
i32 808613730, label %86
i32 808679266, label %86
i32 808477794, label %86
i32 808477795, label %86
i32 808476511, label %86
i32 1230194260, label %86
i32 1230197315, label %86
i32 1229865293, label %86
i32 1230193226, label %86
i32 1229017684, label %86
i32 1229147984, label %86
i32 1229147476, label %86
]
62: ; preds = %46
%63 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %19)
%64 = tail call i32 @getid(i32* %19)
%65 = load i32, i32* %3
%66 = lshr i32 %64, 24
%67 = tail call i32 @xx(i32 %66)
%68 = lshr i32 %64, 16
%69 = tail call i32 @xx(i32 %68)
%70 = lshr i32 %64, 8
%71 = tail call i32 @xx(i32 %70)
%72 = tail call i32 @xx(i32 %64)
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0), i32 %65, i32 %67, i32 %69, i32 %71, i32 %72)
br label %131
74: ; preds = %46
%75 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %19)
%76 = tail call i32 @getid(i32* %19)
%77 = load i32, i32* %3
%78 = lshr i32 %76, 24
%79 = tail call i32 @xx(i32 %78)
%80 = lshr i32 %76, 16
%81 = tail call i32 @xx(i32 %80)
%82 = lshr i32 %76, 8
%83 = tail call i32 @xx(i32 %82)
%84 = tail call i32 @xx(i32 %76)
%85 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %77, i32 %79, i32 %81, i32 %83, i32 %84)
br label %131
86: ; preds = %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46
%87 = tail call i32 @ftell(i32* %19)
%88 = icmp ne i32 %43, 0
%89 = select i1 %88, i1 %13, i1 false
br i1 %89, label %90, label %99
90: ; preds = %86
%91 = load i32, i32* @SEEK_SET
%92 = tail call i32 @fseek(i32* %19, i32 %43, i32 %91)
%93 = sub i32 %87, %43
%94 = add i32 %93, -8
store i32 %94, i32* %3
%95 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i32 %94)
%96 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32* %19)
%97 = load i32, i32* @SEEK_SET
%98 = tail call i32 @fseek(i32* %19, i32 %87, i32 %97)
br label %99
99: ; preds = %90, %86
%100 = phi i32 [ 0, %90 ], [ %43, %86 ]
%101 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %19)
%102 = load i32, i32* %3
%103 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i32 %102)
%104 = and i32 %102, 1
%105 = add i32 %104, %102
%106 = load i32, i32* @SEEK_CUR
%107 = tail call i32 @fseek(i32* %19, i32 %105, i32 %106)
br label %131
108: ; preds = %46
br i1 %45, label %109, label %114
109: ; preds = %108
%110 = add i32 %48, 1
%111 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0), i32 %110)
%112 = tail call i64 @feof(i32* %19)
%113 = icmp eq i64 %112, 0
br i1 %113, label %46, label %143
114: ; preds = %108
%115 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.12, i64 0, i64 0), i32 %44)
%116 = load i32, i32* @SEEK_SET
%117 = tail call i32 @fseek(i32* %19, i32 %44, i32 %116)
%118 = tail call i32 @fgetc(i32* %19)
%119 = tail call i32 @fgetc(i32* %19)
%120 = shl i32 %118, 16
%121 = shl i32 %119, 8
%122 = or i32 %121, %120
%123 = tail call i32 @fgetc(i32* %19)
%124 = or i32 %122, %123
%125 = tail call i64 @feof(i32* %19)
%126 = icmp eq i64 %125, 0
br i1 %126, label %127, label %143
127: ; preds = %114, %131
%128 = phi i32 [ %124, %114 ], [ %140, %131 ]
%129 = phi i32 [ %44, %114 ], [ %133, %131 ]
%130 = phi i32 [ 0, %114 ], [ %132, %131 ]
br label %41
131: ; preds = %62, %74, %99
%132 = phi i32 [ %87, %99 ], [ %44, %74 ], [ %44, %62 ]
%133 = phi i32 [ %100, %99 ], [ %43, %74 ], [ %43, %62 ]
%134 = tail call i32 @fgetc(i32* %19)
%135 = tail call i32 @fgetc(i32* %19)
%136 = shl i32 %134, 16
%137 = shl i32 %135, 8
%138 = or i32 %137, %136
%139 = tail call i32 @fgetc(i32* %19)
%140 = or i32 %138, %139
%141 = tail call i64 @feof(i32* %19)
%142 = icmp eq i64 %141, 0
br i1 %142, label %127, label %143
143: ; preds = %131, %114, %109, %21
ret i32 0
}