// File: /workspace/github_cpp_makefile_star2_O2/kebwi[P]Trifid/src/SteerablePyramid.cpp
// Function: SteerablePyramid::DoOneStepWaveletSynthesisUsingFT(int, double*, double*)
void SteerablePyramid::DoOneStepWaveletSynthesisUsingFT(int level, Float_t* pixelValues, Float_t *upsampledThumbnail)
{
	int horDim = width_ / pow(2, level);
	int verDim = height_ / pow(2, level);
	int totalPixels = horDim * verDim;
	
	int filterIndex = getFilterFTIndex();
	
	for (int i = 0; i < verDim; i++)
		yLookup_[i] = i * horDim;
	
	Float_t *finalImage = NULL;
	Float_t *pixelPtr = NULL;
	Float_t *coeffPtr = NULL;
	
	if (level == 0)
		finalImage = new Float_t[totalPixels];
	
	//Is this necessary or did new clear out the allocated memory?
	memset(upsampledThumbnail, 0, totalPixels * sizeof(Float_t));
	
	//Upsample the growing thumbnail from the base thumbnail (lowest level) or the previous iteration's thumbnail
	
	if (level == numLevels_ - 1)	//Lowest level, upsample actual stored thumbnail
		pixelPtr = l1Coeffs_[level];
	else	//Intermediate level, upsample growing thumbnail from previous iteration
		pixelPtr = pixelValues;
	
	for (int y = 0; y < verDim / 2; y++)
	{
		coeffPtr = &upsampledThumbnail[(y * 2) * horDim];
		for (int x = 0; x < horDim / 2; x++)
		{
			*coeffPtr = *pixelPtr++ * 4;
			coeffPtr += 2;
		}
	}
	
	assert(doFourierAnalysis(upsampledThumbnail, scratch_2D_A_, horDim, verDim));
	assert(multiplyFourierTransformsAndInvert(scratch_2D_A_, skFiltersFTs[filterIndex].filtersInvFTs[2][level], horDim, verDim, pixelValues));
	
	assert(doFourierAnalysis(b1Coeffs_[level], scratch_2D_A_, horDim, verDim));
	assert(multiplyFourierTransformsAndInvert(scratch_2D_A_, skFiltersFTs[filterIndex].filtersInvFTs[3][level], horDim, verDim, scratch_2D_B_));
	for (int i = 0; i < totalPixels; i++)
		pixelValues[i] += scratch_2D_B_[i];
	
	assert(doFourierAnalysis(b2Coeffs_[level], scratch_2D_A_, horDim, verDim));
	assert(multiplyFourierTransformsAndInvert(scratch_2D_A_, skFiltersFTs[filterIndex].filtersInvFTs[4][level], horDim, verDim, scratch_2D_B_));
	for (int i = 0; i < totalPixels; i++)
		pixelValues[i] += scratch_2D_B_[i];
	
	assert(doFourierAnalysis(b3Coeffs_[level], scratch_2D_A_, horDim, verDim));
	assert(multiplyFourierTransformsAndInvert(scratch_2D_A_, skFiltersFTs[filterIndex].filtersInvFTs[5][level], horDim, verDim, scratch_2D_B_));
	for (int i = 0; i < totalPixels; i++)
		pixelValues[i] += scratch_2D_B_[i];
	
	assert(doFourierAnalysis(b4Coeffs_[level], scratch_2D_A_, horDim, verDim));
	assert(multiplyFourierTransformsAndInvert(scratch_2D_A_, skFiltersFTs[filterIndex].filtersInvFTs[6][level], horDim, verDim, scratch_2D_B_));
	for (int i = 0; i < totalPixels; i++)
		pixelValues[i] += scratch_2D_B_[i];
	
	if (level == 0)
	{
		assert(doFourierAnalysis(pixelValues, scratch_2D_A_, horDim, verDim));
		assert(multiplyFourierTransformsAndInvert(scratch_2D_A_, skFiltersFTs[filterIndex].filtersInvFTs[1][level], horDim, verDim, finalImage));
		
		assert(doFourierAnalysis(h0Coeffs_, scratch_2D_A_, horDim, verDim));
		assert(multiplyFourierTransformsAndInvert(scratch_2D_A_, skFiltersFTs[filterIndex].filtersInvFTs[0][level], horDim, verDim, scratch_2D_B_));
		for (int i = 0; i < totalPixels; i++)
			finalImage[i] += scratch_2D_B_[i];
	}
	
	if (level == 0)
		memcpy(pixelValues, finalImage, totalPixels * sizeof(Float_t));
	
	if (level == 0)
		delete [] finalImage;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r15
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r12
cvtsi2sdl 0x30(%rdi), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0xa320(%rip), %xmm0     # 0x22058
movl %esi, %edi
callq 0x33f0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %r14d
cvtsi2sdl 0x34(%r12), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0xa2f5(%rip), %xmm0     # 0x22058
movl %ebp, 0x1c(%rsp)
movl %ebp, %edi
callq 0x33f0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebp
movq %r12, %rdi
callq 0x15ee0
movl %eax, 0x10(%rsp)
movq %r12, 0x8(%rsp)
movq 0x40(%r12), %rax
xorl %ecx, %ecx
testl %ebp, %ebp
movl $0x0, %edx
cmovgl %ebp, %edx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x17db0
movl %ecx, (%rax,%rsi,4)
incq %rsi
addl %r14d, %ecx
jmp 0x17da0
movl %ebp, %r12d
imull %r14d, %r12d
movslq %r12d, %rdx
cmpl $0x0, 0x1c(%rsp)
movl %ebp, 0x2c(%rsp)
je 0x17dce
shlq $0x3, %rdx
xorl %r13d, %r13d
jmp 0x17dea
shlq $0x3, %rdx
testl %r12d, %r12d
pushq $-0x1
popq %rdi
cmovnsq %rdx, %rdi
movq %rdx, %r13
callq 0x3030
movq %r13, %rdx
movq %rax, %r13
xorl %ebp, %ebp
movq %r15, %rdi
xorl %esi, %esi
movq %rdx, 0x30(%rsp)
callq 0x3170
movq 0x8(%rsp), %rax
movl 0x38(%rax), %eax
decl %eax
movl 0x1c(%rsp), %ecx
movslq %ecx, %rdx
movq %rbx, %rsi
cmpl %ecx, %eax
jne 0x17e20
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rax
movq (%rax,%rdx,8), %rsi
movq %rdx, 0x20(%rsp)
pushq $0x2
popq %rdi
movl 0x2c(%rsp), %eax
cltd
idivl %edi
movl %eax, %ecx
movl %r14d, %eax
cltd
idivl %edi
testl %eax, %eax
cmovlel %ebp, %eax
testl %ecx, %ecx
cmovlel %ebp, %ecx
leal (%r14,%r14), %edx
addl %eax, %eax
movsd 0xd349(%rip), %xmm0     # 0x25198
xorl %edi, %edi
cmpq %rcx, %rdi
je 0x17e84
movslq %ebp, %r8
leaq (%r15,%r8,8), %r8
xorl %r9d, %r9d
cmpl %r9d, %eax
je 0x17e7d
movsd (%rsi), %xmm1
mulsd %xmm0, %xmm1
addq $0x8, %rsi
movsd %xmm1, (%r8,%r9,8)
addq $0x2, %r9
jmp 0x17e60
incq %rdi
addl %edx, %ebp
jmp 0x17e51
movq 0x1ac45(%rip), %rsi     # 0x32ad0
movq %r15, %rdi
movl %r14d, %edx
movl 0x2c(%rsp), %ebp
movl %ebp, %ecx
callq 0x140ee
testb %al, %al
je 0x18226
movq 0x1ac25(%rip), %rdi     # 0x32ad0
movslq 0x10(%rsp), %rax
movq 0x1ac01(%rip), %rcx     # 0x32ab8
imulq $0x158, %rax, %rax      # imm = 0x158
movq %rax, 0x10(%rsp)
movq 0xe0(%rcx,%rax), %rax
movq 0x20(%rsp), %r15
movq (%rax,%r15,8), %rsi
movl %r14d, %edx
movl %ebp, %ecx
movq %rbx, %r8
callq 0x142ba
testb %al, %al
je 0x18245
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax,%r15,8), %rdi
movq 0x1abd3(%rip), %rsi     # 0x32ad0
movl %r14d, %edx
movl %ebp, %ecx
callq 0x140ee
testb %al, %al
je 0x18264
movq 0x1abba(%rip), %rdi     # 0x32ad0
movq 0x1ab9b(%rip), %rax     # 0x32ab8
movq 0x10(%rsp), %rcx
movq 0xf8(%rax,%rcx), %rax
movq (%rax,%r15,8), %rsi
movq 0x1aba3(%rip), %r8      # 0x32ad8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x142ba
testb %al, %al
je 0x18283
movq 0x1ab8a(%rip), %rax     # 0x32ad8
xorl %ecx, %ecx
testl %r12d, %r12d
cmovlel %ecx, %r12d
movq 0x20(%rsp), %rdx
cmpq %rcx, %r12
je 0x17f75
movsd (%rax,%rcx,8), %xmm0
addsd (%rbx,%rcx,8), %xmm0
movsd %xmm0, (%rbx,%rcx,8)
incq %rcx
jmp 0x17f5c
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rdx,8), %rdi
movq 0x1ab47(%rip), %rsi     # 0x32ad0
movq %rdx, %r15
movl %r14d, %edx
movl %ebp, %ecx
callq 0x140ee
testb %al, %al
je 0x182a2
movq 0x1ab2b(%rip), %rdi     # 0x32ad0
movq 0x1ab0c(%rip), %rax     # 0x32ab8
movq 0x10(%rsp), %rcx
movq 0x110(%rax,%rcx), %rax
movq (%rax,%r15,8), %rsi
movq 0x1ab14(%rip), %r8      # 0x32ad8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x142ba
testb %al, %al
je 0x182c1
movq 0x1aafb(%rip), %rax     # 0x32ad8
xorl %ecx, %ecx
movq 0x20(%rsp), %rdx
cmpq %rcx, %r12
je 0x17ffd
movsd (%rax,%rcx,8), %xmm0
addsd (%rbx,%rcx,8), %xmm0
movsd %xmm0, (%rbx,%rcx,8)
incq %rcx
jmp 0x17fe4
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax,%rdx,8), %rdi
movq 0x1aabf(%rip), %rsi     # 0x32ad0
movq %rdx, %r15
movl %r14d, %edx
movl %ebp, %ecx
callq 0x140ee
testb %al, %al
je 0x182e0
movq 0x1aaa3(%rip), %rdi     # 0x32ad0
movq 0x1aa84(%rip), %rax     # 0x32ab8
movq 0x10(%rsp), %rcx
movq 0x128(%rax,%rcx), %rax
movq (%rax,%r15,8), %rsi
movq 0x1aa8c(%rip), %r8      # 0x32ad8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x142ba
testb %al, %al
je 0x182ff
movq 0x1aa73(%rip), %rax     # 0x32ad8
xorl %ecx, %ecx
movq 0x20(%rsp), %rdx
cmpq %rcx, %r12
je 0x18085
movsd (%rax,%rcx,8), %xmm0
addsd (%rbx,%rcx,8), %xmm0
movsd %xmm0, (%rbx,%rcx,8)
incq %rcx
jmp 0x1806c
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq (%rax,%rdx,8), %rdi
movq 0x1aa37(%rip), %rsi     # 0x32ad0
movq %rdx, %r15
movl %r14d, %edx
movl %ebp, %ecx
callq 0x140ee
testb %al, %al
je 0x1831e
movq 0x1aa1b(%rip), %rdi     # 0x32ad0
movq 0x1a9fc(%rip), %rax     # 0x32ab8
movq 0x10(%rsp), %rcx
movq 0x140(%rax,%rcx), %rax
movq (%rax,%r15,8), %rsi
movq 0x1aa04(%rip), %r8      # 0x32ad8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x142ba
testb %al, %al
je 0x1833d
movq 0x1a9eb(%rip), %rax     # 0x32ad8
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x18108
movsd (%rax,%rcx,8), %xmm0
addsd (%rbx,%rcx,8), %xmm0
movsd %xmm0, (%rbx,%rcx,8)
incq %rcx
jmp 0x180ef
cmpl $0x0, 0x1c(%rsp)
je 0x1811e
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a9ab(%rip), %rsi     # 0x32ad0
movq %rbx, %rdi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x140ee
testb %al, %al
je 0x1835c
movq 0x1a98f(%rip), %rdi     # 0x32ad0
movq 0x1a970(%rip), %rax     # 0x32ab8
movq 0x10(%rsp), %rcx
movq 0xc8(%rax,%rcx), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movl %r14d, %edx
movl %ebp, %ecx
movq %r13, %r8
callq 0x142ba
testb %al, %al
je 0x1837b
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq 0x1a94e(%rip), %rsi     # 0x32ad0
movl %r14d, %edx
movl %ebp, %ecx
callq 0x140ee
testb %al, %al
je 0x1839a
movq 0x1a935(%rip), %rdi     # 0x32ad0
movq 0x1a916(%rip), %rax     # 0x32ab8
movq 0x10(%rsp), %rcx
movq 0xb0(%rax,%rcx), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x1a919(%rip), %r8      # 0x32ad8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x142ba
testb %al, %al
je 0x183b9
movq 0x1a900(%rip), %rax     # 0x32ad8
xorl %ecx, %ecx
movq 0x30(%rsp), %rdx
cmpq %rcx, %r12
je 0x181fc
movsd (%rax,%rcx,8), %xmm0
addsd (%r13,%rcx,8), %xmm0
movsd %xmm0, (%r13,%rcx,8)
incq %rcx
jmp 0x181df
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3240
testq %r13, %r13
je 0x1810f
movq %r13, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3380
leaq 0xd88d(%rip), %rdi      # 0x25aba
leaq 0xd08e(%rip), %rsi      # 0x252c2
leaq 0xd8c4(%rip), %rcx      # 0x25aff
movl $0x57d, %edx            # imm = 0x57D
callq 0x31a0
leaq 0xd906(%rip), %rdi      # 0x25b52
leaq 0xd06f(%rip), %rsi      # 0x252c2
leaq 0xd8a5(%rip), %rcx      # 0x25aff
movl $0x57e, %edx            # imm = 0x57E
callq 0x31a0
leaq 0xd969(%rip), %rdi      # 0x25bd4
leaq 0xd050(%rip), %rsi      # 0x252c2
leaq 0xd886(%rip), %rcx      # 0x25aff
movl $0x580, %edx            # imm = 0x580
callq 0x31a0
leaq 0xd98d(%rip), %rdi      # 0x25c17
leaq 0xd031(%rip), %rsi      # 0x252c2
leaq 0xd867(%rip), %rcx      # 0x25aff
movl $0x581, %edx            # imm = 0x581
callq 0x31a0
leaq 0xd9f2(%rip), %rdi      # 0x25c9b
leaq 0xd012(%rip), %rsi      # 0x252c2
leaq 0xd848(%rip), %rcx      # 0x25aff
movl $0x585, %edx            # imm = 0x585
callq 0x31a0
leaq 0xda16(%rip), %rdi      # 0x25cde
leaq 0xcff3(%rip), %rsi      # 0x252c2
leaq 0xd829(%rip), %rcx      # 0x25aff
movl $0x586, %edx            # imm = 0x586
callq 0x31a0
leaq 0xda7b(%rip), %rdi      # 0x25d62
leaq 0xcfd4(%rip), %rsi      # 0x252c2
leaq 0xd80a(%rip), %rcx      # 0x25aff
movl $0x58a, %edx            # imm = 0x58A
callq 0x31a0
leaq 0xda9f(%rip), %rdi      # 0x25da5
leaq 0xcfb5(%rip), %rsi      # 0x252c2
leaq 0xd7eb(%rip), %rcx      # 0x25aff
movl $0x58b, %edx            # imm = 0x58B
callq 0x31a0
leaq 0xdb04(%rip), %rdi      # 0x25e29
leaq 0xcf96(%rip), %rsi      # 0x252c2
leaq 0xd7cc(%rip), %rcx      # 0x25aff
movl $0x58f, %edx            # imm = 0x58F
callq 0x31a0
leaq 0xdb28(%rip), %rdi      # 0x25e6c
leaq 0xcf77(%rip), %rsi      # 0x252c2
leaq 0xd7ad(%rip), %rcx      # 0x25aff
movl $0x590, %edx            # imm = 0x590
callq 0x31a0
leaq 0xdb8d(%rip), %rdi      # 0x25ef0
leaq 0xcf58(%rip), %rsi      # 0x252c2
leaq 0xd78e(%rip), %rcx      # 0x25aff
movl $0x596, %edx            # imm = 0x596
callq 0x31a0
leaq 0xdbac(%rip), %rdi      # 0x25f2e
leaq 0xcf39(%rip), %rsi      # 0x252c2
leaq 0xd76f(%rip), %rcx      # 0x25aff
movl $0x597, %edx            # imm = 0x597
callq 0x31a0
leaq 0xdc0e(%rip), %rdi      # 0x25faf
leaq 0xcf1a(%rip), %rsi      # 0x252c2
leaq 0xd750(%rip), %rcx      # 0x25aff
movl $0x599, %edx            # imm = 0x599
callq 0x31a0
leaq 0xdc2b(%rip), %rdi      # 0x25feb
leaq 0xcefb(%rip), %rsi      # 0x252c2
leaq 0xd731(%rip), %rcx      # 0x25aff
movl $0x59a, %edx            # imm = 0x59A
callq 0x31a0