// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/SteerablePyramid.cpp
// Function: SteerablePyramid::GenerateMaxAbsImages(char const*)
void SteerablePyramid::GenerateMaxAbsImages(const char* filenameHeader)
{
	for (int i = 0; i < numLevels_; i++)
	{
		int horDim = width_ / pow(2, i);
		int verDim = height_ / pow(2, i);
		int totalPixelsThisLevel = horDim * verDim;
		Float_t *img = new Float_t[totalPixelsThisLevel];
		
		for (int j = 0; j < totalPixelsThisLevel; j++)
		{
			Float_t meanVal = 0;
			meanVal += b1Coeffs_[i][j];
			meanVal += b2Coeffs_[i][j];
			meanVal += b3Coeffs_[i][j];
			meanVal += b4Coeffs_[i][j];
			meanVal /= 4;
			
			if (meanVal < 0)	//Min
			{
				img[j] = b1Coeffs_[i][j];
				if (b2Coeffs_[i][j] < img[j])
					img[j] = b2Coeffs_[i][j];
				if (b3Coeffs_[i][j] < img[j])
					img[j] = b3Coeffs_[i][j];
				if (b4Coeffs_[i][j] < img[j])
					img[j] = b4Coeffs_[i][j];
			}
			else if (meanVal > 0)	//Max
			{
				img[j] = b1Coeffs_[i][j];
				if (b2Coeffs_[i][j] > img[j])
					img[j] = b2Coeffs_[i][j];
				if (b3Coeffs_[i][j] > img[j])
					img[j] = b3Coeffs_[i][j];
				if (b4Coeffs_[i][j] > img[j])
					img[j] = b4Coeffs_[i][j];
				
				img[j] = -img[j];
			}
			else img[j] = 1;
		}
		
		Float_t maxCoeff = 0;
		for (int j = 0; j < totalPixelsThisLevel; j++)
			if (fabs(img[j]) > maxCoeff)
				maxCoeff = fabs(img[j]);
		
		Float_t coeffScalar = 127.0 / maxCoeff;
		
		string filename(filenameHeader);
		filename += "_";
		filename += '0' + i;
		filename += ".pgm";
		
		GeneratePGMimage(img, horDim, verDim, coeffScalar, 128, filename);
		
		delete [] img;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, 0x60(%rsp)
cmpl $0x0, 0x38(%rdi)
jle 0x21000
movq %rdi, %r14
xorl %r12d, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd %xmm0, 0x40(%rsp)
movss 0x30(%r14), %xmm1
movaps %xmm1, 0x30(%rsp)
callq 0x32a0
movapd %xmm0, 0x50(%rsp)
movups 0x34(%r14), %xmm0
unpcklps 0x30(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
cvtdq2pd %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movsd 0x40(%rsp), %xmm0
callq 0x32a0
unpcklpd 0x50(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd 0x30(%rsp), %xmm1
divpd %xmm0, %xmm1
cvttpd2dq %xmm1, %xmm0
movd %xmm0, %ebp
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ebx
movl %ebp, 0x50(%rsp)
imull %ebx, %ebp
movslq %ebp, %r15
leaq (,%r15,8), %rdi
testl %r15d, %r15d
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x3030
movq %rax, %r13
xorpd %xmm1, %xmm1
testl %r15d, %r15d
movapd 0x9246(%rip), %xmm4     # 0x2a010
jle 0x20f20
movq 0x8(%r14), %rax
movq 0x10(%r14), %rdx
movq (%rax,%r12,8), %rcx
movq (%rdx,%r12,8), %rdx
movq 0x18(%r14), %rax
movq (%rax,%r12,8), %rsi
movq 0x20(%r14), %rax
movq (%rax,%r12,8), %rdi
movl %ebp, %eax
xorl %r8d, %r8d
xorpd %xmm2, %xmm2
movsd 0xadf7(%rip), %xmm3     # 0x2bbf8
movapd 0xa677(%rip), %xmm5     # 0x2b480
movabsq $0x3ff0000000000000, %r9 # imm = 0x3FF0000000000000
movsd (%rcx,%r8,8), %xmm0
movapd %xmm0, %xmm1
addsd %xmm2, %xmm1
addsd (%rdx,%r8,8), %xmm1
addsd (%rsi,%r8,8), %xmm1
addsd (%rdi,%r8,8), %xmm1
mulsd %xmm3, %xmm1
ucomisd %xmm1, %xmm2
jbe 0x20e87
movsd %xmm0, (%r13,%r8,8)
movsd (%rdx,%r8,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x20e5b
movsd %xmm1, (%r13,%r8,8)
movapd %xmm1, %xmm0
movsd (%rsi,%r8,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x20e72
movsd %xmm1, (%r13,%r8,8)
movapd %xmm1, %xmm0
movsd (%rdi,%r8,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x20eeb
movsd %xmm1, (%r13,%r8,8)
jmp 0x20eeb
ucomisd %xmm2, %xmm1
jbe 0x20ee6
movsd %xmm0, (%r13,%r8,8)
movsd (%rdx,%r8,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x20eab
movsd %xmm1, (%r13,%r8,8)
movapd %xmm1, %xmm0
movsd (%rsi,%r8,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x20ec2
movsd %xmm1, (%r13,%r8,8)
movapd %xmm1, %xmm0
movsd (%rdi,%r8,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x20ed9
movsd %xmm1, (%r13,%r8,8)
movapd %xmm1, %xmm0
xorpd %xmm5, %xmm0
movlpd %xmm0, (%r13,%r8,8)
jmp 0x20eeb
movq %r9, (%r13,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0x20e13
xorpd %xmm1, %xmm1
testl %ebp, %ebp
jle 0x20f20
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
movsd (%r13,%rcx,8), %xmm1
andpd %xmm4, %xmm1
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %rax
jne 0x20f05
movapd %xmm1, 0x40(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq 0x60(%rsp), %rsi
leaq 0xf(%rsp), %rdx
callq 0x9ee4
movq %rbp, %rdi
leaq 0xd416(%rip), %rsi      # 0x2e35d
callq 0x3540
leaq 0x78(%rsp), %r15
leal 0x30(%r12), %eax
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3280
movq %rbp, %rdi
leaq 0xa272(%rip), %rsi      # 0x2b1dd
callq 0x3540
movq %r15, 0x68(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0xa92c
movsd 0xc224(%rip), %xmm0     # 0x2d1b8
divsd 0x40(%rsp), %xmm0
movq %r13, %rsi
movl %ebx, %edx
movl 0x50(%rsp), %ecx
movsd 0xc215(%rip), %xmm1     # 0x2d1c0
leaq 0x68(%rsp), %r8
callq 0x20a86
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x20fcc
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3310
movq %r13, %rdi
callq 0x33c0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x20ff0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3310
incq %r12
movslq 0x38(%r14), %rax
cmpq %rax, %r12
jl 0x20d30
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x21031
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x21031
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2104d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3310
movq %rbx, %rdi
callq 0x3500
nop