// File: /workspace/github_c_makefile_star2_O1/lh3[P]minigraph/gchain1.c
// Function: bridge_lchains
static int32_t bridge_lchains(mg_gchains_t *gc, bridge_aux_t *aux, int32_t kmer_size, int32_t gdp_max_ed, const mg_lchain_t *l0, const mg_lchain_t *l1, const mg128_t *a)
{
	if (l1->v != l0->v) { // bridging two segments
		int32_t ed = -1, ret = 0;
		if (aux->n_seg > 1 || !bridge_gwfa(aux, kmer_size, gdp_max_ed, l0, l1, &ed))
			ret = bridge_shortk(aux, l0, l1);
		if (ret < 0) return -1;
		if (aux->n_llc == aux->m_llc) KEXPAND(aux->km, aux->llc, aux->m_llc);
		copy_lchain(&aux->llc[aux->n_llc++], l1, &aux->n_a, gc->a, a, ed);
	} else { // on one segment
		int32_t k;
		mg_llchain_t *t = &aux->llc[aux->n_llc - 1];
		for (k = 0; k < l1->cnt; ++k) { // FIXME: this part is made redundant by resolve_overlap()
			const mg128_t *ak = &a[l1->off + k];
			if ((int32_t)ak->x > l0->re && (int32_t)ak->y > l0->qe)
				break;
		}
		if (k < l1->cnt) { // l1 contained. TODO: check what is happening...
			t->cnt += l1->cnt - k, t->score += l1->score;
			memcpy(&gc->a[aux->n_a], &a[l1->off + k], (l1->cnt - k) * sizeof(mg128_t));
			aux->n_a += l1->cnt - k;
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %r15
movq %r8, %r13
movq %rsi, %rbx
movq %rdi, 0x48(%rsp)
movq 0xb0(%rsp), %rsi
movl 0x8(%r9), %r12d
movl 0x8(%r8), %ebp
cmpl %ebp, %r12d
jne 0x1a7be
movl 0x4(%r15), %ecx
addl %ecx, %ecx
sarl %ecx
testl %ecx, %ecx
setg %dl
jle 0x1aba4
movslq 0x24(%rbx), %rax
leaq (%rax,%rax,4), %rax
shlq $0x2, %rax
addq 0x30(%rbx), %rax
movslq (%r15), %rdi
movl 0x10(%r13), %r9d
movl %ecx, %ecx
shlq $0x4, %rdi
addq %rsi, %rdi
addq $0x8, %rdi
xorl %r14d, %r14d
cmpl -0x8(%rdi), %r9d
jge 0x1a7a7
movl 0x18(%r13), %r8d
cmpl (%rdi), %r8d
jl 0x1a935
incq %r14
cmpq %rcx, %r14
setb %dl
addq $0x10, %rdi
cmpq %r14, %rcx
jne 0x1a794
jmp 0x1aba4
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0x1, 0x20(%rbx)
movq %r15, 0x10(%rsp)
jg 0x1a9b3
movslq 0x18(%r13), %r14
movslq %edx, %rax
subq %rax, %r14
movl %ecx, 0x8(%rsp)
movq %r15, %rcx
movl 0x14(%r15), %r15d
addl %eax, %r15d
movl 0x10(%r13), %edx
subl %eax, %edx
movq %rdx, 0x50(%rsp)
movl 0xc(%rcx), %ecx
addl %ecx, %eax
decl %eax
movl %eax, 0x1c(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xb478
movabsq $0x3e800000001, %rax    # imm = 0x3E800000001
leaq 0x58(%rsp), %rsi
movq %rax, (%rsi)
movl $0x3e8, 0xc(%rsi)       # imm = 0x3E8
movl 0x8(%rsp), %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
movl %eax, 0x8(%rsi)
movq $0x1dcd6500, 0x18(%rsi) # imm = 0x1DCD6500
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rcx
subl %r14d, %r15d
addq 0x18(%rbx), %r14
movl %r15d, %r8d
movq %r14, %r9
pushq 0x50(%rsp)
pushq %rbp
callq 0xba47
addq $0x10, %rsp
movq %rax, %r14
leaq 0x20(%rsp), %r15
movq %rax, %rdi
movl %r12d, %esi
movl 0x1c(%rsp), %edx
movl 0x8(%rsp), %ecx
movq %r15, %r8
callq 0xbfb9
movq %r14, %rdi
callq 0xe242
movl (%r15), %ebp
testl %ebp, %ebp
js 0x1a99c
cmpl $0x3, 0x34(%rsp)
jl 0x1a921
movl $0x1, %r14d
movl $0x10, %r15d
movl 0x28(%rbx), %eax
cmpl %eax, 0x24(%rbx)
jne 0x1a8da
movl %eax, %ecx
shrl %ecx
addl %eax, %ecx
cmpl $0x4, %eax
cmovll %r15d, %ecx
movl %ecx, 0x28(%rbx)
movq (%rbx), %rdi
movq 0x30(%rbx), %rsi
shlq $0x2, %rcx
leaq (%rcx,%rcx,4), %rdx
callq 0x32c4
movq %rax, 0x30(%rbx)
movq 0x30(%rbx), %rax
movslq 0x24(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x24(%rbx)
leaq (%rcx,%rcx,4), %rcx
movl $0x0, 0xc(%rax,%rcx,4)
movq $0x0, (%rax,%rcx,4)
movq 0x40(%rsp), %rdx
movl (%rdx,%r14,4), %edx
movl %edx, 0x8(%rax,%rcx,4)
movl $0xffffffff, 0x10(%rax,%rcx,4) # imm = 0xFFFFFFFF
incq %r14
movslq 0x34(%rsp), %rax
decq %rax
cmpq %rax, %r14
jl 0x1a8aa
movq (%rbx), %rdi
movq 0x40(%rsp), %rsi
callq 0x30f6
movl 0x20(%rsp), %r14d
jmp 0x1a9a2
testb $0x1, %dl
je 0x1aba4
addl -0x10(%rax), %ecx
subl %r14d, %ecx
movl %ecx, -0x10(%rax)
movl 0x1c(%r15), %ecx
addl %ecx, -0x8(%rax)
movslq 0x2c(%rbx), %rdi
shlq $0x4, %rdi
movq 0x48(%rsp), %rax
addq 0x28(%rax), %rdi
movl (%r15), %eax
addl %r14d, %eax
cltq
shlq $0x4, %rax
addq %rax, %rsi
movl 0x4(%r15), %edx
shlq $0x21, %rdx
sarq $0x21, %rdx
subq %r14, %rdx
shlq $0x4, %rdx
callq 0x2230
movl 0x4(%r15), %eax
addl %eax, %eax
sarl %eax
addl 0x2c(%rbx), %eax
subl %r14d, %eax
movl %eax, 0x2c(%rbx)
jmp 0x1aba4
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %ebp, %ebp
js 0x1a9ae
xorl %r15d, %r15d
jmp 0x1aade
movq 0x10(%rsp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl $0x0, 0x40(%rsp)
movl 0x8(%r13), %eax
xorl $0x1, %eax
movl %eax, 0x20(%rsp)
movl 0x20(%r15), %r9d
testl %r9d, %r9d
js 0x1ac53
leaq 0x20(%rsp), %r8
movl %r9d, 0x4(%r8)
movl 0x24(%r15), %eax
movl %eax, 0x8(%r8)
orb $0x40, 0xf(%r8)
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movl 0x8(%r15), %edx
xorl $0x1, %edx
leaq 0x58(%rsp), %r15
movl $0x1, %ecx
pushq %r15
pushq $0xf
callq 0x10beb
addq $0x10, %rsp
movq %rax, %rbp
movl (%r15), %r15d
testl %r15d, %r15d
je 0x1abb7
movl 0x28(%rsp), %eax
cmpl 0x40(%rsp), %eax
jne 0x1abb7
cmpl $0x3, %r15d
jl 0x1aad0
addl $-0x2, %r15d
leaq (%r15,%r15,2), %rax
incq %r15
leaq (,%rax,4), %r12
addq %rbp, %r12
movl $0x10, %r13d
movl 0x28(%rbx), %eax
cmpl %eax, 0x24(%rbx)
jne 0x1aa8e
movl %eax, %ecx
shrl %ecx
addl %eax, %ecx
cmpl $0x4, %eax
cmovll %r13d, %ecx
movl %ecx, 0x28(%rbx)
movq (%rbx), %rdi
movq 0x30(%rbx), %rsi
shlq $0x2, %rcx
leaq (%rcx,%rcx,4), %rdx
callq 0x32c4
movq %rax, 0x30(%rbx)
movq 0x30(%rbx), %rax
movslq 0x24(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x24(%rbx)
leaq (%rcx,%rcx,4), %rcx
movl $0x0, 0xc(%rax,%rcx,4)
movq $0x0, (%rax,%rcx,4)
movl (%r12), %edx
xorl $0x1, %edx
movl %edx, 0x8(%rax,%rcx,4)
movl $0xffffffff, 0x10(%rax,%rcx,4) # imm = 0xFFFFFFFF
decq %r15
addq $-0xc, %r12
cmpq $0x1, %r15
jg 0x1aa5e
xorl %r15d, %r15d
movq (%rbx), %rdi
movq %rbp, %rsi
callq 0x30f6
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %r15b, %r15b
jne 0x1aba6
movl 0x28(%rbx), %eax
cmpl %eax, 0x24(%rbx)
jne 0x1ab20
movl %eax, %ecx
shrl %ecx
addl %eax, %ecx
cmpl $0x4, %eax
movl $0x10, %eax
cmovgel %ecx, %eax
movl %eax, 0x28(%rbx)
movq (%rbx), %rdi
movq 0x30(%rbx), %rsi
shlq $0x2, %rax
leaq (%rax,%rax,4), %rdx
callq 0x32c4
movq %rax, 0x30(%rbx)
movq 0x30(%rbx), %r12
movslq 0x24(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x24(%rbx)
leaq (%rax,%rax,4), %r13
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rsp), %rsi
movl 0x4(%rsi), %edx
leal (%rdx,%rdx), %ecx
sarl %ecx
movl %ecx, 0x4(%r12,%r13,4)
movl 0x8(%rsi), %ecx
movl %ecx, 0x8(%r12,%r13,4)
movl 0x1c(%rsi), %ecx
movl %ecx, 0xc(%r12,%r13,4)
movl %r14d, 0x10(%r12,%r13,4)
movslq 0x2c(%rbx), %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movslq (%rsi), %rax
shlq $0x4, %rax
movq 0xb0(%rsp), %rsi
addq %rax, %rsi
shlq $0x21, %rdx
sarq $0x21, %rdx
shlq $0x4, %rdx
callq 0x2230
movl 0x2c(%rbx), %eax
movl %eax, (%r12,%r13,4)
movl 0x4(%r12,%r13,4), %eax
addl %eax, 0x2c(%rbx)
testb %r15b, %r15b
jne 0x1aba6
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1743a(%rip), %rax     # 0x31ff8
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movl 0x8(%rax), %eax
movq %rax, %r9
xorq $0x1, %r9
movl %r9d, %ecx
andl $0x1, %ecx
leaq 0xdacd(%rip), %rdx      # 0x286aa
movsbl (%rcx,%rdx), %ecx
movq 0x8(%rbx), %rsi
movq 0x10(%rsi), %r10
shrl %eax
shlq $0x6, %rax
movq 0x18(%r10,%rax), %r8
movl 0x8(%r13), %r11d
movq %r11, %r15
xorq $0x1, %r15
movl %r15d, %eax
andl $0x1, %eax
movsbl (%rax,%rdx), %eax
movq %rax, 0x8(%rsp)
shrl %r11d
shlq $0x6, %r11
movl 0x24(%rsp), %r13d
movl 0x3c(%rsp), %r12d
subq $0x8, %rsp
leaq 0xec47(%rip), %rsi      # 0x29871
leaq 0xec86(%rip), %rdx      # 0x298b7
xorl %eax, %eax
pushq %r13
pushq %r12
pushq %r15
pushq 0x18(%r10,%r11)
pushq 0x30(%rsp)
callq 0x2210
addq $0x30, %rsp
movb $0x1, %r15b
jmp 0x1aad3
leaq 0xebb5(%rip), %rdi      # 0x2980f
leaq 0xe7e7(%rip), %rsi      # 0x29448
leaq 0xebb9(%rip), %rcx      # 0x29821
movl $0x146, %edx            # imm = 0x146
callq 0x2160