// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/SteerablePyramid.cpp
// Function: SteerablePyramid::DoOneStepWaveletSynthesis(int, double*, double*)
void SteerablePyramid::DoOneStepWaveletSynthesis(int level, Float_t* pixelValues, Float_t *upsampledThumbnail)
{
	int horDim = width_ / pow(2, level);
	int verDim = height_ / pow(2, level);
	int totalPixels = horDim * verDim;
	
	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;
		}
	}
	
	ConvolveImage(upsampledThumbnail, horDim, verDim, skFiltersInv[2], skFilterDims[2], pixelValues, true);
	ConvolveImage(b1Coeffs_[level], horDim, verDim, skFiltersInv[3], skFilterDims[3], pixelValues, false);
	ConvolveImage(b2Coeffs_[level], horDim, verDim, skFiltersInv[4], skFilterDims[4], pixelValues, false);
	ConvolveImage(b3Coeffs_[level], horDim, verDim, skFiltersInv[5], skFilterDims[5], pixelValues, false);
	ConvolveImage(b4Coeffs_[level], horDim, verDim, skFiltersInv[6], skFilterDims[6], pixelValues, false);
	
	if (level == 0)
	{
		ConvolveImage(pixelValues, horDim, verDim, skFiltersInv[1], skFilterDims[1], finalImage, true);
		ConvolveImage(h0Coeffs_, horDim, verDim, skFiltersInv[0], skFilterDims[0], finalImage, false);
	}
	
	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, %r13
movq %rdx, 0x20(%rsp)
movl %esi, %ebp
movq %rdi, %r14
cvtsi2sdl 0x30(%rdi), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0xc772(%rip), %xmm0     # 0x2a058
movl %esi, %edi
callq 0x3410
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %r15d
xorps %xmm0, %xmm0
cvtsi2sdl 0x34(%r14), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0xc745(%rip), %xmm0     # 0x2a058
movl %ebp, %edi
callq 0x3410
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %r12d
movl %r12d, %eax
imull %r15d, %eax
testl %r12d, %r12d
jle 0x1d9e1
movq 0x40(%r14), %rcx
movl %r12d, %esi
leal 0x1(%r12), %edx
decq %rsi
movq %rsi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl %edx
shlq $0x3, %rdx
leal (%r15,%r15), %esi
movdqa 0xf86c(%rip), %xmm1     # 0x2d1d0
xorl %edi, %edi
movdqa 0xf872(%rip), %xmm2     # 0x2d1e0
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0xf872(%rip), %xmm4     # 0x2d1f0
xorl %r8d, %r8d
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %r9d
notl %r9d
testb $0x1, %r9b
je 0x1d9b9
movl %edi, (%rcx,%r8)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %r9d
testb $0x1, %r9b
je 0x1d9d2
leal (%r15,%rdi), %r9d
movl %r9d, 0x4(%rcx,%r8)
paddq %xmm4, %xmm1
addq $0x8, %r8
addl %esi, %edi
cmpq %r8, %rdx
jne 0x1d981
movslq %eax, %rdx
testl %ebp, %ebp
je 0x1d9f7
shlq $0x3, %rdx
movq $0x0, 0x10(%rsp)
jmp 0x1da19
leaq (,%rdx,8), %rbx
testl %edx, %edx
movq $-0x1, %rdi
cmovnsq %rbx, %rdi
callq 0x3030
movq %rax, 0x10(%rsp)
movq %rbx, %rdx
movq %r13, %rdi
xorl %esi, %esi
movq %rdx, 0x18(%rsp)
callq 0x3190
movl 0x38(%r14), %ecx
decl %ecx
movslq %ebp, %rbx
movl %ebp, %edx
movq 0x20(%rsp), %rbp
movq %rbp, %rax
movl %edx, 0x8(%rsp)
cmpl %edx, %ecx
jne 0x1da4b
movq 0x28(%r14), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x2, %r12d
jl 0x1daaf
movl %r12d, %ecx
shrl %ecx
leal (%r15,%r15), %edx
movl %r15d, %esi
shrl $0x1f, %esi
addl %r15d, %esi
sarl %esi
xorl %edi, %edi
movsd 0xf759(%rip), %xmm0     # 0x2d1c8
cmpl $0x2, %r15d
jl 0x1daa7
movl %edx, %r8d
imull %edi, %r8d
movslq %r8d, %r8
leaq (,%r8,8), %r8
addq %r13, %r8
movl %esi, %r9d
movsd (%rax), %xmm1
mulsd %xmm0, %xmm1
addq $0x8, %rax
movsd %xmm1, (%r8)
addq $0x10, %r8
decl %r9d
jne 0x1da8d
incq %rdi
cmpq %rcx, %rdi
jne 0x1da6f
movq 0x1c0ba(%rip), %r8      # 0x39b70
movl 0x1c04b(%rip), %r9d     # 0x39b08
movq %r14, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl %r12d, %ecx
pushq $0x1
pushq %rbp
callq 0x1c474
addq $0x10, %rsp
movq 0x8(%r14), %rax
movq (%rax,%rbx,8), %rsi
movq 0x1c094(%rip), %r8      # 0x39b78
movl 0x1c021(%rip), %r9d     # 0x39b0c
xorl %r13d, %r13d
movq %r14, %rdi
movl %r15d, %edx
movl %r12d, %ecx
pushq %r13
pushq %rbp
callq 0x1c474
addq $0x10, %rsp
movq 0x10(%r14), %rax
movq (%rax,%rbx,8), %rsi
movq 0x1c06e(%rip), %r8      # 0x39b80
movl 0x1bff7(%rip), %r9d     # 0x39b10
movq %r14, %rdi
movl %r15d, %edx
movl %r12d, %ecx
pushq %r13
pushq %rbp
callq 0x1c474
addq $0x10, %rsp
movq 0x18(%r14), %rax
movq (%rax,%rbx,8), %rsi
movq 0x1c04b(%rip), %r8      # 0x39b88
movl 0x1bfd0(%rip), %r9d     # 0x39b14
movq %r14, %rdi
movl %r15d, %edx
movl %r12d, %ecx
pushq %r13
pushq %rbp
callq 0x1c474
addq $0x10, %rsp
movq 0x20(%r14), %rax
movq (%rax,%rbx,8), %rsi
movq 0x1c028(%rip), %r8      # 0x39b90
movl 0x1bfa9(%rip), %r9d     # 0x39b18
movq %r14, %rdi
movl %r15d, %edx
movl %r12d, %ecx
pushq %r13
pushq %rbp
callq 0x1c474
addq $0x10, %rsp
cmpl $0x0, 0x8(%rsp)
je 0x1db9a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1bfc7(%rip), %r8      # 0x39b68
movl 0x1bf5c(%rip), %r9d     # 0x39b04
movq %r14, %rdi
movq %rbp, %rsi
movl %r15d, %edx
movl %r12d, %ecx
pushq $0x1
movq 0x18(%rsp), %rbx
pushq %rbx
callq 0x1c474
addq $0x10, %rsp
movq (%r14), %rsi
movq 0x1bf91(%rip), %r8      # 0x39b60
movl 0x1bf2a(%rip), %r9d     # 0x39b00
movq %r14, %rdi
movl %r15d, %edx
movl %r12d, %ecx
pushq $0x0
pushq %rbx
callq 0x1c474
addq $0x10, %rsp
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
callq 0x3260
testq %rbx, %rbx
je 0x1db8b
movq 0x10(%rsp), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x33c0