// File: /workspace/github_c_makefile_star2_O0/DrYerzinia[P]C_DigiMode/src/psk31/psk31_wcpd.cpp
// Function: psk31_wcpd::proccess_byte(char)
bool psk31_wcpd::proccess_byte(char next_data_point){

	bool newByte = false;

	input_data[input_position] = next_data_point;

	if(input_count > input_data_width){


		int pos;
		int postmp;

		pos = input_position+1;

		int topsum1, topsum2;
		float max;

		float phasesum[(int)ninty_deg_phase_width];

		for(int i = 0; i < ninty_deg_phase_width; i++)
			phasesum[i] = 0.0f;

		for(int i = 0; i < ninty_deg_phase_width; i++){

			postmp = pos + i;
			if(postmp < 0) postmp = input_data_width + postmp;
			else if(postmp >= input_data_width) postmp = postmp - input_data_width;

			for(int j = 0; j < ninty_deg_phase_width; j++){
				phasesum[j] += input_data[postmp]*sin(((input_count+i)/ninty_deg_phase_width)*2*PI+(j*2*PI/ninty_deg_phase_width));
			}

		}

		max = -100000;
		for(int i = 0; i < ninty_deg_phase_width; i++){
			if(phasesum[i] > max){
				max = phasesum[i];
				topsum1 = i;
			}
		}

		pos = (int)floor(input_position-ninty_deg_phase_width+1.5);

		for(int i = 0; i < ninty_deg_phase_width; i++)
			phasesum[i] = 0.0f;

		for(int i = 0; i < ninty_deg_phase_width; i++){

			postmp = pos + i;
			if(postmp < 0) postmp = input_data_width + postmp;
			else if(postmp >= input_data_width) postmp = postmp - input_data_width;

			for(int j = 0; j < ninty_deg_phase_width; j++){
				phasesum[j] += input_data[postmp]*sin(((input_count+i)/ninty_deg_phase_width)*2*PI+(j*2*PI/ninty_deg_phase_width));
			}

		}

		max = -100000;
		for(int i = 0; i < ninty_deg_phase_width; i++){
			if(phasesum[i] > max){
				max = phasesum[i];
				topsum2 = i;
			}
		}

		float pd = std::abs(topsum1-topsum2);
		if(pd > ninty_deg_phase_width/2) pd = std::abs(pd-ninty_deg_phase_width);
 		phase_change_data.push_back(pd);

	}

	input_position++;
	input_count++;

	if(input_position > input_data_width) input_position = 0;

	if(phase_change_data.size() >= bitwidth/4){

		float phase_change_sum = 0.0;

		for(std::list<float>::iterator it = phase_change_data.begin(); it != phase_change_data.end(); it++){

			phase_change_sum += (*it);

		}

		if(phase_change_sum > max) max = phase_change_sum;

		int current_value;

		if(phase_change_sum > threshhold_value*max)
			current_value = 1;
		else
			current_value = 0;

		if(last == -1) last = current_value;

		if(current_value != last){

			for(int i = 0; i < floor(((float)countlast)/((float)bitwidth)+0.5); i++)
				bit_sequence.push_back(current_value);

			if(bit_sequence.size() >= 2 && bit_sequence[bit_sequence.size()-1] == 0 && bit_sequence[bit_sequence.size()-2] == 0){
				int one = 1;
				int val = 0;
				for(int i = bit_sequence.size()-3; i >= 0; i--){
					if(bit_sequence[i] == 1)
						val |= one;
					one <<= 1;
				}

				newByte = true;

				byte_sequence.push_back(getVaricode(val));
				bit_sequence.clear();
			}

			last = current_value;
			countlast = 1;

		} else countlast++;

		phase_change_data.pop_front();

	}

	return newByte;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movb $0x0, -0xa(%rbp)
movb -0x9(%rbp), %sil
movq 0x60(%rcx), %rax
movl 0x50(%rcx), %edx
movb %sil, (%rax,%rdx)
movl 0x54(%rcx), %eax
cmpl 0x58(%rcx), %eax
jbe 0xd602
movq -0x90(%rbp), %rax
movl 0x50(%rax), %ecx
incl %ecx
movl %ecx, -0x10(%rbp)
cvttss2si 0x18(%rax), %eax
movq %rsp, %rcx
movq %rcx, -0x28(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x98(%rbp)
movq %rcx, %rsp
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x90(%rbp), %rax
cvtsi2ssl -0x34(%rbp), %xmm1
movss 0x18(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xd1c5
movq -0x98(%rbp), %rax
movslq -0x34(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xd191
movl $0x0, -0x38(%rbp)
movq -0x90(%rbp), %rax
cvtsi2ssl -0x38(%rbp), %xmm1
movss 0x18(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xd30f
movl -0x10(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0xd207
movq -0x90(%rbp), %rax
movl 0x58(%rax), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0xd228
movq -0x90(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x58(%rcx), %eax
jb 0xd226
movq -0x90(%rbp), %rcx
movl -0x14(%rbp), %eax
subl 0x58(%rcx), %eax
movl %eax, -0x14(%rbp)
jmp 0xd228
movl $0x0, -0x3c(%rbp)
movq -0x90(%rbp), %rax
cvtsi2ssl -0x3c(%rbp), %xmm1
movss 0x18(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xd2ff
movq -0x90(%rbp), %rax
movq 0x60(%rax), %rcx
movslq -0x14(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, -0xa0(%rbp)
movl 0x54(%rax), %ecx
movl -0x38(%rbp), %edx
addl %edx, %ecx
cvtsi2ss %rcx, %xmm0
divss 0x18(%rax), %xmm0
movss 0x1e9a(%rip), %xmm1     # 0xf11c
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x3c(%rbp), %ecx
shll %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x1e2d(%rip), %xmm2     # 0xf0c8
mulsd %xmm2, %xmm1
movss 0x18(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
divsd %xmm2, %xmm1
movsd 0x1e14(%rip), %xmm2     # 0xf0c8
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x30c0
movq -0x98(%rbp), %rax
movaps %xmm0, %xmm2
movsd -0xa0(%rbp), %xmm0
movslq -0x3c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xd22f
jmp 0xd301
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xd1cc
movss 0x1e01(%rip), %xmm0     # 0xf118
movss %xmm0, -0x20(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x90(%rbp), %rax
cvtsi2ssl -0x40(%rbp), %xmm1
movss 0x18(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xd377
movq -0x98(%rbp), %rax
movslq -0x40(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
ucomiss -0x20(%rbp), %xmm0
jbe 0xd36a
movq -0x98(%rbp), %rax
movslq -0x40(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x20(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0xd36c
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xd323
movq -0x90(%rbp), %rax
movl 0x50(%rax), %ecx
cvtsi2ss %rcx, %xmm0
subss 0x18(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x1d29(%rip), %xmm1     # 0xf0c0
addsd %xmm1, %xmm0
callq 0x3430
cvttsd2si %xmm0, %eax
movl %eax, -0x10(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x90(%rbp), %rax
cvtsi2ssl -0x44(%rbp), %xmm1
movss 0x18(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xd3e2
movq -0x98(%rbp), %rax
movslq -0x44(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xd3ae
movl $0x0, -0x48(%rbp)
movq -0x90(%rbp), %rax
cvtsi2ssl -0x48(%rbp), %xmm1
movss 0x18(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xd52c
movl -0x10(%rbp), %eax
addl -0x48(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0xd424
movq -0x90(%rbp), %rax
movl 0x58(%rax), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0xd445
movq -0x90(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x58(%rcx), %eax
jb 0xd443
movq -0x90(%rbp), %rcx
movl -0x14(%rbp), %eax
subl 0x58(%rcx), %eax
movl %eax, -0x14(%rbp)
jmp 0xd445
movl $0x0, -0x4c(%rbp)
movq -0x90(%rbp), %rax
cvtsi2ssl -0x4c(%rbp), %xmm1
movss 0x18(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xd51c
movq -0x90(%rbp), %rax
movq 0x60(%rax), %rcx
movslq -0x14(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, -0xa8(%rbp)
movl 0x54(%rax), %ecx
movl -0x48(%rbp), %edx
addl %edx, %ecx
cvtsi2ss %rcx, %xmm0
divss 0x18(%rax), %xmm0
movss 0x1c7d(%rip), %xmm1     # 0xf11c
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x4c(%rbp), %ecx
shll %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x1c10(%rip), %xmm2     # 0xf0c8
mulsd %xmm2, %xmm1
movss 0x18(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
divsd %xmm2, %xmm1
movsd 0x1bf7(%rip), %xmm2     # 0xf0c8
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x30c0
movq -0x98(%rbp), %rax
movaps %xmm0, %xmm2
movsd -0xa8(%rbp), %xmm0
movslq -0x4c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xd44c
jmp 0xd51e
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xd3e9
movss 0x1be4(%rip), %xmm0     # 0xf118
movss %xmm0, -0x20(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x90(%rbp), %rax
cvtsi2ssl -0x50(%rbp), %xmm1
movss 0x18(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xd594
movq -0x98(%rbp), %rax
movslq -0x50(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
ucomiss -0x20(%rbp), %xmm0
jbe 0xd587
movq -0x98(%rbp), %rax
movslq -0x50(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x20(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0xd589
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xd540
movq -0x90(%rbp), %rax
movl -0x18(%rbp), %ecx
subl -0x1c(%rbp), %ecx
movl %ecx, %edx
negl %edx
cmovnsl %edx, %ecx
cvtsi2ss %ecx, %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
movss 0x18(%rax), %xmm1
movss 0x1b59(%rip), %xmm2     # 0xf11c
divss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
jbe 0xd5e7
movq -0x90(%rbp), %rax
movss -0x54(%rbp), %xmm0
subss 0x18(%rax), %xmm0
callq 0xd990
movss %xmm0, -0x54(%rbp)
movq -0x90(%rbp), %rdi
addq $0x68, %rdi
leaq -0x54(%rbp), %rsi
callq 0xba20
movq -0x28(%rbp), %rax
movq %rax, %rsp
movq -0x90(%rbp), %rcx
movl 0x50(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x50(%rcx)
movl 0x54(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x54(%rcx)
movl 0x50(%rcx), %eax
cmpl 0x58(%rcx), %eax
jbe 0xd631
movq -0x90(%rbp), %rax
movl $0x0, 0x50(%rax)
movq -0x90(%rbp), %rdi
addq $0x68, %rdi
callq 0xba60
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, -0xb0(%rbp)
movl 0x1c(%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xb0(%rbp), %rax
movslq %ecx, %rcx
cmpq %rcx, %rax
jb 0xd982
movq -0x90(%rbp), %rdi
xorps %xmm0, %xmm0
movss %xmm0, -0x58(%rbp)
addq $0x68, %rdi
callq 0xba90
movq %rax, -0x60(%rbp)
movq -0x90(%rbp), %rdi
addq $0x68, %rdi
callq 0xbae0
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xbac0
testb $0x1, %al
jne 0xd6b5
jmp 0xd6dd
leaq -0x60(%rbp), %rdi
callq 0xbb10
movss (%rax), %xmm0
addss -0x58(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
callq 0xbb30
movq %rax, -0x70(%rbp)
jmp 0xd68e
movq -0x90(%rbp), %rax
movss -0x58(%rbp), %xmm0
cvtsi2ssl 0x9c(%rax), %xmm1
ucomiss %xmm1, %xmm0
jbe 0xd708
movq -0x90(%rbp), %rax
cvttss2si -0x58(%rbp), %ecx
movl %ecx, 0x9c(%rax)
movq -0x90(%rbp), %rax
movss -0x58(%rbp), %xmm0
movss 0x14(%rax), %xmm1
cvtsi2ssl 0x9c(%rax), %xmm2
mulss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
jbe 0xd733
movl $0x1, -0x74(%rbp)
jmp 0xd73a
movl $0x0, -0x74(%rbp)
movq -0x90(%rbp), %rax
cmpl $-0x1, 0x98(%rax)
jne 0xd75a
movq -0x90(%rbp), %rax
movl -0x74(%rbp), %ecx
movl %ecx, 0x98(%rax)
movq -0x90(%rbp), %rcx
movl -0x74(%rbp), %eax
cmpl 0x98(%rcx), %eax
je 0xd95c
movl $0x0, -0x78(%rbp)
movq -0x90(%rbp), %rax
cvtsi2sdl -0x78(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
cvtsi2ssl 0xa0(%rax), %xmm0
cvtsi2ssl 0x1c(%rax), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x1910(%rip), %xmm1     # 0xf0b8
addsd %xmm1, %xmm0
callq 0x3430
movsd -0xb8(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd7e1
movq -0x90(%rbp), %rdi
addq $0x80, %rdi
leaq -0x74(%rbp), %rsi
callq 0xbb60
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0xd777
movq -0x90(%rbp), %rdi
addq $0x80, %rdi
callq 0xbbd0
cmpq $0x2, %rax
jb 0xd940
movq -0x90(%rbp), %rdi
movq %rdi, %rax
addq $0x80, %rax
movq %rax, -0xc0(%rbp)
addq $0x80, %rdi
callq 0xbbd0
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0xbbf0
cmpl $0x0, (%rax)
jne 0xd940
movq -0x90(%rbp), %rdi
movq %rdi, %rax
addq $0x80, %rax
movq %rax, -0xc8(%rbp)
addq $0x80, %rdi
callq 0xbbd0
movq -0xc8(%rbp), %rdi
movq %rax, %rsi
subq $0x2, %rsi
callq 0xbbf0
cmpl $0x0, (%rax)
jne 0xd940
movq -0x90(%rbp), %rdi
movl $0x1, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
addq $0x80, %rdi
callq 0xbbd0
subq $0x3, %rax
movl %eax, -0x84(%rbp)
cmpl $0x0, -0x84(%rbp)
jl 0xd8f1
movq -0x90(%rbp), %rdi
addq $0x80, %rdi
movslq -0x84(%rbp), %rsi
callq 0xbbf0
cmpl $0x1, (%rax)
jne 0xd8d8
movl -0x7c(%rbp), %eax
orl -0x80(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x7c(%rbp), %eax
shll %eax
movl %eax, -0x7c(%rbp)
movl -0x84(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0xd8a7
movq -0x90(%rbp), %rdi
movb $0x1, -0xa(%rbp)
movq %rdi, %rax
addq $0xa8, %rax
movq %rax, -0xd0(%rbp)
movl -0x80(%rbp), %esi
callq 0x4e30
movq -0xd0(%rbp), %rdi
movb %al, -0x85(%rbp)
leaq -0x85(%rbp), %rsi
callq 0xbc10
movq -0x90(%rbp), %rdi
addq $0x80, %rdi
callq 0xbc40
movq -0x90(%rbp), %rax
movl -0x74(%rbp), %ecx
movl %ecx, 0x98(%rax)
movl $0x1, 0xa0(%rax)
jmp 0xd972
movq -0x90(%rbp), %rax
movl 0xa0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xa0(%rax)
movq -0x90(%rbp), %rdi
addq $0x68, %rdi
callq 0xbc60
movb -0xa(%rbp), %al
andb $0x1, %al
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)