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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double, double, double, double, ...);
double ssd_to_psnr(int, int);
double ssim_db(double, int);
void print_results(uint64_t ssd[3], double ssim[3], int frames, int w, int h) {
  printf(
      "PSNR Y:%.3f  U:%.3f  V:%.3f  All:%.3f | ",
      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 (%.5f)", ssim[0] / frames,
         ssim[1] / frames, ssim[2] / frames,
         (ssim[0] * 4 + ssim[1] + ssim[2]) / (frames * 6),
         ssim_db(ssim[0] * 4 + ssim[1] + ssim[2], frames * 6));
}


x86 assembly (clang, -O0):
<print_results>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
imul   -0x18(%rbp),%esi
imul   -0x1c(%rbp),%esi
call   1030 <ssd_to_psnr@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1030 <ssd_to_psnr@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1030 <ssd_to_psnr@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
add    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
add    0x8(%rax),%edi
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
imul   $0x3,%eax,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1030 <ssd_to_psnr@plt>
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x48(%rbp),%xmm0
lea    0xe0d(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  0xda1(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
addsd  0x10(%rax),%xmm0
imul   $0x6,-0x14(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  0xd66(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
addsd  0x10(%rax),%xmm0
imul   $0x6,-0x14(%rbp),%edi
call   1050 <ssim_db@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movaps %xmm0,%xmm4
movsd  -0x28(%rbp),%xmm0
lea    0xd5f(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_results>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%r12
mov    (%rdi),%edi
imul   %edx,%ebx
imul   %r8d,%ebx
mov    %ebx,%esi
call   1030 <ssd_to_psnr@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x4(%r12),%edi
lea    0x3(%rbx),%ebp
test   %ebx,%ebx
cmovns %ebx,%ebp
sar    $0x2,%ebp
mov    %ebp,%esi
call   1030 <ssd_to_psnr@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x8(%r12),%edi
mov    %ebp,%esi
call   1030 <ssd_to_psnr@plt>
movsd  %xmm0,(%rsp)
mov    0x4(%r12),%edi
add    (%r12),%edi
add    0x8(%r12),%edi
lea    (%rbx,%rbx,2),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
call   1030 <ssd_to_psnr@plt>
movaps %xmm0,%xmm3
lea    0xe54(%rip),%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
mov    $0x4,%al
call   1040 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
movsd  (%r14),%xmm0
movsd  0x8(%r14),%xmm2
movapd %xmm0,%xmm3
divsd  %xmm1,%xmm3
movsd  %xmm3,0x10(%rsp)
mulsd  0xe0b(%rip),%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0x10(%r14),%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
add    %r15d,%r15d
lea    (%r15,%r15,2),%edi
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%rsp)
call   1050 <ssim_db@plt>
movapd %xmm0,%xmm4
lea    0xdef(%rip),%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
mov    $0x5,%al
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"PSNR Y:%.3f U:%.3f V:%.3f All:%.3f | \00"
@.str.1 = [42 x i8] c"SSIM Y:%.5f U:%.5f V:%.5f All:%.5f (%.5f)\00"
define void @print_results(i32* %0, double* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %6
store double* %1, double** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32*, i32** %6
%12 = getelementptr inbounds i32, i32* %11, i64 0
%13 = load i32, i32* %12
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = mul nsw i32 %14, %15
%17 = load i32, i32* %10
%18 = mul nsw i32 %16, %17
%19 = call double @ssd_to_psnr(i32 %13, i32 %18)
%20 = load i32*, i32** %6
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = mul nsw i32 %23, %24
%26 = load i32, i32* %10
%27 = mul nsw i32 %25, %26
%28 = sdiv i32 %27, 4
%29 = call double @ssd_to_psnr(i32 %22, i32 %28)
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i64 2
%32 = load i32, i32* %31
%33 = load i32, i32* %8
%34 = load i32, i32* %9
%35 = mul nsw i32 %33, %34
%36 = load i32, i32* %10
%37 = mul nsw i32 %35, %36
%38 = sdiv i32 %37, 4
%39 = call double @ssd_to_psnr(i32 %32, i32 %38)
%40 = load i32*, i32** %6
%41 = getelementptr inbounds i32, i32* %40, i64 0
%42 = load i32, i32* %41
%43 = load i32*, i32** %6
%44 = getelementptr inbounds i32, i32* %43, i64 1
%45 = load i32, i32* %44
%46 = add nsw i32 %42, %45
%47 = load i32*, i32** %6
%48 = getelementptr inbounds i32, i32* %47, i64 2
%49 = load i32, i32* %48
%50 = add nsw i32 %46, %49
%51 = load i32, i32* %8
%52 = load i32, i32* %9
%53 = mul nsw i32 %51, %52
%54 = load i32, i32* %10
%55 = mul nsw i32 %53, %54
%56 = mul nsw i32 %55, 3
%57 = sdiv i32 %56, 2
%58 = call double @ssd_to_psnr(i32 %50, i32 %57)
%59 = call i32 (i8*, double, double, double, double, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %19, double %29, double %39, double %58)
%60 = load double*, double** %7
%61 = getelementptr inbounds double, double* %60, i64 0
%62 = load double, double* %61
%63 = load i32, i32* %8
%64 = sitofp i32 %63 to double
%65 = fdiv double %62, %64
%66 = load double*, double** %7
%67 = getelementptr inbounds double, double* %66, i64 1
%68 = load double, double* %67
%69 = load i32, i32* %8
%70 = sitofp i32 %69 to double
%71 = fdiv double %68, %70
%72 = load double*, double** %7
%73 = getelementptr inbounds double, double* %72, i64 2
%74 = load double, double* %73
%75 = load i32, i32* %8
%76 = sitofp i32 %75 to double
%77 = fdiv double %74, %76
%78 = load double*, double** %7
%79 = getelementptr inbounds double, double* %78, i64 0
%80 = load double, double* %79
%81 = load double*, double** %7
%82 = getelementptr inbounds double, double* %81, i64 1
%83 = load double, double* %82
%84 = call double @llvm.fmuladd.f64(double %80, double 4.000000e+00, double %83)
%85 = load double*, double** %7
%86 = getelementptr inbounds double, double* %85, i64 2
%87 = load double, double* %86
%88 = fadd double %84, %87
%89 = load i32, i32* %8
%90 = mul nsw i32 %89, 6
%91 = sitofp i32 %90 to double
%92 = fdiv double %88, %91
%93 = load double*, double** %7
%94 = getelementptr inbounds double, double* %93, i64 0
%95 = load double, double* %94
%96 = load double*, double** %7
%97 = getelementptr inbounds double, double* %96, i64 1
%98 = load double, double* %97
%99 = call double @llvm.fmuladd.f64(double %95, double 4.000000e+00, double %98)
%100 = load double*, double** %7
%101 = getelementptr inbounds double, double* %100, i64 2
%102 = load double, double* %101
%103 = fadd double %99, %102
%104 = load i32, i32* %8
%105 = mul nsw i32 %104, 6
%106 = call double @ssim_db(double %103, i32 %105)
%107 = call i32 (i8*, double, double, double, double, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), double %65, double %71, double %77, double %92, double %106)
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"PSNR Y:%.3f U:%.3f V:%.3f All:%.3f | \00"
@.str.1 = [42 x i8] c"SSIM Y:%.5f U:%.5f V:%.5f All:%.5f (%.5f)\00"
define void @print_results(i32* nocapture %0, double* nocapture %1, i32 %2, i32 %3, i32 %4) {
%6 = load i32, i32* %0
%7 = mul nsw i32 %3, %2
%8 = mul nsw i32 %7, %4
%9 = tail call double @ssd_to_psnr(i32 %6, i32 %8)
%10 = getelementptr inbounds i32, i32* %0, i64 1
%11 = load i32, i32* %10
%12 = sdiv i32 %8, 4
%13 = tail call double @ssd_to_psnr(i32 %11, i32 %12)
%14 = getelementptr inbounds i32, i32* %0, i64 2
%15 = load i32, i32* %14
%16 = tail call double @ssd_to_psnr(i32 %15, i32 %12)
%17 = load i32, i32* %0
%18 = load i32, i32* %10
%19 = add nsw i32 %18, %17
%20 = load i32, i32* %14
%21 = add nsw i32 %19, %20
%22 = mul nsw i32 %8, 3
%23 = sdiv i32 %22, 2
%24 = tail call double @ssd_to_psnr(i32 %21, i32 %23)
%25 = tail call i32 (i8*, double, double, double, double, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %9, double %13, double %16, double %24)
%26 = load double, double* %1
%27 = sitofp i32 %2 to double
%28 = fdiv double %26, %27
%29 = getelementptr inbounds double, double* %1, i64 1
%30 = load double, double* %29
%31 = fdiv double %30, %27
%32 = getelementptr inbounds double, double* %1, i64 2
%33 = load double, double* %32
%34 = fdiv double %33, %27
%35 = tail call double @llvm.fmuladd.f64(double %26, double 4.000000e+00, double %30)
%36 = fadd double %35, %33
%37 = mul nsw i32 %2, 6
%38 = sitofp i32 %37 to double
%39 = fdiv double %36, %38
%40 = tail call double @ssim_db(double %36, i32 %37)
%41 = tail call i32 (i8*, double, double, double, double, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), double %28, double %31, double %34, double %39, double %40)
ret void
}