#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint8_t;
typedef int uint64_t;
typedef int int64_t;
typedef int int16_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int abs(int);
int atoi(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int int_sqrt(int);
int log16(int);
scalar_t__ memcmp(int *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int i, j;
  uint64_t sse = 0;
  uint64_t dev;
  FILE *f[2];
  uint8_t buf[2][2048];
  uint64_t psnr;
  int len = argc < 4 ? 1 : atoi(argv[3]);
  int64_t max = (1 << (8 * len)) - 1;
  int shift = argc < 5 ? 0 : atoi(argv[4]);
  int skip_bytes = argc < 6 ? 0 : atoi(argv[5]);
  int size0 = 0;
  int size1 = 0;
  int maxdist = 0;
  if (argc < 3) {
    printf(
        "tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\n");
    printf("WAV headers are skipped automatically.\n");
    return 1;
  }
  f[0] = fopen(argv[1], "rb");
  f[1] = fopen(argv[2], "rb");
  if (!f[0] || !f[1]) {
    fprintf(stderr, "Could not open input files.\n");
    return 1;
  }
  for (i = 0; i < 2; i++) {
    uint8_t *p = buf[i];
    if (fread(p, 1, 12, f[i]) != 12)
      return 1;
    if (!memcmp(p, "RIFF", 4) && !memcmp(p + 8, "WAVE", 4)) {
      if (fread(p, 1, 8, f[i]) != 8)
        return 1;
      while (memcmp(p, "data", 4)) {
        int s = p[4] | p[5] << 8 | p[6] << 16 | p[7] << 24;
        fseek(f[i], s, SEEK_CUR);
        if (fread(p, 1, 8, f[i]) != 8)
          return 1;
      }
    } else {
      fseek(f[i], -12, SEEK_CUR);
    }
  }
  fseek(f[shift < 0], abs(shift), SEEK_CUR);
  fseek(f[0], skip_bytes, SEEK_CUR);
  fseek(f[1], skip_bytes, SEEK_CUR);
  for (;;) {
    int s0 = fread(buf[0], 1, 2048, f[0]);
    int s1 = fread(buf[1], 1, 2048, f[1]);
    for (j = 0; j < ((s0) > (s1) ? (s1) : (s0)); j++) {
      int64_t a = buf[0][j];
      int64_t b = buf[1][j];
      int dist;
      if (len == 2) {
        a = (int16_t)(a | (buf[0][++j] << 8));
        b = (int16_t)(b | (buf[1][j] << 8));
      }
      sse += (a - b) * (a - b);
      dist = abs(a - b);
      if (dist > maxdist)
        maxdist = dist;
    }
    size0 += s0;
    size1 += s1;
    if (s0 + s1 <= 0)
      break;
  }
  i = ((size0) > (size1) ? (size1) : (size0)) / len;
  if (!i)
    i = 1;
  dev =
      int_sqrt(((sse / i) * 100 * 100) + (((sse % i) * 100 * 100) + i / 2) / i);
  if (sse)
    psnr = ((2 * log16(max << 16) + log16(i) - log16(sse)) * 284619LL * 100 +
            (1LL << 31)) /
           (1LL << 32);
  else
    psnr = 1000 * 100 - 1;
  printf("stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5d bytes:%9d/%9d\n",
         (int)(dev / 100), (int)(dev % 100), (int)(psnr / 100),
         (int)(psnr % 100), maxdist, size0, size1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11da <main+0x3a>
mov    $0x1,%eax
mov    %eax,-0x4074(%rbp)
jmp    11ed <main+0x4d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x4074(%rbp)
mov    -0x4074(%rbp),%eax
mov    %eax,-0x4038(%rbp)
mov    -0x4038(%rbp),%ecx
shl    $0x3,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    %eax,-0x403c(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1229 <main+0x89>
xor    %eax,%eax
mov    %eax,-0x4078(%rbp)
jmp    123c <main+0x9c>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x4078(%rbp)
mov    -0x4078(%rbp),%eax
mov    %eax,-0x4040(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    125f <main+0xbf>
xor    %eax,%eax
mov    %eax,-0x407c(%rbp)
jmp    1272 <main+0xd2>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x407c(%rbp)
mov    -0x407c(%rbp),%eax
mov    %eax,-0x4044(%rbp)
movl   $0x0,-0x4048(%rbp)
movl   $0x0,-0x404c(%rbp)
movl   $0x0,-0x4050(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    12ce <main+0x12e>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    18b3 <main+0x713>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd8d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd75(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1314 <main+0x174>
cmpq   $0x0,-0x28(%rbp)
jne    1335 <main+0x195>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
lea    0xd49(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    18b3 <main+0x713>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    14fd <main+0x35d>
movslq -0x14(%rbp),%rcx
lea    -0x4030(%rbp),%rax
shl    $0xd,%rcx
add    %rcx,%rax
mov    %rax,-0x4058(%rbp)
mov    -0x4058(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rcx
mov    $0x1,%esi
mov    $0xc,%edx
call   1030 <fread@plt>
cmp    $0xc,%eax
je     1393 <main+0x1f3>
movl   $0x1,-0x4(%rbp)
jmp    18b3 <main+0x713>
mov    -0x4058(%rbp),%rdi
lea    0xce9(%rip),%rsi
mov    $0x4,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
jne    14ce <main+0x32e>
mov    -0x4058(%rbp),%rdi
add    $0x20,%rdi
lea    0xcc8(%rip),%rsi
mov    $0x4,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
jne    14ce <main+0x32e>
mov    -0x4058(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
cmp    $0x8,%eax
je     140f <main+0x26f>
movl   $0x1,-0x4(%rbp)
jmp    18b3 <main+0x713>
jmp    1414 <main+0x274>
mov    -0x4058(%rbp),%rdi
lea    0xc72(%rip),%rsi
mov    $0x4,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     14c9 <main+0x329>
mov    -0x4058(%rbp),%rax
mov    0x10(%rax),%eax
mov    -0x4058(%rbp),%rcx
mov    0x14(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x4058(%rbp),%rcx
mov    0x18(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x4058(%rbp),%rcx
mov    0x1c(%rcx),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x405c(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
mov    -0x405c(%rbp),%esi
mov    0x2b5f(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x4058(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
cmp    $0x8,%eax
je     14c4 <main+0x324>
movl   $0x1,-0x4(%rbp)
jmp    18b3 <main+0x713>
jmp    1414 <main+0x274>
jmp    14ea <main+0x34a>
movslq -0x14(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
mov    0x2b0a(%rip),%rax
mov    (%rax),%edx
mov    $0xfffffff4,%esi
call   1080 <fseek@plt>
jmp    14ef <main+0x34f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    133c <main+0x19c>
cmpl   $0x0,-0x4040(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    -0x30(%rbp,%rax,8),%rax
mov    %rax,-0x4088(%rbp)
mov    -0x4040(%rbp),%edi
call   1040 <abs@plt>
mov    -0x4088(%rbp),%rdi
mov    %eax,%esi
mov    0x2ab3(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x30(%rbp),%rdi
mov    -0x4044(%rbp),%esi
mov    0x2a9b(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x28(%rbp),%rdi
mov    -0x4044(%rbp),%esi
mov    0x2a83(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
lea    -0x4030(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
mov    $0x800,%edx
call   1030 <fread@plt>
mov    %eax,-0x4060(%rbp)
lea    -0x4030(%rbp),%rdi
add    $0x2000,%rdi
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
mov    $0x800,%edx
call   1030 <fread@plt>
mov    %eax,-0x4064(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x408c(%rbp)
mov    -0x4060(%rbp),%eax
cmp    -0x4064(%rbp),%eax
jle    15e6 <main+0x446>
mov    -0x4064(%rbp),%eax
mov    %eax,-0x4090(%rbp)
jmp    15f2 <main+0x452>
mov    -0x4060(%rbp),%eax
mov    %eax,-0x4090(%rbp)
mov    -0x408c(%rbp),%eax
mov    -0x4090(%rbp),%ecx
cmp    %ecx,%eax
jge    16de <main+0x53e>
movslq -0x18(%rbp),%rax
mov    -0x4030(%rbp,%rax,4),%eax
mov    %eax,-0x4068(%rbp)
movslq -0x18(%rbp),%rax
mov    -0x2030(%rbp,%rax,4),%eax
mov    %eax,-0x406c(%rbp)
cmpl   $0x2,-0x4038(%rbp)
jne    1675 <main+0x4d5>
mov    -0x4068(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
movslq %ecx,%rcx
mov    -0x4030(%rbp,%rcx,4),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x4068(%rbp)
mov    -0x406c(%rbp),%eax
movslq -0x18(%rbp),%rcx
mov    -0x2030(%rbp,%rcx,4),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x406c(%rbp)
mov    -0x4068(%rbp),%eax
sub    -0x406c(%rbp),%eax
mov    -0x4068(%rbp),%ecx
sub    -0x406c(%rbp),%ecx
imul   %ecx,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4068(%rbp),%edi
sub    -0x406c(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0x4070(%rbp)
mov    -0x4070(%rbp),%eax
cmp    -0x4050(%rbp),%eax
jle    16cb <main+0x52b>
mov    -0x4070(%rbp),%eax
mov    %eax,-0x4050(%rbp)
jmp    16d0 <main+0x530>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    15ba <main+0x41a>
mov    -0x4060(%rbp),%eax
add    -0x4048(%rbp),%eax
mov    %eax,-0x4048(%rbp)
mov    -0x4064(%rbp),%eax
add    -0x404c(%rbp),%eax
mov    %eax,-0x404c(%rbp)
mov    -0x4060(%rbp),%eax
add    -0x4064(%rbp),%eax
cmp    $0x0,%eax
jg     171c <main+0x57c>
jmp    1721 <main+0x581>
jmp    156c <main+0x3cc>
mov    -0x4048(%rbp),%eax
cmp    -0x404c(%rbp),%eax
jle    1744 <main+0x5a4>
mov    -0x404c(%rbp),%eax
mov    %eax,-0x4094(%rbp)
jmp    1750 <main+0x5b0>
mov    -0x4048(%rbp),%eax
mov    %eax,-0x4094(%rbp)
mov    -0x4094(%rbp),%eax
cltd
idivl  -0x4038(%rbp)
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1771 <main+0x5d1>
movl   $0x1,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x14(%rbp)
imul   $0x64,%eax,%eax
imul   $0x64,%eax,%edi
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x14(%rbp)
imul   $0x64,%edx,%eax
imul   $0x64,%eax,%eax
mov    %eax,-0x4098(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4098(%rbp),%eax
add    %ecx,%eax
cltd
idivl  -0x14(%rbp)
add    %eax,%edi
call   10c0 <int_sqrt@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1833 <main+0x693>
mov    -0x403c(%rbp),%edi
shl    $0x10,%edi
call   10a0 <log16@plt>
shl    $0x1,%eax
mov    %eax,-0x40a0(%rbp)
mov    -0x14(%rbp),%edi
call   10a0 <log16@plt>
mov    %eax,%ecx
mov    -0x40a0(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x409c(%rbp)
mov    -0x1c(%rbp),%edi
call   10a0 <log16@plt>
mov    %eax,%ecx
mov    -0x409c(%rbp),%eax
sub    %ecx,%eax
cltq
imul   $0x457cb,%rax,%rax
imul   $0x64,%rax,%rax
movabs $0x80000000,%rcx
add    %rcx,%rax
movabs $0x100000000,%rcx
cqto
idiv   %rcx
mov    %eax,-0x4034(%rbp)
jmp    183d <main+0x69d>
movl   $0x1869f,-0x4034(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x20(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x40a4(%rbp)
mov    -0x4034(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4034(%rbp),%eax
mov    $0x64,%edi
cltd
idiv   %edi
mov    %edx,%r8d
mov    -0x40a4(%rbp),%edx
mov    -0x4050(%rbp),%r9d
mov    -0x4048(%rbp),%r10d
mov    -0x404c(%rbp),%eax
lea    0x7fc(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4038,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
cmp    $0x4,%edi
jge    11ce <main+0x2e>
cmp    $0x3,%ebp
jne    11ff <main+0x5f>
mov    $0x1,%r15d
mov    $0xff,%r13d
jmp    11f3 <main+0x53>
mov    0x18(%r14),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r15d
lea    0x0(,%r15,8),%ecx
mov    $0xffffffff,%r13d
shl    %cl,%r13d
not    %r13d
cmp    $0x4,%ebp
jne    121c <main+0x7c>
movl   $0x0,(%rsp)
xor    %r12d,%r12d
jmp    1242 <main+0xa2>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
jmp    14b5 <main+0x315>
mov    0x20(%r14),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r12d
cmp    $0x6,%ebp
jae    1236 <main+0x96>
movl   $0x0,(%rsp)
jmp    1242 <main+0xa2>
mov    0x28(%r14),%rdi
call   10b0 <atoi@plt>
mov    %eax,(%rsp)
mov    0x8(%r14),%rdi
lea    0xdb3(%rip),%rbp
mov    %rbp,%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    %rax,0x20(%rsp)
mov    0x10(%r14),%rdi
mov    %rbp,%rsi
call   1090 <fopen@plt>
mov    %rax,0x28(%rsp)
mov    %rbx,0x8(%rsp)
test   %rbx,%rbx
je     14a0 <main+0x300>
test   %rax,%rax
je     14a0 <main+0x300>
mov    %rax,0x10(%rsp)
lea    0x30(%rsp),%rdi
mov    $0x1,%r14d
mov    $0x1,%esi
mov    $0xc,%edx
mov    0x8(%rsp),%rcx
call   1040 <fread@plt>
cmp    $0xc,%eax
jne    14bb <main+0x31b>
lea    0xd67(%rip),%rsi
lea    0x30(%rsp),%rdi
mov    $0x4,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
jne    12ec <main+0x14c>
lea    0x50(%rsp),%rdi
lea    0xd4c(%rip),%rsi
mov    $0x4,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     15ca <main+0x42a>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edx
mov    0x8(%rsp),%rdi
mov    $0xfffffff4,%esi
call   1080 <fseek@plt>
lea    0x2030(%rsp),%rbp
mov    $0x1,%r14d
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0xc,%edx
mov    0x10(%rsp),%rcx
call   1040 <fread@plt>
cmp    $0xc,%eax
jne    14bb <main+0x31b>
lea    0xce7(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
jne    136d <main+0x1cd>
lea    0x2050(%rsp),%rdi
lea    0xccb(%rip),%rsi
mov    $0x4,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     167a <main+0x4da>
mov    0x2c74(%rip),%rax
mov    (%rax),%edx
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xfffffff4,%esi
call   1080 <fseek@plt>
mov    %r13d,0x1c(%rsp)
mov    %r12d,%eax
shr    $0x1f,%eax
mov    0x20(%rsp,%rax,8),%rdi
mov    %r12d,%esi
neg    %esi
cmovs  %r12d,%esi
mov    0x2c40(%rip),%r14
mov    (%r14),%edx
call   1080 <fseek@plt>
mov    (%r14),%edx
mov    0x8(%rsp),%rdi
mov    (%rsp),%ebx
mov    %ebx,%esi
call   1080 <fseek@plt>
mov    (%r14),%edx
mov    %rbp,%rdi
mov    %ebx,%esi
call   1080 <fseek@plt>
xor    %ecx,%ecx
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    13f3 <main+0x253>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rcx
add    %r14d,%ecx
add    %eax,%r13d
add    %r14d,%eax
jle    14d0 <main+0x330>
mov    %rcx,(%rsp)
lea    0x30(%rsp),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
mov    0x8(%rsp),%rcx
call   1040 <fread@plt>
mov    %eax,%r14d
lea    0x2030(%rsp),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
mov    0x10(%rsp),%rcx
call   1040 <fread@plt>
cmp    %eax,%r14d
mov    %r14d,%r8d
cmovg  %eax,%r8d
test   %r8d,%r8d
jle    13e0 <main+0x240>
xor    %edx,%edx
jmp    1472 <main+0x2d2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
sub    %edi,%esi
mov    %esi,%ecx
imul   %esi,%ecx
add    %ecx,%r12d
mov    %esi,%ecx
neg    %ecx
cmovs  %esi,%ecx
cmp    %ebp,%ecx
cmovg  %ecx,%ebp
add    $0x1,%edx
cmp    %r8d,%edx
jge    13e0 <main+0x240>
movslq %edx,%rbx
mov    0x30(%rsp,%rbx,4),%esi
mov    0x2030(%rsp,%rbx,4),%edi
cmp    $0x2,%r15d
jne    1450 <main+0x2b0>
lea    0x1(%rbx),%edx
mov    0x34(%rsp,%rbx,4),%ecx
shl    $0x8,%ecx
or     %ecx,%esi
mov    0x2034(%rsp,%rbx,4),%ecx
shl    $0x8,%ecx
or     %ecx,%edi
jmp    1450 <main+0x2b0>
mov    0x2b31(%rip),%rax
mov    (%rax),%edi
lea    0xb53(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x4038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    %r13d,%ecx
mov    %rcx,(%rsp)
mov    %ecx,%eax
cmovg  %r13d,%eax
cltd
idiv   %r15d
test   %eax,%eax
mov    $0x1,%ebx
cmovne %eax,%ebx
mov    %r12d,%eax
cltd
idiv   %ebx
imul   $0x2710,%eax,%edi
imul   $0x2710,%edx,%ecx
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
add    %ecx,%eax
cltd
idiv   %ebx
add    %eax,%edi
call   10c0 <int_sqrt@plt>
mov    %eax,%r15d
test   %r12d,%r12d
je     1569 <main+0x3c9>
mov    0x1c(%rsp),%edi
shl    $0x10,%edi
call   10a0 <log16@plt>
mov    %eax,%r14d
mov    %ebx,%edi
call   10a0 <log16@plt>
lea    (%rax,%r14,2),%ebx
mov    %r12d,%edi
call   10a0 <log16@plt>
sub    %eax,%ebx
movslq %ebx,%rax
imul   $0x1b24b4c,%rax,%rcx
movabs $0x17fffffff,%rax
add    %rcx,%rax
sub    $0xffffffff80000000,%rcx
test   %rcx,%rcx
cmovns %rcx,%rax
shr    $0x20,%rax
jmp    156e <main+0x3ce>
mov    $0x1869f,%eax
movslq %r15d,%rdx
imul   $0x51eb851f,%rdx,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rsi
add    %ecx,%esi
imul   $0x64,%esi,%ecx
sub    %ecx,%edx
movslq %eax,%r8
imul   $0x51eb851f,%r8,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x25,%rcx
add    %eax,%ecx
imul   $0x64,%ecx,%eax
sub    %eax,%r8d
lea    0xa81(%rip),%rdi
xor    %r14d,%r14d
mov    %ebp,%r9d
xor    %eax,%eax
push   %r13
push   0x8(%rsp)
call   1050 <printf@plt>
add    $0x10,%rsp
jmp    14bb <main+0x31b>
lea    0x30(%rsp),%rdi
mov    $0x1,%r14d
mov    $0x1,%esi
mov    $0x8,%edx
mov    0x8(%rsp),%rcx
call   1040 <fread@plt>
cmp    $0x8,%eax
jne    14bb <main+0x31b>
lea    0x30(%rsp),%rbp
mov    0x8(%rsp),%rbx
mov    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
lea    0xa10(%rip),%rsi
mov    $0x4,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     1304 <main+0x164>
mov    0x44(%rsp),%eax
mov    0x48(%rsp),%ecx
shl    $0x8,%eax
or     0x40(%rsp),%eax
shl    $0x10,%ecx
mov    0x4c(%rsp),%esi
shl    $0x18,%esi
or     %ecx,%esi
or     %eax,%esi
mov    0x2997(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1080 <fseek@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x8,%eax
je     1610 <main+0x470>
jmp    14bb <main+0x31b>
mov    $0x1,%r14d
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    0x10(%rsp),%rcx
call   1040 <fread@plt>
cmp    $0x8,%eax
jne    14bb <main+0x31b>
lea    0x983(%rip),%rbx
mov    $0x1,%r14d
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
mov    0x10(%rsp),%rbp
je     1388 <main+0x1e8>
mov    0x2044(%rsp),%eax
mov    0x2048(%rsp),%ecx
shl    $0x8,%eax
or     0x2040(%rsp),%eax
shl    $0x10,%ecx
mov    0x204c(%rsp),%esi
shl    $0x18,%esi
or     %ecx,%esi
or     %eax,%esi
mov    0x28ed(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
call   1080 <fseek@plt>
mov    %rbp,%rcx
lea    0x2030(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
call   1040 <fread@plt>
cmp    $0x8,%eax
je     16ad <main+0x50d>
jmp    14bb <main+0x31b>

LLVM IR (-O0):
@.str = [66 x i8] c"tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\0A\00"
@.str.1 = [40 x i8] c"WAV headers are skipped automatically.\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.3 = [29 x i8] c"Could not open input files.\0A\00"
@.str.4 = [5 x i8] c"RIFF\00"
@.str.5 = [5 x i8] c"WAVE\00"
@.str.6 = [5 x i8] c"data\00"
@SEEK_CUR = global i32 0
@.str.7 = [57 x i8] c"stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5d bytes:%9d/%9d\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 [2 x i32*]
%11 = alloca [2 x [2048 x i32]]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 4
br i1 %28, label %29, label %30
29: ; preds = %2
br label %35
30: ; preds = %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
br label %35
35: ; preds = %30, %29
%36 = phi i32 [ 1, %29 ], [ %34, %30 ]
store i32 %36, i32* %13
%37 = load i32, i32* %13
%38 = mul nsw i32 8, %37
%39 = shl i32 1, %38
%40 = sub nsw i32 %39, 1
store i32 %40, i32* %14
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 5
br i1 %42, label %43, label %44
43: ; preds = %35
br label %49
44: ; preds = %35
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 4
%47 = load i8*, i8** %46
%48 = call i32 @atoi(i8* %47)
br label %49
49: ; preds = %44, %43
%50 = phi i32 [ 0, %43 ], [ %48, %44 ]
store i32 %50, i32* %15
%51 = load i32, i32* %4
%52 = icmp slt i32 %51, 6
br i1 %52, label %53, label %54
53: ; preds = %49
br label %59
54: ; preds = %49
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 5
%57 = load i8*, i8** %56
%58 = call i32 @atoi(i8* %57)
br label %59
59: ; preds = %54, %53
%60 = phi i32 [ 0, %53 ], [ %58, %54 ]
store i32 %60, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
%61 = load i32, i32* %4
%62 = icmp slt i32 %61, 3
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %351
66: ; preds = %59
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 1
%69 = load i8*, i8** %68
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%71 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 0
store i32* %70, i32** %71
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 2
%74 = load i8*, i8** %73
%75 = call i32* @fopen(i8* %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%76 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 1
store i32* %75, i32** %76
%77 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 0
%78 = load i32*, i32** %77
%79 = icmp ne i32* %78, null
br i1 %79, label %80, label %84
80: ; preds = %66
%81 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 1
%82 = load i32*, i32** %81
%83 = icmp ne i32* %82, null
br i1 %83, label %87, label %84
84: ; preds = %80, %66
%85 = load i32, i32* @stderr
%86 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %351
87: ; preds = %80
store i32 0, i32* %6
br label %88
88: ; preds = %171, %87
%89 = load i32, i32* %6
%90 = icmp slt i32 %89, 2
br i1 %90, label %91, label %174
91: ; preds = %88
%92 = load i32, i32* %6
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %11, i64 0, i64 %93
%95 = getelementptr inbounds [2048 x i32], [2048 x i32]* %94, i64 0, i64 0
store i32* %95, i32** %20
%96 = load i32*, i32** %20
%97 = load i32, i32* %6
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 %98
%100 = load i32*, i32** %99
%101 = call i32 @fread(i32* %96, i32 1, i32 12, i32* %100)
%102 = icmp ne i32 %101, 12
br i1 %102, label %103, label %104
103: ; preds = %91
store i32 1, i32* %3
br label %351
104: ; preds = %91
%105 = load i32*, i32** %20
%106 = call i64 @memcmp(i32* %105, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%107 = icmp ne i64 %106, 0
br i1 %107, label %163, label %108
108: ; preds = %104
%109 = load i32*, i32** %20
%110 = getelementptr inbounds i32, i32* %109, i64 8
%111 = call i64 @memcmp(i32* %110, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%112 = icmp ne i64 %111, 0
br i1 %112, label %163, label %113
113: ; preds = %108
%114 = load i32*, i32** %20
%115 = load i32, i32* %6
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 %116
%118 = load i32*, i32** %117
%119 = call i32 @fread(i32* %114, i32 1, i32 8, i32* %118)
%120 = icmp ne i32 %119, 8
br i1 %120, label %121, label %122
121: ; preds = %113
store i32 1, i32* %3
br label %351
122: ; preds = %113
br label %123
123: ; preds = %161, %122
%124 = load i32*, i32** %20
%125 = call i64 @memcmp(i32* %124, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%126 = icmp ne i64 %125, 0
br i1 %126, label %127, label %162
127: ; preds = %123
%128 = load i32*, i32** %20
%129 = getelementptr inbounds i32, i32* %128, i64 4
%130 = load i32, i32* %129
%131 = load i32*, i32** %20
%132 = getelementptr inbounds i32, i32* %131, i64 5
%133 = load i32, i32* %132
%134 = shl i32 %133, 8
%135 = or i32 %130, %134
%136 = load i32*, i32** %20
%137 = getelementptr inbounds i32, i32* %136, i64 6
%138 = load i32, i32* %137
%139 = shl i32 %138, 16
%140 = or i32 %135, %139
%141 = load i32*, i32** %20
%142 = getelementptr inbounds i32, i32* %141, i64 7
%143 = load i32, i32* %142
%144 = shl i32 %143, 24
%145 = or i32 %140, %144
store i32 %145, i32* %21
%146 = load i32, i32* %6
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 %147
%149 = load i32*, i32** %148
%150 = load i32, i32* %21
%151 = load i32, i32* @SEEK_CUR
%152 = call i32 @fseek(i32* %149, i32 %150, i32 %151)
%153 = load i32*, i32** %20
%154 = load i32, i32* %6
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 %155
%157 = load i32*, i32** %156
%158 = call i32 @fread(i32* %153, i32 1, i32 8, i32* %157)
%159 = icmp ne i32 %158, 8
br i1 %159, label %160, label %161
160: ; preds = %127
store i32 1, i32* %3
br label %351
161: ; preds = %127
br label %123
162: ; preds = %123
br label %170
163: ; preds = %108, %104
%164 = load i32, i32* %6
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 %165
%167 = load i32*, i32** %166
%168 = load i32, i32* @SEEK_CUR
%169 = call i32 @fseek(i32* %167, i32 -12, i32 %168)
br label %170
170: ; preds = %163, %162
br label %171
171: ; preds = %170
%172 = load i32, i32* %6
%173 = add nsw i32 %172, 1
store i32 %173, i32* %6
br label %88
174: ; preds = %88
%175 = load i32, i32* %15
%176 = icmp slt i32 %175, 0
%177 = zext i1 %176 to i32
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 %178
%180 = load i32*, i32** %179
%181 = load i32, i32* %15
%182 = call i32 @abs(i32 %181)
%183 = load i32, i32* @SEEK_CUR
%184 = call i32 @fseek(i32* %180, i32 %182, i32 %183)
%185 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 0
%186 = load i32*, i32** %185
%187 = load i32, i32* %16
%188 = load i32, i32* @SEEK_CUR
%189 = call i32 @fseek(i32* %186, i32 %187, i32 %188)
%190 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 1
%191 = load i32*, i32** %190
%192 = load i32, i32* %16
%193 = load i32, i32* @SEEK_CUR
%194 = call i32 @fseek(i32* %191, i32 %192, i32 %193)
br label %195
195: ; preds = %284, %174
%196 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %11, i64 0, i64 0
%197 = getelementptr inbounds [2048 x i32], [2048 x i32]* %196, i64 0, i64 0
%198 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 0
%199 = load i32*, i32** %198
%200 = call i32 @fread(i32* %197, i32 1, i32 2048, i32* %199)
store i32 %200, i32* %22
%201 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %11, i64 0, i64 1
%202 = getelementptr inbounds [2048 x i32], [2048 x i32]* %201, i64 0, i64 0
%203 = getelementptr inbounds [2 x i32*], [2 x i32*]* %10, i64 0, i64 1
%204 = load i32*, i32** %203
%205 = call i32 @fread(i32* %202, i32 1, i32 2048, i32* %204)
store i32 %205, i32* %23
store i32 0, i32* %7
br label %206
206: ; preds = %269, %195
%207 = load i32, i32* %7
%208 = load i32, i32* %22
%209 = load i32, i32* %23
%210 = icmp sgt i32 %208, %209
br i1 %210, label %211, label %213
211: ; preds = %206
%212 = load i32, i32* %23
br label %215
213: ; preds = %206
%214 = load i32, i32* %22
br label %215
215: ; preds = %213, %211
%216 = phi i32 [ %212, %211 ], [ %214, %213 ]
%217 = icmp slt i32 %207, %216
br i1 %217, label %218, label %272
218: ; preds = %215
%219 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %11, i64 0, i64 0
%220 = load i32, i32* %7
%221 = sext i32 %220 to i64
%222 = getelementptr inbounds [2048 x i32], [2048 x i32]* %219, i64 0, i64 %221
%223 = load i32, i32* %222
store i32 %223, i32* %24
%224 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %11, i64 0, i64 1
%225 = load i32, i32* %7
%226 = sext i32 %225 to i64
%227 = getelementptr inbounds [2048 x i32], [2048 x i32]* %224, i64 0, i64 %226
%228 = load i32, i32* %227
store i32 %228, i32* %25
%229 = load i32, i32* %13
%230 = icmp eq i32 %229, 2
br i1 %230, label %231, label %249
231: ; preds = %218
%232 = load i32, i32* %24
%233 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %11, i64 0, i64 0
%234 = load i32, i32* %7
%235 = add nsw i32 %234, 1
store i32 %235, i32* %7
%236 = sext i32 %235 to i64
%237 = getelementptr inbounds [2048 x i32], [2048 x i32]* %233, i64 0, i64 %236
%238 = load i32, i32* %237
%239 = shl i32 %238, 8
%240 = or i32 %232, %239
store i32 %240, i32* %24
%241 = load i32, i32* %25
%242 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %11, i64 0, i64 1
%243 = load i32, i32* %7
%244 = sext i32 %243 to i64
%245 = getelementptr inbounds [2048 x i32], [2048 x i32]* %242, i64 0, i64 %244
%246 = load i32, i32* %245
%247 = shl i32 %246, 8
%248 = or i32 %241, %247
store i32 %248, i32* %25
br label %249
249: ; preds = %231, %218
%250 = load i32, i32* %24
%251 = load i32, i32* %25
%252 = sub nsw i32 %250, %251
%253 = load i32, i32* %24
%254 = load i32, i32* %25
%255 = sub nsw i32 %253, %254
%256 = mul nsw i32 %252, %255
%257 = load i32, i32* %8
%258 = add nsw i32 %257, %256
store i32 %258, i32* %8
%259 = load i32, i32* %24
%260 = load i32, i32* %25
%261 = sub nsw i32 %259, %260
%262 = call i32 @abs(i32 %261)
store i32 %262, i32* %26
%263 = load i32, i32* %26
%264 = load i32, i32* %19
%265 = icmp sgt i32 %263, %264
br i1 %265, label %266, label %268
266: ; preds = %249
%267 = load i32, i32* %26
store i32 %267, i32* %19
br label %268
268: ; preds = %266, %249
br label %269
269: ; preds = %268
%270 = load i32, i32* %7
%271 = add nsw i32 %270, 1
store i32 %271, i32* %7
br label %206
272: ; preds = %215
%273 = load i32, i32* %22
%274 = load i32, i32* %17
%275 = add nsw i32 %274, %273
store i32 %275, i32* %17
%276 = load i32, i32* %23
%277 = load i32, i32* %18
%278 = add nsw i32 %277, %276
store i32 %278, i32* %18
%279 = load i32, i32* %22
%280 = load i32, i32* %23
%281 = add nsw i32 %279, %280
%282 = icmp sle i32 %281, 0
br i1 %282, label %283, label %284
283: ; preds = %272
br label %285
284: ; preds = %272
br label %195
285: ; preds = %283
%286 = load i32, i32* %17
%287 = load i32, i32* %18
%288 = icmp sgt i32 %286, %287
br i1 %288, label %289, label %291
289: ; preds = %285
%290 = load i32, i32* %18
br label %293
291: ; preds = %285
%292 = load i32, i32* %17
br label %293
293: ; preds = %291, %289
%294 = phi i32 [ %290, %289 ], [ %292, %291 ]
%295 = load i32, i32* %13
%296 = sdiv i32 %294, %295
store i32 %296, i32* %6
%297 = load i32, i32* %6
%298 = icmp ne i32 %297, 0
br i1 %298, label %300, label %299
299: ; preds = %293
store i32 1, i32* %6
br label %300
300: ; preds = %299, %293
%301 = load i32, i32* %8
%302 = load i32, i32* %6
%303 = sdiv i32 %301, %302
%304 = mul nsw i32 %303, 100
%305 = mul nsw i32 %304, 100
%306 = load i32, i32* %8
%307 = load i32, i32* %6
%308 = srem i32 %306, %307
%309 = mul nsw i32 %308, 100
%310 = mul nsw i32 %309, 100
%311 = load i32, i32* %6
%312 = sdiv i32 %311, 2
%313 = add nsw i32 %310, %312
%314 = load i32, i32* %6
%315 = sdiv i32 %313, %314
%316 = add nsw i32 %305, %315
%317 = call i32 @int_sqrt(i32 %316)
store i32 %317, i32* %9
%318 = load i32, i32* %8
%319 = icmp ne i32 %318, 0
br i1 %319, label %320, label %337
320: ; preds = %300
%321 = load i32, i32* %14
%322 = shl i32 %321, 16
%323 = call i32 @log16(i32 %322)
%324 = mul nsw i32 2, %323
%325 = load i32, i32* %6
%326 = call i32 @log16(i32 %325)
%327 = add nsw i32 %324, %326
%328 = load i32, i32* %8
%329 = call i32 @log16(i32 %328)
%330 = sub nsw i32 %327, %329
%331 = sext i32 %330 to i64
%332 = mul nsw i64 %331, 284619
%333 = mul nsw i64 %332, 100
%334 = add nsw i64 %333, 2147483648
%335 = sdiv i64 %334, 4294967296
%336 = trunc i64 %335 to i32
store i32 %336, i32* %12
br label %338
337: ; preds = %300
store i32 99999, i32* %12
br label %338
338: ; preds = %337, %320
%339 = load i32, i32* %9
%340 = sdiv i32 %339, 100
%341 = load i32, i32* %9
%342 = srem i32 %341, 100
%343 = load i32, i32* %12
%344 = sdiv i32 %343, 100
%345 = load i32, i32* %12
%346 = srem i32 %345, 100
%347 = load i32, i32* %19
%348 = load i32, i32* %17
%349 = load i32, i32* %18
%350 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), i32 %340, i32 %342, i32 %344, i32 %346, i32 %347, i32 %348, i32 %349)
store i32 0, i32* %3
br label %351
351: ; preds = %338, %160, %121, %103, %84, %63
%352 = load i32, i32* %3
ret i32 %352
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.3 = [29 x i8] c"Could not open input files.\0A\00"
@.str.4 = [5 x i8] c"RIFF\00"
@.str.5 = [5 x i8] c"WAVE\00"
@.str.6 = [5 x i8] c"data\00"
@SEEK_CUR = global i32 0
@.str.7 = [57 x i8] c"stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5d bytes:%9d/%9d\0A\00"
@str = [65 x i8] c"tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\00"
@str.8 = [39 x i8] c"WAV headers are skipped automatically.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32*]
%4 = alloca [2 x [2048 x i32]]
%5 = bitcast [2 x i32*]* %3 to i8*
%6 = bitcast [2 x [2048 x i32]]* %4 to i8*
%7 = icmp slt i32 %0, 4
br i1 %7, label %25, label %8
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = shl nsw i32 %11, 3
%13 = shl nsw i32 -1, %12
%14 = xor i32 %13, -1
%15 = icmp eq i32 %0, 4
br i1 %15, label %30, label %16
16: ; preds = %8
%17 = getelementptr inbounds i8*, i8** %1, i64 4
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = icmp ult i32 %0, 6
br i1 %20, label %30, label %21
21: ; preds = %16
%22 = getelementptr inbounds i8*, i8** %1, i64 5
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
br label %30
25: ; preds = %2
%26 = icmp eq i32 %0, 3
br i1 %26, label %30, label %27
27: ; preds = %25
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.8, i64 0, i64 0))
br label %227
30: ; preds = %21, %16, %8, %25
%31 = phi i32 [ 0, %25 ], [ 0, %8 ], [ 0, %16 ], [ %24, %21 ]
%32 = phi i32 [ 255, %25 ], [ %14, %8 ], [ %14, %16 ], [ %14, %21 ]
%33 = phi i32 [ 1, %25 ], [ %11, %8 ], [ %11, %16 ], [ %11, %21 ]
%34 = phi i32 [ 0, %25 ], [ 0, %8 ], [ %19, %16 ], [ %19, %21 ]
%35 = getelementptr inbounds i8*, i8** %1, i64 1
%36 = load i8*, i8** %35
%37 = tail call i32* @fopen(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%38 = getelementptr inbounds [2 x i32*], [2 x i32*]* %3, i64 0, i64 0
store i32* %37, i32** %38
%39 = getelementptr inbounds i8*, i8** %1, i64 2
%40 = load i8*, i8** %39
%41 = tail call i32* @fopen(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%42 = getelementptr inbounds [2 x i32*], [2 x i32*]* %3, i64 0, i64 1
store i32* %41, i32** %42
%43 = icmp ne i32* %37, null
%44 = icmp ne i32* %41, null
%45 = and i1 %43, %44
br i1 %45, label %46, label %50
46: ; preds = %30
%47 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 0, i64 0
%48 = call i32 @fread(i32* %47, i32 1, i32 12, i32* %37)
%49 = icmp eq i32 %48, 12
br i1 %49, label %53, label %227
50: ; preds = %30
%51 = load i32, i32* @stderr
%52 = tail call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %227
53: ; preds = %46
%54 = call i64 @memcmp(i32* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %86
56: ; preds = %53
%57 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 0, i64 8
%58 = call i64 @memcmp(i32* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %86
60: ; preds = %56
%61 = call i32 @fread(i32* %47, i32 1, i32 8, i32* %37)
%62 = icmp eq i32 %61, 8
br i1 %62, label %63, label %227
63: ; preds = %60
%64 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 0, i64 4
%65 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 0, i64 5
%66 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 0, i64 6
%67 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 0, i64 7
br label %68
68: ; preds = %63, %71
%69 = call i64 @memcmp(i32* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%70 = icmp eq i64 %69, 0
br i1 %70, label %89, label %71
71: ; preds = %68
%72 = load i32, i32* %64
%73 = load i32, i32* %65
%74 = shl i32 %73, 8
%75 = or i32 %74, %72
%76 = load i32, i32* %66
%77 = shl i32 %76, 16
%78 = or i32 %75, %77
%79 = load i32, i32* %67
%80 = shl i32 %79, 24
%81 = or i32 %78, %80
%82 = load i32, i32* @SEEK_CUR
%83 = call i32 @fseek(i32* %37, i32 %81, i32 %82)
%84 = call i32 @fread(i32* %47, i32 1, i32 8, i32* %37)
%85 = icmp eq i32 %84, 8
br i1 %85, label %68, label %227
86: ; preds = %56, %53
%87 = load i32, i32* @SEEK_CUR
%88 = call i32 @fseek(i32* %37, i32 -12, i32 %87)
br label %89
89: ; preds = %68, %86
%90 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 1, i64 0
%91 = call i32 @fread(i32* %90, i32 1, i32 12, i32* %41)
%92 = icmp eq i32 %91, 12
br i1 %92, label %93, label %227
93: ; preds = %89
%94 = call i64 @memcmp(i32* %90, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %100
96: ; preds = %93
%97 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 1, i64 8
%98 = call i64 @memcmp(i32* %97, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%99 = icmp eq i64 %98, 0
br i1 %99, label %103, label %100
100: ; preds = %96, %93
%101 = load i32, i32* @SEEK_CUR
%102 = call i32 @fseek(i32* %41, i32 -12, i32 %101)
br label %129
103: ; preds = %96
%104 = call i32 @fread(i32* %90, i32 1, i32 8, i32* %41)
%105 = icmp eq i32 %104, 8
br i1 %105, label %106, label %227
106: ; preds = %103
%107 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 1, i64 4
%108 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 1, i64 5
%109 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 1, i64 6
%110 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 1, i64 7
br label %111
111: ; preds = %114, %106
%112 = call i64 @memcmp(i32* %90, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%113 = icmp eq i64 %112, 0
br i1 %113, label %129, label %114
114: ; preds = %111
%115 = load i32, i32* %107
%116 = load i32, i32* %108
%117 = shl i32 %116, 8
%118 = or i32 %117, %115
%119 = load i32, i32* %109
%120 = shl i32 %119, 16
%121 = or i32 %118, %120
%122 = load i32, i32* %110
%123 = shl i32 %122, 24
%124 = or i32 %121, %123
%125 = load i32, i32* @SEEK_CUR
%126 = call i32 @fseek(i32* %41, i32 %124, i32 %125)
%127 = call i32 @fread(i32* %90, i32 1, i32 8, i32* %41)
%128 = icmp eq i32 %127, 8
br i1 %128, label %111, label %227
129: ; preds = %111, %100
%130 = lshr i32 %34, 31
%131 = zext i32 %130 to i64
%132 = getelementptr inbounds [2 x i32*], [2 x i32*]* %3, i64 0, i64 %131
%133 = load i32*, i32** %132
%134 = call i32 @llvm.abs.i32(i32 %34, i1 true)
%135 = load i32, i32* @SEEK_CUR
%136 = call i32 @fseek(i32* %133, i32 %134, i32 %135)
%137 = load i32, i32* @SEEK_CUR
%138 = call i32 @fseek(i32* %37, i32 %31, i32 %137)
%139 = load i32, i32* @SEEK_CUR
%140 = call i32 @fseek(i32* %41, i32 %31, i32 %139)
%141 = icmp eq i32 %33, 2
br label %142
142: ; preds = %184, %129
%143 = phi i32 [ 0, %129 ], [ %187, %184 ]
%144 = phi i32 [ 0, %129 ], [ %188, %184 ]
%145 = phi i32 [ 0, %129 ], [ %185, %184 ]
%146 = phi i32 [ 0, %129 ], [ %186, %184 ]
%147 = call i32 @fread(i32* %47, i32 1, i32 2048, i32* %37)
%148 = call i32 @fread(i32* %90, i32 1, i32 2048, i32* %41)
%149 = icmp sgt i32 %147, %148
%150 = select i1 %149, i32 %148, i32 %147
%151 = icmp sgt i32 %150, 0
br i1 %151, label %152, label %184
152: ; preds = %142, %172
%153 = phi i32 [ %182, %172 ], [ 0, %142 ]
%154 = phi i32 [ %178, %172 ], [ %146, %142 ]
%155 = phi i32 [ %181, %172 ], [ %145, %142 ]
%156 = sext i32 %153 to i64
%157 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 0, i64 %156
%158 = load i32, i32* %157
%159 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 1, i64 %156
%160 = load i32, i32* %159
br i1 %141, label %161, label %172
161: ; preds = %152
%162 = add nsw i32 %153, 1
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 0, i64 %163
%165 = load i32, i32* %164
%166 = shl i32 %165, 8
%167 = or i32 %166, %158
%168 = getelementptr inbounds [2 x [2048 x i32]], [2 x [2048 x i32]]* %4, i64 0, i64 1, i64 %163
%169 = load i32, i32* %168
%170 = shl i32 %169, 8
%171 = or i32 %170, %160
br label %172
172: ; preds = %161, %152
%173 = phi i32 [ %162, %161 ], [ %153, %152 ]
%174 = phi i32 [ %167, %161 ], [ %158, %152 ]
%175 = phi i32 [ %171, %161 ], [ %160, %152 ]
%176 = sub nsw i32 %174, %175
%177 = mul nsw i32 %176, %176
%178 = add nsw i32 %177, %154
%179 = call i32 @llvm.abs.i32(i32 %176, i1 true)
%180 = icmp sgt i32 %179, %155
%181 = select i1 %180, i32 %179, i32 %155
%182 = add nsw i32 %173, 1
%183 = icmp slt i32 %182, %150
br i1 %183, label %152, label %184
184: ; preds = %172, %142
%185 = phi i32 [ %145, %142 ], [ %181, %172 ]
%186 = phi i32 [ %146, %142 ], [ %178, %172 ]
%187 = add nsw i32 %147, %143
%188 = add nsw i32 %148, %144
%189 = add nsw i32 %148, %147
%190 = icmp slt i32 %189, 1
br i1 %190, label %191, label %142
191: ; preds = %184
%192 = icmp sgt i32 %187, %188
%193 = select i1 %192, i32 %188, i32 %187
%194 = sdiv i32 %193, %33
%195 = icmp eq i32 %194, 0
%196 = select i1 %195, i32 1, i32 %194
%197 = sdiv i32 %186, %196
%198 = mul i32 %197, 10000
%199 = srem i32 %186, %196
%200 = mul i32 %199, 10000
%201 = sdiv i32 %196, 2
%202 = add nsw i32 %200, %201
%203 = sdiv i32 %202, %196
%204 = add nsw i32 %203, %198
%205 = call i32 @int_sqrt(i32 %204)
%206 = icmp eq i32 %186, 0
br i1 %206, label %220, label %207
207: ; preds = %191
%208 = shl i32 %32, 16
%209 = call i32 @log16(i32 %208)
%210 = shl nsw i32 %209, 1
%211 = call i32 @log16(i32 %196)
%212 = add nsw i32 %210, %211
%213 = call i32 @log16(i32 %186)
%214 = sub i32 %212, %213
%215 = sext i32 %214 to i64
%216 = mul nsw i64 %215, 28461900
%217 = add nsw i64 %216, 2147483648
%218 = sdiv i64 %217, 4294967296
%219 = trunc i64 %218 to i32
br label %220
220: ; preds = %191, %207
%221 = phi i32 [ %219, %207 ], [ 99999, %191 ]
%222 = sdiv i32 %205, 100
%223 = srem i32 %205, 100
%224 = sdiv i32 %221, 100
%225 = srem i32 %221, 100
%226 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), i32 %222, i32 %223, i32 %224, i32 %225, i32 %185, i32 %187, i32 %188)
br label %227
227: ; preds = %71, %114, %60, %46, %89, %103, %220, %50, %27
%228 = phi i32 [ 1, %27 ], [ 0, %220 ], [ 1, %50 ], [ 1, %103 ], [ 1, %89 ], [ 1, %46 ], [ 1, %60 ], [ 1, %114 ], [ 1, %71 ]
ret i32 %228
}