// File: /workspace/github_cpp_makefile_star2_O3/Alcaro[P]bridges/arlib/deflate-decomp.cpp
// Function: inflator::inflate()
inflator::ret_t inflator::inflate()
{
	enum {
		st_blockinit,
		st_litblock_head,
		st_litblock,
		st_huff1,
		st_huff2,
		st_huff3,
		st_mainloop,
		st_litbyte,
		st_copy
	};
	
	switch (m_state)
	{
		while (true)
		{
		[[fallthrough]];
		case st_blockinit:
			bits_refill_fast();
			if (UNLIKELY(m_in_nbits < 3+7)) // empty block with default huffman tables is 3+7 bits; literal can also use 3+7
			{
				assert_reached();
				m_state = st_blockinit;
				goto do_ret_more_input;
			}
			m_block_type = bits_extract(3);
			if (m_block_type < 1*2) // literal block
			{
				m_in_bits_buf >>= m_in_nbits&7;
				m_in_nbits &= ~7;
				
			[[fallthrough]];
			case st_litblock_head:
				bits_refill_fast();
				
				if (UNLIKELY(m_in_nbits < 32))
				{
					assert_reached();
					m_state = st_litblock_head;
					goto do_ret_more_input;
				}
				
				uint32_t len;
				{
					len = m_in_bits_buf; // this truncates to 32 bits
					len = len ^ ((~len)<<16);
					if (UNLIKELY(len >= 0x10000)) RET_FAIL();
					m_in_nbits -= 32;
					m_in_bits_buf >>= 32;
				}
				
				if(0) {
			case st_litblock:
					len = m_stlitblk_len;
				}
				while (m_in_nbits && len)
				{
					if (UNLIKELY(m_out_end == m_out_at))
					{
						assert_reached();
						m_state = st_litblock;
						m_stlitblk_len = len;
						return ret_more_output;
					}
					assert_reached();
					*m_out_at++ = bits_extract(8);
					len--;
				}
				
				uint32_t len_actual = min(len, m_in_end-m_in_at, m_out_end-m_out_at);
				memcpy(m_out_at, m_in_at, len_actual);
				len -= len_actual;
				m_in_at += len_actual;
				m_out_at += len_actual;
				
				if (UNLIKELY(len))
				{
					assert_reached();
					m_state = st_litblock;
					m_stlitblk_len = len;
					if (m_in_at == m_in_end) goto do_ret_more_input;
					else return ret_more_output;
				}
				
				if (m_in_nbits) assert_reached();
			}
			else if (LIKELY(m_block_type < 3*2))
			{
				if (m_block_type & 4)
				{
				[[fallthrough]];
				case st_huff1:
					bits_refill_fast();
					if (UNLIKELY(m_in_nbits < 5+5+4))
					{
						assert_reached();
						m_state = st_huff1;
						goto do_ret_more_input;
					}
					// if we run out of bits, we'll read infinite zeroes, which will either error out or emit nonsense tables
					// in both cases, it will terminate, so it's safe to defer the underflow check to later
					
					// dynamic huffman
					uint32_t huff_sizes;
					huff_sizes = bits_extract(5+5+4);
					if(0) {
				case st_huff2:
						huff_sizes = m_sthuff2_sizes;
					}
					
					uint32_t hlit;
					uint32_t hdist;
					{
						hlit = (huff_sizes&31) + 257;
						hdist = ((huff_sizes>>5)&31) + 1;
						uint32_t hclen = (huff_sizes>>10) + 4;
						
						// DEFLATE can represent 288 symbols and 32 distance codes, but only 286 resp. 30 are valid. why
						// RFC 1951 seems to explicitly allow HDIST > 30 (though using them is forbidden), but zlib rejects it
						if (UNLIKELY(hlit > 286 || hdist > 30)) RET_FAIL();
						
						bits_refill_all();
						if (UNLIKELY(m_in_nbits < hclen*3))
						{
							assert_reached();
							m_state = st_huff2;
							m_sthuff2_sizes = huff_sizes;
							goto do_ret_more_input;
						}
						
						static const uint8_t huff_al_order[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
						uint8_t huff_al_len[19];
						memset(huff_al_len, 0, 16); // last 3 are guaranteed overwritten by below loop, no point clearing them
						// first is guaranteed overwritten too, but 16 optimizes better than 15
						
						for (uint32_t i=0;i<hclen;i++) huff_al_len[huff_al_order[i]] = bits_extract(3);
						
						bool ok = unpack_huffman_dfl(m_huff_symbol, huff_al_len, 19, 19);
						if (UNLIKELY(!ok)) RET_FAIL();
					}
					
					uint32_t i;
					i = 0;
					if(0) {
				case st_huff3:
						huff_sizes = m_sthuff2_sizes;
						hlit = (m_sthuff2_sizes&31) + 257;
						hdist = ((m_sthuff2_sizes>>5)&31) + 1;
						i = m_sthuff3_iter;
					}
					while (i < hlit+hdist)
					{
						bits_refill_fast();
						if (UNLIKELY(m_in_nbits < 15+7 && !m_in_last))
						{
							assert_reached();
							m_state = st_huff3;
							m_sthuff2_sizes = huff_sizes;
							m_sthuff3_iter = i;
							goto do_ret_more_input;
						}
						
						int sym = bits_read_huffman(m_huff_symbol); // takes 15 bits
						if (UNLIKELY((int32_t)m_in_nbits < 0)) RET_FAIL();
						
						if (sym <= 15)
						{
							m_symbol_lengths[i++] = sym;
						}
						else if (sym == 16) // repeat last length
						{
							uint32_t n_rep = bits_extract(2) + 3;
							if (UNLIKELY(i == 0)) RET_FAIL();
							if (UNLIKELY(i+n_rep > hlit+hdist)) RET_FAIL();
							int last = m_symbol_lengths[i-1];
							for (uint32_t j=0;j<n_rep;j++)
								m_symbol_lengths[i++] = last;
						}
						else // sym 17 or 18 (invalid symbols are impossible)
						{
							uint32_t n_rep = bits_extract((sym-17)*4+3) + (sym-17)*8+3; // takes 7 bits
							if (UNLIKELY(i+n_rep > hlit+hdist)) RET_FAIL();
							for (uint32_t j=0;j<n_rep;j++)
								m_symbol_lengths[i++] = 0;
						}
					}
					
					if (UNLIKELY(!unpack_huffman_dfl(m_huff_symbol, m_symbol_lengths, hlit, 287))) RET_FAIL();
					uint8_t tmp[32];
					memcpy(tmp, m_symbol_lengths+hlit, 32); // copy it - m_symbol_lengths is a union with m_huff_distance
					if (UNLIKELY(!unpack_huffman_dfl(m_huff_distance, tmp, hdist, 31))) RET_FAIL();
				}
				else
				{
					// static huffman
					uint8_t len[288];
					for (int i=0 ; i<=32; i++) len[i] = 5;
					unpack_huffman_dfl(m_huff_distance, len, 32, 0);
					for (int i=0 ; i<=143;i++) len[i] = 8;
					for (int i=144;i<=255;i++) len[i] = 9;
					for (int i=256;i<=279;i++) len[i] = 7;
					for (int i=280;i<=287;i++) len[i] = 8;
					unpack_huffman_dfl(m_huff_symbol, len, 288, 0);
				}
				
				m_state = st_mainloop;
			[[fallthrough]];
			case st_mainloop:
			case st_copy:
			case st_litbyte:
				// moving these to locals drops runtime to ~75% of using members directly
				const uint8_t * out_prev = m_out_prev;
				uint8_t * out_start = m_out_start;
				uint8_t * out_at = m_out_at;
				uint8_t * out_end = m_out_end;
				const uint8_t * in_at = m_in_at;
				const uint8_t * in_end = m_in_end;
				uint64_t bits_buf = m_in_bits_buf;
				uint32_t nbits = m_in_nbits;
				
				ret_t ret_state = ret_done;
				
				if (m_state != st_mainloop)
				{
					if (m_state == st_copy) goto st_copy_inner;
					else if (m_state == st_litbyte) goto st_litbyte_inner;
					else __builtin_unreachable();
				}
				
				while (true)
				{
					// max bits needed per symbol: 15 (huff_symbol) + 5 (length bits) + 15 (huff_distance) + 13 (distance bits) = 48
					
					if (LIKELY(in_end-in_at >= 8))
					{
						if (nbits <= 32)
						{
							bits_buf |= (uint64_t)readu_le32(in_at) << nbits;
							nbits += 32;
							in_at += 4;
						}
					}
					else
					{
						while (nbits <= 56 && in_at != in_end)
						{
							assert_reached();
							bits_buf |= (uint64_t)*in_at++ << nbits;
							nbits += 8;
						}
						
						if (nbits < 48 && !m_in_last)
						{
							assert_reached();
							ret_state = ret_more_input;
							goto inner_return;
						}
					}
					
					// at this point, we know that either
					// - there are at least 32 bits in the bit buffer, and at least 32 bits in the byte buffer
					//    -> a 32bit refill without bounds check is safe
					// - there are at least 48 bits in the bit buffer
					//    -> there's no need to refill
					// - we're at EOF
					//    -> comp_at == in_end
					// -> either comp_at == in_end, a 32bit refill is safe, or there's no need to refill
					// -> can do a 32bit refill if comp_at != in_end
					// TODO: investigate performance of adding a 16bit refill up there and not refilling further down
					
					int symbol;
					HUFF_READ_FAST(m_huff_symbol, symbol); // takes 15 bits
					if (UNLIKELY((int32_t)nbits < 0)) RET_FAIL();
					
					if (symbol < 256)
					{
						if (0)
						{
					st_litbyte_inner:
							symbol = m_stlitby_val;
						}
						if (UNLIKELY(out_at == out_end))
						{
							assert_reached();
							ret_state = ret_more_output;
							m_state = st_litbyte;
							m_stlitby_val = symbol;
							goto inner_return;
						}
						*out_at++ = symbol;
					}
					else if (LIKELY(symbol <= 285))
					{
						size_t len;
						size_t dist;
						
						{
							static const uint16_t sym_detail[] = {
								  3+(0<<12),  4+(0<<12),  5+(0<<12),  6+(0<<12),   7+(0<<12), 8+(0<<12), 9+(0<<12), 10+(0<<12),
								 11+(1<<12), 13+(1<<12), 15+(1<<12), 17+(1<<12),  19+(2<<12),23+(2<<12),27+(2<<12), 31+(2<<12),
								 35+(3<<12), 43+(3<<12), 51+(3<<12), 59+(3<<12),  67+(4<<12),83+(4<<12),99+(4<<12),115+(4<<12),
								131+(5<<12),163+(5<<12),195+(5<<12),227+(5<<12), 258+(0<<12)
							};
							uint16_t detail = sym_detail[symbol-257];
							
							BITS_FAST(detail>>12, len); // takes 5 bits
							len += (detail&511);
							
							// do not refill after underflow, shift by huge is UB
							if (LIKELY((uint32_t)nbits >= 15+13)) assert_reached();
							else if (LIKELY(in_at != in_end))
							{
								assert_reached();
								bits_buf |= (uint64_t)readu_le32(in_at) << nbits;
								nbits += 32;
								in_at += 4;
							}
							else assert_reached();
							
							int dist_key;
							HUFF_READ_FAST(m_huff_distance, dist_key); // takes 15 bits
							
							int dist_base = ((2+(dist_key&1)) << (dist_key>>1) >> 1) + (dist_key!=0);
							int dist_bits = (dist_key>>1) - (dist_key >= 2);
							
							BITS_FAST(dist_bits, dist); // takes 13 bits
							dist += dist_base;
							
							if (dist == 32768) assert_reached();
							if (UNLIKELY(dist > 32768)) RET_FAIL(); // dist_key >= 30 ends up here
							// no need to check earlier, underflow just yields endless zeroes
							if (UNLIKELY((int32_t)nbits < 0)) RET_FAIL();
						}
						
						if(0) {
					st_copy_inner:
							len = m_stcopy_len;
							dist = m_stcopy_dist;
						}
						
						if (dist > (size_t)(out_at-out_start))
						{
							if (!out_prev) RET_FAIL();
							assert_reached();
							
							size_t dist_prev = dist-(out_at-out_start);
							
							const uint8_t * src = out_prev-dist_prev;
							size_t len_actual = min(len, dist_prev);
							rep_movsb(out_at, src, len_actual);
							len -= len_actual;
						}
						
						const uint8_t * src = out_at-dist;
						size_t len_actual = min(len, out_end-out_at);
						rep_movsb(out_at, src, len_actual);
						
						len -= len_actual;
						if (UNLIKELY(len))
						{
							assert_reached();
							m_stcopy_len = len;
							m_stcopy_dist = dist;
							m_state = st_copy;
							ret_state = ret_more_output;
							goto inner_return;
						}
					}
					else if (LIKELY(symbol == 384))
						break;
					else
						RET_FAIL();
				}
				
			inner_return:
				// most of the variables don't change, no need to write them back
				m_in_at = in_at;
				m_in_bits_buf = bits_buf;
				m_in_nbits = nbits;
				m_out_at = out_at;
				
				if (ret_state != ret_done)
					return ret_state;
			}
			else RET_FAIL();
			
			if (m_block_type&1) return ret_done;
		}
	default: __builtin_unreachable();
	}
do_ret_more_input:
	if (m_in_last) RET_FAIL();
	else return ret_more_input;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movzbl (%rdi), %ecx
leaq 0x26c9d(%rip), %rax     # 0x2f440
movslq (%rax,%rcx,4), %rdx
addq %rax, %rdx
jmpq *%rdx
movq 0x20(%rbx), %r12
movq 0x28(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x30(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rbx), %rdi
movq 0x38(%rbx), %r8
leaq 0x10(%rbx), %rax
movq %rax, 0x28(%rsp)
movq 0x10(%rbx), %r10
movq 0x18(%rbx), %r9
leaq 0x8(%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%rbx), %r15
leaq 0x4(%rbx), %rax
movq %rax, 0x18(%rsp)
movl 0x4(%rbx), %eax
cmpl $0x6, %ecx
je 0x8ccd
cmpl $0x8, %ecx
jne 0x882a
movzwl 0x40(%rbx), %r11d
movzwl 0x42(%rbx), %r14d
jmp 0x8e47
movzwl 0x40(%rbx), %eax
movl %eax, 0x8(%rsp)
jmp 0x89da
movzwl 0x40(%rbx), %eax
movl 0x4(%rbx), %ecx
jmp 0x88fd
movzbl 0x40(%rbx), %edx
jmp 0x8d55
movzwl 0x40(%rbx), %ecx
movl %ecx, %eax
andl $0x1f, %eax
movl %ecx, 0x8(%rsp)
shrl $0x5, %ecx
andl $0x1f, %ecx
movzwl 0x42(%rbx), %r13d
leal (%rax,%rcx), %r12d
addl $0x102, %r12d           # imm = 0x102
movl %eax, %r15d
addl $0x101, %r15d           # imm = 0x101
movl %ecx, %eax
incl %eax
movl %eax, 0x10(%rsp)
cmpl %r13d, %r12d
ja 0x8ab6
jmp 0x8bb6
movq %rbx, %rdi
callq 0x86a4
movl 0x4(%rbx), %eax
cmpl $0x9, %eax
jbe 0x8c91
movq 0x8(%rbx), %rcx
movl %ecx, %esi
andl $0x7, %esi
addl $-0x3, %eax
movl %eax, 0x4(%rbx)
movq %rcx, %rdx
shrq $0x3, %rdx
movq %rdx, 0x8(%rbx)
movb %sil, 0x1(%rbx)
cmpl $0x1, %esi
ja 0x89a0
movl %eax, %ecx
andb $0x7, %cl
shrq %cl, %rdx
movq %rdx, 0x8(%rbx)
andl $-0x8, %eax
movl %eax, 0x4(%rbx)
movq %rbx, %rdi
callq 0x86a4
movl 0x4(%rbx), %ecx
cmpl $0x1f, %ecx
jbe 0x8c96
movq 0x8(%rbx), %rdx
movl %edx, %eax
notl %eax
shll $0x10, %eax
xorl %edx, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
ja 0x8cc3
addl $-0x20, %ecx
movl %ecx, 0x4(%rbx)
shrq $0x20, %rdx
movq %rdx, 0x8(%rbx)
testl %ecx, %ecx
je 0x8946
testl %eax, %eax
je 0x8946
movq 0x30(%rbx), %rdx
cmpq %rdx, 0x38(%rbx)
je 0x8c80
movq 0x8(%rbx), %rsi
addl $-0x8, %ecx
movl %ecx, 0x4(%rbx)
movq %rsi, %rcx
shrq $0x8, %rcx
movq %rcx, 0x8(%rbx)
leaq 0x1(%rdx), %rcx
movq %rcx, 0x30(%rbx)
movb %sil, (%rdx)
leal -0x1(%rax), %ebp
movl 0x4(%rbx), %ecx
testl %ecx, %ecx
je 0x8948
cmpl $0x1, %eax
movl %ebp, %eax
jne 0x8905
jmp 0x8948
movl %eax, %ebp
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rax
subq %rsi, %rax
movq 0x38(%rbx), %r15
movq 0x30(%rbx), %rdi
subq %rdi, %r15
cmpq %rax, %r15
cmovgeq %rax, %r15
cmpl %ebp, %r15d
movl %ebp, %r14d
cmovbl %r15d, %r14d
movq %r14, %rdx
callq 0x3280
movq 0x10(%rbx), %rax
addq %r14, %rax
movq %rax, 0x10(%rbx)
addq %r14, 0x30(%rbx)
cmpl %r15d, %ebp
ja 0x8ca8
testb $0x1, 0x1(%rbx)
je 0x8876
xorl %ebp, %ebp
jmp 0x8ed5
cmpl $0x5, %esi
ja 0x8cc3
testb $0x4, %cl
jne 0x89bb
movq %rbx, %rdi
callq 0x3a29
jmp 0x8c13
leaq 0x30(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b03
movl (%r14), %ecx
movl %ecx, 0x8(%rsp)
testb $0x1, %al
je 0x8c70
movl 0x8(%rsp), %eax
movl %eax, %r14d
andl $0x1f, %r14d
movl $0x1, %ebp
cmpl $0x1d, %r14d
ja 0x8ed5
movl %eax, %r12d
shrl $0x5, %r12d
andl $0x1f, %r12d
cmpl $0x1d, %r12d
ja 0x8ed5
movl %eax, %r13d
shrl $0xa, %r13d
leal 0x4(%r13), %r15d
movq %rbx, %rdi
callq 0x86da
movl 0x4(%rbx), %eax
leal (%r15,%r15,2), %ecx
cmpl %ecx, %eax
jb 0x8c9b
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x8(%rbx), %rcx
leal (%r13,%r13,2), %edx
negl %edx
movl %r15d, %esi
xorl %edi, %edi
leaq 0x26a26(%rip), %r8      # 0x2f470
movl %ecx, %r9d
andb $0x7, %r9b
shrq $0x3, %rcx
movzbl (%rdi,%r8), %r10d
movb %r9b, 0x30(%rsp,%r10)
incq %rdi
cmpq %rdi, %rsi
jne 0x8a4a
addl %edx, %eax
addl $-0xc, %eax
movq %rcx, 0x8(%rbx)
movl %eax, 0x4(%rbx)
leaq 0x504(%rbx), %rdi
leaq 0x30(%rsp), %rsi
movl $0x13, %edx
movl $0x13, %ecx
callq 0x8f7a
testb %al, %al
je 0x8ed5
movl %r12d, %eax
incl %eax
movl %eax, 0x10(%rsp)
movl %r14d, %r15d
addl $0x101, %r15d           # imm = 0x101
addl %r14d, %r12d
addl $0x102, %r12d           # imm = 0x102
xorl %r13d, %r13d
leaq 0x504(%rbx), %r14
movl $0x1, %ebp
movq %rbx, %rdi
callq 0x86a4
cmpl $0x15, 0x4(%rbx)
ja 0x8ada
testb $0x1, 0x2(%rbx)
je 0x8c60
movq %rbx, %rdi
movq %r14, %rsi
callq 0x873a
movl 0x4(%rbx), %edx
testl %edx, %edx
js 0x8ed5
cmpl $0xf, %eax
ja 0x8b04
movl %r13d, %ecx
incl %r13d
movb %al, 0x44(%rbx,%rcx)
jmp 0x8bad
cmpl $0x10, %eax
jne 0x8b55
movq 0x8(%rbx), %rax
addl $-0x2, %edx
movl %edx, 0x4(%rbx)
movq %rax, %rcx
shrq $0x2, %rcx
movq %rcx, 0x8(%rbx)
testl %r13d, %r13d
je 0x8ed5
andl $0x3, %eax
leal (%rax,%r13), %ecx
addl $0x3, %ecx
cmpl %r12d, %ecx
ja 0x8ed5
addl $0x3, %eax
leal -0x1(%r13), %ecx
movb 0x44(%rbx,%rcx), %cl
movl %r13d, %edx
incl %r13d
movb %cl, 0x44(%rbx,%rdx)
decl %eax
jne 0x8b45
jmp 0x8bad
leal -0x41(,%rax,4), %ecx
movq 0x8(%rbx), %rdi
movq $-0x1, %rsi
shlq %cl, %rsi
notl %esi
andl %edi, %esi
subl %ecx, %edx
movl %edx, 0x4(%rbx)
shrq %cl, %rdi
movq %rdi, 0x8(%rbx)
leal (%rsi,%rax,8), %ecx
addl $0xffffff78, %ecx       # imm = 0xFFFFFF78
addl %r13d, %ecx
addl $0x3, %ecx
cmpl %r12d, %ecx
ja 0x8ed5
leal (%rsi,%rax,8), %eax
addl $0xffffff7b, %eax       # imm = 0xFFFFFF7B
testl %eax, %eax
je 0x8bad
movl %r13d, %ecx
incl %r13d
movb $0x0, 0x44(%rbx,%rcx)
decl %eax
jne 0x8b9e
cmpl %r12d, %r13d
jb 0x8ac2
leaq 0x504(%rbx), %rdi
leaq 0x44(%rbx), %r14
movl %r15d, %r15d
movl $0x11f, %ecx            # imm = 0x11F
movq %r14, %rsi
movq %r15, %rdx
callq 0x8f7a
movl $0x1, %ebp
testb %al, %al
movl 0x10(%rsp), %eax
je 0x8ed5
movups (%r14,%r15), %xmm0
movups 0x10(%r14,%r15), %xmm1
leaq 0x30(%rsp), %rsi
movaps %xmm1, 0x10(%rsi)
movaps %xmm0, (%rsi)
movl %eax, %edx
movl $0x1f, %ecx
movq %r14, %rdi
callq 0x8f7a
testb %al, %al
je 0x8ed5
movb $0x6, (%rbx)
movq 0x20(%rbx), %r12
movq 0x28(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x30(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rbx), %rdi
movq 0x38(%rbx), %r8
leaq 0x10(%rbx), %rax
movq %rax, 0x28(%rsp)
movq 0x10(%rbx), %r10
movq 0x18(%rbx), %r9
leaq 0x8(%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%rbx), %r15
leaq 0x4(%rbx), %rax
movq %rax, 0x18(%rsp)
movl 0x4(%rbx), %eax
jmp 0x8ccd
movb $0x5, (%rbx)
movl 0x8(%rsp), %eax
movw %ax, 0x40(%rbx)
movw %r13w, 0x42(%rbx)
movzbl 0x2(%rbx), %eax
movl $0x2, %ebp
subl %eax, %ebp
jmp 0x8ed5
movb $0x2, (%rbx)
movw %ax, 0x40(%rbx)
movl $0x3, %ebp
jmp 0x8ed5
movb $0x0, (%rbx)
jmp 0x8c70
movb $0x1, (%rbx)
jmp 0x8c70
movb $0x4, (%rbx)
movl 0x8(%rsp), %eax
movw %ax, 0x40(%rbx)
jmp 0x8c70
subl %r14d, %ebp
movb $0x2, (%rbx)
movw %bp, 0x40(%rbx)
movl $0x3, %ebp
cmpq 0x18(%rbx), %rax
jne 0x8ed5
jmp 0x8c70
movl $0x1, %ebp
jmp 0x8ed5
movq %r9, %rcx
subq %r10, %rcx
cmpq $0x7, %rcx
jle 0x8ee6
cmpl $0x20, %eax
ja 0x8cf4
movl (%r10), %edx
movl %eax, %ecx
shlq %cl, %rdx
orq %rdx, %r15
addl $0x20, %eax
addq $0x4, %r10
movl %r15d, %ecx
andl $0x1ff, %ecx            # imm = 0x1FF
movzwl 0x504(%rbx,%rcx,2), %edx
testw %dx, %dx
jns 0x8d32
movl %edx, %esi
andl $0x7ff, %esi            # imm = 0x7FF
shrl $0xb, %edx
andb $0xf, %dl
movq %r15, %r11
movl %edx, %ecx
shrq %cl, %r11
andl $0x7, %r11d
orl %esi, %r11d
movzwl 0x504(%rbx,%r11,2), %edx
jmp 0x8d05
movl %edx, %ecx
shrl $0xb, %ecx
shrq %cl, %r15
subl %ecx, %eax
movl $0x1, %ebp
js 0x8ed5
andl $0x1ff, %edx            # imm = 0x1FF
cmpl $0xff, %edx
ja 0x8d68
cmpq %r8, %rdi
je 0x8eab
movb %dl, (%rdi)
incq %rdi
jmp 0x8ccd
cmpl $0x11d, %edx            # imm = 0x11D
ja 0x8f2e
movl %edx, %ecx
leaq 0x26713(%rip), %rdx     # 0x2f490
movzwl -0x202(%rdx,%rcx,2), %r11d
movl %r11d, %ecx
shrl $0xc, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
notl %edx
andl %r15d, %edx
shrq %cl, %r15
subl %ecx, %eax
andl $0x1ff, %r11d           # imm = 0x1FF
addq %rdx, %r11
cmpl $0x1b, %eax
jbe 0x8f5a
movl %r15d, %ecx
andl $0x1ff, %ecx            # imm = 0x1FF
movzwl 0x44(%rbx,%rcx,2), %edx
movl %edx, %esi
testw %dx, %dx
jns 0x8de8
andl $0x7ff, %esi            # imm = 0x7FF
shrl $0xb, %edx
andb $0xf, %dl
movq %r15, %r14
movl %edx, %ecx
shrq %cl, %r14
andl $0x7, %r14d
orl %esi, %r14d
movzwl 0x44(%rbx,%r14,2), %edx
jmp 0x8dbe
shrl $0xb, %esi
movl %esi, %ecx
shrq %cl, %r15
movl %edx, %r14d
andl $0x1ff, %r14d           # imm = 0x1FF
andl $0x1, %edx
orl $0x2, %edx
movl %r14d, %ecx
shrl %ecx
shll %cl, %edx
sarl %edx
cmpl $0x1, %r14d
sbbl $-0x1, %edx
cmpl $0x2, %r14d
adcl $-0x1, %ecx
movq $-0x1, %r13
shlq %cl, %r13
notq %r13
andq %r15, %r13
movslq %edx, %r14
addq %r13, %r14
cmpq $0x8000, %r14           # imm = 0x8000
ja 0x8ed5
shrq %cl, %r15
addl %ecx, %esi
subl %esi, %eax
js 0x8ed5
movq %rdi, %rcx
subq 0x10(%rsp), %rcx
movq %r14, %rdx
subq %rcx, %rdx
jbe 0x8e75
testq %r12, %r12
je 0x8cc3
movq %r12, %rsi
subq %rdx, %rsi
cmpq %r11, %rdx
cmovaeq %r11, %rdx
movq %rdx, %rcx
rep  movsb (%rsi), %es:(%rdi)
subq %rdx, %r11
movq %r8, %r13
subq %rdi, %r13
movq %rdi, %rsi
subq %r14, %rsi
cmpq %r11, %r13
movq %r11, %rdx
cmovbq %r13, %rdx
movq %rdx, %rcx
rep  movsb (%rsi), %es:(%rdi)
cmpq %r13, %r11
jbe 0x8ccd
subl %edx, %r11d
movw %r11w, 0x40(%rbx)
movw %r14w, 0x42(%rbx)
movb $0x8, (%rbx)
jmp 0x8eb1
movb $0x7, (%rbx)
movb %dl, 0x40(%rbx)
movl $0x3, %ebp
movq 0x28(%rsp), %rcx
movq %r10, (%rcx)
movq 0x20(%rsp), %rcx
movq %r15, (%rcx)
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
movq 0x8(%rsp), %rax
movq %rdi, (%rax)
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x38, %eax
ja 0x8f14
cmpq %r9, %r10
je 0x8f14
movl %eax, %eax
movq %r15, %rdx
movq %rax, %rcx
movzbl (%r10), %r15d
shlq %cl, %r15
incq %r10
orq %rdx, %r15
addq $0x8, %rax
cmpq $0x30, %rcx
ja 0x8f14
cmpq %r9, %r10
jne 0x8ef2
cmpl $0x2f, %eax
ja 0x8cf4
cmpb $0x1, 0x2(%rbx)
je 0x8cf4
movl $0x2, %ebp
jmp 0x8eb6
cmpl $0x180, %edx            # imm = 0x180
jne 0x8ed5
movq 0x28(%rsp), %rcx
movq %r10, (%rcx)
movq 0x20(%rsp), %rcx
movq %r15, (%rcx)
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
movq 0x8(%rsp), %rax
movq %rdi, (%rax)
jmp 0x898f
cmpq %r9, %r10
je 0x8db0
movl (%r10), %edx
movl %eax, %ecx
shlq %cl, %rdx
orq %rdx, %r15
orl $0x20, %eax
addq $0x4, %r10
jmp 0x8db0