// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq %rsi, 0x30(%rsp)
movq %rdi, %r14
movabsq $0x3ff0000000000000, %r12 # imm = 0x3FF0000000000000
xorl %r15d, %r15d
movslq 0x38(%r14), %rax
cmpq %rax, %r15
jge 0x1a155
cvtsi2sd %r15d, %xmm0
movsd %xmm0, 0x8(%rsp)
movss 0x30(%r14), %xmm1
movaps %xmm1, 0x20(%rsp)
callq 0x3280
movapd %xmm0, 0x10(%rsp)
movups 0x34(%r14), %xmm0
unpcklps 0x20(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
cvtdq2pd %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x3280
unpcklpd 0x10(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd 0x20(%rsp), %xmm1
divpd %xmm0, %xmm1
cvttpd2dq %xmm1, %xmm0
movd %xmm0, %eax
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ebp
movl %eax, 0x8(%rsp)
imull %ebp, %eax
movslq %eax, %r13
leaq (,%r13,8), %rdi
testl %r13d, %r13d
pushq $-0x1
popq %rax
cmovsq %rax, %rdi
movl $0x0, %eax
cmovlel %eax, %r13d
callq 0x3030
movapd 0x94ec(%rip), %xmm4     # 0x23470
movsd 0x9c5c(%rip), %xmm3     # 0x23be8
xorpd %xmm2, %xmm2
movq %rax, %rbx
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
movq 0x18(%r14), %rdx
movq 0x20(%r14), %rsi
xorl %edi, %edi
cmpq %rdi, %r13
je 0x1a08b
movq (%rax,%r15,8), %r8
movsd (%r8,%rdi,8), %xmm0
movapd %xmm0, %xmm1
addsd %xmm2, %xmm1
movq (%rcx,%r15,8), %r10
addsd (%r10,%rdi,8), %xmm1
movq (%rdx,%r15,8), %r9
addsd (%r9,%rdi,8), %xmm1
movq (%rsi,%r15,8), %r8
addsd (%r8,%rdi,8), %xmm1
mulsd %xmm3, %xmm1
ucomisd %xmm1, %xmm2
jbe 0x1a02a
movsd %xmm0, (%rbx,%rdi,8)
movsd (%r10,%rdi,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1a002
movsd %xmm1, (%rbx,%rdi,8)
movapd %xmm1, %xmm0
movsd (%r9,%rdi,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1a017
movsd %xmm1, (%rbx,%rdi,8)
movapd %xmm1, %xmm0
movsd (%r8,%rdi,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1a083
movsd %xmm1, (%rbx,%rdi,8)
jmp 0x1a083
ucomisd %xmm2, %xmm1
jbe 0x1a07f
movsd %xmm0, (%rbx,%rdi,8)
movsd (%r10,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1a04a
movsd %xmm1, (%rbx,%rdi,8)
movapd %xmm1, %xmm0
movsd (%r9,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1a05f
movsd %xmm1, (%rbx,%rdi,8)
movapd %xmm1, %xmm0
movsd (%r8,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1a074
movsd %xmm1, (%rbx,%rdi,8)
movapd %xmm1, %xmm0
xorpd %xmm4, %xmm0
movlpd %xmm0, (%rbx,%rdi,8)
jmp 0x1a083
movq %r12, (%rbx,%rdi,8)
incq %rdi
jmp 0x19fa5
pxor %xmm0, %xmm0
xorl %eax, %eax
movapd 0x7f77(%rip), %xmm1     # 0x22010
movq %xmm0, 0x10(%rsp)
cmpq %rax, %r13
je 0x1a0b8
movsd (%rbx,%rax,8), %xmm0
andpd %xmm1, %xmm0
maxsd 0x10(%rsp), %xmm0
incq %rax
jmp 0x1a099
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq 0x30(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x7fcc
movq %r13, %rdi
leaq 0xc224(%rip), %rsi      # 0x262fd
callq 0x3510
leal 0x30(%r15), %eax
movsbl %al, %esi
movq %r13, %rdi
callq 0x3250
movq %r13, %rdi
leaq 0x90d6(%rip), %rsi      # 0x231cd
callq 0x3510
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x33b0
movsd 0xb077(%rip), %xmm0     # 0x25188
divsd 0x10(%rsp), %xmm0
movq %rbx, %rsi
movl %ebp, %edx
movl 0x8(%rsp), %ecx
movsd 0xb068(%rip), %xmm1     # 0x25190
leaq 0x38(%rsp), %rbp
movq %rbp, %r8
callq 0x19d1c
movq %rbp, %rdi
callq 0x3548
movq %rbx, %rdi
callq 0x3380
movq %r13, %rdi
callq 0x3548
incq %r15
jmp 0x19ee5
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3548
jmp 0x1a176
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x3548
movq %rbx, %rdi
callq 0x34d0