// File: xdsopl[P]FEC/./berlekamp_massey.hh
// Function: BerlekampMassey<6, GF::Types<4, 19, unsigned char>>::algorithm(GF::Value<4, 19, unsigned char>*, GF::Value<4, 19, unsigned char>*, int)
static int algorithm(ValueType *s, ValueType *C, int count = 0)
	{
		ValueType B[NR+1];
		for (int i = 0; i <= NR; ++i)
			B[i] = C[i];
		int L = count;
		for (int n = count, m = 1; n < NR; ++n) {
			ValueType d(s[n]);
			for (int i = 1; i <= L; ++i)
				d += C[i] * s[n-i];
			if (!d) {
				++m;
			} else {
				ValueType T[NR+1];
				for (int i = 0; i < m; ++i)
					T[i] = C[i];
				for (int i = m; i <= NR; ++i)
					T[i] = fma(d, B[i-m], C[i]);
				if (2 * L <= n + count) {
					L = n + count + 1 - L;
					for (int i = 0; i <= NR; ++i)
						B[i] = C[i] / d;
					m = 1;
				} else {
					++m;
				}
				for (int i = 0; i <= NR; ++i)
					C[i] = T[i];
			}
		}
		return L;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq -0x1b(%rbp), %rax
movq %rax, %rcx
addq $0x7, %rcx
movq %rcx, -0x68(%rbp)
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0xbc20
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
addq $0x1, %rax
cmpq %rcx, %rax
movq %rax, -0x60(%rbp)
jne 0xd419
movl $0x0, -0x20(%rbp)
cmpl $0x6, -0x20(%rbp)
jg 0xd466
movq -0x10(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movslq -0x20(%rbp), %rax
movb (%rcx,%rdx), %cl
movb %cl, -0x1b(%rbp,%rax)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xd442
movl -0x14(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x28(%rbp)
movl $0x1, -0x2c(%rbp)
cmpl $0x6, -0x28(%rbp)
jge 0xd684
movq -0x8(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x2d(%rbp)
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0xd4ee
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x36(%rbp)
movq -0x8(%rbp), %rax
movl -0x28(%rbp), %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x37(%rbp)
movb -0x36(%rbp), %al
movzbl %al, %edi
movzbl -0x37(%rbp), %esi
callq 0xd9f0
movb %al, -0x35(%rbp)
leaq -0x2d(%rbp), %rdi
movzbl -0x35(%rbp), %esi
callq 0xbd00
movb %al, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xd498
leaq -0x2d(%rbp), %rdi
callq 0xbce0
testb $0x1, %al
jne 0xd509
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xd674
leaq -0x3f(%rbp), %rax
movq %rax, %rcx
addq $0x7, %rcx
movq %rcx, -0x80(%rbp)
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0xbc20
movq -0x88(%rbp), %rax
movq -0x80(%rbp), %rcx
addq $0x1, %rax
cmpq %rcx, %rax
movq %rax, -0x78(%rbp)
jne 0xd51c
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xd571
movq -0x10(%rbp), %rcx
movslq -0x44(%rbp), %rdx
movslq -0x44(%rbp), %rax
movb (%rcx,%rdx), %cl
movb %cl, -0x3f(%rbp,%rax)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xd54b
movl -0x2c(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x6, -0x48(%rbp)
jg 0xd5ce
movb -0x2d(%rbp), %al
movb %al, -0x4a(%rbp)
movl -0x48(%rbp), %eax
subl -0x2c(%rbp), %eax
cltq
movb -0x1b(%rbp,%rax), %al
movb %al, -0x4b(%rbp)
movq -0x10(%rbp), %rax
movslq -0x48(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x4c(%rbp)
movb -0x4a(%rbp), %cl
movb -0x4b(%rbp), %al
movzbl %cl, %edi
movzbl %al, %esi
movzbl -0x4c(%rbp), %edx
callq 0xdac0
movb %al, -0x49(%rbp)
movslq -0x48(%rbp), %rax
movb -0x49(%rbp), %cl
movb %cl, -0x3f(%rbp,%rax)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xd577
movl -0x24(%rbp), %eax
shll %eax
movl -0x28(%rbp), %ecx
addl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jg 0xd63e
movl -0x28(%rbp), %eax
addl -0x14(%rbp), %eax
addl $0x1, %eax
subl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x50(%rbp)
cmpl $0x6, -0x50(%rbp)
jg 0xd635
movq -0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x52(%rbp)
movb -0x2d(%rbp), %al
movb %al, -0x53(%rbp)
movb -0x52(%rbp), %al
movzbl %al, %edi
movzbl -0x53(%rbp), %esi
callq 0xdbd0
movb %al, -0x51(%rbp)
movslq -0x50(%rbp), %rax
movb -0x51(%rbp), %cl
movb %cl, -0x1b(%rbp,%rax)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xd5f3
movl $0x1, -0x2c(%rbp)
jmp 0xd647
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x58(%rbp)
cmpl $0x6, -0x58(%rbp)
jg 0xd672
movslq -0x58(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x58(%rbp), %rcx
movb -0x3f(%rbp,%rdx), %dl
movb %dl, (%rax,%rcx)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0xd64e
jmp 0xd674
jmp 0xd676
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xd479
movl -0x24(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq