// File: kebwi[P]Trifid/src/ImagePairStats.cpp
// Function: calc1ChnlMSE(ImageReal const&, ImageReal const&)
Float_t calc1ChnlMSE(const ImageReal &img1, const ImageReal &img2)
{
	assert(img1.width() > 0 && img1.height() > 0);
	assert(img1.width() == img2.width() && img1.height() == img2.height());
	
	Float_t mse = 0;
	
	int width = img1.width(), height = img1.height();
	int numNonborderPixels = 0;
	for (int y = skEdgeSkip; y < height - skEdgeSkip; y++)
		for (int x = skEdgeSkip; x < width - skEdgeSkip; x++)
		{
			mse += SQR(img2(x, y) - img1(x, y));
			numNonborderPixels++;
		}
	
	assert(mse >= 0);
	
	mse /= (Float_t)numNonborderPixels;
	
	return mse;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0xedd0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2d(%rbp)
jle 0x372d7
movq -0x8(%rbp), %rdi
callq 0xedf0
cmpl $0x0, %eax
setg %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
testb $0x1, %al
jne 0x372e0
jmp 0x372e2
jmp 0x37301
leaq 0x1629b(%rip), %rdi     # 0x4d584
leaq 0x162ba(%rip), %rsi     # 0x4d5aa
movl $0x4e, %edx
leaq 0x1634d(%rip), %rcx     # 0x4d649
callq 0x4240
movq -0x8(%rbp), %rdi
callq 0xedd0
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
callq 0xedd0
movl -0x34(%rbp), %ecx
movl %eax, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x2e(%rbp)
jne 0x37346
movq -0x8(%rbp), %rdi
callq 0xedf0
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0xedf0
movl %eax, %ecx
movl -0x38(%rbp), %eax
cmpl %ecx, %eax
sete %al
movb %al, -0x2e(%rbp)
movb -0x2e(%rbp), %al
testb $0x1, %al
jne 0x3734f
jmp 0x37351
jmp 0x37370
leaq 0x147ce(%rip), %rdi     # 0x4bb26
leaq 0x1624b(%rip), %rsi     # 0x4d5aa
movl $0x4f, %edx
leaq 0x162de(%rip), %rcx     # 0x4d649
callq 0x4240
xorps %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0xedd0
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
callq 0xedf0
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl -0x20(%rbp), %ecx
subl $0x0, %ecx
cmpl %ecx, %eax
jge 0x3746a
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x0, %ecx
cmpl %ecx, %eax
jge 0x3745a
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x1d980
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x1d980
movsd -0x50(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x1d980
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x1d980
movsd -0x48(%rbp), %xmm2
movsd -0x40(%rbp), %xmm0
subsd (%rax), %xmm2
movsd -0x18(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x373b6
jmp 0x3745c
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3739e
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x3747a
jmp 0x37499
leaq 0x161bf(%rip), %rdi     # 0x4d640
leaq 0x16122(%rip), %rsi     # 0x4d5aa
movl $0x5c, %edx
leaq 0x161b5(%rip), %rcx     # 0x4d649
callq 0x4240
cvtsi2sdl -0x24(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)