// File: /workspace/github_c_makefile_star2_O2/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 $0x68, %rsp
movq %r9, %r14
movq %r8, %r13
movq %rsi, %rbx
movq %rdi, %r8
movq 0xa0(%rsp), %r9
movl 0x8(%r14), %esi
movl 0x8(%r13), %r15d
cmpl %r15d, %esi
jne 0x172a2
movslq 0x24(%rbx), %rax
imulq $0x14, %rax, %rax
addq 0x30(%rbx), %rax
movl 0x4(%r14), %ecx
addl %ecx, %ecx
sarl %ecx
xorl %ebp, %ebp
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
xorl %r15d, %r15d
cmpl %r15d, %edx
je 0x175b6
movslq (%r14), %rsi
addq %r15, %rsi
shlq $0x4, %rsi
movl 0x10(%r13), %edi
cmpl (%r9,%rsi), %edi
jge 0x1729d
addq %r9, %rsi
movl 0x18(%r13), %edi
cmpl 0x8(%rsi), %edi
jl 0x173ea
incq %r15
jmp 0x17270
movq %r8, 0x10(%rsp)
cmpl $0x1, 0x20(%rbx)
pushq $0x10
popq %r12
jg 0x1744e
movslq 0x18(%r13), %rbp
movslq %edx, %rax
subq %rax, %rbp
movl 0x14(%r14), %edx
addl %eax, %edx
movl %edx, 0x4(%rsp)
movl 0x10(%r13), %edx
subl %eax, %edx
movq %rdx, 0x40(%rsp)
movl %ecx, (%rsp)
movl 0xc(%r14), %ecx
addl %ecx, %eax
decl %eax
movl %eax, 0xc(%rsp)
leaq 0x48(%rsp), %rdi
movl %esi, 0x8(%rsp)
callq 0x96d8
movabsq $0x3e800000001, %rax    # imm = 0x3E800000001
leaq 0x48(%rsp), %rsi
movq %rax, (%rsi)
movl $0x3e8, 0xc(%rsi)       # imm = 0x3E8
pushq $0x2
popq %rcx
movl (%rsp), %eax
cltd
idivl %ecx
movl %eax, 0x8(%rsi)
movq $0x1dcd6500, 0x18(%rsi) # imm = 0x1DCD6500
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rcx
movl 0x4(%rsp), %r8d
subl %ebp, %r8d
addq 0x18(%rbx), %rbp
movq %rbp, %r9
pushq 0x40(%rsp)
pushq %r15
callq 0x9cb1
popq %rcx
popq %rdx
movq %rax, %rbp
leaq 0x18(%rsp), %r15
movq %rax, %rdi
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movl (%rsp), %ecx
movq %r15, %r8
callq 0xa199
movq %rbp, %rdi
callq 0xbdc8
cmpl $0x0, (%r15)
js 0x1744a
pushq $0x1
popq %r15
movslq 0x2c(%rsp), %rax
decq %rax
cmpq %rax, %r15
jge 0x17434
movl 0x24(%rbx), %ecx
movq 0x30(%rbx), %rax
cmpl 0x28(%rbx), %ecx
jne 0x173bc
movl %ecx, %edx
shrl %edx
addl %ecx, %edx
cmpl $0x4, %ecx
cmovll %r12d, %edx
movl %edx, 0x28(%rbx)
movq (%rbx), %rdi
imulq $0x14, %rdx, %rdx
movq %rax, %rsi
callq 0x2774
movq %rax, 0x30(%rbx)
movl 0x24(%rbx), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x24(%rbx)
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
andl $0x0, 0xc(%rax,%rcx)
andq $0x0, (%rax,%rcx)
movq 0x38(%rsp), %rdx
movl (%rdx,%r15,4), %edx
movl %edx, 0x8(%rax,%rcx)
orl $-0x1, 0x10(%rax,%rcx)
incq %r15
jmp 0x17379
addl -0x10(%rax), %ecx
subl %r15d, %ecx
movl %ecx, -0x10(%rax)
movl 0x1c(%r14), %ecx
addl %ecx, -0x8(%rax)
movslq 0x2c(%rbx), %rdi
shlq $0x4, %rdi
addq 0x28(%r8), %rdi
movl 0x4(%r14), %edx
shlq $0x21, %rdx
sarq $0x21, %rdx
subq %r15, %rdx
shlq $0x4, %rdx
callq 0x2230
movl 0x4(%r14), %eax
addl %eax, %eax
sarl %eax
addl 0x2c(%rbx), %eax
subl %r15d, %eax
movl %eax, 0x2c(%rbx)
jmp 0x175b6
movq (%rbx), %rdi
movq 0x38(%rsp), %rsi
callq 0x2577
movl 0x18(%rsp), %ebp
jmp 0x1754b
movl 0x8(%r13), %r15d
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
andl $0x0, 0x38(%rsp)
xorl $0x1, %r15d
movl %r15d, 0x18(%rsp)
movl 0x20(%r14), %r9d
testl %r9d, %r9d
js 0x17664
leaq 0x18(%rsp), %r8
movl %r9d, 0x4(%r8)
movl 0x24(%r14), %eax
movl %eax, 0x8(%r8)
movl $0x40000000, 0xc(%r8)   # imm = 0x40000000
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movl 0x8(%r14), %edx
xorl $0x1, %edx
leaq 0x48(%rsp), %r15
pushq $0x1
popq %rcx
pushq %r15
pushq $0xf
callq 0xe567
popq %rcx
popq %rdx
movq %rax, %rbp
movl (%r15), %r15d
testl %r15d, %r15d
je 0x175c7
movl 0x20(%rsp), %eax
cmpl 0x38(%rsp), %eax
jne 0x175c7
addl $-0x2, %r15d
imulq $0xc, %r15, %rax
movq %rbp, %r13
addq %rax, %r13
testl %r15d, %r15d
jle 0x1753d
movl 0x24(%rbx), %ecx
movq 0x30(%rbx), %rax
cmpl 0x28(%rbx), %ecx
jne 0x1750d
movl %ecx, %edx
shrl %edx
addl %ecx, %edx
cmpl $0x4, %ecx
cmovll %r12d, %edx
movl %edx, 0x28(%rbx)
movq (%rbx), %rdi
imulq $0x14, %rdx, %rdx
movq %rax, %rsi
callq 0x2774
movq %rax, 0x30(%rbx)
movl 0x24(%rbx), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x24(%rbx)
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
andl $0x0, 0xc(%rax,%rcx)
andq $0x0, (%rax,%rcx)
movl (%r13), %edx
xorl $0x1, %edx
movl %edx, 0x8(%rax,%rcx)
orl $-0x1, 0x10(%rax,%rcx)
addq $-0xc, %r13
decl %r15d
jmp 0x174d6
movq (%rbx), %rdi
movq %rbp, %rsi
callq 0x2577
pushq $-0x1
popq %rbp
movl 0x24(%rbx), %ecx
cmpl 0x28(%rbx), %ecx
jne 0x1757d
movl %ecx, %eax
shrl %eax
addl %ecx, %eax
cmpl $0x4, %ecx
cmovgel %eax, %r12d
movl %r12d, 0x28(%rbx)
movq (%rbx), %rdi
movq 0x30(%rbx), %rsi
imulq $0x14, %r12, %rdx
callq 0x2774
movq %rax, 0x30(%rbx)
movl 0x24(%rbx), %ecx
jmp 0x17581
movq 0x30(%rbx), %rax
movq 0x10(%rsp), %rsi
movq 0xa0(%rsp), %r8
leal 0x1(%rcx), %edx
movl %edx, 0x24(%rbx)
movslq %ecx, %rcx
imulq $0x14, %rcx, %rdi
addq %rax, %rdi
addq $0x2c, %rbx
movq 0x28(%rsi), %rcx
movq %r14, %rsi
movq %rbx, %rdx
movl %ebp, %r9d
callq 0x171c1
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x16a2a(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
movl 0x8(%r14), %eax
movq %rax, %r9
xorq $0x1, %r9
movl %r9d, %ecx
andl $0x1, %ecx
leaq 0xc0ca(%rip), %rdx      # 0x236b3
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 0x1c(%rsp), %r12d
movl 0x34(%rsp), %r13d
subq $0x8, %rsp
leaq 0xd2c7(%rip), %rsi      # 0x248f9
leaq 0xd306(%rip), %rdx      # 0x2493f
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 0x2577
pushq $-0x1
popq %rbp
jmp 0x175b6
leaq 0xd22c(%rip), %rdi      # 0x24897
leaq 0xce5e(%rip), %rsi      # 0x244d0
leaq 0xd230(%rip), %rcx      # 0x248a9
movl $0x146, %edx            # imm = 0x146
callq 0x2160