// File: 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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl $0x0, -0x14(%rbp)
movq -0xb0(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x38(%rcx), %eax
jge 0x31e74
movq -0xb0(%rbp), %rax
cvtsi2sdl 0x30(%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
movl -0x14(%rbp), %esi
movl $0x2, %edi
callq 0x1d7f0
movq -0xb0(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0xc0(%rbp), %xmm0
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, -0x18(%rbp)
cvtsi2sdl 0x34(%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
movl -0x14(%rbp), %esi
movl $0x2, %edi
callq 0x1d7f0
movaps %xmm0, %xmm1
movsd -0xb8(%rbp), %xmm0
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
imull -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movslq -0x20(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x4030
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x31c84
movq -0xb0(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x8(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x2c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x10(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x2c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x18(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x2c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
movsd 0x1a88c(%rip), %xmm1    # 0x4c240
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x38(%rbp), %xmm0
jbe 0x31afa
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x2c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq -0x28(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
movsd %xmm0, (%rcx,%rdx,8)
movq 0x10(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x31a45
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0xb0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x31a9d
movq -0xb0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0xb0(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x31af5
movq -0xb0(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x31c74
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x31c5d
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x2c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq -0x28(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
movsd %xmm0, (%rcx,%rdx,8)
movq 0x10(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x31b82
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0xb0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x31bd6
movq -0xb0(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0xb0(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x31c2a
movq -0xb0(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x31c72
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd 0x173b3(%rip), %xmm0    # 0x49020
movsd %xmm0, (%rax,%rcx,8)
jmp 0x31c74
jmp 0x31c76
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x31910
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x31ce4
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x17391(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
ucomisd -0x40(%rbp), %xmm0
jbe 0x31cd7
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x17372(%rip), %xmm1    # 0x49040
pand %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x31cd9
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x31c93
movsd -0x40(%rbp), %xmm1
movsd 0x1a537(%rip), %xmm0    # 0x4c228
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x4630
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0xe110
jmp 0x31d2e
leaq -0x71(%rbp), %rdi
callq 0x43f0
leaq 0x1a7ff(%rip), %rsi     # 0x4c53d
leaq -0x70(%rbp), %rdi
callq 0x4360
jmp 0x31d49
movl -0x14(%rbp), %eax
addl $0x30, %eax
movsbl %al, %esi
leaq -0x70(%rbp), %rdi
callq 0x4220
jmp 0x31d5d
leaq 0x18551(%rip), %rsi     # 0x4a2b5
leaq -0x70(%rbp), %rdi
callq 0x4360
jmp 0x31d6f
movq -0x28(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0xe0(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xdc(%rbp)
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x4180
jmp 0x31dab
movsd -0xd8(%rbp), %xmm0
movl -0xdc(%rbp), %ecx
movl -0xe0(%rbp), %edx
movq -0xe8(%rbp), %rsi
movq -0xb0(%rbp), %rdi
movsd 0x1a463(%rip), %xmm1    # 0x4c238
leaq -0xa8(%rbp), %r8
callq 0x31510
jmp 0x31de3
leaq -0xa8(%rbp), %rdi
callq 0x46c8
movq -0x28(%rbp), %rax
movq %rax, -0xf0(%rbp)
cmpq $0x0, %rax
je 0x31e0c
movq -0xf0(%rbp), %rdi
callq 0x44d0
leaq -0x70(%rbp), %rdi
callq 0x46c8
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x31855
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x43f0
jmp 0x31e7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x31e69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x46c8
leaq -0x70(%rbp), %rdi
callq 0x46c8
jmp 0x31e7d
addq $0xf0, %rsp
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x4620
nopw %cs:(%rax,%rax)