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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
void *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *, int *);
int ssd_plane(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
double ssd_to_psnr(int, int);
scalar_t__ ssim_plane(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *, int, int,
                      int, int *, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *f[2];
  uint8_t *buf[2], *plane[2][3];
  int *temp;
  uint64_t ssd[3] = {0, 0, 0};
  double ssim[3] = {0, 0, 0};
  int frame_size, w, h;
  int frames, seek;
  int i;
  if (argc < 4 || 2 != sscanf(argv[3], "%dx%d", &w, &h)) {
    printf("tiny_ssim <file1.yuv> <file2.yuv> <width>x<height> [<seek>]\n");
    return -1;
  }
  f[0] = fopen(argv[1], "rb");
  f[1] = fopen(argv[2], "rb");
  sscanf(argv[3], "%dx%d", &w, &h);
  frame_size = w * h * 3 / 2;
  for (i = 0; i < 2; i++) {
    buf[i] = malloc(frame_size);
    plane[i][0] = buf[i];
    plane[i][1] = plane[i][0] + w * h;
    plane[i][2] = plane[i][1] + w * h / 4;
  }
  temp = malloc((2 * w + 12) * sizeof(*temp));
  seek = argc < 5 ? 0 : atoi(argv[4]);
  fseek(f[seek < 0], seek < 0 ? -seek : seek, SEEK_SET);
  for (frames = 0;; frames++) {
    if (fread(buf[0], frame_size, 1, f[0]) != 1)
      break;
    if (fread(buf[1], frame_size, 1, f[1]) != 1)
      break;
    for (i = 0; i < 3; i++) {
      ssd[i] += ssd_plane(plane[0][i], plane[1][i], w * h >> 2 * !!i);
      ssim[i] += ssim_plane(plane[0][i], w >> !!i, plane[1][i], w >> !!i,
                            w >> !!i, h >> !!i, temp, NULL);
    }
  }
  if (!frames)
    return 0;
  printf(
      "PSNR Y:%.3f  U:%.3f  V:%.3f  All:%.3f\n",
      ssd_to_psnr(ssd[0], (uint64_t)frames * w * h),
      ssd_to_psnr(ssd[1], (uint64_t)frames * w * h / 4),
      ssd_to_psnr(ssd[2], (uint64_t)frames * w * h / 4),
      ssd_to_psnr(ssd[0] + ssd[1] + ssd[2], (uint64_t)frames * w * h * 3 / 2));
  printf("SSIM Y:%.5f U:%.5f V:%.5f All:%.5f\n", ssim[0] / frames,
         ssim[1] / frames, ssim[2] / frames,
         (ssim[0] * 4 + ssim[1] + ssim[2]) / (frames * 6));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x74(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
cmpl   $0x4,-0x8(%rbp)
jl     1227 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe03(%rip),%rsi
lea    -0x98(%rbp),%rdx
lea    -0x9c(%rbp),%rcx
call   1090 <sscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
je     1241 <main+0x91>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1787 <main+0x5d7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfb(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde3(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd88(%rip),%rsi
lea    -0x98(%rbp),%rdx
lea    -0x9c(%rbp),%rcx
call   1090 <sscanf@plt>
mov    -0x98(%rbp),%eax
imul   -0x9c(%rbp),%eax
imul   $0x3,%eax,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x94(%rbp)
movl   $0x0,-0xa8(%rbp)
cmpl   $0x2,-0xa8(%rbp)
jge    13a2 <main+0x1f2>
mov    -0x94(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
movslq -0xa8(%rbp),%rax
mov    %rcx,-0x30(%rbp,%rax,8)
movslq -0xa8(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rcx
movslq -0xa8(%rbp),%rdx
lea    -0x60(%rbp),%rax
imul   $0x18,%rdx,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
movslq -0xa8(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%rcx
mov    -0x98(%rbp),%eax
imul   -0x9c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rcx
movslq -0xa8(%rbp),%rdx
lea    -0x60(%rbp),%rax
imul   $0x18,%rdx,%rdx
add    %rdx,%rax
mov    %rcx,0x8(%rax)
movslq -0xa8(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rcx
mov    -0x98(%rbp),%eax
imul   -0x9c(%rbp),%eax
mov    $0x4,%esi
cltd
idiv   %esi
cltq
shl    $0x2,%rax
add    %rax,%rcx
movslq -0xa8(%rbp),%rdx
lea    -0x60(%rbp),%rax
imul   $0x18,%rdx,%rdx
add    %rdx,%rax
mov    %rcx,0x10(%rax)
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    12bb <main+0x10b>
mov    -0x98(%rbp),%eax
shl    $0x1,%eax
add    $0xc,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x68(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    13d6 <main+0x226>
xor    %eax,%eax
mov    %eax,-0xac(%rbp)
jmp    13e9 <main+0x239>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0xac(%rbp)
mov    -0xac(%rbp),%eax
mov    %eax,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    -0x20(%rbp,%rax,8),%rax
mov    %rax,-0xb8(%rbp)
cmpl   $0x0,-0xa4(%rbp)
jge    1432 <main+0x282>
xor    %eax,%eax
sub    -0xa4(%rbp),%eax
mov    %eax,-0xbc(%rbp)
jmp    143e <main+0x28e>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xbc(%rbp)
mov    -0xb8(%rbp),%rdi
mov    -0xbc(%rbp),%esi
mov    0x2b8e(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
movl   $0x0,-0xa0(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x94(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1489 <main+0x2d9>
jmp    1614 <main+0x464>
mov    -0x28(%rbp),%rdi
mov    -0x94(%rbp),%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     14af <main+0x2ff>
jmp    1614 <main+0x464>
movl   $0x0,-0xa8(%rbp)
cmpl   $0x3,-0xa8(%rbp)
jge    15fb <main+0x44b>
movslq -0xa8(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
movslq -0xa8(%rbp),%rax
mov    -0x48(%rbp,%rax,8),%rsi
mov    -0x98(%rbp),%edx
imul   -0x9c(%rbp),%edx
cmpl   $0x0,-0xa8(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%ecx
shl    $0x1,%ecx
sar    %cl,%edx
call   10b0 <ssd_plane@plt>
mov    %eax,%ecx
movslq -0xa8(%rbp),%rax
add    -0x74(%rbp,%rax,4),%ecx
mov    %ecx,-0x74(%rbp,%rax,4)
movslq -0xa8(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
mov    -0x98(%rbp),%esi
cmpl   $0x0,-0xa8(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%ecx
sar    %cl,%esi
movslq -0xa8(%rbp),%rax
mov    -0x48(%rbp,%rax,8),%rdx
mov    -0x98(%rbp),%eax
cmpl   $0x0,-0xa8(%rbp)
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
sar    %cl,%eax
mov    %eax,-0xc0(%rbp)
mov    -0x98(%rbp),%r8d
cmpl   $0x0,-0xa8(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%ecx
sar    %cl,%r8d
mov    -0x9c(%rbp),%r9d
cmpl   $0x0,-0xa8(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%ecx
sar    %cl,%r9d
mov    -0xc0(%rbp),%ecx
mov    -0x68(%rbp),%rax
xor    %r10d,%r10d
mov    %rax,(%rsp)
movq   $0x0,0x8(%rsp)
call   1070 <ssim_plane@plt>
cvtsi2sd %rax,%xmm0
movslq -0xa8(%rbp),%rax
addsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x90(%rbp,%rax,8)
ff ff
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    14b9 <main+0x309>
jmp    1600 <main+0x450>
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
jmp    1463 <main+0x2b3>
cmpl   $0x0,-0xa0(%rbp)
jne    162d <main+0x47d>
movl   $0x0,-0x4(%rbp)
jmp    1787 <main+0x5d7>
mov    -0x74(%rbp),%edi
mov    -0xa0(%rbp),%esi
imul   -0x98(%rbp),%esi
imul   -0x9c(%rbp),%esi
call   1040 <ssd_to_psnr@plt>
movsd  %xmm0,-0xc8(%rbp)
ff
mov    -0x70(%rbp),%edi
mov    -0xa0(%rbp),%eax
imul   -0x98(%rbp),%eax
imul   -0x9c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1040 <ssd_to_psnr@plt>
movsd  %xmm0,-0xd8(%rbp)
ff
mov    -0x6c(%rbp),%edi
mov    -0xa0(%rbp),%eax
imul   -0x98(%rbp),%eax
imul   -0x9c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1040 <ssd_to_psnr@plt>
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x74(%rbp),%edi
add    -0x70(%rbp),%edi
add    -0x6c(%rbp),%edi
mov    -0xa0(%rbp),%eax
imul   -0x98(%rbp),%eax
imul   -0x9c(%rbp),%eax
imul   $0x3,%eax,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1040 <ssd_to_psnr@plt>
movsd  -0xd8(%rbp),%xmm1
ff
movsd  -0xd0(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xc8(%rbp),%xmm0
ff
lea    0x950(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
movsd  -0x90(%rbp),%xmm0
ff
cvtsi2sdl -0xa0(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
cvtsi2sdl -0xa0(%rbp),%xmm2
ff
divsd  %xmm2,%xmm1
movsd  -0x80(%rbp),%xmm2
cvtsi2sdl -0xa0(%rbp),%xmm3
ff
divsd  %xmm3,%xmm2
movsd  -0x90(%rbp),%xmm3
ff
movsd  -0x88(%rbp),%xmm4
ff
movsd  0x8aa(%rip),%xmm5
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
addsd  -0x80(%rbp),%xmm3
imul   $0x6,-0xa0(%rbp),%eax
cvtsi2sd %eax,%xmm4
divsd  %xmm4,%xmm3
lea    0x8fc(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
cmp    $0x4,%edi
jl     14f2 <main+0x342>
mov    %rsi,%r14
mov    %edi,%r13d
mov    0x18(%rsi),%rdi
lea    0xe2d(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1090 <sscanf@plt>
cmp    $0x2,%eax
jne    14f2 <main+0x342>
mov    0x8(%r14),%rdi
lea    0xe10(%rip),%rbp
mov    %rbp,%rsi
call   10c0 <fopen@plt>
mov    %rax,0x18(%rsp)
mov    %rax,0x80(%rsp)
mov    0x10(%r14),%rdi
mov    %rbp,%rsi
call   10c0 <fopen@plt>
mov    %rax,0x20(%rsp)
mov    %rax,0x88(%rsp)
mov    0x18(%r14),%rdi
lea    0xdd1(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1090 <sscanf@plt>
movslq 0x8(%rsp),%r15
movslq 0x4(%rsp),%r12
imul   %r15,%r12
lea    (%r12,%r12,2),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
lea    0x3(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
mov    %ebx,0x44(%rsp)
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0x30(,%r15,8),%edi
call   1080 <malloc@plt>
mov    %rax,0x78(%rsp)
xor    %r15d,%r15d
mov    $0x0,%eax
cmp    $0x5,%r13d
jb     12b2 <main+0x102>
mov    0x20(%r14),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
mov    0x80(%rsp,%rcx,8),%rdi
mov    %eax,%esi
neg    %esi
cmovs  %eax,%esi
mov    0x2d13(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
mov    %rbp,%rdi
mov    0x44(%rsp),%r14d
mov    %r14d,%esi
mov    $0x1,%edx
mov    0x18(%rsp),%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    1504 <main+0x354>
mov    0x10(%rsp),%eax
sar    $0x2,%eax
cltq
lea    0x0(,%r12,4),%rcx
add    %rbp,%rcx
lea    (%rbx,%r12,4),%rdx
mov    %rcx,0x68(%rsp)
lea    (%rcx,%rax,4),%rcx
mov    %rcx,0x58(%rsp)
mov    %rdx,0x60(%rsp)
lea    (%rdx,%rax,4),%rax
mov    %rax,0x50(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %r15d,%r15d
mov    %r14d,%r12d
movl   $0x0,0xc(%rsp)
xor    %r14d,%r14d
xor    %r13d,%r13d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x30(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x38(%rsp)
mov    %rbx,0x70(%rsp)
mov    %rbp,0x48(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12d,%esi
mov    $0x1,%edx
mov    0x20(%rsp),%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    1519 <main+0x369>
mov    0x4(%rsp),%edx
imul   0x8(%rsp),%edx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10b0 <ssd_plane@plt>
add    %eax,0xc(%rsp)
mov    0x8(%rsp),%ecx
mov    0x4(%rsp),%r9d
mov    %rbp,%rdi
mov    %ecx,%esi
mov    %rbx,%rdx
mov    %ecx,%r8d
push   $0x0
mov    %r15,0x30(%rsp)
mov    0x80(%rsp),%r15
push   %r15
call   1070 <ssim_plane@plt>
add    $0x10,%rsp
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    0x4(%rsp),%edx
imul   0x8(%rsp),%edx
sar    $0x2,%edx
mov    0x68(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12d,%ebp
mov    %r13d,%r12d
mov    0x60(%rsp),%r13
mov    %r13,%rsi
call   10b0 <ssd_plane@plt>
add    %eax,%r14d
mov    0x8(%rsp),%ecx
sar    %ecx
mov    0x4(%rsp),%r9d
sar    %r9d
mov    %rbx,%rdi
mov    %ecx,%esi
mov    %r13,%rdx
mov    %r12d,%r13d
mov    %ecx,%r8d
push   $0x0
push   %r15
call   1070 <ssim_plane@plt>
add    $0x10,%rsp
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x30(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rsp)
mov    0x4(%rsp),%edx
imul   0x8(%rsp),%edx
sar    $0x2,%edx
mov    0x58(%rsp),%rbx
mov    %rbx,%rdi
mov    0x50(%rsp),%r12
mov    %r12,%rsi
call   10b0 <ssd_plane@plt>
add    %eax,%r13d
mov    0x8(%rsp),%ecx
sar    %ecx
mov    0x4(%rsp),%r9d
sar    %r9d
mov    %rbx,%rdi
mov    %ecx,%esi
mov    %r12,%rdx
mov    %ebp,%r12d
mov    %ecx,%r8d
push   $0x0
push   %r15
mov    0x38(%rsp),%r15
mov    0x58(%rsp),%rbp
mov    0x80(%rsp),%rbx
call   1070 <ssim_plane@plt>
add    $0x10,%rsp
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x38(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x38(%rsp)
mov    %rbp,%rdi
mov    %r12d,%esi
mov    $0x1,%edx
mov    0x18(%rsp),%rcx
call   1040 <fread@plt>
add    $0xffffffff,%r15d
cmp    $0x1,%eax
je     1370 <main+0x1c0>
jmp    1522 <main+0x372>
lea    0xb63(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r15d,%r15d
je     1635 <main+0x485>
neg    %r15d
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%esi
imul   %r15d,%esi
imul   0x4(%rsp),%esi
mov    %ebp,%edi
call   1050 <ssd_to_psnr@plt>
movsd  %xmm0,0x28(%rsp)
mov    0x8(%rsp),%eax
imul   %r15d,%eax
imul   0x4(%rsp),%eax
lea    0x3(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0x2,%esi
mov    %r14d,%edi
call   1050 <ssd_to_psnr@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x8(%rsp),%eax
imul   %r15d,%eax
imul   0x4(%rsp),%eax
lea    0x3(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0x2,%esi
mov    %r13d,%edi
call   1050 <ssd_to_psnr@plt>
movsd  %xmm0,0x20(%rsp)
add    %ebp,%r14d
add    %r13d,%r14d
mov    0x8(%rsp),%eax
imul   %r15d,%eax
imul   0x4(%rsp),%eax
lea    (%rax,%rax,2),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    %r14d,%edi
call   1050 <ssd_to_psnr@plt>
movapd %xmm0,%xmm3
lea    0xa50(%rip),%rdi
movsd  0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
mov    $0x4,%al
call   1060 <printf@plt>
cvtsi2sd %r15d,%xmm4
movsd  0x10(%rsp),%xmm3
movapd %xmm3,%xmm0
divsd  %xmm4,%xmm0
movsd  0x30(%rsp),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm4,%xmm1
mulsd  0x9fd(%rip),%xmm3
addsd  %xmm2,%xmm3
movsd  0x38(%rsp),%xmm2
addsd  %xmm2,%xmm3
divsd  %xmm4,%xmm2
add    %r15d,%r15d
lea    (%r15,%r15,2),%eax
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
divsd  %xmm4,%xmm3
lea    0xa0a(%rip),%rdi
mov    $0x4,%al
call   1060 <printf@plt>
xor    %r15d,%r15d
jmp    1504 <main+0x354>

LLVM IR (-O0):
@.str = [6 x i8] c"%dx%d\00"
@.str.1 = [61 x i8] c"tiny_ssim <file1.yuv> <file2.yuv> <width>x<height> [<seek>]\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@SEEK_SET = global i32 0
@.str.3 = [39 x i8] c"PSNR Y:%.3f U:%.3f V:%.3f All:%.3f\0A\00"
@.str.4 = [36 x i8] c"SSIM Y:%.5f U:%.5f V:%.5f All:%.5f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i32*]
%7 = alloca [2 x i32*]
%8 = alloca [2 x [3 x i32*]]
%9 = alloca i32*
%10 = alloca [3 x i32]
%11 = alloca [3 x double]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = bitcast [3 x i32]* %10 to i8*
%19 = bitcast [3 x double]* %11 to i8*
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 4
br i1 %21, label %28, label %22
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %13, i32* %14)
%27 = icmp ne i32 2, %26
br i1 %27, label %28, label %30
28: ; preds = %22, %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %314
30: ; preds = %22
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%35 = getelementptr inbounds [2 x i32*], [2 x i32*]* %6, i64 0, i64 0
store i32* %34, i32** %35
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = getelementptr inbounds [2 x i32*], [2 x i32*]* %6, i64 0, i64 1
store i32* %39, i32** %40
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 3
%43 = load i8*, i8** %42
%44 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %13, i32* %14)
%45 = load i32, i32* %13
%46 = load i32, i32* %14
%47 = mul nsw i32 %45, %46
%48 = mul nsw i32 %47, 3
%49 = sdiv i32 %48, 2
store i32 %49, i32* %12
store i32 0, i32* %17
br label %50
50: ; preds = %97, %30
%51 = load i32, i32* %17
%52 = icmp slt i32 %51, 2
br i1 %52, label %53, label %100
53: ; preds = %50
%54 = load i32, i32* %12
%55 = call i8* @malloc(i32 %54)
%56 = bitcast i8* %55 to i32*
%57 = load i32, i32* %17
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [2 x i32*], [2 x i32*]* %7, i64 0, i64 %58
store i32* %56, i32** %59
%60 = load i32, i32* %17
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [2 x i32*], [2 x i32*]* %7, i64 0, i64 %61
%63 = load i32*, i32** %62
%64 = load i32, i32* %17
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [2 x [3 x i32*]], [2 x [3 x i32*]]* %8, i64 0, i64 %65
%67 = getelementptr inbounds [3 x i32*], [3 x i32*]* %66, i64 0, i64 0
store i32* %63, i32** %67
%68 = load i32, i32* %17
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [2 x [3 x i32*]], [2 x [3 x i32*]]* %8, i64 0, i64 %69
%71 = getelementptr inbounds [3 x i32*], [3 x i32*]* %70, i64 0, i64 0
%72 = load i32*, i32** %71
%73 = load i32, i32* %13
%74 = load i32, i32* %14
%75 = mul nsw i32 %73, %74
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i32, i32* %72, i64 %76
%78 = load i32, i32* %17
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [2 x [3 x i32*]], [2 x [3 x i32*]]* %8, i64 0, i64 %79
%81 = getelementptr inbounds [3 x i32*], [3 x i32*]* %80, i64 0, i64 1
store i32* %77, i32** %81
%82 = load i32, i32* %17
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [2 x [3 x i32*]], [2 x [3 x i32*]]* %8, i64 0, i64 %83
%85 = getelementptr inbounds [3 x i32*], [3 x i32*]* %84, i64 0, i64 1
%86 = load i32*, i32** %85
%87 = load i32, i32* %13
%88 = load i32, i32* %14
%89 = mul nsw i32 %87, %88
%90 = sdiv i32 %89, 4
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i32, i32* %86, i64 %91
%93 = load i32, i32* %17
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [2 x [3 x i32*]], [2 x [3 x i32*]]* %8, i64 0, i64 %94
%96 = getelementptr inbounds [3 x i32*], [3 x i32*]* %95, i64 0, i64 2
store i32* %92, i32** %96
br label %97
97: ; preds = %53
%98 = load i32, i32* %17
%99 = add nsw i32 %98, 1
store i32 %99, i32* %17
br label %50
100: ; preds = %50
%101 = load i32, i32* %13
%102 = mul nsw i32 2, %101
%103 = add nsw i32 %102, 12
%104 = sext i32 %103 to i64
%105 = mul i64 %104, 4
%106 = trunc i64 %105 to i32
%107 = call i8* @malloc(i32 %106)
%108 = bitcast i8* %107 to i32*
store i32* %108, i32** %9
%109 = load i32, i32* %4
%110 = icmp slt i32 %109, 5
br i1 %110, label %111, label %112
111: ; preds = %100
br label %117
112: ; preds = %100
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 4
%115 = load i8*, i8** %114
%116 = call i32 @atoi(i8* %115)
br label %117
117: ; preds = %112, %111
%118 = phi i32 [ 0, %111 ], [ %116, %112 ]
store i32 %118, i32* %16
%119 = load i32, i32* %16
%120 = icmp slt i32 %119, 0
%121 = zext i1 %120 to i32
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [2 x i32*], [2 x i32*]* %6, i64 0, i64 %122
%124 = load i32*, i32** %123
%125 = load i32, i32* %16
%126 = icmp slt i32 %125, 0
br i1 %126, label %127, label %130
127: ; preds = %117
%128 = load i32, i32* %16
%129 = sub nsw i32 0, %128
br label %132
130: ; preds = %117
%131 = load i32, i32* %16
br label %132
132: ; preds = %130, %127
%133 = phi i32 [ %129, %127 ], [ %131, %130 ]
%134 = load i32, i32* @SEEK_SET
%135 = call i32 @fseek(i32* %124, i32 %133, i32 %134)
store i32 0, i32* %15
br label %136
136: ; preds = %235, %132
%137 = getelementptr inbounds [2 x i32*], [2 x i32*]* %7, i64 0, i64 0
%138 = load i32*, i32** %137
%139 = load i32, i32* %12
%140 = getelementptr inbounds [2 x i32*], [2 x i32*]* %6, i64 0, i64 0
%141 = load i32*, i32** %140
%142 = call i32 @fread(i32* %138, i32 %139, i32 1, i32* %141)
%143 = icmp ne i32 %142, 1
br i1 %143, label %144, label %145
144: ; preds = %136
br label %238
145: ; preds = %136
%146 = getelementptr inbounds [2 x i32*], [2 x i32*]* %7, i64 0, i64 1
%147 = load i32*, i32** %146
%148 = load i32, i32* %12
%149 = getelementptr inbounds [2 x i32*], [2 x i32*]* %6, i64 0, i64 1
%150 = load i32*, i32** %149
%151 = call i32 @fread(i32* %147, i32 %148, i32 1, i32* %150)
%152 = icmp ne i32 %151, 1
br i1 %152, label %153, label %154
153: ; preds = %145
br label %238
154: ; preds = %145
store i32 0, i32* %17
br label %155
155: ; preds = %231, %154
%156 = load i32, i32* %17
%157 = icmp slt i32 %156, 3
br i1 %157, label %158, label %234
158: ; preds = %155
%159 = getelementptr inbounds [2 x [3 x i32*]], [2 x [3 x i32*]]* %8, i64 0, i64 0
%160 = load i32, i32* %17
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds [3 x i32*], [3 x i32*]* %159, i64 0, i64 %161
%163 = load i32*, i32** %162
%164 = getelementptr inbounds [2 x [3 x i32*]], [2 x [3 x i32*]]* %8, i64 0, i64 1
%165 = load i32, i32* %17
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds [3 x i32*], [3 x i32*]* %164, i64 0, i64 %166
%168 = load i32*, i32** %167
%169 = load i32, i32* %13
%170 = load i32, i32* %14
%171 = mul nsw i32 %169, %170
%172 = load i32, i32* %17
%173 = icmp ne i32 %172, 0
%174 = xor i1 %173, true
%175 = xor i1 %174, true
%176 = zext i1 %175 to i32
%177 = mul nsw i32 2, %176
%178 = ashr i32 %171, %177
%179 = call i32 @ssd_plane(i32* %163, i32* %168, i32 %178)
%180 = load i32, i32* %17
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 %181
%183 = load i32, i32* %182
%184 = add nsw i32 %183, %179
store i32 %184, i32* %182
%185 = getelementptr inbounds [2 x [3 x i32*]], [2 x [3 x i32*]]* %8, i64 0, i64 0
%186 = load i32, i32* %17
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [3 x i32*], [3 x i32*]* %185, i64 0, i64 %187
%189 = load i32*, i32** %188
%190 = load i32, i32* %13
%191 = load i32, i32* %17
%192 = icmp ne i32 %191, 0
%193 = xor i1 %192, true
%194 = xor i1 %193, true
%195 = zext i1 %194 to i32
%196 = ashr i32 %190, %195
%197 = getelementptr inbounds [2 x [3 x i32*]], [2 x [3 x i32*]]* %8, i64 0, i64 1
%198 = load i32, i32* %17
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds [3 x i32*], [3 x i32*]* %197, i64 0, i64 %199
%201 = load i32*, i32** %200
%202 = load i32, i32* %13
%203 = load i32, i32* %17
%204 = icmp ne i32 %203, 0
%205 = xor i1 %204, true
%206 = xor i1 %205, true
%207 = zext i1 %206 to i32
%208 = ashr i32 %202, %207
%209 = load i32, i32* %13
%210 = load i32, i32* %17
%211 = icmp ne i32 %210, 0
%212 = xor i1 %211, true
%213 = xor i1 %212, true
%214 = zext i1 %213 to i32
%215 = ashr i32 %209, %214
%216 = load i32, i32* %14
%217 = load i32, i32* %17
%218 = icmp ne i32 %217, 0
%219 = xor i1 %218, true
%220 = xor i1 %219, true
%221 = zext i1 %220 to i32
%222 = ashr i32 %216, %221
%223 = load i32*, i32** %9
%224 = call i64 @ssim_plane(i32* %189, i32 %196, i32* %201, i32 %208, i32 %215, i32 %222, i32* %223, i32* null)
%225 = sitofp i64 %224 to double
%226 = load i32, i32* %17
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 %227
%229 = load double, double* %228
%230 = fadd double %229, %225
store double %230, double* %228
br label %231
231: ; preds = %158
%232 = load i32, i32* %17
%233 = add nsw i32 %232, 1
store i32 %233, i32* %17
br label %155
234: ; preds = %155
br label %235
235: ; preds = %234
%236 = load i32, i32* %15
%237 = add nsw i32 %236, 1
store i32 %237, i32* %15
br label %136
238: ; preds = %153, %144
%239 = load i32, i32* %15
%240 = icmp ne i32 %239, 0
br i1 %240, label %242, label %241
241: ; preds = %238
store i32 0, i32* %3
br label %314
242: ; preds = %238
%243 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%244 = load i32, i32* %243
%245 = load i32, i32* %15
%246 = load i32, i32* %13
%247 = mul nsw i32 %245, %246
%248 = load i32, i32* %14
%249 = mul nsw i32 %247, %248
%250 = call double @ssd_to_psnr(i32 %244, i32 %249)
%251 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 1
%252 = load i32, i32* %251
%253 = load i32, i32* %15
%254 = load i32, i32* %13
%255 = mul nsw i32 %253, %254
%256 = load i32, i32* %14
%257 = mul nsw i32 %255, %256
%258 = sdiv i32 %257, 4
%259 = call double @ssd_to_psnr(i32 %252, i32 %258)
%260 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 2
%261 = load i32, i32* %260
%262 = load i32, i32* %15
%263 = load i32, i32* %13
%264 = mul nsw i32 %262, %263
%265 = load i32, i32* %14
%266 = mul nsw i32 %264, %265
%267 = sdiv i32 %266, 4
%268 = call double @ssd_to_psnr(i32 %261, i32 %267)
%269 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%270 = load i32, i32* %269
%271 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 1
%272 = load i32, i32* %271
%273 = add nsw i32 %270, %272
%274 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 2
%275 = load i32, i32* %274
%276 = add nsw i32 %273, %275
%277 = load i32, i32* %15
%278 = load i32, i32* %13
%279 = mul nsw i32 %277, %278
%280 = load i32, i32* %14
%281 = mul nsw i32 %279, %280
%282 = mul nsw i32 %281, 3
%283 = sdiv i32 %282, 2
%284 = call double @ssd_to_psnr(i32 %276, i32 %283)
%285 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), double %250, double %259, double %268, double %284)
%286 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%287 = load double, double* %286
%288 = load i32, i32* %15
%289 = sitofp i32 %288 to double
%290 = fdiv double %287, %289
%291 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%292 = load double, double* %291
%293 = load i32, i32* %15
%294 = sitofp i32 %293 to double
%295 = fdiv double %292, %294
%296 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%297 = load double, double* %296
%298 = load i32, i32* %15
%299 = sitofp i32 %298 to double
%300 = fdiv double %297, %299
%301 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%302 = load double, double* %301
%303 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%304 = load double, double* %303
%305 = call double @llvm.fmuladd.f64(double %302, double 4.000000e+00, double %304)
%306 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%307 = load double, double* %306
%308 = fadd double %305, %307
%309 = load i32, i32* %15
%310 = mul nsw i32 %309, 6
%311 = sitofp i32 %310 to double
%312 = fdiv double %308, %311
%313 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), double %290, double %295, double %300, double %312)
store i32 0, i32* %3
br label %314
314: ; preds = %242, %241, %28
%315 = load i32, i32* %3
ret i32 %315
}

LLVM IR (-O2):
@.str = [6 x i8] c"%dx%d\00"
@.str.2 = [3 x i8] c"rb\00"
@SEEK_SET = global i32 0
@.str.3 = [39 x i8] c"PSNR Y:%.3f U:%.3f V:%.3f All:%.3f\0A\00"
@.str.4 = [36 x i8] c"SSIM Y:%.5f U:%.5f V:%.5f All:%.5f\0A\00"
@str = [60 x i8] c"tiny_ssim <file1.yuv> <file2.yuv> <width>x<height> [<seek>]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32*]
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [2 x i32*]* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp slt i32 %0, 4
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%14 = icmp eq i32 %13, 2
br i1 %14, label %17, label %15
15: ; preds = %10, %2
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
br label %161
17: ; preds = %10
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds [2 x i32*], [2 x i32*]* %3, i64 0, i64 0
store i32* %20, i32** %21
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = getelementptr inbounds [2 x i32*], [2 x i32*]* %3, i64 0, i64 1
store i32* %24, i32** %25
%26 = load i8*, i8** %11
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = mul nsw i32 %29, %28
%31 = mul nsw i32 %30, 3
%32 = sdiv i32 %31, 2
%33 = sext i32 %30 to i64
%34 = sdiv i32 %30, 4
%35 = sext i32 %34 to i64
%36 = call i8* @malloc(i32 %32)
%37 = bitcast i8* %36 to i32*
%38 = getelementptr inbounds i32, i32* %37, i64 %33
%39 = getelementptr inbounds i32, i32* %38, i64 %35
%40 = call i8* @malloc(i32 %32)
%41 = bitcast i8* %40 to i32*
%42 = getelementptr inbounds i32, i32* %41, i64 %33
%43 = getelementptr inbounds i32, i32* %42, i64 %35
%44 = shl i32 %28, 3
%45 = add i32 %44, 48
%46 = call i8* @malloc(i32 %45)
%47 = bitcast i8* %46 to i32*
%48 = icmp ult i32 %0, 5
br i1 %48, label %53, label %49
49: ; preds = %17
%50 = getelementptr inbounds i8*, i8** %1, i64 4
%51 = load i8*, i8** %50
%52 = call i32 @atoi(i8* %51)
br label %53
53: ; preds = %17, %49
%54 = phi i32 [ %52, %49 ], [ 0, %17 ]
%55 = lshr i32 %54, 31
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds [2 x i32*], [2 x i32*]* %3, i64 0, i64 %56
%58 = load i32*, i32** %57
%59 = call i32 @llvm.abs.i32(i32 %54, i1 true)
%60 = load i32, i32* @SEEK_SET
%61 = call i32 @fseek(i32* %58, i32 %59, i32 %60)
%62 = call i32 @fread(i32* %37, i32 %32, i32 1, i32* %20)
%63 = icmp eq i32 %62, 1
br i1 %63, label %64, label %161
64: ; preds = %53, %74
%65 = phi i32 [ %79, %74 ], [ 0, %53 ]
%66 = phi i32 [ %90, %74 ], [ 0, %53 ]
%67 = phi i32 [ %103, %74 ], [ 0, %53 ]
%68 = phi double [ %84, %74 ], [ 0.000000e+00, %53 ]
%69 = phi double [ %97, %74 ], [ 0.000000e+00, %53 ]
%70 = phi double [ %110, %74 ], [ 0.000000e+00, %53 ]
%71 = phi i32 [ %111, %74 ], [ 0, %53 ]
%72 = call i32 @fread(i32* %41, i32 %32, i32 1, i32* %24)
%73 = icmp eq i32 %72, 1
br i1 %73, label %74, label %114
74: ; preds = %64
%75 = load i32, i32* %4
%76 = load i32, i32* %5
%77 = mul nsw i32 %76, %75
%78 = call i32 @ssd_plane(i32* %37, i32* %41, i32 %77)
%79 = add nsw i32 %65, %78
%80 = load i32, i32* %4
%81 = load i32, i32* %5
%82 = call i64 @ssim_plane(i32* %37, i32 %80, i32* %41, i32 %80, i32 %80, i32 %81, i32* %47, i32* null)
%83 = sitofp i64 %82 to double
%84 = fadd double %68, %83
%85 = load i32, i32* %4
%86 = load i32, i32* %5
%87 = mul nsw i32 %86, %85
%88 = ashr i32 %87, 2
%89 = call i32 @ssd_plane(i32* %38, i32* %42, i32 %88)
%90 = add nsw i32 %66, %89
%91 = load i32, i32* %4
%92 = ashr i32 %91, 1
%93 = load i32, i32* %5
%94 = ashr i32 %93, 1
%95 = call i64 @ssim_plane(i32* %38, i32 %92, i32* %42, i32 %92, i32 %92, i32 %94, i32* %47, i32* null)
%96 = sitofp i64 %95 to double
%97 = fadd double %69, %96
%98 = load i32, i32* %4
%99 = load i32, i32* %5
%100 = mul nsw i32 %99, %98
%101 = ashr i32 %100, 2
%102 = call i32 @ssd_plane(i32* %39, i32* %43, i32 %101)
%103 = add nsw i32 %67, %102
%104 = load i32, i32* %4
%105 = ashr i32 %104, 1
%106 = load i32, i32* %5
%107 = ashr i32 %106, 1
%108 = call i64 @ssim_plane(i32* %39, i32 %105, i32* %43, i32 %105, i32 %105, i32 %107, i32* %47, i32* null)
%109 = sitofp i64 %108 to double
%110 = fadd double %70, %109
%111 = add nuw nsw i32 %71, 1
%112 = call i32 @fread(i32* %37, i32 %32, i32 1, i32* %20)
%113 = icmp eq i32 %112, 1
br i1 %113, label %64, label %116
114: ; preds = %64
%115 = icmp eq i32 %71, 0
br i1 %115, label %161, label %116
116: ; preds = %74, %114
%117 = phi i32 [ %71, %114 ], [ %111, %74 ]
%118 = phi double [ %70, %114 ], [ %110, %74 ]
%119 = phi double [ %69, %114 ], [ %97, %74 ]
%120 = phi double [ %68, %114 ], [ %84, %74 ]
%121 = phi i32 [ %67, %114 ], [ %103, %74 ]
%122 = phi i32 [ %66, %114 ], [ %90, %74 ]
%123 = phi i32 [ %65, %114 ], [ %79, %74 ]
%124 = load i32, i32* %4
%125 = mul nsw i32 %124, %117
%126 = load i32, i32* %5
%127 = mul nsw i32 %125, %126
%128 = call double @ssd_to_psnr(i32 %123, i32 %127)
%129 = load i32, i32* %4
%130 = mul nsw i32 %129, %117
%131 = load i32, i32* %5
%132 = mul nsw i32 %130, %131
%133 = sdiv i32 %132, 4
%134 = call double @ssd_to_psnr(i32 %122, i32 %133)
%135 = load i32, i32* %4
%136 = mul nsw i32 %135, %117
%137 = load i32, i32* %5
%138 = mul nsw i32 %136, %137
%139 = sdiv i32 %138, 4
%140 = call double @ssd_to_psnr(i32 %121, i32 %139)
%141 = add nsw i32 %122, %123
%142 = add nsw i32 %141, %121
%143 = load i32, i32* %4
%144 = load i32, i32* %5
%145 = mul i32 %117, 3
%146 = mul i32 %145, %143
%147 = mul i32 %146, %144
%148 = sdiv i32 %147, 2
%149 = call double @ssd_to_psnr(i32 %142, i32 %148)
%150 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), double %128, double %134, double %140, double %149)
%151 = sitofp i32 %117 to double
%152 = fdiv double %120, %151
%153 = fdiv double %119, %151
%154 = fdiv double %118, %151
%155 = call double @llvm.fmuladd.f64(double %120, double 4.000000e+00, double %119)
%156 = fadd double %155, %118
%157 = mul nsw i32 %117, 6
%158 = sitofp i32 %157 to double
%159 = fdiv double %156, %158
%160 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), double %152, double %153, double %154, double %159)
br label %161
161: ; preds = %53, %114, %116, %15
%162 = phi i32 [ -1, %15 ], [ 0, %116 ], [ 0, %114 ], [ 0, %53 ]
ret i32 %162
}