#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 *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
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);
    ;
    switch (id) {
    case ((('R') << 24) | (('I') << 16) | (('F') << 8) | ('F')):
      fread(&len, 4, 1, f);
      id = getid(f);
      ;
      break;
    case ((('L') << 24) | (('I') << 16) | (('S') << 8) | ('T')):
      fread(&len, 4, 1, f);
      id = getid(f);
      ;
      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;
        ;
        fwrite(&len, 4, 1, f);
        fseek(f, lastgood, SEEK_SET);
        fixat = 0;
      }
      fread(&len, 4, 1, f);
      ;
      len += len & 1;
      fseek(f, len, SEEK_CUR);
      break;
    default:
      if (!lastgood) {
        ++offset;
        ;
        goto faszom;
      };
      fseek(f, lastgood, SEEK_SET);
      fixat = lastgood;
      lastgood = 0;
      goto again;
    }
    offset = 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     1219 <main+0x59>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf6(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1263 <main+0xa3>
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdce(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
jmp    1284 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdac(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12c2 <main+0x102>
lea    0xd94(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd7d(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
jmp    12c7 <main+0x107>
jmp    12cc <main+0x10c>
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <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   1060 <fgetc@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     1328 <main+0x168>
jmp    163b <main+0x47b>
mov    -0x2c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x30305f5f,%eax
je     153f <main+0x37f>
jmp    135a <main+0x19a>
mov    -0x3c(%rbp),%eax
add    $0xcfcf9b9e,%eax
sub    $0x2,%eax
jb     153f <main+0x37f>
jmp    1370 <main+0x1b0>
mov    -0x3c(%rbp),%eax
sub    $0x30317762,%eax
je     153f <main+0x37f>
jmp    1383 <main+0x1c3>
mov    -0x3c(%rbp),%eax
sub    $0x30327762,%eax
je     153f <main+0x37f>
jmp    1396 <main+0x1d6>
mov    -0x3c(%rbp),%eax
sub    $0x30337762,%eax
je     153f <main+0x37f>
jmp    13a9 <main+0x1e9>
mov    -0x3c(%rbp),%eax
sub    $0x49415254,%eax
je     153f <main+0x37f>
jmp    13bc <main+0x1fc>
mov    -0x3c(%rbp),%eax
sub    $0x49434d54,%eax
je     153f <main+0x37f>
jmp    13cf <main+0x20f>
mov    -0x3c(%rbp),%eax
sub    $0x49434f50,%eax
je     153f <main+0x37f>
jmp    13e2 <main+0x222>
mov    -0x3c(%rbp),%eax
sub    $0x494e414d,%eax
je     153f <main+0x37f>
jmp    13f5 <main+0x235>
mov    -0x3c(%rbp),%eax
sub    $0x4953424a,%eax
je     153f <main+0x37f>
jmp    1408 <main+0x248>
mov    -0x3c(%rbp),%eax
sub    $0x49534654,%eax
je     153f <main+0x37f>
jmp    141b <main+0x25b>
mov    -0x3c(%rbp),%eax
sub    $0x49535243,%eax
je     153f <main+0x37f>
jmp    142e <main+0x26e>
mov    -0x3c(%rbp),%eax
sub    $0x4a554e4b,%eax
je     153f <main+0x37f>
jmp    1441 <main+0x281>
mov    -0x3c(%rbp),%eax
sub    $0x4c495354,%eax
je     1517 <main+0x357>
jmp    1454 <main+0x294>
mov    -0x3c(%rbp),%eax
sub    $0x52494646,%eax
je     14ef <main+0x32f>
jmp    1467 <main+0x2a7>
mov    -0x3c(%rbp),%eax
sub    $0x61766968,%eax
je     153f <main+0x37f>
jmp    147a <main+0x2ba>
mov    -0x3c(%rbp),%eax
sub    $0x646d6c68,%eax
je     153f <main+0x37f>
jmp    148d <main+0x2cd>
mov    -0x3c(%rbp),%eax
sub    $0x69647831,%eax
je     153f <main+0x37f>
jmp    14a0 <main+0x2e0>
mov    -0x3c(%rbp),%eax
sub    $0x696e6478,%eax
je     153f <main+0x37f>
jmp    14b3 <main+0x2f3>
mov    -0x3c(%rbp),%eax
add    $0x9687cfd0,%eax
sub    $0x2,%eax
jb     153f <main+0x37f>
jmp    14c9 <main+0x309>
mov    -0x3c(%rbp),%eax
sub    $0x73747266,%eax
je     153f <main+0x37f>
jmp    14dc <main+0x31c>
mov    -0x3c(%rbp),%eax
sub    $0x73747268,%eax
je     153f <main+0x37f>
jmp    15f0 <main+0x430>
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)
jmp    162f <main+0x46f>
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)
jmp    162f <main+0x46f>
mov    -0x28(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     15b3 <main+0x3f3>
cmpl   $0x0,-0x20(%rbp)
je     15b3 <main+0x3f3>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2a6b(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2a33(%rip),%rax
mov    (%rax),%edx
call   10a0 <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),%eax
and    $0x1,%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    0x2a04(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
jmp    162f <main+0x46f>
cmpl   $0x0,-0x14(%rbp)
jne    1608 <main+0x448>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1310 <main+0x150>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x29c2(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    12cc <main+0x10c>
movl   $0x0,-0x1c(%rbp)
jmp    12c7 <main+0x107>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x1,%edi
jle    1546 <main+0x386>
mov    %edi,%ebp
mov    0x8(%r14),%rdi
lea    0xe3a(%rip),%rsi
call   1070 <strcmp@plt>
add    $0xffffffff,%ebp
mov    %eax,0x4(%rsp)
test   %eax,%eax
mov    (%r14,%rbp,8),%rdi
lea    0xe26(%rip),%rax
lea    0xe23(%rip),%rsi
cmove  %rax,%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     155f <main+0x39f>
mov    %rax,%r15
mov    %rax,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     1257 <main+0x97>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
shl    $0x8,%r14d
shl    $0x10,%ebp
or     %r14d,%ebp
or     %r12d,%ebp
xor    %r12d,%r12d
mov    %rsp,%r14
xor    %r13d,%r13d
nopl   (%rax)
mov    %ebp,%ebx
shl    $0x8,%ebx
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
or     %ebx,%ebp
cmp    $0x49535242,%ebp
jg     12c0 <main+0x100>
cmp    $0x49415253,%ebp
jg     1300 <main+0x140>
cmp    $0x30317761,%ebp
jg     1370 <main+0x1b0>
lea    -0x30306462(%rbp),%eax
cmp    $0x2,%eax
jb     1400 <main+0x240>
cmp    $0x30305f5f,%ebp
jne    13e0 <main+0x220>
jmp    1400 <main+0x240>
nopl   (%rax)
cmp    $0x69647830,%ebp
jg     1340 <main+0x180>
cmp    $0x52494645,%ebp
jg     138e <main+0x1ce>
cmp    $0x49535243,%ebp
je     1400 <main+0x240>
cmp    $0x4a554e4b,%ebp
je     1400 <main+0x240>
cmp    $0x4c495354,%ebp
jne    13e0 <main+0x220>
jmp    14d1 <main+0x311>
nopl   (%rax)
cmp    $0x494e414c,%ebp
jg     13ac <main+0x1ec>
cmp    $0x49415254,%ebp
je     1400 <main+0x240>
cmp    $0x49434d54,%ebp
je     1400 <main+0x240>
cmp    $0x49434f50,%ebp
jne    13e0 <main+0x220>
jmp    1400 <main+0x240>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x6978302f,%ebp
jle    13c6 <main+0x206>
lea    -0x69783030(%rbp),%eax
cmp    $0x2,%eax
jb     1400 <main+0x240>
cmp    $0x73747266,%ebp
je     1400 <main+0x240>
cmp    $0x73747268,%ebp
jne    13e0 <main+0x220>
jmp    1400 <main+0x240>
cmp    $0x30317762,%ebp
je     1400 <main+0x240>
cmp    $0x30327762,%ebp
je     1400 <main+0x240>
cmp    $0x30337762,%ebp
jne    13e0 <main+0x220>
jmp    1400 <main+0x240>
cmp    $0x52494646,%ebp
je     14d1 <main+0x311>
cmp    $0x61766968,%ebp
je     1400 <main+0x240>
cmp    $0x646d6c68,%ebp
jne    13e0 <main+0x220>
jmp    1400 <main+0x240>
cmp    $0x494e414d,%ebp
je     1400 <main+0x240>
cmp    $0x4953424a,%ebp
je     1400 <main+0x240>
cmp    $0x49534654,%ebp
jne    13e0 <main+0x220>
jmp    1400 <main+0x240>
cmp    $0x69647831,%ebp
je     1400 <main+0x240>
cmp    $0x696e6478,%ebp
je     1400 <main+0x240>
cs nopw 0x0(%rax,%rax,1)
test   %r13d,%r13d
jne    14f0 <main+0x330>
mov    %r15,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     1270 <main+0xb0>
jmp    1246 <main+0x86>
nop
mov    %r15,%rdi
call   1080 <ftell@plt>
mov    %eax,%r13d
test   %r12d,%r12d
je     145c <main+0x29c>
cmpl   $0x0,0x4(%rsp)
jne    145c <main+0x29c>
mov    0x2bba(%rip),%rbx
mov    (%rbx),%edx
mov    %r15,%rdi
mov    %r12d,%esi
call   10a0 <fseek@plt>
mov    %r13d,%eax
sub    %r12d,%eax
add    $0xfffffff8,%eax
mov    %eax,(%rsp)
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10e0 <fwrite@plt>
mov    (%rbx),%edx
mov    %r15,%rdi
mov    %r13d,%esi
call   10a0 <fseek@plt>
xor    %r12d,%r12d
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    (%rsp),%eax
mov    %eax,%esi
and    $0x1,%esi
add    %eax,%esi
mov    0x2b66(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
call   10a0 <fseek@plt>
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r14d
shl    $0x10,%ebp
shl    $0x8,%r14d
or     %ebp,%r14d
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
or     %r14d,%ebp
mov    %r15,%rdi
call   1090 <feof@plt>
test   %rax,%rax
mov    %rsp,%r14
je     1270 <main+0xb0>
jmp    1246 <main+0x86>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %r15,%rdi
call   1050 <getid@plt>
jmp    148c <main+0x2cc>
mov    0x2ae1(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %r13d,%esi
call   10a0 <fseek@plt>
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r12d
shl    $0x10,%ebp
shl    $0x8,%r12d
or     %ebp,%r12d
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
or     %r12d,%ebp
mov    %r15,%rdi
call   1090 <feof@plt>
mov    %r13d,%r12d
mov    $0x0,%r13d
jmp    13f1 <main+0x231>
mov    (%r14),%rsi
lea    0xab0(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xac4(%rip),%rdi
call   10c0 <perror@plt>
mov    (%r14,%rbp,8),%rsi
lea    0xaba(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   10d0 <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"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
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 @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 @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, %139
br label %58
58: ; preds = %133, %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 = %130, %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 %140
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* %11
switch i32 %82, label %127 [
i32 1380533830, label %83
i32 1279873876, label %88
i32 1635150184, label %93
i32 1937011304, label %93
i32 1937011302, label %93
i32 1247104587, label %93
i32 1768192049, label %93
i32 1684892776, label %93
i32 1768842360, label %93
i32 1769484336, label %93
i32 1769484337, label %93
i32 808548194, label %93
i32 808613730, label %93
i32 808679266, label %93
i32 808477794, label %93
i32 808477795, label %93
i32 808476511, label %93
i32 1230194260, label %93
i32 1230197315, label %93
i32 1229865293, label %93
i32 1230193226, label %93
i32 1229017684, label %93
i32 1229147984, label %93
i32 1229147476, label %93
]
83: ; preds = %76
%84 = load i32*, i32** %10
%85 = call i32 @fread(i32* %12, i32 4, i32 1, i32* %84)
%86 = load i32*, i32** %10
%87 = call i32 @getid(i32* %86)
store i32 %87, i32* %11
br label %139
88: ; preds = %76
%89 = load i32*, i32** %10
%90 = call i32 @fread(i32* %12, i32 4, i32 1, i32* %89)
%91 = load i32*, i32** %10
%92 = call i32 @getid(i32* %91)
store i32 %92, i32* %11
br label %139
93: ; preds = %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76, %76
%94 = load i32*, i32** %10
%95 = call i32 @ftell(i32* %94)
store i32 %95, i32* %6
%96 = load i32, i32* %7
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %116
98: ; preds = %93
%99 = load i32, i32* %9
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %116
101: ; preds = %98
%102 = load i32*, i32** %10
%103 = load i32, i32* %7
%104 = load i32, i32* @SEEK_SET
%105 = call i32 @fseek(i32* %102, i32 %103, i32 %104)
%106 = load i32, i32* %6
%107 = load i32, i32* %7
%108 = sub i32 %106, %107
%109 = sub i32 %108, 8
store i32 %109, i32* %12
%110 = load i32*, i32** %10
%111 = call i32 @fwrite(i32* %12, i32 4, i32 1, i32* %110)
%112 = load i32*, i32** %10
%113 = load i32, i32* %6
%114 = load i32, i32* @SEEK_SET
%115 = call i32 @fseek(i32* %112, i32 %113, i32 %114)
store i32 0, i32* %7
br label %116
116: ; preds = %101, %98, %93
%117 = load i32*, i32** %10
%118 = call i32 @fread(i32* %12, i32 4, i32 1, i32* %117)
%119 = load i32, i32* %12
%120 = and i32 %119, 1
%121 = load i32, i32* %12
%122 = add i32 %121, %120
store i32 %122, i32* %12
%123 = load i32*, i32** %10
%124 = load i32, i32* %12
%125 = load i32, i32* @SEEK_CUR
%126 = call i32 @fseek(i32* %123, i32 %124, i32 %125)
br label %139
127: ; preds = %76
%128 = load i32, i32* %6
%129 = icmp ne i32 %128, 0
br i1 %129, label %133, label %130
130: ; preds = %127
%131 = load i32, i32* %8
%132 = add i32 %131, 1
store i32 %132, i32* %8
br label %71
133: ; preds = %127
%134 = load i32*, i32** %10
%135 = load i32, i32* %6
%136 = load i32, i32* @SEEK_SET
%137 = call i32 @fseek(i32* %134, i32 %135, i32 %136)
%138 = load i32, i32* %6
store i32 %138, i32* %7
store i32 0, i32* %6
br label %58
139: ; preds = %116, %88, %83
store i32 0, i32* %8
br label %57
140: ; preds = %75
%141 = load i32, i32* %3
ret i32 %141
}

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"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
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 @printf(i8* 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 %109
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 @printf(i8* 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 = %93, %28
%42 = phi i32 [ %32, %28 ], [ %94, %93 ]
%43 = phi i32 [ 0, %28 ], [ %95, %93 ]
%44 = phi i32 [ 0, %28 ], [ %96, %93 ]
%45 = icmp eq i32 %44, 0
br label %46
46: ; preds = %41, %78
%47 = phi i32 [ %42, %41 ], [ %50, %78 ]
%48 = shl i32 %47, 8
%49 = tail call i32 @fgetc(i32* %19)
%50 = or i32 %49, %48
switch i32 %50, label %77 [
i32 1380533830, label %51
i32 1279873876, label %54
i32 1635150184, label %57
i32 1937011304, label %57
i32 1937011302, label %57
i32 1247104587, label %57
i32 1768192049, label %57
i32 1684892776, label %57
i32 1768842360, label %57
i32 1769484336, label %57
i32 1769484337, label %57
i32 808548194, label %57
i32 808613730, label %57
i32 808679266, label %57
i32 808477794, label %57
i32 808477795, label %57
i32 808476511, label %57
i32 1230194260, label %57
i32 1230197315, label %57
i32 1229865293, label %57
i32 1230193226, label %57
i32 1229017684, label %57
i32 1229147984, label %57
i32 1229147476, label %57
]
51: ; preds = %46
%52 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %19)
%53 = tail call i32 @getid(i32* %19)
br label %97
54: ; preds = %46
%55 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %19)
%56 = tail call i32 @getid(i32* %19)
br label %97
57: ; preds = %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46, %46
%58 = tail call i32 @ftell(i32* %19)
%59 = icmp ne i32 %43, 0
%60 = select i1 %59, i1 %13, i1 false
br i1 %60, label %61, label %69
61: ; preds = %57
%62 = load i32, i32* @SEEK_SET
%63 = tail call i32 @fseek(i32* %19, i32 %43, i32 %62)
%64 = sub i32 -8, %43
%65 = add i32 %64, %58
store i32 %65, i32* %3
%66 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32* %19)
%67 = load i32, i32* @SEEK_SET
%68 = tail call i32 @fseek(i32* %19, i32 %58, i32 %67)
br label %69
69: ; preds = %61, %57
%70 = phi i32 [ 0, %61 ], [ %43, %57 ]
%71 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %19)
%72 = load i32, i32* %3
%73 = and i32 %72, 1
%74 = add i32 %73, %72
%75 = load i32, i32* @SEEK_CUR
%76 = tail call i32 @fseek(i32* %19, i32 %74, i32 %75)
br label %97
77: ; preds = %46
br i1 %45, label %78, label %81
78: ; preds = %77
%79 = tail call i64 @feof(i32* %19)
%80 = icmp eq i64 %79, 0
br i1 %80, label %46, label %109
81: ; preds = %77
%82 = load i32, i32* @SEEK_SET
%83 = tail call i32 @fseek(i32* %19, i32 %44, i32 %82)
%84 = tail call i32 @fgetc(i32* %19)
%85 = tail call i32 @fgetc(i32* %19)
%86 = shl i32 %84, 16
%87 = shl i32 %85, 8
%88 = or i32 %87, %86
%89 = tail call i32 @fgetc(i32* %19)
%90 = or i32 %88, %89
%91 = tail call i64 @feof(i32* %19)
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %109
93: ; preds = %81, %97
%94 = phi i32 [ %90, %81 ], [ %106, %97 ]
%95 = phi i32 [ %44, %81 ], [ %99, %97 ]
%96 = phi i32 [ 0, %81 ], [ %98, %97 ]
br label %41
97: ; preds = %51, %54, %69
%98 = phi i32 [ %58, %69 ], [ %44, %54 ], [ %44, %51 ]
%99 = phi i32 [ %70, %69 ], [ %43, %54 ], [ %43, %51 ]
%100 = tail call i32 @fgetc(i32* %19)
%101 = tail call i32 @fgetc(i32* %19)
%102 = shl i32 %100, 16
%103 = shl i32 %101, 8
%104 = or i32 %103, %102
%105 = tail call i32 @fgetc(i32* %19)
%106 = or i32 %104, %105
%107 = tail call i64 @feof(i32* %19)
%108 = icmp eq i64 %107, 0
br i1 %108, label %93, label %109
109: ; preds = %97, %81, %78, %21
ret i32 0
}