// File: /workspace/github_c_makefile_star2_O1/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, 0x40(%rsp)
cmpl $0x0, 0x8(%rsi)
jle 0x19db8
movq %rsi, %rbx
xorl %r14d, %r14d
movq %rsi, 0x38(%rsp)
movq 0x18(%rbx), %r15
imulq $0x68, %r14, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, 0x28(%r15,%rax)
movq $-0x1, 0x18(%r15,%rax)
movabsq $-0x4080000000000000, %rcx # imm = 0xBF80000000000000
movq %rcx, 0x30(%r15,%rax)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movq %rcx, 0x20(%r15,%rax)
movl 0xc(%r15,%rax), %ecx
movq %rcx, 0x10(%rsp)
testq %rcx, %rcx
je 0x19da8
addq %rax, %r15
movq 0x20(%rbx), %rcx
movslq 0x8(%r15), %rdx
leaq (%rdx,%rdx,4), %rax
cmpl $0x0, 0x4(%rcx,%rax,4)
jle 0x19dc7
movslq 0x10(%rsp), %rsi
addq %rsi, %rdx
leaq (%rdx,%rdx,4), %rdi
movslq -0x10(%rcx,%rdi,4), %rsi
testq %rsi, %rsi
jle 0x19dc7
leaq (%rcx,%rax,4), %rax
movq 0x28(%rbx), %r10
movq %rax, 0x68(%rsp)
movslq (%rax), %rdx
shlq $0x4, %rdx
movq 0x8(%r10,%rdx), %r8
movq %r8, %rax
shrq $0x20, %rax
movzbl %al, %r9d
subl %r9d, %r8d
leal 0x1(%r8), %eax
movl %eax, 0x18(%r15)
movq %r10, 0x8(%rsp)
movq (%r10,%rdx), %rax
movl %eax, %r10d
movl %r9d, 0x30(%rsp)
subl %r9d, %r10d
incl %r10d
incl %r8d
movl %r10d, 0x24(%r15)
js 0x19e05
movl %r10d, %r8d
testl %r10d, %r10d
js 0x19e05
movl %r8d, 0x2c(%rsp)
leaq (%rcx,%rdi,4), %rcx
movslq -0x14(%rcx), %rdi
addq %rsi, %rdi
shlq $0x4, %rdi
movq 0x8(%rsp), %r8
movl -0x8(%r8,%rdi), %esi
incl %esi
movl %esi, 0x1c(%r15)
movq 0x40(%rsp), %rsi
movq 0x10(%rsi), %r9
movl -0xc(%rcx), %ecx
shrl %ecx
shlq $0x6, %rcx
movq -0x10(%r8,%rdi), %r8
movl %r8d, %esi
notl %esi
movq %r9, 0x60(%rsp)
addl (%r9,%rcx), %esi
movl %esi, 0x28(%rsp)
movl %esi, 0x28(%r15)
movl 0x10(%r15), %ecx
testl %ecx, %ecx
jle 0x19de6
shrq $0x20, %rax
shrq $0x20, %r8
subl %eax, %r8d
incl %r8d
cmpl $0x0, 0x10(%rsp)
jle 0x19d55
movl %ecx, 0x24(%rsp)
movq %r14, 0x48(%rsp)
movq 0x8(%rsp), %rax
addq %rax, %rdx
addq $-0x10, %rax
movq %rax, 0x50(%rsp)
movl 0x20(%r15), %edi
xorl %ebx, %ebx
xorl %ecx, %ecx
movq %r15, 0x58(%rsp)
leaq (%rbx,%rbx,4), %rax
movq 0x68(%rsp), %rsi
leaq (%rsi,%rax,4), %r9
movl 0x8(%r9), %eax
shrl %eax
shlq $0x6, %rax
movq 0x60(%rsp), %rsi
movl (%rsi,%rax), %esi
movslq 0x4(%r9), %r14
testq %r14, %r14
jle 0x19d18
movl %esi, 0x34(%rsp)
movl %edi, 0x18(%rsp)
movq %r9, 0x70(%rsp)
movslq (%r9), %r11
leal 0x1(%rcx), %esi
movl 0x2c(%r15), %r10d
movl 0x30(%r15), %edi
shlq $0x4, %r11
addq 0x8(%rsp), %r11
xorl %eax, %eax
movq %r11, %r13
movq 0x8(%r11), %r9
movq %r9, %r11
shrq $0x20, %r11
movzbl %r11b, %r15d
movl %eax, %r11d
orl %ebx, %r11d
movl %r15d, %r12d
movl %r15d, %r11d
je 0x19cad
movl %r9d, %r11d
movl (%r13), %r12d
subl 0x8(%rdx), %r11d
testq %rbx, %rbx
sete %r9b
testq %rax, %rax
setne %bpl
orb %r9b, %bpl
jne 0x19caa
addl %esi, %r12d
jmp 0x19cad
subl (%rdx), %r12d
testl %r11d, %r11d
jns 0x19cbd
negl %r11d
addl 0x4(%rdx), %r8d
subl 0x4(%r13), %r8d
cmpl %r11d, %r12d
movl %r11d, %edx
cmovgl %r12d, %edx
movl %r11d, %r9d
cmovll %r12d, %r9d
addl %edx, %r10d
cmpl %r15d, %r11d
movl %r9d, %edx
cmovgl %r15d, %edx
cmpl %r15d, %r12d
cmovlel %r9d, %edx
addl %edx, %edi
incq %rax
leaq 0x10(%r13), %r11
movq %r13, %rdx
cmpq %rax, %r14
jne 0x19c67
movq 0x58(%rsp), %r15
movl %r10d, 0x2c(%r15)
movl %edi, 0x30(%r15)
addq $-0x10, %r11
movq %r11, %rdx
movl 0x18(%rsp), %edi
movl 0x34(%rsp), %esi
movq 0x70(%rsp), %r9
testl %r14d, %r14d
je 0x19d31
movslq (%r9), %rax
addq %r14, %rax
shlq $0x4, %rax
movq 0x50(%rsp), %rcx
movl (%rcx,%rax), %ecx
notl %ecx
addl %esi, %edi
addl %esi, %ecx
incq %rbx
cmpq 0x10(%rsp), %rbx
jne 0x19c15
movl %edi, 0x20(%r15)
movq 0x38(%rsp), %rbx
movq 0x48(%rsp), %r14
movl 0x24(%rsp), %ecx
movl 0x20(%r15), %eax
subl 0x28(%rsp), %eax
movl %eax, 0x28(%r15)
cmpl 0x2c(%rsp), %eax
jl 0x19e24
cvtsi2sdl 0x30(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
cmpl %ecx, %r8d
movl %ecx, %eax
cmovgl %r8d, %eax
cmovll %r8d, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
callq 0x21a0
divsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x34(%r15)
incq %r14
movslq 0x8(%rbx), %rax
cmpq %rax, %r14
jl 0x19a99
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf822(%rip), %rdi      # 0x295f0
leaq 0xf673(%rip), %rsi      # 0x29448
leaq 0xf852(%rip), %rcx      # 0x2962e
movl $0xfe, %edx
callq 0x2160
leaq 0xf88e(%rip), %rdi      # 0x2967b
leaq 0xf654(%rip), %rsi      # 0x29448
leaq 0xf833(%rip), %rcx      # 0x2962e
movl $0x109, %edx            # imm = 0x109
callq 0x2160
leaq 0xf856(%rip), %rdi      # 0x29662
leaq 0xf635(%rip), %rsi      # 0x29448
leaq 0xf814(%rip), %rcx      # 0x2962e
movl $0x104, %edx            # imm = 0x104
callq 0x2160
leaq 0xf860(%rip), %rdi      # 0x2968b
leaq 0xf616(%rip), %rsi      # 0x29448
leaq 0xf7f5(%rip), %rcx      # 0x2962e
movl $0x125, %edx            # imm = 0x125
callq 0x2160