// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/gchain1.c
// Function: mg_gchain_extra
void mg_gchain_extra(const gfa_t *g, mg_gchains_t *gs)
{
	int32_t i, j, k;
	for (i = 0; i < gs->n_gc; ++i) { // iterate over gchains
		mg_gchain_t *p = &gs->gc[i];
		const mg_llchain_t *q;
		const mg128_t *last_a;
		int32_t q_span, rest_pl, tmp, n_mini;

		p->qs = p->qe = p->ps = p->pe = -1, p->plen = p->blen = p->mlen = 0, p->div = -1.0f;
		if (p->cnt == 0) continue;

		assert(gs->lc[p->off].cnt > 0 && gs->lc[p->off + p->cnt - 1].cnt > 0); // first and last lchains can't be empty
		q = &gs->lc[p->off];
		q_span = (int32_t)(gs->a[q->off].y>>32&0xff);
		p->qs = (int32_t)gs->a[q->off].y + 1 - q_span;
		p->ps = (int32_t)gs->a[q->off].x + 1 - q_span;
		tmp = (int32_t)(gs->a[q->off].x>>32);
		assert(p->qs >= 0 && p->ps >= 0);
		q = &gs->lc[p->off + p->cnt - 1];
		p->qe = (int32_t)gs->a[q->off + q->cnt - 1].y + 1;
		p->pe = g->seg[q->v>>1].len - (int32_t)gs->a[q->off + q->cnt - 1].x - 1; // this is temporary
		n_mini = (int32_t)(gs->a[q->off + q->cnt - 1].x>>32) - tmp + 1;
		assert(p->n_anchor > 0);

		rest_pl = 0; // this value is never used if the first lchain is not empty (which should always be true)
		last_a = &gs->a[gs->lc[p->off].off];
		for (j = 0; j < p->cnt; ++j) { // iterate over lchains
			const mg_llchain_t *q = &gs->lc[p->off + j];
			int32_t vlen = g->seg[q->v>>1].len;
			p->plen += vlen;
			for (k = 0; k < q->cnt; ++k) { // iterate over anchors
				const mg128_t *r = &gs->a[q->off + k];
				int32_t pl, ql = (int32_t)r->y - (int32_t)last_a->y;
				int32_t span = (int32_t)(r->y>>32&0xff);
				if (j == 0 && k == 0) { // the first anchor on the first lchain
					pl = ql = span;
				} else if (j > 0 && k == 0) { // the first anchor but not on the first lchain
					pl = (int32_t)r->x + 1 + rest_pl;
				} else {
					pl = (int32_t)r->x - (int32_t)last_a->x;
				}
				if (ql < 0) ql = -ql, n_mini += (int32_t)(last_a->x>>32) - (int32_t)(r->x>>32); // dealing with overlapping query at junctions
				p->blen += pl > ql? pl : ql;
				p->mlen += pl > span && ql > span? span : pl < ql? pl : ql;
				last_a = r;
			}
			if (q->cnt == 0) rest_pl += vlen;
			else rest_pl = vlen - (int32_t)gs->a[q->off + q->cnt - 1].x - 1;
		}
		p->pe = p->plen - p->pe;
		assert(p->pe >= p->ps);
		// here n_mini >= p->n_anchor should stand almost all the time
		p->div = n_mini >= p->n_anchor? log((double)n_mini / p->n_anchor) / q_span : log((double)p->n_anchor / n_mini) / q_span;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, 0x38(%rsp)
xorl %r10d, %r10d
movq %rsi, 0x30(%rsp)
movslq 0x8(%rsi), %rax
cmpq %rax, %r10
jge 0x169b7
movq 0x18(%rsi), %rbp
imulq $0x68, %r10, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, 0x28(%rbp,%rax)
movabsq $-0x4080000000000000, %rcx # imm = 0xBF80000000000000
movq %rcx, 0x30(%rbp,%rax)
movaps 0xdddd(%rip), %xmm0     # 0x244b0
movups %xmm0, 0x18(%rbp,%rax)
movl 0xc(%rbp,%rax), %ecx
testl %ecx, %ecx
je 0x169af
movq %rcx, %r11
addq %rax, %rbp
movq 0x20(%rsi), %rax
movslq 0x8(%rbp), %rcx
imulq $0x14, %rcx, %rdi
cmpl $0x0, 0x4(%rax,%rdi)
jle 0x169c6
movq %rdi, %rdx
addl %r11d, %ecx
movslq %ecx, %rcx
imulq $0x14, %rcx, %rdi
movslq -0x10(%rax,%rdi), %r9
testq %r9, %r9
jle 0x169c6
movq %rdx, %rcx
addq %rax, %rcx
movq 0x28(%rsi), %rdx
movq %rcx, 0x58(%rsp)
movslq (%rcx), %rbx
shlq $0x4, %rbx
movq 0x8(%rdx,%rbx), %r8
movq %r8, %rcx
shrq $0x20, %rcx
movzbl %cl, %r14d
subl %r14d, %r8d
leal 0x1(%r8), %ecx
movl %ecx, 0x18(%rbp)
movq (%rdx,%rbx), %rcx
movl %ecx, %r15d
subl %r14d, %r15d
incl %r15d
incl %r8d
movl %r15d, 0x24(%rbp)
js 0x169e5
testl %r15d, %r15d
js 0x169e5
movl %r15d, 0x24(%rsp)
movl %r14d, 0x1c(%rsp)
movq %r10, 0x40(%rsp)
addq %rdi, %rax
movslq -0x14(%rax), %rdi
addq %r9, %rdi
shlq $0x4, %rdi
movl -0x8(%rdx,%rdi), %esi
incl %esi
movl %esi, 0x1c(%rbp)
movq 0x38(%rsp), %rsi
movq 0x10(%rsi), %r8
movl -0xc(%rax), %eax
shrl %eax
shlq $0x6, %rax
movq -0x10(%rdx,%rdi), %rsi
movl %esi, %edi
notl %edi
movq %r8, 0x50(%rsp)
addl (%r8,%rax), %edi
movl %edi, 0x20(%rsp)
movl %edi, 0x28(%rbp)
movl 0x10(%rbp), %eax
movl %eax, 0x18(%rsp)
testl %eax, %eax
jle 0x16a04
addq %rdx, %rbx
shrq $0x20, %rcx
shrq $0x20, %rsi
subl %ecx, %esi
incl %esi
movq %rsi, 0x10(%rsp)
leaq -0x10(%rdx), %rax
movq %rax, 0x48(%rsp)
xorl %r14d, %r14d
testl %r11d, %r11d
cmovlel %r14d, %r11d
movq %r11, 0x60(%rsp)
xorl %r15d, %r15d
xorl %r9d, %r9d
xorl %esi, %esi
xorl %r10d, %r10d
cmpq 0x60(%rsp), %rsi
je 0x16952
imulq $0x14, %rsi, %rax
movq 0x58(%rsp), %rdi
leaq (%rdi,%rax), %r12
movl 0x8(%rdi,%rax), %ecx
shrl %ecx
shlq $0x6, %rcx
movq 0x50(%rsp), %r8
movl (%r8,%rcx), %ecx
movl %ecx, 0x28(%rsp)
addl %ecx, %r9d
movl %r9d, 0x2c(%rsp)
movl %r9d, 0x20(%rbp)
movslq 0x4(%rdi,%rax), %rax
movq %r10, 0x70(%rsp)
leal 0x1(%r10), %ecx
movq %rcx, 0x8(%rsp)
testl %eax, %eax
movl $0x0, %r10d
movq %rax, 0x68(%rsp)
cmovgl %eax, %r10d
xorl %ecx, %ecx
cmpl %ecx, %r10d
je 0x1691b
movslq (%r12), %rax
addq %rcx, %rax
shlq $0x4, %rax
leaq (%rdx,%rax), %r11
movq 0x8(%rdx,%rax), %r9
movq %r9, %rax
shrq $0x20, %rax
movzbl %al, %r13d
movl %ecx, %eax
orl %esi, %eax
je 0x168b3
testq %rsi, %rsi
sete %dil
testl %ecx, %ecx
setne %r8b
movq (%r11), %rax
orb %dil, %r8b
jne 0x168bb
movq 0x8(%rsp), %rdi
addl %eax, %edi
jmp 0x168c3
movl %r13d, %edi
movl %r13d, %r9d
jmp 0x168e1
movl (%rbx), %r8d
movl %eax, %edi
subl %r8d, %edi
subl 0x8(%rbx), %r9d
jns 0x168e1
negl %r9d
shrq $0x20, %rax
movq 0x10(%rsp), %r8
addl 0x4(%rbx), %r8d
subl %eax, %r8d
movq %r8, 0x10(%rsp)
cmpl %r9d, %edi
movl %r9d, %eax
cmovgl %edi, %eax
movl %r9d, %r8d
cmovll %edi, %r8d
addl %eax, %r15d
cmpl %r13d, %r9d
movl %r8d, %eax
cmoval %r13d, %eax
movl %r15d, 0x2c(%rbp)
cmpl %r13d, %edi
cmovlel %r8d, %eax
addl %eax, %r14d
movl %r14d, 0x30(%rbp)
incq %rcx
movq %r11, %rbx
jmp 0x16867
movq 0x68(%rsp), %rcx
testl %ecx, %ecx
movq 0x70(%rsp), %r10
je 0x16940
movslq (%r12), %rax
addq %rcx, %rax
shlq $0x4, %rax
movq 0x48(%rsp), %rcx
movl (%rcx,%rax), %r10d
notl %r10d
addl 0x28(%rsp), %r10d
incq %rsi
movl 0x2c(%rsp), %r9d
jmp 0x16806
subl 0x20(%rsp), %r9d
movl %r9d, 0x28(%rbp)
cmpl 0x24(%rsp), %r9d
jl 0x16a23
cvtsi2sdl 0x1c(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x10(%rsp), %rcx
movl 0x18(%rsp), %edx
cmpl %edx, %ecx
movl %edx, %eax
cmovgl %ecx, %eax
cmovll %ecx, %edx
cvtsi2sd %eax, %xmm0
cvtsi2sd %edx, %xmm1
divsd %xmm1, %xmm0
callq 0x21a0
divsd 0x8(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x34(%rbp)
movq 0x30(%rsp), %rsi
movq 0x40(%rsp), %r10
incq %r10
jmp 0x1669e
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xdcab(%rip), %rdi      # 0x24678
leaq 0xdafc(%rip), %rsi      # 0x244d0
leaq 0xdcdb(%rip), %rcx      # 0x246b6
movl $0xfe, %edx
callq 0x2160
leaq 0xdcfe(%rip), %rdi      # 0x246ea
leaq 0xdadd(%rip), %rsi      # 0x244d0
leaq 0xdcbc(%rip), %rcx      # 0x246b6
movl $0x104, %edx            # imm = 0x104
callq 0x2160
leaq 0xdcf8(%rip), %rdi      # 0x24703
leaq 0xdabe(%rip), %rsi      # 0x244d0
leaq 0xdc9d(%rip), %rcx      # 0x246b6
movl $0x109, %edx            # imm = 0x109
callq 0x2160
leaq 0xdce9(%rip), %rdi      # 0x24713
leaq 0xda9f(%rip), %rsi      # 0x244d0
leaq 0xdc7e(%rip), %rcx      # 0x246b6
movl $0x125, %edx            # imm = 0x125
callq 0x2160