// File: /workspace/github_c_makefile_star2_O0/calmopyrin[P]tedplay/Filter.cpp
// Function: Filter::reCalcWindowTable()
void Filter::reCalcWindowTable()
{
	int i;
	const double pi = 4 * atan(1.0);
	const double f = fc_;
	double gain = double(1 << precision_) - 1.0; // 4095.0
	double kernelSum = 0;
	
	// #intervals between time steps for resampling
	timeStep = 1U;

	windowTableSize = order_ * int(timeStep);
	int midorder = windowTableSize / 2;
	double *dblCoeffs = new double[windowTableSize + 1];

	if (sampleHistory_) delete [] sampleHistory_;
	sampleHistory_ = new int [windowTableSize + 1];

	if (windowTable_) delete [] windowTable_;
	windowTable_ = new int[windowTableSize + 1];

	// this is used for resampling
	for (i = 0; i < windowTableSize; i++) {
		double j = i - midorder;
		double x = pi * j / double(timeStep);

		// Blackman has better stop-band attenuation
		double blackman = 0.42 + 0.5 * cos(2 * x / double(windowTableSize)) 
			- 0.08*cos(4 * pi * j / double(windowTableSize));
		// Hamming has 20% faster roll-off
		double hamming = 0.54 + 0.46 * cos(2 * x / double(windowTableSize));
		// von Hann is in between
		double vonHann = 0.5 * (1.0 + cos(2 * x / double(windowTableSize)));
		// Blackman-Harris window
		double a0 = 0.35875, a1 = 0.48229, a2 = 0.14128, a3 = 0.01168;
		double blackmanHarris = a0 + a1 * cos(2 * x / double(windowTableSize)) 
			- a2 * cos(4 * x / double(windowTableSize))
			+ a3 * cos(6 * x / double(windowTableSize));

		double c = (j == 0) ? 2.0 * f : sin(2.0 * f * x ) / x;

		c *= vonHann;
		dblCoeffs[i] = c;
		kernelSum += c;
	}

	for (i = 0; i < windowTableSize; i++) {
		double rebasedCoeff = dblCoeffs[i] / kernelSum * gain * mixingVolume;
		windowTable_[i] = (int)(rebasedCoeff + 0.5);
		sampleHistory_[i] = 0;
	}
	// Now decrease filter order if side coeffs are zero...
	i = 0;
	while (0 == windowTable_[i] && i < midorder) i++;
	if (i) {
		int k;
		int drop = i;

		i = 0;
		for(k = drop; k <= midorder; k++, i++)
			windowTable_[i] = windowTable_[k];
		order_ = order_ - drop * 2;

		if (i > 1) {
			int *b = windowTable_ + i - 2;
			do {
				windowTable_[i] = *b--;
			} while (++i < order_);
		}
		midorder = (order_ - 1) / 2;
	}
	windowTableSize = order_ * int(timeStep);
	if (!windowTableSize) {
		windowTableSize = 1;
		windowTable_[0] = int(gain);
		windowTable_[1] = 0;
	}

	sampleBufPtr_ = 0;
	sampleBufMask_ = (midorder << 1) + 1;

	delete [] dblCoeffs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movsd 0xa89e(%rip), %xmm0     # 0x1e020
callq 0x31e0
movq -0xb8(%rbp), %rax
movaps %xmm0, %xmm1
movsd 0xbac7(%rip), %xmm0     # 0x1f260
mulsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movl 0x40(%rax), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cvtsi2sd %ecx, %xmm0
movsd 0xa85c(%rip), %xmm1     # 0x1e020
subsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movl $0x1, 0x38(%rax)
movl 0x8(%rax), %ecx
imull 0x38(%rax), %ecx
movl %ecx, 0x18(%rax)
movl 0x18(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xb8(%rbp), %rax
movl %ecx, -0x34(%rbp)
movl 0x18(%rax), %eax
addl $0x1, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3040
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq %rcx, -0x40(%rbp)
cmpq $0x0, 0x20(%rax)
je 0x13861
movq -0xb8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, %rax
je 0x1385f
movq -0xc0(%rbp), %rdi
callq 0x3330
jmp 0x13861
movq -0xb8(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3040
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq %rcx, 0x20(%rax)
cmpq $0x0, 0x10(%rax)
je 0x138cc
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
je 0x138ca
movq -0xc8(%rbp), %rdi
callq 0x3330
jmp 0x138cc
movq -0xb8(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3040
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0xc(%rbp)
movq -0xb8(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x18(%rcx), %eax
jge 0x13c51
movq -0xb8(%rbp), %rax
movl -0xc(%rbp), %ecx
movl -0x34(%rbp), %edx
subl %edx, %ecx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
mulsd %xmm1, %xmm0
movl 0x38(%rax), %ecx
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd 0xb915(%rip), %xmm0     # 0x1f278
mulsd -0x50(%rbp), %xmm0
cvtsi2sdl 0x18(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x3460
movq -0xb8(%rbp), %rax
movsd 0xb8e3(%rip), %xmm1     # 0x1f268
mulsd %xmm1, %xmm0
movsd 0xb927(%rip), %xmm1     # 0x1f2b8
addsd %xmm1, %xmm0
movsd %xmm0, -0x100(%rbp)
movsd 0xb8bb(%rip), %xmm0     # 0x1f260
mulsd -0x18(%rbp), %xmm0
mulsd -0x48(%rbp), %xmm0
cvtsi2sdl 0x18(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x3460
movsd -0x100(%rbp), %xmm1
movq -0xb8(%rbp), %rax
movsd 0xb8dc(%rip), %xmm2     # 0x1f2b0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd 0xb88f(%rip), %xmm0     # 0x1f278
mulsd -0x50(%rbp), %xmm0
cvtsi2sdl 0x18(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x3460
movq -0xb8(%rbp), %rax
movsd 0xb895(%rip), %xmm1     # 0x1f2a0
mulsd %xmm1, %xmm0
movsd 0xb891(%rip), %xmm1     # 0x1f2a8
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd 0xb850(%rip), %xmm0     # 0x1f278
mulsd -0x50(%rbp), %xmm0
cvtsi2sdl 0x18(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x3460
movq -0xb8(%rbp), %rax
movsd 0xa5d6(%rip), %xmm1     # 0x1e020
addsd %xmm0, %xmm1
movsd 0xb812(%rip), %xmm0     # 0x1f268
mulsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0xb831(%rip), %xmm0     # 0x1f298
movsd %xmm0, -0x70(%rbp)
movsd 0xb81c(%rip), %xmm0     # 0x1f290
movsd %xmm0, -0x78(%rbp)
movsd 0xb807(%rip), %xmm0     # 0x1f288
movsd %xmm0, -0x80(%rbp)
movsd 0xb7f2(%rip), %xmm0     # 0x1f280
movsd %xmm0, -0x88(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
movsd 0xb7c0(%rip), %xmm0     # 0x1f278
mulsd -0x50(%rbp), %xmm0
cvtsi2sdl 0x18(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x3460
movsd -0xf8(%rbp), %xmm1
movq -0xb8(%rbp), %rax
movaps %xmm0, %xmm2
movsd -0xf0(%rbp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd 0xb756(%rip), %xmm0     # 0x1f260
mulsd -0x50(%rbp), %xmm0
cvtsi2sdl 0x18(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x3460
movsd -0xe8(%rbp), %xmm1
movq -0xb8(%rbp), %rax
movaps %xmm0, %xmm2
movsd -0xe0(%rbp), %xmm0
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd 0xb6fa(%rip), %xmm0     # 0x1f270
mulsd -0x50(%rbp), %xmm0
cvtsi2sdl 0x18(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x3460
movsd -0xd8(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0xd0(%rbp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x13bd3
jp 0x13bd3
movsd 0xb6b4(%rip), %xmm0     # 0x1f278
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
jmp 0x13bf7
movsd 0xb69d(%rip), %xmm0     # 0x1f278
mulsd -0x20(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
callq 0x30a0
divsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
movsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x68(%rbp), %xmm0
mulsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movq -0x40(%rbp), %rax
movslq -0xc(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x98(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x13911
movl $0x0, -0xc(%rbp)
movq -0xb8(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x18(%rcx), %eax
jge 0x13ccb
movq -0xb8(%rbp), %rax
movq -0x40(%rbp), %rcx
movslq -0xc(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
divsd -0x30(%rbp), %xmm0
mulsd -0x28(%rbp), %xmm0
mulsd 0x48(%rax), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd 0xb5ce(%rip), %xmm0     # 0x1f268
addsd -0xa0(%rbp), %xmm0
cvttsd2si %xmm0, %esi
movq 0x10(%rax), %rcx
movslq -0xc(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x20(%rax), %rax
movslq -0xc(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x13c58
movl $0x0, -0xc(%rbp)
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rdx
movslq -0xc(%rbp), %rsi
xorl %eax, %eax
xorl %ecx, %ecx
cmpl (%rdx,%rsi,4), %ecx
movb %al, -0x109(%rbp)
jne 0x13cff
movl -0xc(%rbp), %eax
cmpl -0x34(%rbp), %eax
setl %al
movb %al, -0x109(%rbp)
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x13d0b
jmp 0x13d16
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x13cd2
cmpl $0x0, -0xc(%rbp)
je 0x13e17
movl -0xc(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x13d81
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0xa4(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x13d3c
movq -0xb8(%rbp), %rax
movl 0x8(%rax), %ecx
movl -0xa8(%rbp), %edx
shll %edx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
cmpl $0x1, -0xc(%rbp)
jle 0x13dff
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $-0x8, %rax
movq %rax, -0xb0(%rbp)
movq -0xb8(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, %rdx
addq $-0x4, %rdx
movq %rdx, -0xb0(%rbp)
movl (%rcx), %edx
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0xb8(%rbp), %rcx
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
cmpl 0x8(%rcx), %eax
jl 0x13dbf
jmp 0x13dff
movq -0xb8(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x34(%rbp)
movq -0xb8(%rbp), %rax
movl 0x8(%rax), %ecx
imull 0x38(%rax), %ecx
movl %ecx, 0x18(%rax)
cmpl $0x0, 0x18(%rax)
jne 0x13e52
movq -0xb8(%rbp), %rax
movl $0x1, 0x18(%rax)
cvttsd2si -0x28(%rbp), %edx
movq 0x10(%rax), %rcx
movl %edx, (%rcx)
movq 0x10(%rax), %rax
movl $0x0, 0x4(%rax)
movq -0xb8(%rbp), %rax
movl $0x0, 0x28(%rax)
movl -0x34(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x118(%rbp)
cmpq $0x0, %rax
je 0x13e88
movq -0x118(%rbp), %rdi
callq 0x3330
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)