// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/rld0.c
// Function: rld_rank2a
void rld_rank2a(const rld_t *e, uint64_t k, uint64_t l, uint64_t *ok, uint64_t *ol)
{
	uint64_t z, y, len;
	rlditr_t itr;
	int a = -1;
	if (k == 0) {
		for (a = 0; a < e->asize; ++a) ok[a] = 0;
		rld_rank1a(e, l, ol);
		return;
	}
	y = rld_locate_blk(e, &itr, k-1, ok, &z); // locate the block bracketing k
	while (1) { // compute ok[]
#ifdef _DNA_ONLY
		len = rld_dec0_fast_dna(e, &itr, &a);
#else
		len = rld_dec0(e, &itr, &a);
#endif
		if (z + len >= k) break;
		z += len; ok[a] += len;
	}
	if (y > l) { // we do not need to decode other blocks
		int b;
		for (b = 0; b < e->asize; ++b) ol[b] = ok[b]; // copy ok[] to ol[]
		ok[a] += k - z; // finalize ok[a]
		if (z + len < l) { // we need to decode the next run
			z += len; ol[a] += len;
			while (1) {
				len = rld_dec0(e, &itr, &a);
				if (z + len >= l) break;
				z += len; ol[a] += len;
			}
		}
		ol[a] += l - z;
	} else { // we have to decode other blocks
		ok[a] += k - z;
		rld_rank1a(e, l, ol);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x10(%rbp)
jne 0xd3a3
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movq -0x8(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jge 0xd38d
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0xd364
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xccb0
jmp 0xd523
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rdx
subq $0x1, %rdx
movq -0x20(%rbp), %rcx
leaq -0x78(%rbp), %rsi
leaq -0x30(%rbp), %r8
callq 0xcda0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x7c(%rbp), %rdx
callq 0xd190
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
addq -0x40(%rbp), %rax
cmpq -0x10(%rbp), %rax
jb 0xd3e9
jmp 0xd40b
movq -0x40(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0xd3c4
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jbe 0xd4fa
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
movq -0x8(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jge 0xd451
movq -0x20(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x28(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0xd420
movq -0x10(%rbp), %rdx
subq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
addq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0xd4e0
movq -0x40(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rax
movslq -0x7c(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x7c(%rbp), %rdx
callq 0xd530
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
addq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jb 0xd4bc
jmp 0xd4de
movq -0x40(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rax
movslq -0x7c(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0xd497
jmp 0xd4e0
movq -0x18(%rbp), %rdx
subq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rax
movslq -0x7c(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0xd523
movq -0x10(%rbp), %rdx
subq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xccb0
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)