// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/rld0.c
// Function: enc_next_block
static inline void enc_next_block(rld_t *e, rlditr_t *itr)
{
	int i, type;
	if (itr->stail + 2 - *itr->i == RLD_LSIZE) {
		++e->n;
		e->z = realloc(e->z, e->n * sizeof(void*));
		itr->i = e->z + e->n - 1;
		itr->shead = *itr->i = xcalloc(RLD_LSIZE, 8);
	} else itr->shead += e->ssize;
	if (e->cnt[0] - e->mcnt[0] < 0x4000) {
		uint16_t *p = (uint16_t*)itr->shead;
		for (i = 0; i <= e->asize; ++i) p[i] = e->cnt[i] - e->mcnt[i];
		type = 0;
	} else if (e->cnt[0] - e->mcnt[0] < 0x40000000) {
		uint32_t *p = (uint32_t*)itr->shead;
		for (i = 0; i <= e->asize; ++i) p[i] = e->cnt[i] - e->mcnt[i];
		type = 1;
	} else {
		uint64_t *p = (uint64_t*)itr->shead;
		for (i = 0; i <= e->asize; ++i) p[i] = e->cnt[i] - e->mcnt[i];
		type = 2;
	}
	*itr->shead |= (uint64_t)type<<62;
	itr->p = itr->shead + e->offset0[type];
	itr->stail = rld_get_stail(e, itr);
	itr->q = (uint8_t*)itr->p;
	itr->r = 64;
	for (i = 0; i <= e->asize; ++i) e->mcnt[i] = e->cnt[i];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
addq $0x10, %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
sarq $0x3, %rax
cmpq $0x800000, %rax         # imm = 0x800000
jne 0xc081
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movslq 0xc(%rax), %rsi
shlq $0x3, %rsi
callq 0x21e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x8(%rbp), %rax
movslq 0xc(%rax), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $-0x8, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x800000, %edi         # imm = 0x800000
movl $0x8, %esi
callq 0x2140
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0xc09e
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movslq %edx, %rdx
shlq $0x3, %rdx
addq %rdx, %rcx
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq (%rcx), %rax
cmpq $0x4000, %rax           # imm = 0x4000
jae 0xc123
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0xc117
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x14(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movw %ax, %dx
movq -0x20(%rbp), %rax
movslq -0x14(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xc0cf
movl $0x0, -0x18(%rbp)
jmp 0xc204
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
subq (%rcx), %rax
cmpq $0x40000000, %rax       # imm = 0x40000000
jae 0xc1a3
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0xc19a
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x14(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xc154
movl $0x1, -0x18(%rbp)
jmp 0xc202
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0xc1fb
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
subq (%rax,%rcx,8), %rdx
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xc1b6
movl $0x2, -0x18(%rbp)
jmp 0xc204
movslq -0x18(%rbp), %rcx
shlq $0x3e, %rcx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rdx
movsbl 0x5(%rax,%rdx), %eax
cltq
shlq $0x3, %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x8(%rbp), %rax
movslq 0x8(%rax), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x8(%rbp), %rax
movslq 0x8(%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
subq %rax, %rsi
sarq $0x3, %rsi
movl $0x1, %eax
movl $0x2, %edx
cmpq $0x800000, %rsi         # imm = 0x800000
cmovel %edx, %eax
movslq %eax, %rdx
xorl %eax, %eax
subq %rdx, %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movl $0x40, (%rax)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jg 0xc305
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xc2cc
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)