// File: /workspace/github_c_makefile_star2_O3/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, %r10
movq %r8, %r13
movq %rsi, %rbx
movq %rdi, %r15
movq 0xb0(%rsp), %rsi
movl 0x8(%r9), %r12d
movl 0x8(%r8), %ebp
cmpl %ebp, %r12d
jne 0x1a7f2
movl 0x4(%r10), %edx
addl %edx, %edx
sarl %edx
testl %edx, %edx
jle 0x1abbd
movslq 0x24(%rbx), %rax
leaq (%rax,%rax,4), %rcx
shlq $0x2, %rcx
addq 0x30(%rbx), %rcx
movslq (%r10), %rdi
movl %edi, %eax
movl 0x10(%r13), %r9d
movl %edx, %edx
shlq $0x4, %rdi
addq %rsi, %rdi
addq $0x8, %rdi
xorl %r14d, %r14d
cmpl -0x8(%rdi), %r9d
jge 0x1a7e1
movl 0x18(%r13), %r8d
cmpl (%rdi), %r8d
jl 0x1a95e
incq %r14
addq $0x10, %rdi
cmpq %r14, %rdx
jne 0x1a7ce
jmp 0x1abbd
cmpl $0x1, 0x20(%rbx)
movq %r10, 0x10(%rsp)
jg 0x1a9c2
movq %r15, 0x18(%rsp)
movslq 0x18(%r13), %r15
movslq %edx, %rax
subq %rax, %r15
movl 0x14(%r10), %r14d
addl %eax, %r14d
movl 0x10(%r13), %edx
subl %eax, %edx
movq %rdx, 0x50(%rsp)
movl %ecx, 0xc(%rsp)
movl 0xc(%r10), %ecx
addl %ecx, %eax
decl %eax
movl %eax, 0x24(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xb8cc
movabsq $0x3e800000001, %rax    # imm = 0x3E800000001
leaq 0x58(%rsp), %rsi
movq %rax, (%rsi)
movl $0x3e8, 0xc(%rsi)       # imm = 0x3E8
movl 0xc(%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 %r15d, %r14d
addq 0x18(%rbx), %r15
movl %r14d, %r8d
movq %r15, %r9
pushq 0x50(%rsp)
pushq %rbp
callq 0xbe6f
addq $0x10, %rsp
movq %rax, %r14
leaq 0x28(%rsp), %r15
movq %rax, %rdi
movl %r12d, %esi
movl 0x24(%rsp), %edx
movl 0xc(%rsp), %ecx
movq %r15, %r8
callq 0xc3ae
movq %r14, %rdi
callq 0xe611
cmpl $0x0, (%r15)
js 0x1a9b4
movl 0x3c(%rsp), %ecx
cmpl $0x2, %ecx
jle 0x1aaf0
movl 0x24(%rbx), %edx
movq 0x30(%rbx), %rax
movl $0x1, %r14d
movl $0x10, %ebp
movq 0x18(%rsp), %r15
cmpl 0x28(%rbx), %edx
jne 0x1a919
movl %edx, %ecx
shrl %ecx
addl %edx, %ecx
cmpl $0x4, %edx
cmovll %ebp, %ecx
movl %ecx, 0x28(%rbx)
movq (%rbx), %rdi
shlq $0x2, %rcx
leaq (%rcx,%rcx,4), %rdx
movq %rax, %rsi
callq 0x31ed
movq %rax, 0x30(%rbx)
movl 0x24(%rbx), %edx
movl 0x3c(%rsp), %ecx
movslq %edx, %rsi
incl %edx
movl %edx, 0x24(%rbx)
leaq (%rsi,%rsi,4), %rdi
movl $0x0, 0xc(%rax,%rdi,4)
movq $0x0, (%rax,%rdi,4)
movq 0x48(%rsp), %rsi
movl (%rsi,%r14,4), %r8d
movl %r8d, 0x8(%rax,%rdi,4)
movl $0xffffffff, 0x10(%rax,%rdi,4) # imm = 0xFFFFFFFF
incq %r14
leal -0x1(%rcx), %edi
movslq %edi, %rdi
cmpq %rdi, %r14
jl 0x1a8e7
jmp 0x1aafa
addl -0x10(%rcx), %edx
subl %r14d, %edx
movl %edx, -0x10(%rcx)
movl 0x1c(%r10), %edx
addl %edx, -0x8(%rcx)
movslq 0x2c(%rbx), %rdi
shlq $0x4, %rdi
addq 0x28(%r15), %rdi
addl %r14d, %eax
cltq
shlq $0x4, %rax
addq %rax, %rsi
movl 0x4(%r10), %edx
shlq $0x21, %rdx
sarq $0x21, %rdx
subq %r14, %rdx
shlq $0x4, %rdx
movq %r10, %r15
callq 0x2230
movl 0x4(%r15), %eax
addl %eax, %eax
sarl %eax
addl 0x2c(%rbx), %eax
subl %r14d, %eax
jmp 0x1abba
movl 0x8(%r13), %ebp
movq 0x10(%rsp), %r10
movq 0x18(%rsp), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rsp)
movl $0x0, 0x48(%rsp)
xorl $0x1, %ebp
movl %ebp, 0x28(%rsp)
movl 0x20(%r10), %r9d
testl %r9d, %r9d
js 0x1ac71
leaq 0x28(%rsp), %r8
movl %r9d, 0x4(%r8)
movl 0x24(%r10), %eax
movl %eax, 0x8(%r8)
movl $0x40000000, 0xc(%r8)   # imm = 0x40000000
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movl 0x8(%r10), %edx
xorl $0x1, %edx
leaq 0x58(%rsp), %r14
movl $0x1, %ecx
pushq %r14
pushq $0xf
callq 0x10f8f
addq $0x10, %rsp
movq %rax, %rbp
movl (%r14), %r14d
testl %r14d, %r14d
je 0x1abce
movl 0x30(%rsp), %eax
cmpl 0x48(%rsp), %eax
jne 0x1abce
movq %r15, %r13
cmpl $0x3, %r14d
jl 0x1aadb
addl $-0x2, %r14d
movl 0x24(%rbx), %ecx
movq 0x30(%rbx), %rax
leaq (%r14,%r14,2), %rdx
incq %r14
leaq (,%rdx,4), %r15
addq %rbp, %r15
movl $0x10, %r12d
cmpl 0x28(%rbx), %ecx
jne 0x1aaa0
movl %ecx, %edx
shrl %edx
addl %ecx, %edx
cmpl $0x4, %ecx
cmovll %r12d, %edx
movl %edx, 0x28(%rbx)
movq (%rbx), %rdi
shlq $0x2, %rdx
leaq (%rdx,%rdx,4), %rdx
movq %rax, %rsi
callq 0x31ed
movq %rax, 0x30(%rbx)
movl 0x24(%rbx), %ecx
movslq %ecx, %rdx
incl %ecx
movl %ecx, 0x24(%rbx)
leaq (%rdx,%rdx,4), %rdx
movl $0x0, 0xc(%rax,%rdx,4)
movq $0x0, (%rax,%rdx,4)
movl (%r15), %esi
xorl $0x1, %esi
movl %esi, 0x8(%rax,%rdx,4)
movl $0xffffffff, 0x10(%rax,%rdx,4) # imm = 0xFFFFFFFF
decq %r14
addq $-0xc, %r15
cmpq $0x1, %r14
jg 0x1aa71
movq (%rbx), %rdi
movq %rbp, %rsi
callq 0x301f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r13, %r15
jmp 0x1ab06
movq 0x48(%rsp), %rsi
movq 0x18(%rsp), %r15
movq (%rbx), %rdi
callq 0x301f
movl 0x28(%rsp), %ebp
movl 0x24(%rbx), %eax
cmpl 0x28(%rbx), %eax
jne 0x1ab42
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 0x31ed
movq %rax, %r12
movq %rax, 0x30(%rbx)
movl 0x24(%rbx), %eax
jmp 0x1ab46
movq 0x30(%rbx), %r12
movq 0x10(%rsp), %r8
movq 0xb0(%rsp), %rsi
leal 0x1(%rax), %ecx
movl %ecx, 0x24(%rbx)
cltq
leaq (%rax,%rax,4), %r14
movq 0x28(%r15), %rax
movl 0x4(%r8), %edx
leal (%rdx,%rdx), %ecx
sarl %ecx
movl %ecx, 0x4(%r12,%r14,4)
movl 0x8(%r8), %ecx
movl %ecx, 0x8(%r12,%r14,4)
movl 0x1c(%r8), %ecx
movl %ecx, 0xc(%r12,%r14,4)
movl %ebp, 0x10(%r12,%r14,4)
movslq 0x2c(%rbx), %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movslq (%r8), %rax
shlq $0x4, %rax
addq %rax, %rsi
shlq $0x21, %rdx
sarq $0x21, %rdx
shlq $0x4, %rdx
callq 0x2230
movl 0x2c(%rbx), %eax
movl %eax, (%r12,%r14,4)
addl 0x4(%r12,%r14,4), %eax
movl %eax, 0x2c(%rbx)
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x17423(%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 0xdab6(%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, %r14
xorq $0x1, %r14
movl %r14d, %eax
andl $0x1, %eax
movsbl (%rax,%rdx), %r15d
shrl %r11d
shlq $0x6, %r11
movl 0x2c(%rsp), %r12d
movl 0x44(%rsp), %r13d
subq $0x8, %rsp
leaq 0xeca8(%rip), %rsi      # 0x298e5
leaq 0xece7(%rip), %rdx      # 0x2992b
xorl %eax, %eax
pushq %r12
pushq %r13
pushq %r14
pushq 0x18(%r10,%r11)
pushq %r15
callq 0x2210
addq $0x30, %rsp
movq (%rbx), %rdi
movq %rbp, %rsi
callq 0x301f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1abbf
leaq 0xec0b(%rip), %rdi      # 0x29883
leaq 0xe83d(%rip), %rsi      # 0x294bc
leaq 0xec0f(%rip), %rcx      # 0x29895
movl $0x146, %edx            # imm = 0x146
callq 0x2160