// File: kebwi[P]Trifid/src/SteerablePyramid.cpp
// Function: SteerablePyramid::CalcStats(std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&) const
void SteerablePyramid::CalcStats(vector<Float_t> &means, vector<Float_t> &stdDevs) const
{
	assert(width_ > 0 && height_ > 0);
	
	//Init the vectors
	means.resize(numLevels_ + 1);
	stdDevs.resize(numLevels_ + 1);
	for (int i = 0; i <= numLevels_; i++)
		means[i] = stdDevs[i] = 0;
	
	//Get the H0 means
	int totalPixels = width_ * height_;
	for (int i = 0; i < totalPixels; i++)
		means[0] += fabs(h0Coeffs_[i]);
	means[0] /= totalPixels;
	
	//Get the B means
	for (int i = 0; i < numLevels_; i++)
	{
		totalPixels = (width_ * height_) / (int)(pow(4, i));
		for (int j = 0; j < totalPixels; j++)
		{
			means[i + 1] += fabs(b1Coeffs_[i][j]);
			means[i + 1] += fabs(b2Coeffs_[i][j]);
			means[i + 1] += fabs(b3Coeffs_[i][j]);
			means[i + 1] += fabs(b4Coeffs_[i][j]);
		}
		means[i + 1] /= (totalPixels * 4);
	}
	
	//Get the H0 std devs
	for (int i = 0; i < totalPixels; i++)
		stdDevs[0] += fabs(h0Coeffs_[i] - means[0]);
	stdDevs[0] /= totalPixels;
	
	//Get the B std devs
	for (int i = 0; i < numLevels_; i++)
	{
		totalPixels = (width_ * height_) / (int)(pow(4, i));
		for (int j = 0; j < totalPixels; j++)
		{
			stdDevs[i + 1] += fabs(b1Coeffs_[i][j] - means[i]);
			stdDevs[i + 1] += fabs(b2Coeffs_[i][j] - means[i]);
			stdDevs[i + 1] += fabs(b3Coeffs_[i][j] - means[i]);
			stdDevs[i + 1] += fabs(b4Coeffs_[i][j] - means[i]);
		}
		stdDevs[i + 1] /= (totalPixels * 4);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x48(%rbp)
xorl %eax, %eax
cmpl $0x0, 0x30(%rcx)
movb %al, -0x39(%rbp)
jle 0x2e668
movq -0x48(%rbp), %rax
cmpl $0x0, 0x34(%rax)
setg %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x2e671
jmp 0x2e673
jmp 0x2e692
leaq 0x1eb17(%rip), %rdi     # 0x4d191
leaq 0x1dcd5(%rip), %rsi     # 0x4c356
movl $0x603, %edx            # imm = 0x603
leaq 0x1eb57(%rip), %rcx     # 0x4d1e4
callq 0x4240
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x38(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe5e0
movq -0x48(%rbp), %rax
movq -0x18(%rbp), %rdi
movl 0x38(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe5e0
movl $0x0, -0x1c(%rbp)
movq -0x48(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x38(%rcx), %eax
jg 0x2e704
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0xe670
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0xe670
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2e6c5
movq -0x48(%rbp), %rcx
movl 0x30(%rcx), %eax
imull 0x34(%rcx), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x2e766
movq -0x48(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1a908(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe670
movsd -0x50(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2e719
cvtsi2sdl -0x20(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe670
movsd -0x58(%rbp), %xmm1
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl $0x0, -0x28(%rbp)
movq -0x48(%rbp), %rcx
movl -0x28(%rbp), %eax
cmpl 0x38(%rcx), %eax
jge 0x2e95d
movq -0x48(%rbp), %rcx
movl 0x30(%rcx), %eax
imull 0x34(%rcx), %eax
movl %eax, -0x5c(%rbp)
movl -0x28(%rbp), %esi
movl $0x4, %edi
callq 0x1d7f0
movl -0x5c(%rbp), %eax
cvttsd2si %xmm0, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x2e917
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1a840(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0x80(%rbp), %xmm0
movq %rax, %rcx
movq -0x48(%rbp), %rax
addsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
movq 0x10(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1a7f5(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0x78(%rbp), %xmm0
movq %rax, %rcx
movq -0x48(%rbp), %rax
addsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
movq 0x18(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1a7aa(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0x70(%rbp), %xmm0
movq %rax, %rcx
movq -0x48(%rbp), %rax
addsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
movq 0x20(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1a75f(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0x68(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2e7d4
movl -0x20(%rbp), %eax
shll $0x2, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0x88(%rbp), %xmm1
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2e795
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x2e9d8
movq -0x48(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x98(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe670
movsd -0x98(%rbp), %xmm0
subsd (%rax), %xmm0
movaps 0x1a69c(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe670
movsd -0x90(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2e964
cvtsi2sdl -0x20(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe670
movsd -0xa0(%rbp), %xmm1
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x48(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0x38(%rcx), %eax
jge 0x2ec77
movq -0x48(%rbp), %rcx
movl 0x30(%rcx), %eax
imull 0x34(%rcx), %eax
movl %eax, -0xa4(%rbp)
movl -0x34(%rbp), %esi
movl $0x4, %edi
callq 0x1d7f0
movl -0xa4(%rbp), %eax
cvttsd2si %xmm0, %ecx
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x2ec31
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xe8(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xe670
movsd -0xe8(%rbp), %xmm0
subsd (%rax), %xmm0
movaps 0x1a5a1(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0xe0(%rbp), %xmm0
movq %rax, %rcx
movq -0x48(%rbp), %rax
addsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xd8(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xe670
movsd -0xd8(%rbp), %xmm0
subsd (%rax), %xmm0
movaps 0x1a52f(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0xd0(%rbp), %xmm0
movq %rax, %rcx
movq -0x48(%rbp), %rax
addsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
movq 0x18(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xe670
movsd -0xc8(%rbp), %xmm0
subsd (%rax), %xmm0
movaps 0x1a4bd(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0xc0(%rbp), %xmm0
movq %rax, %rcx
movq -0x48(%rbp), %rax
addsd (%rcx), %xmm0
movsd %xmm0, (%rcx)
movq 0x20(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0xe670
movsd -0xb8(%rbp), %xmm0
subsd (%rax), %xmm0
movaps 0x1a44b(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0xb0(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x2ea52
movl -0x20(%rbp), %eax
shll $0x2, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0xf0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xe670
movsd -0xf0(%rbp), %xmm1
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2ea0d
addq $0xf0, %rsp
popq %rbp
retq