// File: kebwi[P]Trifid/src/SteerablePyramid.cpp
// Function: SteerablePyramid::DoFullWaveletAnalysis(double const*, int, int, bool)
void SteerablePyramid::DoFullWaveletAnalysis(const Float_t* pixelValues, int width, int height, bool useFTconvolution)
{
	gT1 = getCurrentTime_ms();
	gT2 = gT3 = gT4 = gT5 = 0;
	
	Init(width, height);
	
	useFTconvolution_ = useFTconvolution;
	
	if (!useFTconvolution_)
		cout << endl << "SteerablePyramid Fourier Transform convolution disabled" << endl;
	
	int totalPixels = width_ * height_;
	/*
	Float_t minPixel = 999999, maxPixel = -999999;
	for (int i = 0; i < totalPixels; i++)
	{
		if (pixelValues[i] < minPixel)
			minPixel = pixelValues[i];
		if (pixelValues[i] > maxPixel)
			maxPixel = pixelValues[i];
	}
	cout << "Analysis Min/Max Pixels: " << minPixel << "    " << maxPixel << endl;
	*/
	memcpy(scratch_2D_A_, pixelValues, width_ * height_ * sizeof(Float_t));
	
	//cout << "  Performing analysis with " << numLevels_ << " levels" <<  endl;
	for (int i = 0; i < numLevels_; i++)
	{
		//cout << "    Analyzing level " << i << "..." << endl;
		if (!useFTconvolution_)
			DoOneStepWaveletAnalysis(scratch_2D_A_, i);
		else DoOneStepWaveletAnalysisUsingFT(scratch_2D_A_, i);
	}
	
	//cout << "  Done" << endl;
	
	gT1 = getCurrentTime_ms() - gT1;
	Float_t t1Secs = (Float_t)gT1 / CURRENT_TIME_PER_SEC_F;
	Float_t t2Secs = (Float_t)gT2 / CURRENT_TIME_PER_SEC_F;
	Float_t t3Secs = (Float_t)gT3 / CURRENT_TIME_PER_SEC_F;
	Float_t t4Secs = (Float_t)gT4 / CURRENT_TIME_PER_SEC_F;
	Float_t t5Secs = (Float_t)gT5 / CURRENT_TIME_PER_SEC_F;
	Float_t t2Fraction = (Float_t)gT2 / (Float_t)gT1;
	Float_t t3Fraction = (Float_t)gT3 / (Float_t)gT1;
	Float_t t4Fraction = (Float_t)gT4 / (Float_t)gT1;
	Float_t t5Fraction = (Float_t)gT5 / (Float_t)gT1;
	/*
	cout << "  Times:" << endl;
	cout << "    Total: " << t1Secs << endl;
	cout << "    T2: ";
	cout << setw(10) << t2Secs << "   Ratio: ";
	cout << setw(10) << t2Fraction << endl;
	cout << "    T3: ";
	cout << setw(10) << t3Secs << "   Ratio: ";
	cout << setw(10) << t3Fraction << endl;
	*/
	//cout << "  At2 " << t2Fraction << "  At3 " << t3Fraction << "  ";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x55c0
movq -0x78(%rbp), %rdi
movq %rax, 0x2f987(%rip)     # 0x5cc80
movq $0x0, 0x2f984(%rip) # 0x5cc88
movq $0x0, 0x2f981(%rip) # 0x5cc90
movq $0x0, 0x2f95e(%rip) # 0x5cc78
movq $0x0, 0x2f94b(%rip) # 0x5cc70
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x29ce0
movq -0x78(%rbp), %rax
movb -0x19(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x48(%rax)
testb $0x1, 0x48(%rax)
jne 0x2d374
movq 0x2cc86(%rip), %rdi     # 0x59fd0
movq 0x2cc67(%rip), %rsi     # 0x59fb8
callq 0x43d0
movq %rax, %rdi
leaq 0x1f844(%rip), %rsi     # 0x4cba4
callq 0x4390
movq %rax, %rdi
movq 0x2cc49(%rip), %rsi     # 0x59fb8
callq 0x43d0
movq -0x78(%rbp), %rcx
movl 0x30(%rcx), %eax
imull 0x34(%rcx), %eax
movl %eax, -0x20(%rbp)
movq 0x2f827(%rip), %rdi     # 0x5cbb0
movq -0x10(%rbp), %rsi
movl 0x30(%rcx), %eax
imull 0x34(%rcx), %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x4300
movl $0x0, -0x24(%rbp)
movq -0x78(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x38(%rcx), %eax
jge 0x2d3f2
movq -0x78(%rbp), %rax
testb $0x1, 0x48(%rax)
jne 0x2d3d2
movq -0x78(%rbp), %rdi
movq 0x2f7e8(%rip), %rsi     # 0x5cbb0
movl -0x24(%rbp), %edx
callq 0x2c950
jmp 0x2d3e5
movq -0x78(%rbp), %rdi
movq 0x2f7d3(%rip), %rsi     # 0x5cbb0
movl -0x24(%rbp), %edx
callq 0x2ccd0
jmp 0x2d3e7
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2d3a7
callq 0x55c0
movq 0x2f882(%rip), %rcx     # 0x5cc80
subq %rcx, %rax
movq %rax, 0x2f878(%rip)     # 0x5cc80
movq 0x2f870(%rip), %xmm0    # 0x5cc80
movaps 0x1bc39(%rip), %xmm3    # 0x49050
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x1bc3d(%rip), %xmm2    # 0x49060
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x1e7e6(%rip), %xmm1    # 0x4bc20
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x2f825(%rip), %xmm0    # 0x5cc70
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm4
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm4, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x2f809(%rip), %xmm0    # 0x5cc78
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm4
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm4, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq 0x2f7fd(%rip), %xmm0    # 0x5cc90
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm4
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm4, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movq 0x2f7d1(%rip), %xmm0    # 0x5cc88
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm4
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm4, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq 0x2f795(%rip), %xmm0    # 0x5cc70
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x2f78a(%rip), %xmm1    # 0x5cc80
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm4
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm4, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movq 0x2f75e(%rip), %xmm0    # 0x5cc78
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x2f74b(%rip), %xmm1    # 0x5cc80
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm4
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm4, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movq 0x2f737(%rip), %xmm0    # 0x5cc90
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x2f70c(%rip), %xmm1    # 0x5cc80
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm4
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm4, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movq 0x2f6f0(%rip), %xmm0    # 0x5cc88
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x2f6cd(%rip), %xmm1    # 0x5cc80
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)