// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movq %rcx, %r15
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r12
cvtsi2sdl 0x30(%rdi), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0xd0d0(%rip), %xmm0     # 0x2b058
movl %esi, %edi
callq 0x3410
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %r14d
xorps %xmm0, %xmm0
cvtsi2sdl 0x34(%r12), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0xd0a2(%rip), %xmm0     # 0x2b058
movl %ebp, 0x18(%rsp)
movl %ebp, %edi
callq 0x3410
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebp
movl %ebp, %eax
imull %r14d, %eax
movl %eax, 0xc(%rsp)
movq %r12, 0x10(%rsp)
movq %r12, %rdi
callq 0x1bdac
movl %eax, 0x1c(%rsp)
testl %ebp, %ebp
jle 0x1e00b
movq 0x10(%rsp), %rax
movq 0x40(%rax), %rax
movl %ebp, %ecx
xorl %edx, %edx
xorl %esi, %esi
movl %edx, (%rax,%rsi,4)
incq %rsi
addl %r14d, %edx
cmpq %rsi, %rcx
jne 0x1dffd
movslq 0xc(%rsp), %r12
cmpl $0x0, 0x18(%rsp)
je 0x1e01c
xorl %r13d, %r13d
jmp 0x1e03a
leaq (,%r12,8), %rax
testl %r12d, %r12d
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x3030
movq %rax, %r13
shlq $0x3, %r12
movq %r15, %rdi
xorl %esi, %esi
movq %r12, 0x20(%rsp)
movq %r12, %rdx
callq 0x3190
movq 0x10(%rsp), %rax
movl 0x38(%rax), %ecx
decl %ecx
movl 0x18(%rsp), %edx
movslq %edx, %r12
movq %rbx, %rax
cmpl %edx, %ecx
jne 0x1e075
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
movq (%rax,%r12,8), %rax
cmpl $0x2, %ebp
jl 0x1e0d0
movl %ebp, %ecx
shrl %ecx
leal (%r14,%r14), %edx
movl %r14d, %esi
shrl $0x1f, %esi
addl %r14d, %esi
sarl %esi
xorl %edi, %edi
movsd 0x100f9(%rip), %xmm0    # 0x2e190
cmpl $0x2, %r14d
jl 0x1e0c8
movl %edx, %r8d
imull %edi, %r8d
movslq %r8d, %r8
leaq (%r15,%r8,8), %r8
movl %esi, %r9d
movsd (%rax), %xmm1
mulsd %xmm0, %xmm1
addq $0x8, %rax
movsd %xmm1, (%r8)
addq $0x10, %r8
decl %r9d
jne 0x1e0ae
incq %rdi
cmpq %rcx, %rdi
jne 0x1e097
movq 0x1ba09(%rip), %rsi     # 0x39ae0
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x1995b
testb %al, %al
je 0x1e445
movq 0x1b9ed(%rip), %rdi     # 0x39ae0
movslq 0x1c(%rsp), %rax
movq 0x1b9c9(%rip), %rcx     # 0x39ac8
imulq $0x158, %rax, %r15      # imm = 0x158
movq 0xe0(%rcx,%r15), %rax
movq (%rax,%r12,8), %rsi
movl %r14d, %edx
movl %ebp, %ecx
movq %rbx, %r8
callq 0x19b7e
testb %al, %al
je 0x1e464
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax,%r12,8), %rdi
movq 0x1b9a5(%rip), %rsi     # 0x39ae0
movl %r14d, %edx
movl %ebp, %ecx
callq 0x1995b
testb %al, %al
je 0x1e483
movq 0x1b98c(%rip), %rdi     # 0x39ae0
movq 0x1b96d(%rip), %rax     # 0x39ac8
movq 0xf8(%rax,%r15), %rax
movq (%rax,%r12,8), %rsi
movq 0x1b97a(%rip), %r8      # 0x39ae8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x19b7e
testb %al, %al
je 0x1e4a2
movl 0xc(%rsp), %ecx
testl %ecx, %ecx
jle 0x1e1aa
movq 0x1b959(%rip), %rax     # 0x39ae8
movl %ecx, %ecx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm0
addsd (%rbx,%rdx,8), %xmm0
movsd %xmm0, (%rbx,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x1e193
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax,%r12,8), %rdi
movq 0x1b922(%rip), %rsi     # 0x39ae0
movl %r14d, %edx
movl %ebp, %ecx
callq 0x1995b
testb %al, %al
je 0x1e4c1
movq 0x1b909(%rip), %rdi     # 0x39ae0
movq 0x1b8ea(%rip), %rax     # 0x39ac8
movq 0x110(%rax,%r15), %rax
movq (%rax,%r12,8), %rsi
movq 0x1b8f7(%rip), %r8      # 0x39ae8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x19b7e
testb %al, %al
je 0x1e4e0
movl 0xc(%rsp), %ecx
testl %ecx, %ecx
jle 0x1e22d
movq 0x1b8d6(%rip), %rax     # 0x39ae8
movl %ecx, %ecx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm0
addsd (%rbx,%rdx,8), %xmm0
movsd %xmm0, (%rbx,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x1e216
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax,%r12,8), %rdi
movq 0x1b89f(%rip), %rsi     # 0x39ae0
movl %r14d, %edx
movl %ebp, %ecx
callq 0x1995b
testb %al, %al
je 0x1e4ff
movq 0x1b886(%rip), %rdi     # 0x39ae0
movq 0x1b867(%rip), %rax     # 0x39ac8
movq 0x128(%rax,%r15), %rax
movq (%rax,%r12,8), %rsi
movq 0x1b874(%rip), %r8      # 0x39ae8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x19b7e
testb %al, %al
je 0x1e51e
movl 0xc(%rsp), %ecx
testl %ecx, %ecx
jle 0x1e2b0
movq 0x1b853(%rip), %rax     # 0x39ae8
movl %ecx, %ecx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm0
addsd (%rbx,%rdx,8), %xmm0
movsd %xmm0, (%rbx,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x1e299
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movq (%rax,%r12,8), %rdi
movq 0x1b81c(%rip), %rsi     # 0x39ae0
movl %r14d, %edx
movl %ebp, %ecx
callq 0x1995b
testb %al, %al
je 0x1e53d
movq 0x1b803(%rip), %rdi     # 0x39ae0
movq 0x1b7e4(%rip), %rax     # 0x39ac8
movq 0x140(%rax,%r15), %rax
movq (%rax,%r12,8), %rsi
movq 0x1b7f1(%rip), %r8      # 0x39ae8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x19b7e
testb %al, %al
je 0x1e55c
movl 0xc(%rsp), %ecx
testl %ecx, %ecx
jle 0x1e333
movq 0x1b7d0(%rip), %rax     # 0x39ae8
movl %ecx, %ecx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm0
addsd (%rbx,%rdx,8), %xmm0
movsd %xmm0, (%rbx,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x1e31c
cmpl $0x0, 0x18(%rsp)
je 0x1e349
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1b790(%rip), %rsi     # 0x39ae0
movq %rbx, %rdi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x1995b
testb %al, %al
je 0x1e57b
movq 0x1b774(%rip), %rdi     # 0x39ae0
movq 0x1b755(%rip), %rax     # 0x39ac8
movq 0xc8(%rax,%r15), %rax
movq (%rax,%r12,8), %rsi
movl %r14d, %edx
movl %ebp, %ecx
movq %r13, %r8
callq 0x19b7e
testb %al, %al
je 0x1e59a
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movq 0x1b73d(%rip), %rsi     # 0x39ae0
movl %r14d, %edx
movl %ebp, %ecx
callq 0x1995b
testb %al, %al
je 0x1e5b9
movq 0x1b724(%rip), %rdi     # 0x39ae0
movq 0x1b705(%rip), %rax     # 0x39ac8
movq 0xb0(%rax,%r15), %rax
movq (%rax,%r12,8), %rsi
movq 0x1b712(%rip), %r8      # 0x39ae8
movl %r14d, %edx
movl %ebp, %ecx
callq 0x19b7e
testb %al, %al
je 0x1e5d8
movl 0xc(%rsp), %ecx
testl %ecx, %ecx
movq 0x20(%rsp), %rdx
jle 0x1e41b
movq 0x1b6ec(%rip), %rax     # 0x39ae8
movl %ecx, %ecx
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm0
addsd (%r13,%rsi,8), %xmm0
movsd %xmm0, (%r13,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0x1e400
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3260
testq %r13, %r13
je 0x1e33a
movq %r13, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x33c0
leaq 0x10666(%rip), %rdi     # 0x2eab2
leaq 0xfe67(%rip), %rsi      # 0x2e2ba
leaq 0x1069d(%rip), %rcx     # 0x2eaf7
movl $0x57d, %edx            # imm = 0x57D
callq 0x31c0
leaq 0x106df(%rip), %rdi     # 0x2eb4a
leaq 0xfe48(%rip), %rsi      # 0x2e2ba
leaq 0x1067e(%rip), %rcx     # 0x2eaf7
movl $0x57e, %edx            # imm = 0x57E
callq 0x31c0
leaq 0x10742(%rip), %rdi     # 0x2ebcc
leaq 0xfe29(%rip), %rsi      # 0x2e2ba
leaq 0x1065f(%rip), %rcx     # 0x2eaf7
movl $0x580, %edx            # imm = 0x580
callq 0x31c0
leaq 0x10766(%rip), %rdi     # 0x2ec0f
leaq 0xfe0a(%rip), %rsi      # 0x2e2ba
leaq 0x10640(%rip), %rcx     # 0x2eaf7
movl $0x581, %edx            # imm = 0x581
callq 0x31c0
leaq 0x107cb(%rip), %rdi     # 0x2ec93
leaq 0xfdeb(%rip), %rsi      # 0x2e2ba
leaq 0x10621(%rip), %rcx     # 0x2eaf7
movl $0x585, %edx            # imm = 0x585
callq 0x31c0
leaq 0x107ef(%rip), %rdi     # 0x2ecd6
leaq 0xfdcc(%rip), %rsi      # 0x2e2ba
leaq 0x10602(%rip), %rcx     # 0x2eaf7
movl $0x586, %edx            # imm = 0x586
callq 0x31c0
leaq 0x10854(%rip), %rdi     # 0x2ed5a
leaq 0xfdad(%rip), %rsi      # 0x2e2ba
leaq 0x105e3(%rip), %rcx     # 0x2eaf7
movl $0x58a, %edx            # imm = 0x58A
callq 0x31c0
leaq 0x10878(%rip), %rdi     # 0x2ed9d
leaq 0xfd8e(%rip), %rsi      # 0x2e2ba
leaq 0x105c4(%rip), %rcx     # 0x2eaf7
movl $0x58b, %edx            # imm = 0x58B
callq 0x31c0
leaq 0x108dd(%rip), %rdi     # 0x2ee21
leaq 0xfd6f(%rip), %rsi      # 0x2e2ba
leaq 0x105a5(%rip), %rcx     # 0x2eaf7
movl $0x58f, %edx            # imm = 0x58F
callq 0x31c0
leaq 0x10901(%rip), %rdi     # 0x2ee64
leaq 0xfd50(%rip), %rsi      # 0x2e2ba
leaq 0x10586(%rip), %rcx     # 0x2eaf7
movl $0x590, %edx            # imm = 0x590
callq 0x31c0
leaq 0x10966(%rip), %rdi     # 0x2eee8
leaq 0xfd31(%rip), %rsi      # 0x2e2ba
leaq 0x10567(%rip), %rcx     # 0x2eaf7
movl $0x596, %edx            # imm = 0x596
callq 0x31c0
leaq 0x10985(%rip), %rdi     # 0x2ef26
leaq 0xfd12(%rip), %rsi      # 0x2e2ba
leaq 0x10548(%rip), %rcx     # 0x2eaf7
movl $0x597, %edx            # imm = 0x597
callq 0x31c0
leaq 0x109e7(%rip), %rdi     # 0x2efa7
leaq 0xfcf3(%rip), %rsi      # 0x2e2ba
leaq 0x10529(%rip), %rcx     # 0x2eaf7
movl $0x599, %edx            # imm = 0x599
callq 0x31c0
leaq 0x10a04(%rip), %rdi     # 0x2efe3
leaq 0xfcd4(%rip), %rsi      # 0x2e2ba
leaq 0x1050a(%rip), %rcx     # 0x2eaf7
movl $0x59a, %edx            # imm = 0x59A
callq 0x31c0
nop