// File: /workspace/github_cpp_makefile_star2_O2/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 0x191cc
movq %rax, 0x8(%r15)
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x191d9
movq %rax, 0x8(%rbx)
movq %rsp, %r12
xorl %ebp, %ebp
cmpq $0x2, %rbp
je 0x192fd
andq $0x0, (%rsp)
cvtsi2sdl 0x30(%r14), %xmm0
movsd %xmm0, 0x8(%rsp)
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x10(%rsp)
callq 0x3280
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %r13d
cvtsi2sdl 0x34(%r14), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x3280
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
imull %r13d, %eax
movsd (%rsp), %xmm0
movq 0x8(%r14), %rcx
movq 0x10(%r14), %rdx
movq 0x18(%r14), %rsi
movq 0x20(%r14), %rdi
testl %eax, %eax
movl $0x0, %r8d
cmovlel %r8d, %eax
xorl %r8d, %r8d
movapd 0x8da4(%rip), %xmm2     # 0x22010
cmpq %r8, %rax
je 0x192ea
movq (%rcx,%rbp,8), %r9
movsd (%r9,%r8,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1928e
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
movq (%rdx,%rbp,8), %r9
movsd (%r9,%r8,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x192ab
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
movq (%rsi,%rbp,8), %r9
movsd (%r9,%r8,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x192c8
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
movq (%rdi,%rbp,8), %r9
movsd (%r9,%r8,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x192e5
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
incq %r8
jmp 0x1926c
movq %r15, %rdi
movq %r12, %rsi
callq 0x1a958
incq %rbp
jmp 0x191de
movq %rsp, %r15
xorl %r13d, %r13d
movslq 0x38(%r14), %rax
cmpq %rax, %r13
jge 0x193c6
andq $0x0, (%rsp)
cvtsi2sdl 0x30(%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x1(%r13), %rbp
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x3280
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movq %rbx, %r12
cvttsd2si %xmm1, %ebx
cvtsi2sdl 0x34(%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x3280
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
imull %ebx, %eax
movq %r12, %rbx
movsd (%rsp), %xmm0
movq 0x28(%r14), %rcx
testl %eax, %eax
movl $0x0, %edx
cmovlel %edx, %eax
xorl %edx, %edx
movapd 0x8c83(%rip), %xmm2     # 0x22010
cmpq %rdx, %rax
je 0x193b3
movq (%rcx,%r13,8), %rsi
movsd (%rsi,%rdx,8), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x193ae
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
incq %rdx
jmp 0x1938d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1a958
movq %rbp, %r13
jmp 0x19303
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop