// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rsi, %r14
movq %rdi, (%rsp)
movq $0x0, (%rdx)
movq %r8, 0x8(%rsp)
movl $0x0, (%r8)
incq %r14
movq (%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
leaq 0xd0(%rsp), %rdx
callq 0x973b
movq 0x20(%r15), %rcx
movslq %eax, %rbp
movq (%rcx,%rbp,8), %r15
movq 0xd0(%rsp,%rbp,8), %r14
leaq (%r14,%r15), %r12
decq %r12
testl %ebp, %ebp
je 0x9fad
cmpq $0x0, (%r13)
je 0x9ed3
cmpq $0x1, 0x10(%rbx)
jne 0x9f02
movq %r12, (%rbx)
jmp 0x9f30
leal -0x5(%rbp), %eax
negl %eax
cmpl $0x5, %ebp
movq %r15, (%rbx)
cmovael %ebp, %eax
movq 0x8(%rcx,%rbp,8), %rdx
subq (%rcx,%rbp,8), %rdx
movq %rdx, 0x10(%rbx)
cltq
movq (%rcx,%rax,8), %rax
movq %rax, 0x8(%rbx)
movq $0x0, 0x18(%rbx)
jmp 0x9f30
movq (%rsp), %rdi
movq %rbx, %rsi
leaq 0x10(%rsp), %rdx
movl $0x1, %ecx
callq 0x9d23
movq %rbp, %rax
shlq $0x5, %rax
movups 0x10(%rsp,%rax), %xmm0
movups 0x20(%rsp,%rax), %xmm1
movups %xmm0, (%rbx)
movups %xmm1, 0x10(%rbx)
movq (%r13), %rax
incq %rax
cmpq 0x8(%r13), %rax
jb 0x9f82
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%r13)
movq 0x10(%r13), %rdi
callq 0x21d0
movq %rax, 0x10(%r13)
addq %r15, %r14
movq (%r13), %rax
movq 0x10(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r13)
movb %bpl, (%rcx,%rax)
movq (%r13), %rax
movq 0x10(%r13), %rcx
movb $0x0, (%rcx,%rax)
testl %ebp, %ebp
jne 0x9e87
cmpq $0x1, 0x10(%rbx)
jne 0x9fb9
movq %r12, (%rbx)
jmp 0x9ff5
leaq 0x10(%rsp), %r14
movq (%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x1, %ecx
callq 0x9d23
movq 0x10(%r14), %rax
cmpq 0x10(%rbx), %rax
je 0x9fe4
movq 0x8(%rsp), %rax
orb $0x1, (%rax)
movaps 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
leaq 0x10(%rsp), %r14
movq (%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x9d23
movq 0x10(%r14), %rax
cmpq 0x10(%rbx), %rax
je 0xa01d
movq 0x8(%rsp), %rax
orb $0x2, (%rax)
movaps 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
movq %r12, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq