// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movq 0x148(%rsp), %rax
xorl %r10d, %r10d
movq %r10, (%rax)
cmpl $0x1, 0x140(%rsp)
movl $0x0, %ebp
sbbl %ebp, %ebp
movl %ebp, %eax
orl $0x1, %eax
orl %edx, %ebp
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, (%rbx)
movq 0x8(%rsi,%rdx,8), %rdi
subq (%rsi,%rdx,8), %rdi
movq %rdi, 0x10(%rbx)
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(%rbx)
movq %r10, 0x18(%rbx)
leal (%r15,%rax), %ecx
subl %ecx, %ebp
je 0xb039
xorl %ecx, %ecx
cmpl $0x0, 0x140(%rsp)
sete %cl
movl %ecx, 0x8(%rsp)
movslq %eax, %r14
addq %r14, 0x10(%rsp)
movl $0x1, %r12d
movq 0x10(%rsp), %rax
movzbl (%rax,%r15), %eax
leal -0x1(%rax), %ecx
movl $0x5, %r13d
subl %eax, %r13d
cmpb $0x4, %cl
cmovaeq %rax, %r13
cmpl $0x0, 0x140(%rsp)
cmoveq %rax, %r13
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
leaq 0x40(%rsp), %rdx
movl 0x8(%rsp), %ecx
callq 0x9d23
movl %r13d, %r13d
shlq $0x5, %r13
cmpq $0x0, 0x50(%rsp,%r13)
je 0xb039
cmpl 0xc(%rsp), %r12d
jl 0xb014
cmpq $0x0, 0x50(%rsp)
je 0xb014
cmpl $0x0, 0x150(%rsp)
je 0xafa8
movq %r15, 0x58(%rsp)
movq 0x148(%rsp), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, (%rdi)
jne 0xaf8a
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rdi)
movq 0x148(%rsp), %rax
movq 0x10(%rax), %rdi
shlq $0x5, %rsi
callq 0x21d0
movq 0x148(%rsp), %rdi
movq %rax, 0x10(%rdi)
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rdi)
shlq $0x5, %rax
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
jmp 0xb00b
movq %r15, 0x18(%rbx)
movq 0x148(%rsp), %rdi
movq 0x8(%rdi), %rax
cmpq %rax, (%rdi)
jne 0xaff2
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rdi)
movq 0x148(%rsp), %rax
movq 0x10(%rax), %rdi
shlq $0x5, %rsi
callq 0x21d0
movq 0x148(%rsp), %rdi
movq %rax, 0x10(%rdi)
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rdi)
shlq $0x5, %rax
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0x10(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
leaq (%rsp,%r13), %rax
addq $0x40, %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
incl %r12d
addq %r14, %r15
subl %r14d, %ebp
jne 0xaecc
movq 0x148(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0xb0b0
movq (%rax), %rdx
testq %rdx, %rdx
je 0xb0b0
cmpq $0x1, %rdx
je 0xb0b0
movq 0x10(%rax), %rax
movq %rdx, %rcx
shrq %rcx
cmpq $0x1, %rcx
adcq $0x0, %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 0xb073
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq