// File: /workspace/github_c_makefile_star2_O3/lh3[P]fermi-lite/unitig.c
// Function: fm6_retrieve
uint64_t fm6_retrieve(const rld_t *e, uint64_t x, kstring_t *s, rldintv_t *k2, int *contained)
{
	uint64_t k = x, ok[6];
	rldintv_t ok2[6];
	s->l = 0; *contained = 0;
	while (1) {
		int c = rld_rank1a(e, k + 1, ok);
		k = e->cnt[c] + ok[c] - 1;
		if (c == 0) break;
		if (s->l > 0) {
			if (k2->x[2] == 1) k2->x[0] = k;
			else {
				rld_extend(e, k2, ok2, 1);
				*k2 = ok2[c];
			}
		} else fm6_set_intv(e, c, *k2);
		kputc(c, s);
	}
	if (k2->x[2] != 1) {
		rld_extend(e, k2, ok2, 1);
		if (ok2[0].x[2] != k2->x[2]) *contained |= 1; // left contained
		*k2 = ok2[0];
	} else k2->x[0] = k;
	rld_extend(e, k2, ok2, 0);
	if (ok2[0].x[2] != k2->x[2]) *contained |= 2; // right contained
	*k2 = ok2[0];
	return k;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, %rbx
movq %rdx, %r12
movq %rdi, %r14
movq $0x0, (%rdx)
movq %r8, 0x8(%rsp)
movl $0x0, (%r8)
incq %rsi
leaq 0x10(%rsp), %rdx
callq 0x9b65
movq %r14, (%rsp)
movq 0x20(%r14), %rcx
movslq %eax, %r14
movq (%rcx,%r14,8), %rax
movq 0x10(%rsp,%r14,8), %r13
leaq (%rax,%r13), %rbp
decq %rbp
testl %r14d, %r14d
je 0xa488
leaq (%rcx,%r14,8), %rdx
addq %rax, %r13
movl %r14d, %r15d
cmpq $0x0, (%r12)
je 0xa372
cmpq $0x1, 0x10(%rbx)
jne 0xa3a3
movq %rbp, (%rbx)
jmp 0xa3d0
leal -0x5(%r15), %esi
negl %esi
cmpl $0x5, %r15d
movq %rax, (%rbx)
cmovael %r15d, %esi
movq 0x8(%rdx), %rax
subq (%rdx), %rax
movq %rax, 0x10(%rbx)
movslq %esi, %rax
movq (%rcx,%rax,8), %rax
movq %rax, 0x8(%rbx)
movq $0x0, 0x18(%rbx)
jmp 0xa3d0
movq (%rsp), %rdi
movq %rbx, %rsi
leaq 0x40(%rsp), %rdx
movl $0x1, %ecx
callq 0xa1c6
shlq $0x5, %r14
movups 0x40(%rsp,%r14), %xmm0
movups 0x50(%rsp,%r14), %xmm1
movups %xmm0, (%rbx)
movups %xmm1, 0x10(%rbx)
movq (%r12), %rdx
leaq 0x1(%rdx), %rcx
cmpq 0x8(%r12), %rcx
jae 0xa3e6
movq 0x10(%r12), %rax
jmp 0xa436
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%r12)
movq 0x10(%r12), %rdi
callq 0x21c0
movq %rax, 0x10(%r12)
movq (%r12), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, (%r12)
movb %r15b, (%rax,%rdx)
movq (%r12), %rax
movq 0x10(%r12), %rcx
movb $0x0, (%rcx,%rax)
movq (%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
leaq 0x10(%rsp), %rdx
callq 0x9b65
movl %eax, %r15d
movq 0x20(%r14), %rcx
movslq %eax, %r14
leaq (%rcx,%r14,8), %rdx
movq (%rdx), %rax
movq 0x10(%rsp,%r14,8), %r13
leaq (%rax,%r13), %rbp
decq %rbp
addq %rax, %r13
testl %r14d, %r14d
jne 0xa35f
cmpq $0x1, 0x10(%rbx)
jne 0xa494
movq %rbp, (%rbx)
jmp 0xa4d0
leaq 0x40(%rsp), %r14
movq (%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x1, %ecx
callq 0xa1c6
movq 0x10(%r14), %rax
cmpq 0x10(%rbx), %rax
je 0xa4bf
movq 0x8(%rsp), %rax
orb $0x1, (%rax)
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
leaq 0x40(%rsp), %r14
movq (%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xa1c6
movq 0x10(%r14), %rax
cmpq 0x10(%rbx), %rax
je 0xa4f8
movq 0x8(%rsp), %rax
orb $0x2, (%rax)
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
movq %rbp, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq