// File: xdsopl[P]FEC/./correction.hh
// Function: Correction<6, 1, GF::Types<4, 19, unsigned char>>::algorithm(GF::Value<4, 19, unsigned char>*, GF::Index<4, 19, unsigned char>*, GF::Value<4, 19, unsigned char>*, GF::Index<4, 19, unsigned char>*, int)
static int algorithm(ValueType *syndromes, IndexType *locations, ValueType *magnitudes, IndexType *erasures = 0, int erasures_count = 0)
	{
		assert(0 <= erasures_count && erasures_count <= NR);
		ValueType locator[NR+1];
		locator[0] = ValueType(1);
		for (int i = 1; i <= NR; ++i)
			locator[i] = ValueType(0);
		// $locator = \prod_{i=0}^{count}(1-x\,pe^{N-1-erasures_i})$
		if (erasures_count)
			locator[1] = value(IndexType(N-1) / erasures[0]);
		for (int i = 1; i < erasures_count; ++i) {
			IndexType tmp(IndexType(N-1) / erasures[i]);
			for (int j = i; j >= 0; --j)
				locator[j+1] += tmp * locator[j];
		}
		int locator_degree = BerlekampMassey<NR, GF>::algorithm(syndromes, locator, erasures_count);
		assert(locator_degree);
		assert(locator_degree <= NR);
		assert(locator[0] == ValueType(1));
		while (!locator[locator_degree])
			if (--locator_degree < 0)
				return -1;
		int count = FindLocations<NR, GF>::search(locator, locator_degree, locations);
		if (count < locator_degree)
			return -1;
		ValueType evaluator[NR];
		int evaluator_degree = Forney<NR, FCR, GF>::algorithm(syndromes, locator, locations, count, evaluator, magnitudes);
#ifdef NDEBUG
		(void)evaluator_degree;
#else
		static int init;
		if (!init) {
			init = 1;
			std::cout << "syndromes =";
			for (int i = 0; i < NR; ++i)
				std::cout << " " << (int)syndromes[i];
			std::cout << std::endl;
			std::cout << "locator = ";
			for (int i = NR; i > 0; --i) {
				if (!locator[i])
					continue;
				if (locator[i] != ValueType(1))
					std::cout << (int)locator[i] << "*";
				std::cout << "x";
				if (i != 1)
					std::cout << "^" << i;
				std::cout << " + ";
			}
			std::cout << (int)locator[0] << std::endl;
			std::cout << "locations =";
			for (int i = 0; i < count; ++i)
				std::cout << " " << (int)locations[i];
			std::cout << std::endl;
			std::cout << "evaluator = ";
			for (int i = evaluator_degree; i > 0; --i) {
				if (!evaluator[i])
					continue;
				if (evaluator[i] != ValueType(1))
					std::cout << (int)evaluator[i] << "*";
				std::cout << "x";
				if (i != 1)
					std::cout << "^" << i;
				if (i != 1 || evaluator[0])
					std::cout << " + ";
			}
			if (evaluator[0])
				std::cout << (int)evaluator[0];
			std::cout << std::endl;
			std::cout << "magnitudes =";
			for (int i = 0; i < count; ++i)
				std::cout << " " << (int)magnitudes[i];
			std::cout << std::endl;
		}
#endif
		return count;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl -0x2c(%rbp), %ecx
movb %al, -0x85(%rbp)
jg 0xcb1b
cmpl $0x6, -0x2c(%rbp)
setle %al
movb %al, -0x85(%rbp)
movb -0x85(%rbp), %al
testb $0x1, %al
jne 0xcb27
jmp 0xcb29
jmp 0xcb48
leaq 0xd16f(%rip), %rdi      # 0x19c9f
leaq 0xd241(%rip), %rsi      # 0x19d78
movl $0x19, %edx
leaq 0xd245(%rip), %rcx      # 0x19d88
callq 0x2100
leaq -0x33(%rbp), %rax
movq %rax, %rcx
addq $0x7, %rcx
movq %rcx, -0x98(%rbp)
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0xbc20
movq -0xa0(%rbp), %rax
movq -0x98(%rbp), %rcx
addq $0x1, %rax
cmpq %rcx, %rax
movq %rax, -0x90(%rbp)
jne 0xcb61
leaq -0x34(%rbp), %rdi
movl $0x1, %esi
callq 0xbc30
movb -0x34(%rbp), %al
movb %al, -0x33(%rbp)
movl $0x1, -0x38(%rbp)
cmpl $0x6, -0x38(%rbp)
jg 0xcbd4
leaq -0x39(%rbp), %rdi
xorl %esi, %esi
callq 0xbc30
movslq -0x38(%rbp), %rax
movb -0x39(%rbp), %cl
movb %cl, -0x33(%rbp,%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xcbad
cmpl $0x0, -0x2c(%rbp)
je 0xcc15
leaq -0x3c(%rbp), %rdi
movl $0xe, %esi
callq 0xbd80
movq -0x28(%rbp), %rax
movb (%rax), %al
movb %al, -0x3d(%rbp)
movb -0x3c(%rbp), %al
movzbl %al, %edi
movzbl -0x3d(%rbp), %esi
callq 0xd240
movb %al, -0x3b(%rbp)
movzbl -0x3b(%rbp), %edi
callq 0xc0a0
movb %al, -0x3a(%rbp)
movb -0x3a(%rbp), %al
movb %al, -0x32(%rbp)
movl $0x1, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xccbb
leaq -0x46(%rbp), %rdi
movl $0xe, %esi
callq 0xbd80
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x47(%rbp)
movb -0x46(%rbp), %al
movzbl %al, %edi
movzbl -0x47(%rbp), %esi
callq 0xd240
movb %al, -0x45(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jl 0xccab
movb -0x45(%rbp), %al
movb %al, -0x4e(%rbp)
movslq -0x4c(%rbp), %rax
movb -0x33(%rbp,%rax), %al
movb %al, -0x4f(%rbp)
movb -0x4e(%rbp), %al
movzbl %al, %edi
movzbl -0x4f(%rbp), %esi
callq 0xd320
movb %al, -0x4d(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
cltq
leaq -0x33(%rbp), %rdi
addq %rax, %rdi
movzbl -0x4d(%rbp), %esi
callq 0xbd00
movb %al, -0x50(%rbp)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xcc5c
jmp 0xccad
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xcc1c
movq -0x10(%rbp), %rdi
leaq -0x33(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0xd3f0
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0xccd6
jmp 0xccf5
leaq 0xd164(%rip), %rdi      # 0x19e41
leaq 0xd094(%rip), %rsi      # 0x19d78
movl $0x27, %edx
leaq 0xd098(%rip), %rcx      # 0x19d88
callq 0x2100
cmpl $0x6, -0x54(%rbp)
jg 0xccfd
jmp 0xcd1c
leaq 0xd14c(%rip), %rdi      # 0x19e50
leaq 0xd06d(%rip), %rsi      # 0x19d78
movl $0x28, %edx
leaq 0xd071(%rip), %rcx      # 0x19d88
callq 0x2100
movb -0x33(%rbp), %al
movb %al, -0x55(%rbp)
leaq -0x56(%rbp), %rdi
movl $0x1, %esi
callq 0xbc30
movb -0x55(%rbp), %al
movzbl %al, %edi
movzbl -0x56(%rbp), %esi
callq 0xd690
testb $0x1, %al
jne 0xcd45
jmp 0xcd47
jmp 0xcd66
leaq 0xd117(%rip), %rdi      # 0x19e65
leaq 0xd023(%rip), %rsi      # 0x19d78
movl $0x29, %edx
leaq 0xd027(%rip), %rcx      # 0x19d88
callq 0x2100
jmp 0xcd68
movslq -0x54(%rbp), %rax
leaq -0x33(%rbp), %rdi
addq %rax, %rdi
callq 0xbce0
xorb $-0x1, %al
testb $0x1, %al
jne 0xcd80
jmp 0xcd9c
movl -0x54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, %eax
jge 0xcd9a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd213
jmp 0xcd68
leaq -0x33(%rbp), %rdi
movl -0x54(%rbp), %esi
movq -0x18(%rbp), %rdx
callq 0xd710
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0xcdc3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd213
leaq -0x62(%rbp), %rax
movq %rax, %rcx
addq $0x6, %rcx
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0xbc20
movq -0xb8(%rbp), %rax
movq -0xb0(%rbp), %rcx
addq $0x1, %rax
cmpq %rcx, %rax
movq %rax, -0xa8(%rbp)
jne 0xcddc
movq -0x10(%rbp), %rdi
leaq -0x33(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x5c(%rbp), %ecx
leaq -0x62(%rbp), %r8
movq -0x20(%rbp), %r9
callq 0xd970
movl %eax, -0x68(%rbp)
cmpl $0x0, 0xd5371(%rip)     # 0xe21a4
jne 0xd20d
movl $0x1, 0xd5361(%rip)     # 0xe21a4
movq 0xd518e(%rip), %rdi     # 0xe1fd8
leaq 0xd02f(%rip), %rsi      # 0x19e80
callq 0x21b0
movl $0x0, -0x6c(%rbp)
cmpl $0x6, -0x6c(%rbp)
jge 0xcea6
movq 0xd516e(%rip), %rdi     # 0xe1fd8
leaq 0xcd56(%rip), %rsi      # 0x19bc7
callq 0x21b0
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rax
addq %rax, %rdi
callq 0xbfc0
movq -0xc0(%rbp), %rdi
movl %eax, %esi
callq 0x22b0
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0xce5d
movq 0xd512b(%rip), %rdi     # 0xe1fd8
movq 0xd5114(%rip), %rsi     # 0xe1fc8
callq 0x21e0
movq 0xd5118(%rip), %rdi     # 0xe1fd8
leaq 0xcfc5(%rip), %rsi      # 0x19e8c
callq 0x21b0
movl $0x6, -0x70(%rbp)
cmpl $0x0, -0x70(%rbp)
jle 0xcfa9
movslq -0x70(%rbp), %rax
leaq -0x33(%rbp), %rdi
addq %rax, %rdi
callq 0xbce0
testb $0x1, %al
jne 0xcef6
jmp 0xcf9b
movslq -0x70(%rbp), %rax
movb -0x33(%rbp,%rax), %al
movb %al, -0x71(%rbp)
leaq -0x72(%rbp), %rdi
movl $0x1, %esi
callq 0xbc30
movb -0x71(%rbp), %al
movzbl %al, %edi
movzbl -0x72(%rbp), %esi
callq 0xc6b0
testb $0x1, %al
jne 0xcf24
jmp 0xcf51
movslq -0x70(%rbp), %rax
leaq -0x33(%rbp), %rdi
addq %rax, %rdi
callq 0xbfc0
movl %eax, %esi
movq 0xd509b(%rip), %rdi     # 0xe1fd8
callq 0x22b0
movq %rax, %rdi
leaq 0xcf4b(%rip), %rsi      # 0x19e97
callq 0x21b0
movq 0xd5080(%rip), %rdi     # 0xe1fd8
leaq 0xcf3a(%rip), %rsi      # 0x19e99
callq 0x21b0
cmpl $0x1, -0x70(%rbp)
je 0xcf88
movq 0xd5067(%rip), %rdi     # 0xe1fd8
leaq 0xcf23(%rip), %rsi      # 0x19e9b
callq 0x21b0
movq %rax, %rdi
movl -0x70(%rbp), %esi
callq 0x22b0
movq 0xd5049(%rip), %rdi     # 0xe1fd8
leaq 0xcf07(%rip), %rsi      # 0x19e9d
callq 0x21b0
movl -0x70(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0xced3
leaq -0x33(%rbp), %rdi
callq 0xbfc0
movl %eax, %esi
movq 0xd501d(%rip), %rdi     # 0xe1fd8
callq 0x22b0
movq %rax, %rdi
movq 0xd4ffe(%rip), %rsi     # 0xe1fc8
callq 0x21e0
movq 0xd5002(%rip), %rdi     # 0xe1fd8
leaq 0xcec4(%rip), %rsi      # 0x19ea1
callq 0x21b0
movl $0x0, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0xd034
movq 0xd4fe0(%rip), %rdi     # 0xe1fd8
leaq 0xcbc8(%rip), %rsi      # 0x19bc7
callq 0x21b0
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x78(%rbp), %rax
addq %rax, %rdi
callq 0xd220
movq -0xc8(%rbp), %rdi
movl %eax, %esi
callq 0x22b0
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0xcfe9
movq 0xd4f9d(%rip), %rdi     # 0xe1fd8
movq 0xd4f86(%rip), %rsi     # 0xe1fc8
callq 0x21e0
movq 0xd4f8a(%rip), %rdi     # 0xe1fd8
leaq 0xce58(%rip), %rsi      # 0x19ead
callq 0x21b0
movl -0x68(%rbp), %eax
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jle 0xd14d
movslq -0x7c(%rbp), %rax
leaq -0x62(%rbp), %rdi
addq %rax, %rdi
callq 0xbce0
testb $0x1, %al
jne 0xd083
jmp 0xd13f
movslq -0x7c(%rbp), %rax
movb -0x62(%rbp,%rax), %al
movb %al, -0x7d(%rbp)
leaq -0x7e(%rbp), %rdi
movl $0x1, %esi
callq 0xbc30
movb -0x7d(%rbp), %al
movzbl %al, %edi
movzbl -0x7e(%rbp), %esi
callq 0xc6b0
testb $0x1, %al
jne 0xd0b1
jmp 0xd0de
movslq -0x7c(%rbp), %rax
leaq -0x62(%rbp), %rdi
addq %rax, %rdi
callq 0xbfc0
movl %eax, %esi
movq 0xd4f0e(%rip), %rdi     # 0xe1fd8
callq 0x22b0
movq %rax, %rdi
leaq 0xcdbe(%rip), %rsi      # 0x19e97
callq 0x21b0
movq 0xd4ef3(%rip), %rdi     # 0xe1fd8
leaq 0xcdad(%rip), %rsi      # 0x19e99
callq 0x21b0
cmpl $0x1, -0x7c(%rbp)
je 0xd115
movq 0xd4eda(%rip), %rdi     # 0xe1fd8
leaq 0xcd96(%rip), %rsi      # 0x19e9b
callq 0x21b0
movq %rax, %rdi
movl -0x7c(%rbp), %esi
callq 0x22b0
cmpl $0x1, -0x7c(%rbp)
jne 0xd12a
leaq -0x62(%rbp), %rdi
callq 0xbce0
testb $0x1, %al
jne 0xd12a
jmp 0xd13d
movq 0xd4ea7(%rip), %rdi     # 0xe1fd8
leaq 0xcd65(%rip), %rsi      # 0x19e9d
callq 0x21b0
jmp 0xd13f
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0xd060
leaq -0x62(%rbp), %rdi
callq 0xbce0
testb $0x1, %al
jne 0xd15c
jmp 0xd173
leaq -0x62(%rbp), %rdi
callq 0xbfc0
movl %eax, %esi
movq 0xd4e6a(%rip), %rdi     # 0xe1fd8
callq 0x22b0
movq 0xd4e5e(%rip), %rdi     # 0xe1fd8
movq 0xd4e47(%rip), %rsi     # 0xe1fc8
callq 0x21e0
movq 0xd4e4b(%rip), %rdi     # 0xe1fd8
leaq 0xcd26(%rip), %rsi      # 0x19eba
callq 0x21b0
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0xd1fa
movq 0xd4e23(%rip), %rdi     # 0xe1fd8
leaq 0xca0b(%rip), %rsi      # 0x19bc7
callq 0x21b0
movq %rax, -0xd0(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x84(%rbp), %rax
addq %rax, %rdi
callq 0xbfc0
movq -0xd0(%rbp), %rdi
movl %eax, %esi
callq 0x22b0
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0xd1a3
movq 0xd4dd7(%rip), %rdi     # 0xe1fd8
movq 0xd4dc0(%rip), %rsi     # 0xe1fc8
callq 0x21e0
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nop