// File: /workspace/github_cpp_makefile_star2_O1/kebwi[P]Trifid/src/SteerablePyramid.cpp
// Function: SteerablePyramid::FindStrongestCoefficients(std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&)
void SteerablePyramid::FindStrongestCoefficients(vector<Float_t> &maxCoeffs, vector<Float_t> &maxThumbnailPixels)
{
	maxCoeffs.clear();
	maxThumbnailPixels.clear();
	
	//Find the highest magnitude coefficients
	for (int i = 0; i < 2/*numLevels_*/; i++)
	{
		Float_t maxCoeff = 0;
		int horDim = width_ / pow(2, i);
		int verDim = height_ / pow(2, i);
		int totalPixels = horDim * verDim;
		for (int j = 0; j < totalPixels; j++)
		{
			//if (i == 0 && fabs(h0Coeffs_[j]) > maxCoeff)
			//	maxCoeff = fabs(h0Coeffs_[j]);
			if (fabs(b1Coeffs_[i][j]) > maxCoeff)
				maxCoeff = fabs(b1Coeffs_[i][j]);
			if (fabs(b2Coeffs_[i][j]) > maxCoeff)
				maxCoeff = fabs(b2Coeffs_[i][j]);
			if (fabs(b3Coeffs_[i][j]) > maxCoeff)
				maxCoeff = fabs(b3Coeffs_[i][j]);
			if (fabs(b4Coeffs_[i][j]) > maxCoeff)
				maxCoeff = fabs(b4Coeffs_[i][j]);
		}
		maxCoeffs.push_back(maxCoeff);
	}
	
	//Find the highest thumbnail values
	for (int i = 0; i < numLevels_; i++)
	{
		Float_t maxThumbnailPixel = 0;
		int horDim = width_ / pow(2, i + 1);
		int verDim = height_ / pow(2, i + 1);
		int totalPixels = horDim * verDim;
		for (int j = 0; j < totalPixels; j++)
			if (fabs(l1Coeffs_[i][j]) > maxThumbnailPixel)
				maxThumbnailPixel = fabs(l1Coeffs_[i][j]);
		maxThumbnailPixels.push_back(maxThumbnailPixel);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rsi), %rax
cmpq %rax, 0x8(%rsi)
je 0x1f460
movq %rax, 0x8(%r15)
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x1f46d
movq %rax, 0x8(%rbx)
xorl %r13d, %r13d
movq %rsp, %r12
movq $0x0, (%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x30(%r14), %xmm0
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x10(%rsp)
callq 0x32a0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebp
xorps %xmm0, %xmm0
cvtsi2sdl 0x34(%r14), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x32a0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %edi
imull %ebp, %edi
testl %edi, %edi
movapd 0xbb30(%rip), %xmm2     # 0x2b010
jle 0x1f57c
movsd (%rsp), %xmm0
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
movq (%rax,%r13,8), %rax
movq (%rcx,%r13,8), %rcx
movq 0x18(%r14), %rdx
movq (%rdx,%r13,8), %rdx
movq 0x20(%r14), %rsi
movq (%rsi,%r13,8), %rsi
movl %edi, %edi
xorl %r8d, %r8d
movsd (%rax,%r8,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1f529
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
movsd (%rcx,%r8,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1f542
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
movsd (%rdx,%r8,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1f55b
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
movsd (%rsi,%r8,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1f574
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
incq %r8
cmpq %r8, %rdi
jne 0x1f510
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x1f599
movsd (%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r15)
jmp 0x1f5a4
movq %r15, %rdi
movq %r12, %rdx
callq 0x22742
leaq 0x1(%r13), %rax
testq %r13, %r13
movq %rax, %r13
je 0x1f473
cmpl $0x0, 0x38(%r14)
jle 0x1f6a1
xorl %r13d, %r13d
movq %rsp, %r15
movq $0x0, (%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x30(%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x1(%r13), %r12
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x32a0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebp
xorps %xmm0, %xmm0
cvtsi2sdl 0x34(%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x32a0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
imull %ebp, %ecx
testl %ecx, %ecx
movapd 0xb9da(%rip), %xmm2     # 0x2b010
jle 0x1f669
movsd (%rsp), %xmm0
movq 0x28(%r14), %rax
movq (%rax,%r13,8), %rax
movl %ecx, %ecx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1f661
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
incq %rdx
cmpq %rdx, %rcx
jne 0x1f649
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x1f686
movsd (%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x1f691
movq %rbx, %rdi
movq %r15, %rdx
callq 0x22742
movslq 0x38(%r14), %rax
movq %r12, %r13
cmpq %rax, %r12
jl 0x1f5c5
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq