// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x8(%rcx), %eax
je 0x28c9e
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jg 0x28bbe
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
leaq -0x34(%rbp), %r9
callq 0x28fb0
cmpl $0x0, %eax
jne 0x28bd2
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x29230
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jge 0x28be4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x28dc9
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x28c58
jmp 0x28bf6
movq -0x18(%rbp), %rax
cmpl $0x4, 0x28(%rax)
jl 0x28c17
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x18(%rbp), %rcx
movl 0x28(%rcx), %ecx
sarl %ecx
addl %ecx, %eax
movl %eax, -0x54(%rbp)
jmp 0x28c21
movl $0x10, %eax
movl %eax, -0x54(%rbp)
jmp 0x28c21
movl -0x54(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x18(%rbp), %rax
movslq 0x28(%rax), %rax
imulq $0x14, %rax, %rdx
callq 0x2ae0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x28c58
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x18(%rbp), %rcx
movl 0x24(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x24(%rcx)
cltq
imulq $0x14, %rax, %rax
addq %rax, %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rdx
addq $0x2c, %rdx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq 0x10(%rbp), %r8
movl -0x34(%rbp), %r9d
callq 0x28aa0
jmp 0x28dc2
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x24(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %ecx
shll %ecx
sarl %ecx
cmpl %ecx, %eax
jge 0x28d22
movq 0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movl (%rcx), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jle 0x28d15
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jle 0x28d15
jmp 0x28d22
jmp 0x28d17
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x28cc5
movl -0x3c(%rbp), %eax
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %ecx
shll %ecx
sarl %ecx
cmpl %ecx, %eax
jge 0x28dc0
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
shll %ecx
sarl %ecx
subl -0x3c(%rbp), %ecx
movq -0x48(%rbp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x48(%rbp), %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x18(%rbp), %rax
movslq 0x2c(%rax), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq 0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
movl (%rax), %eax
addl -0x3c(%rbp), %eax
cltq
shlq $0x4, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
sarl %eax
subl -0x3c(%rbp), %eax
movslq %eax, %rdx
shlq $0x4, %rdx
callq 0x2230
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
shll %ecx
sarl %ecx
subl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
addl 0x2c(%rax), %ecx
movl %ecx, 0x2c(%rax)
jmp 0x28dc2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)