// File: /workspace/github_c_makefile_star2_O3/lh3[P]fermi-lite/unitig.c
// Function: overlap_intv
static rldintv_t overlap_intv(const rld_t *e, int len, const uint8_t *seq, int min, int j, int at5, rldintv_v *p, int inc_sentinel)
{ // requirement: seq[j] matches the end of a read
	int c, depth, dir, end;
	rldintv_t ik, ok[6];
	p->n = 0;
	dir = at5? 1 : -1; // at5 is true iff we start from the 5'-end of a read
	end = at5? len : -1;
	c = seq[j];
	fm6_set_intv(e, c, ik);
	for (depth = 1, j += dir; j != end; j += dir, ++depth) {
		c = at5? fm6_comp(seq[j]) : seq[j];
		rld_extend(e, &ik, ok, !at5);
		if (!ok[c].x[2]) break; // cannot be extended
		if (depth >= min && ok[0].x[2]) {
			if (inc_sentinel) {
				ok[0].info = j - dir;
				kv_push(rldintv_t, *p, ok[0]);
			} else {
				ik.info = j - dir;
				kv_push(rldintv_t, *p, ik);
			}
		}
		ik = ok[c];
	}
	kv_reverse(rldintv_t, *p, 0); // reverse the array such that the smallest interval comes first
	return ik;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %r8d, 0xc(%rsp)
movq %rdi, %r12
movq 0x148(%rsp), %rax
xorl %r10d, %r10d
cmpl $0x1, 0x140(%rsp)
movl $0x0, %ebx
sbbl %ebx, %ebx
movq %r10, (%rax)
movl %ebx, %eax
orl $0x1, %eax
orl %edx, %ebx
movslq %r9d, %r15
movq %rcx, 0x10(%rsp)
movzbl (%rcx,%r15), %edx
movq %rsi, 0x18(%rsp)
movq 0x20(%rsi), %rsi
movq (%rsi,%rdx,8), %rdi
movq %rdi, (%r12)
movq 0x8(%rsi,%rdx,8), %r8
subq %rdi, %r8
movq %r8, 0x10(%r12)
leal -0x1(%rdx), %edi
movl $0x5, %r8d
subl %edx, %r8d
cmpb $0x4, %dil
cmovael %edx, %r8d
movslq %r8d, %rdx
movq (%rsi,%rdx,8), %rdx
movq %rdx, 0x8(%r12)
movq %r10, 0x18(%r12)
leal (%r15,%rax), %ecx
subl %ecx, %ebx
je 0xb517
xorl %ecx, %ecx
cmpl $0x0, 0x140(%rsp)
sete %cl
movl %ecx, 0x8(%rsp)
movslq %eax, %r14
addq %r14, 0x10(%rsp)
movl $0x1, %r13d
movq 0x10(%rsp), %rax
movzbl (%rax,%r15), %eax
leal -0x1(%rax), %ecx
movl $0x5, %ebp
subl %eax, %ebp
cmpb $0x4, %cl
cmovaeq %rax, %rbp
cmpl $0x0, 0x140(%rsp)
cmoveq %rax, %rbp
movq 0x18(%rsp), %rdi
movq %r12, %rsi
leaq 0x40(%rsp), %rdx
movl 0x8(%rsp), %ecx
callq 0xa1c6
movl %ebp, %ebp
shlq $0x5, %rbp
cmpq $0x0, 0x50(%rsp,%rbp)
je 0xb517
cmpl 0xc(%rsp), %r13d
jl 0xb4ee
cmpq $0x0, 0x50(%rsp)
je 0xb4ee
cmpl $0x0, 0x150(%rsp)
je 0xb486
movq %r15, 0x58(%rsp)
movq 0x148(%rsp), %rdi
movq (%rdi), %rcx
movq 0x10(%rdi), %rax
cmpq 0x8(%rdi), %rcx
jne 0xb46f
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rdi)
shlq $0x5, %rsi
movq %rax, %rdi
callq 0x21c0
movq 0x148(%rsp), %rdi
movq %rax, 0x10(%rdi)
movq (%rdi), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rdi)
shlq $0x5, %rcx
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
jmp 0xb4e5
movq %r15, 0x18(%r12)
movq 0x148(%rsp), %rdi
movq (%rdi), %rcx
movq 0x10(%rdi), %rax
cmpq 0x8(%rdi), %rcx
jne 0xb4cf
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rdi)
shlq $0x5, %rsi
movq %rax, %rdi
callq 0x21c0
movq 0x148(%rsp), %rdi
movq %rax, 0x10(%rdi)
movq (%rdi), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rdi)
shlq $0x5, %rcx
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
leaq (%rsp,%rbp), %rax
addq $0x40, %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%r12)
movups %xmm0, (%r12)
incl %r13d
addq %r14, %r15
subl %r14d, %ebx
jne 0xb3b6
movq 0x148(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0xb586
movq (%rax), %rdx
testq %rdx, %rdx
je 0xb586
cmpq $0x1, %rdx
je 0xb586
movq 0x10(%rax), %rax
movq %rdx, %rcx
shrq %rcx
shlq $0x5, %rdx
addq %rax, %rdx
addq $-0x20, %rdx
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movaps %xmm1, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rdx)
movups %xmm0, (%rdx)
movaps 0x20(%rsp), %xmm0
movaps 0x30(%rsp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
addq $0x20, %rax
addq $-0x20, %rdx
decq %rcx
jne 0xb549
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq