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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ eccedc_generate(unsigned char *, int);
unsigned int edc_partial_computeblock(unsigned int, unsigned char *, int);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(unsigned char *, int, int);
int /*<<< orphan*/ resetcounter(int /*<<< orphan*/);
int /*<<< orphan*/ setcounter(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int unecmify(FILE *in, FILE *out) {
  unsigned checkedc = 0;
  unsigned char sector[2352];
  unsigned type;
  unsigned num;
  fseek(in, 0, SEEK_END);
  resetcounter(ftell(in));
  fseek(in, 0, SEEK_SET);
  if ((fgetc(in) != 'E') || (fgetc(in) != 'C') || (fgetc(in) != 'M') ||
      (fgetc(in) != 0x00)) {
    fprintf(stderr, "Header not found!\n");
    goto corrupt;
  }
  for (;;) {
    int c = fgetc(in);
    int bits = 5;
    if (c == EOF)
      goto uneof;
    type = c & 3;
    num = (c >> 2) & 0x1F;
    while (c & 0x80) {
      c = fgetc(in);
      if (c == EOF)
        goto uneof;
      num |= ((unsigned)(c & 0x7F)) << bits;
      bits += 7;
    }
    if (num == 0xFFFFFFFF)
      break;
    num++;
    if (num >= 0x80000000)
      goto corrupt;
    if (!type) {
      while (num) {
        int b = num;
        if (b > 2352)
          b = 2352;
        if (fread(sector, 1, b, in) != b)
          goto uneof;
        checkedc = edc_partial_computeblock(checkedc, sector, b);
        fwrite(sector, 1, b, out);
        num -= b;
        setcounter(ftell(in));
      }
    } else {
      while (num--) {
        memset(sector, 0, sizeof(sector));
        memset(sector + 1, 0xFF, 10);
        switch (type) {
        case 1:
          sector[0x0F] = 0x01;
          if (fread(sector + 0x00C, 1, 0x003, in) != 0x003)
            goto uneof;
          if (fread(sector + 0x010, 1, 0x800, in) != 0x800)
            goto uneof;
          eccedc_generate(sector, 1);
          checkedc = edc_partial_computeblock(checkedc, sector, 2352);
          fwrite(sector, 2352, 1, out);
          setcounter(ftell(in));
          break;
        case 2:
          sector[0x0F] = 0x02;
          if (fread(sector + 0x014, 1, 0x804, in) != 0x804)
            goto uneof;
          sector[0x10] = sector[0x14];
          sector[0x11] = sector[0x15];
          sector[0x12] = sector[0x16];
          sector[0x13] = sector[0x17];
          eccedc_generate(sector, 2);
          checkedc = edc_partial_computeblock(checkedc, sector + 0x10, 2336);
          fwrite(sector + 0x10, 2336, 1, out);
          setcounter(ftell(in));
          break;
        case 3:
          sector[0x0F] = 0x02;
          if (fread(sector + 0x014, 1, 0x918, in) != 0x918)
            goto uneof;
          sector[0x10] = sector[0x14];
          sector[0x11] = sector[0x15];
          sector[0x12] = sector[0x16];
          sector[0x13] = sector[0x17];
          eccedc_generate(sector, 3);
          checkedc = edc_partial_computeblock(checkedc, sector + 0x10, 2336);
          fwrite(sector + 0x10, 2336, 1, out);
          setcounter(ftell(in));
          break;
        }
      }
    }
  }
  if (fread(sector, 1, 4, in) != 4)
    goto uneof;
  fprintf(stderr, "Decoded %ld bytes -> %ld bytes\n", ftell(in), ftell(out));
  if ((sector[0] != ((checkedc >> 0) & 0xFF)) ||
      (sector[1] != ((checkedc >> 8) & 0xFF)) ||
      (sector[2] != ((checkedc >> 16) & 0xFF)) ||
      (sector[3] != ((checkedc >> 24) & 0xFF))) {
    fprintf(stderr, "EDC error (%08X, should be %02X%02X%02X%02X)\n", checkedc,
            sector[3], sector[2], sector[1], sector[0]);
    goto corrupt;
  }
  fprintf(stderr, "Done; file is OK\n");
  return 0;
uneof:
  fprintf(stderr, "Unexpected EOF!\n");
corrupt:
  fprintf(stderr, "Corrupt ECM file!\n");
  return 1;
}


x86 assembly (clang, -O0):
<unecmify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x980,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e13(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,%edi
call   10b0 <resetcounter@plt>
mov    -0x10(%rbp),%rdi
mov    0x2dcf(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
cmp    $0x45,%eax
jne    124a <unecmify+0x9a>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
cmp    $0x43,%eax
jne    124a <unecmify+0x9a>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
cmp    $0x4d,%eax
jne    124a <unecmify+0x9a>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
cmp    $0x0,%eax
je     1266 <unecmify+0xb6>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    185a <unecmify+0x6aa>
jmp    126b <unecmify+0xbb>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x95c(%rbp)
movl   $0x5,-0x960(%rbp)
mov    -0x95c(%rbp),%eax
mov    0x2d4f(%rip),%rcx
cmp    (%rcx),%eax
jne    129e <unecmify+0xee>
jmp    1843 <unecmify+0x693>
mov    -0x95c(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x954(%rbp)
mov    -0x95c(%rbp),%eax
sar    $0x2,%eax
and    $0x1f,%eax
mov    %eax,-0x958(%rbp)
mov    -0x95c(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     132d <unecmify+0x17d>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x95c(%rbp)
mov    -0x95c(%rbp),%eax
mov    0x2cf1(%rip),%rcx
cmp    (%rcx),%eax
jne    12fc <unecmify+0x14c>
jmp    1843 <unecmify+0x693>
mov    -0x95c(%rbp),%eax
and    $0x7f,%eax
mov    -0x960(%rbp),%ecx
shl    %cl,%eax
or     -0x958(%rbp),%eax
mov    %eax,-0x958(%rbp)
mov    -0x960(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0x960(%rbp)
jmp    12bf <unecmify+0x10f>
cmpl   $0xffffffff,-0x958(%rbp)
jne    133f <unecmify+0x18f>
jmp    1709 <unecmify+0x559>
mov    -0x958(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x958(%rbp)
cmpl   $0x80000000,-0x958(%rbp)
jb     1363 <unecmify+0x1b3>
jmp    185a <unecmify+0x6aa>
cmpl   $0x0,-0x954(%rbp)
jne    1435 <unecmify+0x285>
jmp    1375 <unecmify+0x1c5>
cmpl   $0x0,-0x958(%rbp)
je     1430 <unecmify+0x280>
mov    -0x958(%rbp),%eax
mov    %eax,-0x964(%rbp)
cmpl   $0x930,-0x964(%rbp)
jle    13a8 <unecmify+0x1f8>
movl   $0x930,-0x964(%rbp)
lea    -0x950(%rbp),%rdi
mov    -0x964(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
cmp    -0x964(%rbp),%eax
je     13d4 <unecmify+0x224>
jmp    1843 <unecmify+0x693>
mov    -0x1c(%rbp),%edi
lea    -0x950(%rbp),%rsi
mov    -0x964(%rbp),%edx
call   1040 <edc_partial_computeblock@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x950(%rbp),%rdi
mov    -0x964(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
mov    -0x964(%rbp),%ecx
mov    -0x958(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x958(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,%edi
call   1090 <setcounter@plt>
jmp    1375 <unecmify+0x1c5>
jmp    1704 <unecmify+0x554>
jmp    143a <unecmify+0x28a>
mov    -0x958(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x958(%rbp)
cmp    $0x0,%eax
je     16ff <unecmify+0x54f>
lea    -0x950(%rbp),%rdi
xor    %esi,%esi
mov    $0x930,%edx
call   1050 <memset@plt>
lea    -0x94f(%rbp),%rdi
mov    $0xff,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
mov    -0x954(%rbp),%eax
mov    %eax,-0x968(%rbp)
sub    $0x1,%eax
je     14bf <unecmify+0x30f>
jmp    1497 <unecmify+0x2e7>
mov    -0x968(%rbp),%eax
sub    $0x2,%eax
je     1577 <unecmify+0x3c7>
jmp    14ab <unecmify+0x2fb>
mov    -0x968(%rbp),%eax
sub    $0x3,%eax
je     163b <unecmify+0x48b>
jmp    16fa <unecmify+0x54a>
movb   $0x1,-0x941(%rbp)
lea    -0x950(%rbp),%rdi
add    $0xc,%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x3,%edx
call   1030 <fread@plt>
cmp    $0x3,%eax
je     14f2 <unecmify+0x342>
jmp    1843 <unecmify+0x693>
lea    -0x950(%rbp),%rdi
add    $0x10,%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x800,%edx
call   1030 <fread@plt>
cmp    $0x800,%eax
je     1520 <unecmify+0x370>
jmp    1843 <unecmify+0x693>
lea    -0x950(%rbp),%rdi
mov    $0x1,%esi
call   10c0 <eccedc_generate@plt>
mov    -0x1c(%rbp),%edi
lea    -0x950(%rbp),%rsi
mov    $0x930,%edx
call   1040 <edc_partial_computeblock@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x950(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x930,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,%edi
call   1090 <setcounter@plt>
jmp    16fa <unecmify+0x54a>
movb   $0x2,-0x941(%rbp)
lea    -0x950(%rbp),%rdi
add    $0x14,%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x804,%edx
call   1030 <fread@plt>
cmp    $0x804,%eax
je     15ac <unecmify+0x3fc>
jmp    1843 <unecmify+0x693>
mov    -0x93c(%rbp),%al
mov    %al,-0x940(%rbp)
mov    -0x93b(%rbp),%al
mov    %al,-0x93f(%rbp)
mov    -0x93a(%rbp),%al
mov    %al,-0x93e(%rbp)
mov    -0x939(%rbp),%al
mov    %al,-0x93d(%rbp)
lea    -0x950(%rbp),%rdi
mov    $0x2,%esi
call   10c0 <eccedc_generate@plt>
mov    -0x1c(%rbp),%edi
lea    -0x950(%rbp),%rsi
add    $0x10,%rsi
mov    $0x920,%edx
call   1040 <edc_partial_computeblock@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x950(%rbp),%rdi
add    $0x10,%rdi
mov    -0x18(%rbp),%rcx
mov    $0x920,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,%edi
call   1090 <setcounter@plt>
jmp    16fa <unecmify+0x54a>
movb   $0x2,-0x941(%rbp)
lea    -0x950(%rbp),%rdi
add    $0x14,%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x918,%edx
call   1030 <fread@plt>
cmp    $0x918,%eax
je     1670 <unecmify+0x4c0>
jmp    1843 <unecmify+0x693>
mov    -0x93c(%rbp),%al
mov    %al,-0x940(%rbp)
mov    -0x93b(%rbp),%al
mov    %al,-0x93f(%rbp)
mov    -0x93a(%rbp),%al
mov    %al,-0x93e(%rbp)
mov    -0x939(%rbp),%al
mov    %al,-0x93d(%rbp)
lea    -0x950(%rbp),%rdi
mov    $0x3,%esi
call   10c0 <eccedc_generate@plt>
mov    -0x1c(%rbp),%edi
lea    -0x950(%rbp),%rsi
add    $0x10,%rsi
mov    $0x920,%edx
call   1040 <edc_partial_computeblock@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x950(%rbp),%rdi
add    $0x10,%rdi
mov    -0x18(%rbp),%rcx
mov    $0x920,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,%edi
call   1090 <setcounter@plt>
jmp    143a <unecmify+0x28a>
jmp    1704 <unecmify+0x554>
jmp    126b <unecmify+0xbb>
lea    -0x950(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cmp    $0x4,%eax
je     1731 <unecmify+0x581>
jmp    1843 <unecmify+0x693>
mov    0x2898(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x970(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x96c(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    -0x970(%rbp),%edi
mov    -0x96c(%rbp),%edx
mov    %eax,%ecx
lea    0x8a6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movzbl -0x950(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shr    $0x0,%ecx
and    $0xff,%ecx
cmp    %ecx,%eax
jne    17e0 <unecmify+0x630>
movzbl -0x94f(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
cmp    %ecx,%eax
jne    17e0 <unecmify+0x630>
movzbl -0x94e(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shr    $0x10,%ecx
and    $0xff,%ecx
cmp    %ecx,%eax
jne    17e0 <unecmify+0x630>
movzbl -0x94d(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shr    $0x18,%ecx
and    $0xff,%ecx
cmp    %ecx,%eax
je     1820 <unecmify+0x670>
mov    0x27e9(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
movzbl -0x94d(%rbp),%ecx
movzbl -0x94e(%rbp),%r8d
ff
movzbl -0x94f(%rbp),%r9d
ff
movzbl -0x950(%rbp),%eax
lea    0x822(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    185a <unecmify+0x6aa>
mov    0x27a9(%rip),%rax
mov    (%rax),%edi
lea    0x831(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1878 <unecmify+0x6c8>
mov    0x2786(%rip),%rax
mov    (%rax),%edi
lea    0x820(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x276f(%rip),%rax
mov    (%rax),%edi
lea    0x81a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x980,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unecmify>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x948,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e1a(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %eax,%edi
call   10b0 <resetcounter@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    $0x45,%eax
jne    122c <unecmify+0x7c>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    $0x43,%eax
jne    122c <unecmify+0x7c>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    $0x4d,%eax
jne    122c <unecmify+0x7c>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
test   %eax,%eax
je     1276 <unecmify+0xc6>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
lea    0xdc4(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%ebx
lea    0xe35(%rip),%r15
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %ebx,%eax
add    $0x948,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r12d
mov    0x2d58(%rip),%rax
cmp    (%rax),%r12d
jne    129f <unecmify+0xef>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
lea    0xdd6(%rip),%rsi
jmp    123c <unecmify+0x8c>
movl   $0x0,0xc(%rsp)
lea    0xdd6(%rip),%r15
mov    %r12d,%r13d
shr    $0x2,%r13d
and    $0x1f,%r13d
test   $0x80,%r12b
je     1300 <unecmify+0x150>
mov    $0x5,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    0x2d01(%rip),%rcx
cmp    (%rcx),%eax
je     128d <unecmify+0xdd>
mov    %eax,%edx
and    $0x7f,%edx
mov    %ebp,%ecx
shl    %cl,%edx
or     %edx,%r13d
add    $0x7,%ebp
test   $0x80,%al
jne    12d0 <unecmify+0x120>
cmp    $0xffffffff,%r13d
je     151b <unecmify+0x36b>
inc    %r13d
js     15d3 <unecmify+0x423>
and    $0x3,%r12d
jne    13e5 <unecmify+0x235>
cmp    $0x930,%r13d
mov    $0x930,%ebp
cmovl  %r13d,%ebp
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    %ebp,%eax
jne    128d <unecmify+0xdd>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%r12
mov    %r12,%rsi
mov    %ebp,%edx
call   1040 <edc_partial_computeblock@plt>
mov    %eax,0xc(%rsp)
mov    %r12,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %eax,%edi
call   1090 <setcounter@plt>
sub    %ebp,%r13d
jne    1313 <unecmify+0x163>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r12d
mov    0x2c52(%rip),%rax
cmp    (%rax),%r12d
jne    12ae <unecmify+0xfe>
jmp    128d <unecmify+0xdd>
call   10c0 <eccedc_generate@plt>
mov    0xc(%rsp),%edi
lea    0x20(%rsp),%rbp
mov    %rbp,%rsi
mov    $0x920,%edx
call   1040 <edc_partial_computeblock@plt>
mov    %eax,0xc(%rsp)
mov    %rbp,%rdi
mov    $0x920,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %eax,%edi
call   1090 <setcounter@plt>
add    $0xffffffff,%r13d
je     137c <unecmify+0x1cc>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x930,%edx
call   1050 <memset@plt>
lea    0x11(%rsp),%rdi
mov    $0xff,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
cmp    $0x3,%r12d
je     149f <unecmify+0x2ef>
cmp    $0x2,%r12d
je     14dd <unecmify+0x32d>
cmp    $0x1,%r12d
jne    13df <unecmify+0x22f>
movb   $0x1,0x1f(%rsp)
lea    0x1c(%rsp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x3,%eax
jne    128d <unecmify+0xdd>
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x800,%eax
jne    128d <unecmify+0xdd>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
call   10c0 <eccedc_generate@plt>
mov    0xc(%rsp),%edi
mov    %rbp,%rsi
mov    $0x930,%edx
call   1040 <edc_partial_computeblock@plt>
mov    %eax,0xc(%rsp)
mov    %rbp,%rdi
mov    $0x930,%esi
jmp    13c3 <unecmify+0x213>
movb   $0x2,0x1f(%rsp)
lea    0x24(%rsp),%rdi
mov    $0x1,%esi
mov    $0x918,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x918,%eax
jne    128d <unecmify+0xdd>
mov    0x24(%rsp),%eax
mov    %eax,0x20(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x3,%esi
jmp    139c <unecmify+0x1ec>
movb   $0x2,0x1f(%rsp)
lea    0x24(%rsp),%rdi
mov    $0x1,%esi
mov    $0x804,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x804,%eax
jne    128d <unecmify+0xdd>
mov    0x24(%rsp),%eax
mov    %eax,0x20(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x2,%esi
jmp    139c <unecmify+0x1ec>
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x4,%eax
jne    128d <unecmify+0xdd>
mov    0x2a8e(%rip),%r12
mov    (%r12),%ebp
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1080 <ftell@plt>
lea    0xab4(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
movzbl 0x10(%rsp),%eax
mov    0x11(%rsp),%cl
mov    0xc(%rsp),%edx
cmp    %dl,%al
jne    15af <unecmify+0x3ff>
mov    %edx,%esi
shr    $0x8,%esi
cmp    %sil,%cl
jne    15af <unecmify+0x3ff>
mov    %edx,%esi
shr    $0x10,%esi
cmp    %sil,0x12(%rsp)
jne    15af <unecmify+0x3ff>
movzbl 0x13(%rsp),%edi
mov    %edx,%esi
shr    $0x18,%esi
cmp    %edi,%esi
jne    15af <unecmify+0x3ff>
xor    %ebx,%ebx
lea    0xab7(%rip),%r15
jmp    124f <unecmify+0x9f>
movzbl %cl,%r9d
mov    (%r12),%edi
movzbl 0x13(%rsp),%ecx
movzbl 0x12(%rsp),%r8d
mov    %eax,(%rsp)
lea    0xa67(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%ebx
jmp    124f <unecmify+0x9f>

LLVM IR (-O0):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"Header not found!\0A\00"
@EOF = global i32 0
@.str.1 = [32 x i8] c"Decoded %ld bytes -> %ld bytes\0A\00"
@.str.2 = [46 x i8] c"EDC error (%08X, should be %02X%02X%02X%02X)\0A\00"
@.str.3 = [18 x i8] c"Done; file is OK\0A\00"
@.str.4 = [17 x i8] c"Unexpected EOF!\0A\00"
@.str.5 = [19 x i8] c"Corrupt ECM file!\0A\00"
define i32 @unecmify(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca [2352 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 0, i32* %6
%13 = load i32*, i32** %4
%14 = load i32, i32* @SEEK_END
%15 = call i32 @fseek(i32* %13, i32 0, i32 %14)
%16 = load i32*, i32** %4
%17 = call i32 @ftell(i32* %16)
%18 = call i32 @resetcounter(i32 %17)
%19 = load i32*, i32** %4
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %19, i32 0, i32 %20)
%22 = load i32*, i32** %4
%23 = call i32 @fgetc(i32* %22)
%24 = icmp ne i32 %23, 69
br i1 %24, label %37, label %25
25: ; preds = %2
%26 = load i32*, i32** %4
%27 = call i32 @fgetc(i32* %26)
%28 = icmp ne i32 %27, 67
br i1 %28, label %37, label %29
29: ; preds = %25
%30 = load i32*, i32** %4
%31 = call i32 @fgetc(i32* %30)
%32 = icmp ne i32 %31, 77
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i32*, i32** %4
%35 = call i32 @fgetc(i32* %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33, %29, %25, %2
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %296
40: ; preds = %33
br label %41
41: ; preds = %229, %40
%42 = load i32*, i32** %4
%43 = call i32 @fgetc(i32* %42)
store i32 %43, i32* %10
store i32 5, i32* %11
%44 = load i32, i32* %10
%45 = load i32, i32* @EOF
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %48
47: ; preds = %41
br label %293
48: ; preds = %41
%49 = load i32, i32* %10
%50 = and i32 %49, 3
store i32 %50, i32* %8
%51 = load i32, i32* %10
%52 = ashr i32 %51, 2
%53 = and i32 %52, 31
store i32 %53, i32* %9
br label %54
54: ; preds = %65, %48
%55 = load i32, i32* %10
%56 = and i32 %55, 128
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %74
58: ; preds = %54
%59 = load i32*, i32** %4
%60 = call i32 @fgetc(i32* %59)
store i32 %60, i32* %10
%61 = load i32, i32* %10
%62 = load i32, i32* @EOF
%63 = icmp eq i32 %61, %62
br i1 %63, label %64, label %65
64: ; preds = %58
br label %293
65: ; preds = %58
%66 = load i32, i32* %10
%67 = and i32 %66, 127
%68 = load i32, i32* %11
%69 = shl i32 %67, %68
%70 = load i32, i32* %9
%71 = or i32 %70, %69
store i32 %71, i32* %9
%72 = load i32, i32* %11
%73 = add nsw i32 %72, 7
store i32 %73, i32* %11
br label %54
74: ; preds = %54
%75 = load i32, i32* %9
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %78
77: ; preds = %74
br label %230
78: ; preds = %74
%79 = load i32, i32* %9
%80 = add i32 %79, 1
store i32 %80, i32* %9
%81 = load i32, i32* %9
%82 = icmp uge i32 %81, -2147483648
br i1 %82, label %83, label %84
83: ; preds = %78
br label %296
84: ; preds = %78
%85 = load i32, i32* %8
%86 = icmp ne i32 %85, 0
br i1 %86, label %120, label %87
87: ; preds = %84
br label %88
88: ; preds = %104, %87
%89 = load i32, i32* %9
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %119
91: ; preds = %88
%92 = load i32, i32* %9
store i32 %92, i32* %12
%93 = load i32, i32* %12
%94 = icmp sgt i32 %93, 2352
br i1 %94, label %95, label %96
95: ; preds = %91
store i32 2352, i32* %12
br label %96
96: ; preds = %95, %91
%97 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%98 = load i32, i32* %12
%99 = load i32*, i32** %4
%100 = call i32 @fread(i8* %97, i32 1, i32 %98, i32* %99)
%101 = load i32, i32* %12
%102 = icmp ne i32 %100, %101
br i1 %102, label %103, label %104
103: ; preds = %96
br label %293
104: ; preds = %96
%105 = load i32, i32* %6
%106 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%107 = load i32, i32* %12
%108 = call i32 @edc_partial_computeblock(i32 %105, i8* %106, i32 %107)
store i32 %108, i32* %6
%109 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%110 = load i32, i32* %12
%111 = load i32*, i32** %5
%112 = call i32 @fwrite(i8* %109, i32 1, i32 %110, i32* %111)
%113 = load i32, i32* %12
%114 = load i32, i32* %9
%115 = sub i32 %114, %113
store i32 %115, i32* %9
%116 = load i32*, i32** %4
%117 = call i32 @ftell(i32* %116)
%118 = call i32 @setcounter(i32 %117)
br label %88
119: ; preds = %88
br label %229
120: ; preds = %84
br label %121
121: ; preds = %227, %120
%122 = load i32, i32* %9
%123 = add i32 %122, -1
store i32 %123, i32* %9
%124 = icmp ne i32 %122, 0
br i1 %124, label %125, label %228
125: ; preds = %121
%126 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%127 = call i32 @memset(i8* %126, i32 0, i32 2352)
%128 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%129 = getelementptr inbounds i8, i8* %128, i64 1
%130 = call i32 @memset(i8* %129, i32 255, i32 10)
%131 = load i32, i32* %8
switch i32 %131, label %227 [
i32 1, label %132
i32 2, label %159
i32 3, label %193
]
132: ; preds = %125
%133 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 15
store i8 1, i8* %133
%134 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%135 = getelementptr inbounds i8, i8* %134, i64 12
%136 = load i32*, i32** %4
%137 = call i32 @fread(i8* %135, i32 1, i32 3, i32* %136)
%138 = icmp ne i32 %137, 3
br i1 %138, label %139, label %140
139: ; preds = %132
br label %293
140: ; preds = %132
%141 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%142 = getelementptr inbounds i8, i8* %141, i64 16
%143 = load i32*, i32** %4
%144 = call i32 @fread(i8* %142, i32 1, i32 2048, i32* %143)
%145 = icmp ne i32 %144, 2048
br i1 %145, label %146, label %147
146: ; preds = %140
br label %293
147: ; preds = %140
%148 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%149 = call i32 @eccedc_generate(i8* %148, i32 1)
%150 = load i32, i32* %6
%151 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%152 = call i32 @edc_partial_computeblock(i32 %150, i8* %151, i32 2352)
store i32 %152, i32* %6
%153 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%154 = load i32*, i32** %5
%155 = call i32 @fwrite(i8* %153, i32 2352, i32 1, i32* %154)
%156 = load i32*, i32** %4
%157 = call i32 @ftell(i32* %156)
%158 = call i32 @setcounter(i32 %157)
br label %227
159: ; preds = %125
%160 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 15
store i8 2, i8* %160
%161 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%162 = getelementptr inbounds i8, i8* %161, i64 20
%163 = load i32*, i32** %4
%164 = call i32 @fread(i8* %162, i32 1, i32 2052, i32* %163)
%165 = icmp ne i32 %164, 2052
br i1 %165, label %166, label %167
166: ; preds = %159
br label %293
167: ; preds = %159
%168 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 20
%169 = load i8, i8* %168
%170 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 16
store i8 %169, i8* %170
%171 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 21
%172 = load i8, i8* %171
%173 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 17
store i8 %172, i8* %173
%174 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 22
%175 = load i8, i8* %174
%176 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 18
store i8 %175, i8* %176
%177 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 23
%178 = load i8, i8* %177
%179 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 19
store i8 %178, i8* %179
%180 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%181 = call i32 @eccedc_generate(i8* %180, i32 2)
%182 = load i32, i32* %6
%183 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%184 = getelementptr inbounds i8, i8* %183, i64 16
%185 = call i32 @edc_partial_computeblock(i32 %182, i8* %184, i32 2336)
store i32 %185, i32* %6
%186 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%187 = getelementptr inbounds i8, i8* %186, i64 16
%188 = load i32*, i32** %5
%189 = call i32 @fwrite(i8* %187, i32 2336, i32 1, i32* %188)
%190 = load i32*, i32** %4
%191 = call i32 @ftell(i32* %190)
%192 = call i32 @setcounter(i32 %191)
br label %227
193: ; preds = %125
%194 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 15
store i8 2, i8* %194
%195 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%196 = getelementptr inbounds i8, i8* %195, i64 20
%197 = load i32*, i32** %4
%198 = call i32 @fread(i8* %196, i32 1, i32 2328, i32* %197)
%199 = icmp ne i32 %198, 2328
br i1 %199, label %200, label %201
200: ; preds = %193
br label %293
201: ; preds = %193
%202 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 20
%203 = load i8, i8* %202
%204 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 16
store i8 %203, i8* %204
%205 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 21
%206 = load i8, i8* %205
%207 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 17
store i8 %206, i8* %207
%208 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 22
%209 = load i8, i8* %208
%210 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 18
store i8 %209, i8* %210
%211 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 23
%212 = load i8, i8* %211
%213 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 19
store i8 %212, i8* %213
%214 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%215 = call i32 @eccedc_generate(i8* %214, i32 3)
%216 = load i32, i32* %6
%217 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%218 = getelementptr inbounds i8, i8* %217, i64 16
%219 = call i32 @edc_partial_computeblock(i32 %216, i8* %218, i32 2336)
store i32 %219, i32* %6
%220 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%221 = getelementptr inbounds i8, i8* %220, i64 16
%222 = load i32*, i32** %5
%223 = call i32 @fwrite(i8* %221, i32 2336, i32 1, i32* %222)
%224 = load i32*, i32** %4
%225 = call i32 @ftell(i32* %224)
%226 = call i32 @setcounter(i32 %225)
br label %227
227: ; preds = %125, %201, %167, %147
br label %121
228: ; preds = %121
br label %229
229: ; preds = %228, %119
br label %41
230: ; preds = %77
%231 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%232 = load i32*, i32** %4
%233 = call i32 @fread(i8* %231, i32 1, i32 4, i32* %232)
%234 = icmp ne i32 %233, 4
br i1 %234, label %235, label %236
235: ; preds = %230
br label %293
236: ; preds = %230
%237 = load i32, i32* @stderr
%238 = load i32*, i32** %4
%239 = call i32 @ftell(i32* %238)
%240 = load i32*, i32** %5
%241 = call i32 @ftell(i32* %240)
%242 = call i32 (i32, i8*, ...) @fprintf(i32 %237, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %239, i32 %241)
%243 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%244 = load i8, i8* %243
%245 = zext i8 %244 to i32
%246 = load i32, i32* %6
%247 = lshr i32 %246, 0
%248 = and i32 %247, 255
%249 = icmp ne i32 %245, %248
br i1 %249, label %274, label %250
250: ; preds = %236
%251 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 1
%252 = load i8, i8* %251
%253 = zext i8 %252 to i32
%254 = load i32, i32* %6
%255 = lshr i32 %254, 8
%256 = and i32 %255, 255
%257 = icmp ne i32 %253, %256
br i1 %257, label %274, label %258
258: ; preds = %250
%259 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 2
%260 = load i8, i8* %259
%261 = zext i8 %260 to i32
%262 = load i32, i32* %6
%263 = lshr i32 %262, 16
%264 = and i32 %263, 255
%265 = icmp ne i32 %261, %264
br i1 %265, label %274, label %266
266: ; preds = %258
%267 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 3
%268 = load i8, i8* %267
%269 = zext i8 %268 to i32
%270 = load i32, i32* %6
%271 = lshr i32 %270, 24
%272 = and i32 %271, 255
%273 = icmp ne i32 %269, %272
br i1 %273, label %274, label %290
274: ; preds = %266, %258, %250, %236
%275 = load i32, i32* @stderr
%276 = load i32, i32* %6
%277 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 3
%278 = load i8, i8* %277
%279 = zext i8 %278 to i32
%280 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 2
%281 = load i8, i8* %280
%282 = zext i8 %281 to i32
%283 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 1
%284 = load i8, i8* %283
%285 = zext i8 %284 to i32
%286 = getelementptr inbounds [2352 x i8], [2352 x i8]* %7, i64 0, i64 0
%287 = load i8, i8* %286
%288 = zext i8 %287 to i32
%289 = call i32 (i32, i8*, ...) @fprintf(i32 %275, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %276, i32 %279, i32 %282, i32 %285, i32 %288)
br label %296
290: ; preds = %266
%291 = load i32, i32* @stderr
%292 = call i32 (i32, i8*, ...) @fprintf(i32 %291, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %299
293: ; preds = %235, %200, %166, %146, %139, %103, %64, %47
%294 = load i32, i32* @stderr
%295 = call i32 (i32, i8*, ...) @fprintf(i32 %294, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %296
296: ; preds = %293, %274, %83, %37
%297 = load i32, i32* @stderr
%298 = call i32 (i32, i8*, ...) @fprintf(i32 %297, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %299
299: ; preds = %296, %290
%300 = load i32, i32* %3
ret i32 %300
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"Header not found!\0A\00"
@EOF = global i32 0
@.str.1 = [32 x i8] c"Decoded %ld bytes -> %ld bytes\0A\00"
@.str.2 = [46 x i8] c"EDC error (%08X, should be %02X%02X%02X%02X)\0A\00"
@.str.3 = [18 x i8] c"Done; file is OK\0A\00"
@.str.4 = [17 x i8] c"Unexpected EOF!\0A\00"
@.str.5 = [19 x i8] c"Corrupt ECM file!\0A\00"
define i32 @unecmify(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [2352 x i8]
%4 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @SEEK_END
%6 = tail call i32 @fseek(i32* %0, i32 0, i32 %5)
%7 = tail call i32 @ftell(i32* %0)
%8 = tail call i32 @resetcounter(i32 %7)
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %0, i32 0, i32 %9)
%11 = tail call i32 @fgetc(i32* %0)
%12 = icmp eq i32 %11, 69
br i1 %12, label %13, label %38
13: ; preds = %2
%14 = tail call i32 @fgetc(i32* %0)
%15 = icmp eq i32 %14, 67
br i1 %15, label %16, label %38
16: ; preds = %13
%17 = tail call i32 @fgetc(i32* %0)
%18 = icmp eq i32 %17, 77
br i1 %18, label %19, label %38
19: ; preds = %16
%20 = tail call i32 @fgetc(i32* %0)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = call i32 @fgetc(i32* %0)
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %173, label %26
26: ; preds = %22
%27 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 1
%28 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 15
%29 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 20
%30 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 16
%31 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 21
%32 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 17
%33 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 22
%34 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 18
%35 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 23
%36 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 19
%37 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 12
br label %41
38: ; preds = %19, %16, %13, %2
%39 = load i32, i32* @stderr
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %176
41: ; preds = %26, %129
%42 = phi i32 [ %23, %26 ], [ %131, %129 ]
%43 = phi i32 [ 0, %26 ], [ %130, %129 ]
%44 = and i32 %42, 3
%45 = lshr i32 %42, 2
%46 = and i32 %45, 31
%47 = and i32 %42, 128
%48 = icmp eq i32 %47, 0
br i1 %48, label %64, label %49
49: ; preds = %41, %55
%50 = phi i32 [ %59, %55 ], [ 5, %41 ]
%51 = phi i32 [ %58, %55 ], [ %46, %41 ]
%52 = call i32 @fgetc(i32* %0)
%53 = load i32, i32* @EOF
%54 = icmp eq i32 %52, %53
br i1 %54, label %173, label %55
55: ; preds = %49
%56 = and i32 %52, 127
%57 = shl i32 %56, %50
%58 = or i32 %57, %51
%59 = add nuw nsw i32 %50, 7
%60 = and i32 %52, 128
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %49
62: ; preds = %55
%63 = icmp eq i32 %58, -1
br i1 %63, label %134, label %64
64: ; preds = %41, %62
%65 = phi i32 [ %58, %62 ], [ %46, %41 ]
%66 = add nuw i32 %65, 1
%67 = icmp slt i32 %66, 0
br i1 %67, label %176, label %68
68: ; preds = %64
%69 = icmp eq i32 %44, 0
br i1 %69, label %70, label %84
70: ; preds = %68, %77
%71 = phi i32 [ %80, %77 ], [ %66, %68 ]
%72 = phi i32 [ %78, %77 ], [ %43, %68 ]
%73 = icmp slt i32 %71, 2352
%74 = select i1 %73, i32 %71, i32 2352
%75 = call i32 @fread(i8* %4, i32 1, i32 %74, i32* %0)
%76 = icmp eq i32 %75, %74
br i1 %76, label %77, label %173
77: ; preds = %70
%78 = call i32 @edc_partial_computeblock(i32 %72, i8* %4, i32 %74)
%79 = call i32 @fwrite(i8* %4, i32 1, i32 %74, i32* %1)
%80 = sub i32 %71, %74
%81 = call i32 @ftell(i32* %0)
%82 = call i32 @setcounter(i32 %81)
%83 = icmp eq i32 %80, 0
br i1 %83, label %129, label %70
84: ; preds = %68, %125
%85 = phi i32 [ %127, %125 ], [ %65, %68 ]
%86 = phi i32 [ %126, %125 ], [ %43, %68 ]
%87 = call i32 @memset(i8* %4, i32 0, i32 2352)
%88 = call i32 @memset(i8* %27, i32 255, i32 10)
switch i32 %44, label %125 [
i32 1, label %89
i32 2, label %99
i32 3, label %110
]
89: ; preds = %84
store i8 1, i8* %28
%90 = call i32 @fread(i8* %37, i32 1, i32 3, i32* %0)
%91 = icmp eq i32 %90, 3
br i1 %91, label %92, label %173
92: ; preds = %89
%93 = call i32 @fread(i8* %30, i32 1, i32 2048, i32* %0)
%94 = icmp eq i32 %93, 2048
br i1 %94, label %95, label %173
95: ; preds = %92
%96 = call i32 @eccedc_generate(i8* %4, i32 1)
%97 = call i32 @edc_partial_computeblock(i32 %86, i8* %4, i32 2352)
%98 = call i32 @fwrite(i8* %4, i32 2352, i32 1, i32* %1)
br label %121
99: ; preds = %84
store i8 2, i8* %28
%100 = call i32 @fread(i8* %29, i32 1, i32 2052, i32* %0)
%101 = icmp eq i32 %100, 2052
br i1 %101, label %102, label %173
102: ; preds = %99
%103 = load i8, i8* %29
store i8 %103, i8* %30
%104 = load i8, i8* %31
store i8 %104, i8* %32
%105 = load i8, i8* %33
store i8 %105, i8* %34
%106 = load i8, i8* %35
store i8 %106, i8* %36
%107 = call i32 @eccedc_generate(i8* %4, i32 2)
%108 = call i32 @edc_partial_computeblock(i32 %86, i8* %30, i32 2336)
%109 = call i32 @fwrite(i8* %30, i32 2336, i32 1, i32* %1)
br label %121
110: ; preds = %84
store i8 2, i8* %28
%111 = call i32 @fread(i8* %29, i32 1, i32 2328, i32* %0)
%112 = icmp eq i32 %111, 2328
br i1 %112, label %113, label %173
113: ; preds = %110
%114 = load i8, i8* %29
store i8 %114, i8* %30
%115 = load i8, i8* %31
store i8 %115, i8* %32
%116 = load i8, i8* %33
store i8 %116, i8* %34
%117 = load i8, i8* %35
store i8 %117, i8* %36
%118 = call i32 @eccedc_generate(i8* %4, i32 3)
%119 = call i32 @edc_partial_computeblock(i32 %86, i8* %30, i32 2336)
%120 = call i32 @fwrite(i8* %30, i32 2336, i32 1, i32* %1)
br label %121
121: ; preds = %95, %102, %113
%122 = phi i32 [ %97, %95 ], [ %108, %102 ], [ %119, %113 ]
%123 = call i32 @ftell(i32* %0)
%124 = call i32 @setcounter(i32 %123)
br label %125
125: ; preds = %121, %84
%126 = phi i32 [ %86, %84 ], [ %122, %121 ]
%127 = add i32 %85, -1
%128 = icmp eq i32 %85, 0
br i1 %128, label %129, label %84
129: ; preds = %125, %77
%130 = phi i32 [ %78, %77 ], [ %126, %125 ]
%131 = call i32 @fgetc(i32* %0)
%132 = load i32, i32* @EOF
%133 = icmp eq i32 %131, %132
br i1 %133, label %173, label %41
134: ; preds = %62
%135 = call i32 @fread(i8* %4, i32 1, i32 4, i32* %0)
%136 = icmp eq i32 %135, 4
br i1 %136, label %137, label %173
137: ; preds = %134
%138 = load i32, i32* @stderr
%139 = call i32 @ftell(i32* %0)
%140 = call i32 @ftell(i32* %1)
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %139, i32 %140)
%142 = load i8, i8* %4
%143 = trunc i32 %43 to i8
%144 = icmp eq i8 %142, %143
%145 = load i8, i8* %27
%146 = lshr i32 %43, 8
%147 = trunc i32 %146 to i8
%148 = icmp eq i8 %145, %147
%149 = select i1 %144, i1 %148, i1 false
br i1 %149, label %150, label %162
150: ; preds = %137
%151 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 2
%152 = load i8, i8* %151
%153 = lshr i32 %43, 16
%154 = trunc i32 %153 to i8
%155 = icmp eq i8 %152, %154
br i1 %155, label %156, label %162
156: ; preds = %150
%157 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 3
%158 = load i8, i8* %157
%159 = zext i8 %158 to i32
%160 = lshr i32 %43, 24
%161 = icmp eq i32 %160, %159
br i1 %161, label %176, label %162
162: ; preds = %137, %156, %150
%163 = load i32, i32* @stderr
%164 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 3
%165 = load i8, i8* %164
%166 = zext i8 %165 to i32
%167 = getelementptr inbounds [2352 x i8], [2352 x i8]* %3, i64 0, i64 2
%168 = load i8, i8* %167
%169 = zext i8 %168 to i32
%170 = zext i8 %145 to i32
%171 = zext i8 %142 to i32
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %163, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %166, i32 %169, i32 %170, i32 %171)
br label %176
173: ; preds = %129, %49, %110, %99, %92, %89, %70, %22, %134
%174 = load i32, i32* @stderr
%175 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %176
176: ; preds = %64, %38, %162, %173, %156
%177 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %156 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %173 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %162 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %38 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %64 ]
%178 = phi i32 [ 0, %156 ], [ 1, %173 ], [ 1, %162 ], [ 1, %38 ], [ 1, %64 ]
%179 = load i32, i32* @stderr
%180 = call i32 (i32, i8*, ...) @fprintf(i32 %179, i8* %177)
ret i32 %178
}