// File: /workspace/github_cpp_makefile_star2_O1/xdsopl[P]FEC/testbench.cc
// Function: void test_rs<64, 1, 16, 69643, unsigned short>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, ReedSolomon<64, 1, GF::Types<16, 69643, unsigned short>>&, unsigned short*, unsigned short*, std::vector<unsigned char, std::allocator<unsigned char>>&)
void test_rs(std::string name, ReedSolomon<NR, FCR, GF::Types<M, P, TYPE>> &rs, TYPE *code, TYPE *target, std::vector<uint8_t> &data)
{
	std::cout << "testing: " << name << std::endl;

	{
		rs.encode(code);
		bool error = false;
		for (int i = 0; i < rs.N; ++i)
			error |= code[i] != target[i];
		if (error)
			std::cout << "encoder error!" << std::endl;
		assert(!error);
		//print_table(code + rs.K, "parity", NR);
		error = rs.decode(code);
		if (error)
			std::cout << "decoder error!" << std::endl;
		assert(!error);
		// first symbol is without corruption
		int pos = 0, par = 0, corrupt = -1, erasures_count = 0;
		TYPE erasures[NR];
		// need one parity symbol per erasure
		for (int i = 0; pos < rs.N && par+1 <= NR && i < NR/2; ++i, ++corrupt, ++pos, ++par)
			code[erasures[erasures_count++] = pos] ^= pos;
		// need two parity symbols per error
		for (int i = 0; pos < rs.N && par+2 <= NR && i < NR/2; ++i, ++corrupt, ++pos, par+=2)
			code[pos] ^= pos;
		int corrected = rs.decode(code, erasures, erasures_count);
		if (corrupt != corrected)
			std::cout << "decoder error: expected " << corrupt << " but got " << corrected << std::endl;
		assert(corrupt == corrected);
		TYPE syndromes[NR];
		if (corrected >= 0 && rs.compute_syndromes(code, syndromes)) {
			std::cout << "decoder error: result of correction is not a codeword!" << std::endl;
			assert(false);
		}
		error = false;
		for (int i = 0; i < rs.N; ++i)
			error |= code[i] != target[i];
		if (error)
			std::cout << "decoder error: code doesnt match target" << std::endl;
		assert(!error);
	}

	int blocks = (8 * data.size() + M * rs.K - 1) / (M * rs.K);
	TYPE *coded = new TYPE[rs.N * blocks];
	{
		unsigned acc = 0, bit = 0, pos = 0;
		for (unsigned byte : data) {
			acc |= byte << bit;
			bit += 8;
			while (bit >= M) {
				bit -= M;
				coded[pos++] = rs.N & acc;
				acc >>= M;
				if (pos % rs.N >= rs.K)
					pos += NR;
			}
		}
	}
	{
		auto start = std::chrono::system_clock::now();
		for (int i = 0; i < blocks; ++i)
			rs.encode(coded + i * rs.N);
		auto end = std::chrono::system_clock::now();
		auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
		int mbs = (data.size() + msec.count() / 2) / msec.count();
		int bytes = (rs.N * blocks * M) / 8;
		float redundancy = (100.0f*(bytes-data.size())) / data.size();
		std::cout << "encoding of " << data.size() << " random bytes into " << bytes << " codeword bytes (" << std::setprecision(1) << std::fixed << redundancy << "% redundancy) in " << blocks << " blocks took " << msec.count() << " milliseconds (" << mbs << "KB/s)." << std::endl;
	}
	std::random_device rd;
	std::default_random_engine generator(rd());
	std::uniform_int_distribution<int> bit_dist(0, M-1), pos_dist(0, rs.N-1);
	auto rnd_bit = std::bind(bit_dist, generator);
	auto rnd_pos = std::bind(pos_dist, generator);
	std::vector<uint8_t> recovered(data.size());
	TYPE *tmp = new TYPE[rs.N * blocks];
	TYPE *erasures = new TYPE[NR * blocks];
	for (int places = 0; places <= NR; ++places) {
		for (int erasures_count = 0; erasures_count <= places; ++erasures_count) {
			for (int i = 0; i < rs.N * blocks; ++i)
				tmp[i] = coded[i];
			int corrupt = 0;
			for (int i = 0; i < blocks; ++i) {
				for (int j = 0; j < places; ++j) {
					erasures[i*NR + j] = rnd_pos();
					for (int k = 0; k < j;) {
						if (erasures[i*NR + k++] == erasures[i*NR + j]) {
							erasures[i*NR + j] = rnd_pos();
							k = 0;
						}
					}
					tmp[i * rs.N + erasures[i*NR + j]] ^= 1 << rnd_bit();
					++corrupt;
				}
			}
			int corrected = 0, wrong = 0;
			auto start = std::chrono::system_clock::now();
			for (int i = 0; i < blocks; ++i) {
				int result = rs.decode(tmp + i * rs.N, erasures + i * NR, erasures_count);
				if (places > NR/2 && places > erasures_count && result >= 0)
					for (int j = i * rs.N; j < (i + 1) * rs.N; ++j)
						wrong += coded[j] != tmp[j];
				corrected += result;
			}
			auto end = std::chrono::system_clock::now();
			auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
			int bytes = (rs.N * blocks * M) / 8;
			int mbs = (bytes + msec.count() / 2) / msec.count();
			std::cout << "decoding with " << places << " errors and " << erasures_count << " known erasures per block took " << msec.count() << " milliseconds (" << mbs << "KB/s).";
			if (corrupt != corrected || wrong)
				std::cout << " expected " << corrupt << " corrected errors but got " << corrected << " and " << wrong << " wrong corrections.";
			std::cout << std::endl;
			assert((places > NR/2 && places > erasures_count) || (corrupt == corrected && !wrong));
			if (corrupt == corrected && !wrong) {
				unsigned acc = 0, bit = 0, pos = 0;
				for (uint8_t &byte: recovered) {
					while (bit < 8) {
						acc |= (unsigned)tmp[pos++] << bit;
						bit += M;
						if (pos % rs.N >= rs.K)
							pos += NR;
					}
					bit -= 8;
					byte = 255 & acc;
					acc >>= 8;
				}
				for (int i = 0; i < blocks; ++i) {
					TYPE syndromes[NR];
					if (rs.compute_syndromes(tmp + i * rs.N, syndromes)) {
						std::cout << "decoder error: result of correction is not a codeword!" << std::endl;
						assert(false);
					}
				}
				if (data != recovered) {
					std::cout << "decoder error: data could not be recovered from corruption!" << std::endl;
					assert(places > NR/2 && places > erasures_count);
				}
			}
		}
	}
	delete[] erasures;
	delete[] tmp;
	delete[] coded;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x14c8, %rsp           # imm = 0x14C8
movq %r8, 0x30(%rsp)
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
movq 0xce736(%rip), %r12     # 0xd4fd8
leaq 0x8056(%rip), %rsi      # 0xe8ff
movl $0x9, %edx
movq %r12, %rdi
callq 0x2190
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %r12, %rdi
callq 0x2190
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq %r13, %rdi
movq %r14, %rsi
callq 0xc872
xorl %eax, %eax
xorl %ecx, %ecx
movzwl (%r14,%rax,2), %edx
cmpw (%rbx,%rax,2), %dx
setne %dl
orb %dl, %cl
incq %rax
cmpq $0xffff, %rax           # imm = 0xFFFF
jne 0x68fe
testb $0x1, %cl
jne 0x7407
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xca2c
testl %eax, %eax
jne 0x7441
xorl %eax, %eax
movw %ax, 0x140(%rsp,%rax,2)
xorw %ax, (%r14,%rax,2)
leaq 0x1(%rax), %rcx
movq %rcx, %rax
cmpq $0x20, %rcx
jne 0x6939
movl $0x20, %eax
xorw %ax, (%r14,%rax,2)
incq %rax
cmpl $0x30, %eax
jne 0x6958
leaq 0x140(%rsp), %rdx
movq %r13, %rdi
movq %r14, %rsi
movl $0x20, %ecx
callq 0xca2c
cmpl $0x2f, %eax
jne 0x747b
leaq 0xc0(%rsp), %rdx
movq %r13, %rdi
movq %r14, %rsi
callq 0xcad6
testl %eax, %eax
jne 0x750f
xorl %eax, %eax
xorl %ecx, %ecx
movzwl (%r14,%rax,2), %edx
cmpw (%rbx,%rax,2), %dx
setne %dl
orb %dl, %cl
incq %rax
cmpq $0xffff, %rax           # imm = 0xFFFF
jne 0x69a5
testb $0x1, %cl
jne 0x7549
movq 0x30(%rsp), %rax
movq (%rax), %r14
movq 0x8(%rax), %r15
movq %r15, %rax
subq %r14, %rax
leaq 0xffbef(,%rax,8), %rax
movabsq $0x401044214c74698f, %rcx # imm = 0x401044214C74698F
mulq %rcx
shrq $0x12, %rdx
movl %edx, %eax
shll $0x10, %eax
subl %edx, %eax
movq %rax, 0x40(%rsp)
cltq
addq %rax, %rax
movq %rdx, 0x8(%rsp)
testl %edx, %edx
movq $-0x1, %rbx
cmovnsq %rax, %rbx
movq %rbx, %rdi
callq 0x2030
cmpq %r14, %r15
je 0x6a94
xorl %r9d, %r9d
movl $0x80008001, %r10d      # imm = 0x80008001
xorl %ecx, %ecx
xorl %edi, %edi
movzbl (%r14), %edx
shll %cl, %edx
orl %r9d, %edx
leal 0x8(%rcx), %esi
cmpl $0x8, %ecx
jb 0x6a81
leal 0x1(%rdi), %r8d
movl %edi, %ecx
movw %dx, (%rax,%rcx,2)
movq %r8, %rcx
imulq %r10, %rcx
shrq $0x2f, %rcx
movl %ecx, %r9d
shll $0x10, %r9d
subl %r9d, %ecx
addl %edi, %ecx
incl %ecx
cmpl $0xffbf, %ecx           # imm = 0xFFBF
jb 0x6a71
addl $0x41, %edi
movl %edi, %r8d
addl $-0x10, %esi
shrl $0x10, %edx
movl %r8d, %edi
cmpl $0xf, %esi
ja 0x6a40
jmp 0x6a84
movl %edi, %r8d
incq %r14
movl %edx, %r9d
movl %esi, %ecx
movl %r8d, %edi
cmpq %r15, %r14
jne 0x6a2f
movq %rax, 0x38(%rsp)
callq 0x2050
movq %rax, %r14
cmpl $0x0, 0x8(%rsp)
jle 0x6ad0
movq 0x8(%rsp), %r12
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movq 0x38(%rsp), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0xc872
addq $0x1fffe, %r15          # imm = 0x1FFFE
decq %r12
jne 0x6ab9
callq 0x2050
subq %r14, %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
imulq %rcx
movq %rdx, %r14
sarq $0x12, %r14
movq %rdx, %rax
shrq $0x3f, %rax
addq %rax, %r14
movq 0x30(%rsp), %rsi
movq 0x8(%rsi), %rcx
subq (%rsi), %rcx
sarq $0x13, %rdx
addq %rdx, %rax
addq %rcx, %rax
xorl %edx, %edx
divq %r14
movq %rax, %r15
imull $0xffff0, 0x8(%rsp), %ebp # imm = 0xFFFF0
sarl $0x3, %ebp
movslq %ebp, %rax
movq %rax, 0x98(%rsp)
subq %rcx, %rax
js 0x6b36
cvtsi2ss %rax, %xmm1
jmp 0x6b4b
movq %rax, %rdx
shrq %rdx
andl $0x1, %eax
orq %rdx, %rax
cvtsi2ss %rax, %xmm1
addss %xmm1, %xmm1
mulss 0x74b1(%rip), %xmm1     # 0xe004
testq %rcx, %rcx
movq %r13, 0x68(%rsp)
js 0x6b64
cvtsi2ss %rcx, %xmm0
jmp 0x6b79
movq %rcx, %rax
shrq %rax
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
divss %xmm0, %xmm1
movss %xmm1, 0x10(%rsp)
movq 0xce44e(%rip), %r12     # 0xd4fd8
leaq 0x7efd(%rip), %rsi      # 0xea8e
movl $0xc, %edx
movq %r12, %rdi
callq 0x2190
movq 0x30(%rsp), %r13
movq 0x8(%r13), %rsi
subq (%r13), %rsi
movq %r12, %rdi
callq 0x20d0
movq %rax, %r12
leaq 0x7ede(%rip), %rsi      # 0xea9b
movl $0x13, %edx
movq %rax, %rdi
callq 0x2190
movq %r12, %rdi
movl %ebp, %esi
callq 0x2200
movq %rax, %r12
leaq 0x7ed1(%rip), %rsi      # 0xeaaf
movl $0x11, %edx
movq %rax, %rdi
callq 0x2190
movq (%r12), %rax
movq -0x18(%rax), %rcx
movq $0x1, 0x8(%r12,%rcx)
movq -0x18(%rax), %rax
movl $0xfffffefb, %ecx       # imm = 0xFFFFFEFB
andl 0x18(%r12,%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0x18(%r12,%rax)
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp), %xmm0
movq %r12, %rdi
callq 0x21d0
movq %rax, %r12
leaq 0x7e94(%rip), %rsi      # 0xeac1
movl $0x11, %edx
movq %rax, %rdi
callq 0x2190
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x2200
movq %rax, %r12
leaq 0x7e82(%rip), %rsi      # 0xead3
movl $0xd, %edx
movq %rax, %rdi
callq 0x2190
movq %r12, %rdi
movq %r14, %rsi
callq 0x2130
movq %rax, %r14
leaq 0x7e6e(%rip), %rsi      # 0xeae1
movl $0xf, %edx
movq %rax, %rdi
callq 0x2190
movq %r14, %rdi
movl %r15d, %esi
callq 0x2200
movq %rax, %r14
leaq 0x7e5c(%rip), %rsi      # 0xeaf1
movl $0x6, %edx
movq %rax, %rdi
callq 0x2190
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x140(%rsp), %r14
movq %r14, %rdi
callq 0x28f4
movq %r14, %rdi
callq 0x21b0
movl %eax, %ecx
leaq (%rcx,%rcx,2), %rcx
shrq $0x20, %rcx
movl %eax, %edx
subl %ecx, %edx
shrl %edx
addl %ecx, %edx
shrl $0x1e, %edx
movl %edx, %ecx
shll $0x1f, %ecx
orl %edx, %ecx
leal (%rax,%rcx), %edx
cmpl $0x1, %edx
adcl %eax, %ecx
movabsq $0xf00000000, %rax      # imm = 0xF00000000
movq %rax, 0xb0(%rsp)
movq %rcx, 0xb8(%rsp)
movabsq $0xfffe00000000, %rax   # imm = 0xFFFE00000000
movq %rax, 0x88(%rsp)
movq %rcx, 0x90(%rsp)
movq 0x8(%r13), %rsi
subq (%r13), %rsi
leaq 0x70(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x296e
movq %rbx, %rdi
callq 0x2030
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rbx
movl %ebx, %eax
shll $0x6, %eax
cltq
addq %rax, %rax
testl %ebx, %ebx
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2030
movq %rax, 0x48(%rsp)
movq 0x40(%rsp), %rax
cmpl $0x2, %eax
movl $0x1, %ecx
movl $0x1, 0x28(%rsp)
cmovll %ecx, %eax
addl %eax, %eax
movq %rax, 0x40(%rsp)
movl %ebx, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x50(%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x88(%rsp), %r14
movl $0x0, 0x24(%rsp)
movl $0x0, 0x4(%rsp)
testl %ebx, %ebx
jle 0x6dea
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x2100
movl $0x0, %eax
testl %ebx, %ebx
jle 0x6ee5
xorl %r15d, %r15d
cmpq $0x0, 0x10(%rsp)
je 0x6ec8
movq %r15, %rbp
movq %r15, %rbx
shlq $0x7, %rbx
movq 0x48(%rsp), %rax
leaq (%rax,%rbx), %r12
movabsq $0x1ffffff80, %rcx      # imm = 0x1FFFFFF80
andq %rcx, %rbx
addq %rax, %rbx
shlq $0x11, %rbp
subq %r15, %rbp
subq %r15, %rbp
addq 0x18(%rsp), %rbp
xorl %r13d, %r13d
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
movq %r14, %rdx
callq 0x8e86
movw %ax, (%rbx,%r13,2)
testq %r13, %r13
je 0x6e8f
xorl %eax, %eax
movslq %eax, %rcx
movzwl (%r12,%rcx,2), %ecx
cmpw (%rbx,%r13,2), %cx
jne 0x6e85
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
movq %r14, %rdx
callq 0x8e86
movw %ax, (%rbx,%r13,2)
xorl %eax, %eax
jmp 0x6e87
incl %eax
movslq %eax, %rcx
cmpq %rcx, %r13
jg 0x6e5a
leaq 0xb0(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
movq %rdi, %rdx
callq 0x8e86
movl $0x1, %edx
movl %eax, %ecx
shll %cl, %edx
movzwl (%rbx,%r13,2), %eax
xorw %dx, (%rbp,%rax,2)
incq %r13
cmpq 0x10(%rsp), %r13
jne 0x6e3b
movq %r15, %rax
incq %rax
movq %rax, %r15
cmpq 0x50(%rsp), %rax
jne 0x6dfa
movl 0x24(%rsp), %eax
movq 0x8(%rsp), %rbx
movl %eax, 0x2c(%rsp)
callq 0x2050
movq %rax, 0xa0(%rsp)
movl 0x4(%rsp), %eax
movq %rax, 0x60(%rsp)
movl $0x0, %r13d
testl %ebx, %ebx
movl $0x0, %r15d
jle 0x6fe5
xorl %edi, %edi
movq 0x38(%rsp), %r12
movq 0x18(%rsp), %rbp
xorl %ebx, %ebx
xorl %r13d, %r13d
xorl %r15d, %r15d
movq %rdi, 0xa8(%rsp)
movl %r15d, 0x5c(%rsp)
movq %rdi, %r15
shlq $0x10, %r15
subq %rdi, %r15
movq 0x18(%rsp), %rax
leaq (%rax,%r15,2), %rsi
movq %rdi, %rdx
shlq $0x7, %rdx
addq 0x48(%rsp), %rdx
movq 0x68(%rsp), %rdi
movl 0x4(%rsp), %ecx
callq 0xca2c
movq 0x10(%rsp), %rdx
cmpq 0x60(%rsp), %rdx
setbe %cl
cmpq $0x21, %rdx
setb %dl
testl %eax, %eax
sets %sil
orb %cl, %dl
movq 0xa8(%rsp), %rdi
cmpq $0x8000, %rdi           # imm = 0x8000
setae %cl
orb %dl, %cl
orb %sil, %cl
jne 0x6fbd
addl $0xffff, %r15d          # imm = 0xFFFF
xorl %ecx, %ecx
movzwl (%r12,%rcx,2), %edx
xorl %esi, %esi
cmpw (%rbp,%rcx,2), %dx
setne %sil
addl %esi, %r13d
incq %rcx
leal (%rcx,%rbx), %edx
cmpl %edx, %r15d
jg 0x6f9f
movl 0x5c(%rsp), %r15d
addl %eax, %r15d
incq %rdi
addq $0xffff, %rbx           # imm = 0xFFFF
movl $0x1fffe, %eax          # imm = 0x1FFFE
addq %rax, %rbp
addq %rax, %r12
cmpq 0x50(%rsp), %rdi
jne 0x6f27
callq 0x2050
subq 0xa0(%rsp), %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
imulq %rcx
movq %rdx, %rcx
sarq $0x12, %rcx
movq %rdx, %rax
shrq $0x3f, %rax
addq %rax, %rcx
sarq $0x13, %rdx
addq %rdx, %rax
addq 0x98(%rsp), %rax
cqto
movq %rcx, %rbx
idivq %rcx
movq %rax, %rbp
movl $0xe, %edx
movq 0xcdfa2(%rip), %rdi     # 0xd4fd8
leaq 0x7abb(%rip), %rsi      # 0xeaf8
callq 0x2190
movq 0xcdf8f(%rip), %rdi     # 0xd4fd8
movq 0x10(%rsp), %rsi
callq 0x2200
movl $0xc, %edx
movq %rax, %rdi
leaq 0x7aa5(%rip), %rsi      # 0xeb07
movq %rax, %r12
callq 0x2190
movq %r12, %rdi
movl 0x4(%rsp), %esi
callq 0x2200
movq %rax, %r12
movl $0x1f, %edx
movq %rax, %rdi
leaq 0x7a8c(%rip), %rsi      # 0xeb14
callq 0x2190
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2130
movq %rax, %rbx
movl $0xf, %edx
movq %rax, %rdi
leaq 0x7a37(%rip), %rsi      # 0xeae1
callq 0x2190
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2200
movl $0x6, %edx
movq %rax, %rdi
leaq 0x7a29(%rip), %rsi      # 0xeaf1
callq 0x2190
movl 0x2c(%rsp), %eax
xorl %r15d, %eax
orl %r13d, %eax
setne %bpl
je 0x7161
movl $0xa, %edx
movq 0xcdeeb(%rip), %rdi     # 0xd4fd8
leaq 0x7915(%rip), %rsi      # 0xea09
callq 0x2190
movq 0xcded8(%rip), %rdi     # 0xd4fd8
movl 0x2c(%rsp), %esi
callq 0x2200
movq %rax, %rbx
movl $0x1a, %edx
movq %rax, %rdi
leaq 0x7a19(%rip), %rsi      # 0xeb34
callq 0x2190
movq %rbx, %rdi
movl %r15d, %esi
callq 0x2200
movq %rax, %rbx
movl $0x5, %edx
movq %rax, %rdi
leaq 0x79d1(%rip), %rsi      # 0xeb0e
callq 0x2190
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2200
movl $0x13, %edx
movq %rax, %rdi
leaq 0x79f3(%rip), %rsi      # 0xeb4f
callq 0x2190
movq 0xcde70(%rip), %rcx     # 0xd4fd8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq 0xcde52(%rip), %rdi     # 0xd4fd8
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq 0x10(%rsp), %rcx
cmpq $0x21, %rcx
setb %al
cmpq 0x60(%rsp), %rcx
setbe %r13b
orb %al, %r13b
movl %r13d, %eax
andb %bpl, %al
cmpb $0x1, %al
je 0x73c9
testb %bpl, %bpl
movq 0x8(%rsp), %rbx
movq 0xcde10(%rip), %r12     # 0xd4fd8
jne 0x72fc
movq 0x70(%rsp), %rax
movq 0x78(%rsp), %rdx
cmpq %rdx, %rax
je 0x7246
xorl %edi, %edi
xorl %ecx, %ecx
xorl %esi, %esi
cmpl $0x7, %ecx
ja 0x7235
leal 0x1(%rdi), %r8d
movl %edi, %r9d
movq 0x18(%rsp), %r10
movzwl (%r10,%r9,2), %r9d
shll %cl, %r9d
movq %r8, %r10
movl $0x80008001, %r11d      # imm = 0x80008001
imulq %r11, %r10
shrq $0x2f, %r10
movl %r10d, %r11d
shll $0x10, %r11d
subl %r11d, %r10d
addl %edi, %r10d
incl %r10d
cmpl $0xffbf, %r10d          # imm = 0xFFBF
jb 0x722c
addl $0x41, %edi
movl %edi, %r8d
orl $0x10, %ecx
orl %r9d, %esi
movl %r8d, %edi
addl $-0x8, %ecx
movb %sil, (%rax)
shrl $0x8, %esi
incq %rax
cmpq %rdx, %rax
jne 0x71e3
movq 0x50(%rsp), %r15
movq 0x18(%rsp), %rbx
cmpl $0x0, 0x8(%rsp)
jle 0x7280
movq 0x68(%rsp), %rdi
movq %rbx, %rsi
leaq 0xc0(%rsp), %rdx
callq 0xcad6
testl %eax, %eax
jne 0x7386
addq $0x1fffe, %rbx          # imm = 0x1FFFE
decq %r15
jne 0x7257
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rax
movq %rax, %rdx
subq %rdi, %rdx
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
subq %rsi, %rcx
cmpq %rcx, %rdx
movq 0x8(%rsp), %rbx
jne 0x72b7
cmpq %rdi, %rax
je 0x72fc
callq 0x2180
testl %eax, %eax
je 0x72fc
movl $0x3b, %edx
movq %r12, %rdi
leaq 0x790b(%rip), %rsi      # 0xebd1
callq 0x2190
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
testb %r13b, %r13b
jne 0x73e8
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
cmpl 0x28(%rsp), %eax
jne 0x6dd2
movq 0x10(%rsp), %rcx
incq %rcx
addl %ebx, 0x24(%rsp)
incl 0x28(%rsp)
movq %rcx, 0x10(%rsp)
cmpq $0x41, %rcx
jne 0x6dca
movq 0x48(%rsp), %rdi
callq 0x21a0
movq 0x18(%rsp), %rdi
callq 0x21a0
movq 0x38(%rsp), %rdi
callq 0x21a0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x7367
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0x140(%rsp), %rdi
callq 0x2120
addq $0x14c8, %rsp           # imm = 0x14C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xcdc4b(%rip), %rdi     # 0xd4fd8
leaq 0x7695(%rip), %rsi      # 0xea29
movl $0x36, %edx
callq 0x2190
movq 0xcdc33(%rip), %rdi     # 0xd4fd8
callq 0x2090
leaq 0x76af(%rip), %rdi      # 0xea60
leaq 0x7567(%rip), %rsi      # 0xe91f
leaq 0x975e(%rip), %rcx      # 0x10b1d
movl $0xa3, %edx
callq 0x20c0
leaq 0x7793(%rip), %rdi      # 0xeb63
leaq 0x7548(%rip), %rsi      # 0xe91f
leaq 0x973f(%rip), %rcx      # 0x10b1d
movl $0x91, %edx
callq 0x20c0
leaq 0x781e(%rip), %rdi      # 0xec0d
leaq 0x7529(%rip), %rsi      # 0xe91f
leaq 0x9720(%rip), %rcx      # 0x10b1d
movl $0xa8, %edx
callq 0x20c0
movq 0xcdbca(%rip), %rdi     # 0xd4fd8
leaq 0x74f4(%rip), %rsi      # 0xe909
callq 0x2150
movq %rax, %rdi
callq 0x2090
leaq 0x74ef(%rip), %rdi      # 0xe918
leaq 0x74ef(%rip), %rsi      # 0xe91f
leaq 0x96e6(%rip), %rcx      # 0x10b1d
movl $0x2b, %edx
callq 0x20c0
movq 0xcdb90(%rip), %rdi     # 0xd4fd8
leaq 0x759d(%rip), %rsi      # 0xe9ec
callq 0x2150
movq %rax, %rdi
callq 0x2090
leaq 0x74b5(%rip), %rdi      # 0xe918
leaq 0x74b5(%rip), %rsi      # 0xe91f
leaq 0x96ac(%rip), %rcx      # 0x10b1d
movl $0x30, %edx
callq 0x20c0
movl %eax, %ebp
movq 0xcdb54(%rip), %rbx     # 0xd4fd8
leaq 0x7570(%rip), %rsi      # 0xe9fb
movl $0x18, %edx
movq %rbx, %rdi
callq 0x2190
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x2200
movq %rax, %rbx
leaq 0x7696(%rip), %rsi      # 0xeb45
movl $0x9, %edx
movq %rax, %rdi
callq 0x2190
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2200
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x751d(%rip), %rdi      # 0xea14
leaq 0x7421(%rip), %rsi      # 0xe91f
leaq 0x9618(%rip), %rcx      # 0x10b1d
movl $0x3d, %edx
callq 0x20c0
movq 0xcdac2(%rip), %rdi     # 0xd4fd8
leaq 0x750c(%rip), %rsi      # 0xea29
callq 0x2150
movq %rax, %rdi
callq 0x2090
leaq 0x752f(%rip), %rdi      # 0xea60
leaq 0x73e7(%rip), %rsi      # 0xe91f
leaq 0x95de(%rip), %rcx      # 0x10b1d
movl $0x41, %edx
callq 0x20c0
movq 0xcda88(%rip), %rdi     # 0xd4fd8
leaq 0x750f(%rip), %rsi      # 0xea66
callq 0x2150
movq %rax, %rdi
callq 0x2090
leaq 0x73ad(%rip), %rdi      # 0xe918
leaq 0x73ad(%rip), %rsi      # 0xe91f
leaq 0x95a4(%rip), %rcx      # 0x10b1d
movl $0x48, %edx
callq 0x20c0
jmp 0x75ce
jmp 0x759c
jmp 0x759c
jmp 0x758b
movq %rax, %rbx
jmp 0x75b9
jmp 0x759c
jmp 0x759c
jmp 0x759c
jmp 0x759c
jmp 0x759c
jmp 0x759c
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x75b9
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0x140(%rsp), %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x2210
movq %rax, %rdi
callq 0x75d6