// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/unitig.c
// Function: unitig_unidir
static int unitig_unidir(aux_t *a, kstring_t *s, kstring_t *cov, int beg0, uint64_t k0, uint64_t *end, int *is_loop)
{
	int i, beg = beg0, rbeg, ori_l = s->l, n_reads = 0;
	*is_loop = 0;
	while ((rbeg = try_right(a, beg, s)) >= 0) { // loop if there is at least one overlap
		uint64_t k;
		if (a->nei.n > 1) { // forward bifurcation
			set_bit(a->bend, *end);
			break;
		}
		if ((k = a->nei.a[0].x[0]) == *end) break; // a loop like b>>c>>a><a; keep the link but stop extension
		if (((a->bend[k>>6]>>(k&0x3f)&1) || check_left(a, beg, rbeg, s) < 0)) { // backward bifurcation
			set_bit(a->bend, k);
			break;
		}
		if (k == k0) { // a loop like a>>b>>c>>a
			*is_loop = 1;
			break;
		}
		if (a->nei.a[0].x[1] == *end) { // a loop like b>>c>>a>>a; cut the last link
			a->nei.n = 0;
			break;
		}
		if ((int)a->nei.a[0].info < a->min_merge_len) break; // the overlap is not long enough
		*end = a->nei.a[0].x[1];
		set_bits(a->used, &a->nei.a[0]); // successful extension
		++n_reads;
		if (cov->m < s->m) ks_resize(cov, s->m);
		cov->l = s->l; cov->s[cov->l] = 0;
		for (i = rbeg; i < ori_l; ++i) // update the coverage string
			if (cov->s[i] != '~') ++cov->s[i];
		for (i = ori_l; i < s->l; ++i) cov->s[i] = '"';
		beg = rbeg; ori_l = s->l; a->a[0].n = a->a[1].n = 0; // prepare for the next round of loop
	}
	cov->l = s->l = ori_l; s->s[ori_l] = cov->s[ori_l] = 0;
	return n_reads;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x11ee0
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
jl 0x11d86
movq -0x8(%rbp), %rax
cmpq $0x1, 0x40(%rax)
jbe 0x11ba4
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rsi
callq 0x11630
jmp 0x11d86
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x11bc1
jmp 0x11d86
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x50(%rbp), %rcx
shrq $0x6, %rcx
movq (%rax,%rcx,8), %rax
movq -0x50(%rbp), %rcx
andq $0x3f, %rcx
shrq %cl, %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0x11c02
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movq -0x10(%rbp), %rcx
callq 0x11f50
cmpl $0x0, %eax
jge 0x11c18
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x11630
jmp 0x11d86
movq -0x50(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x11c31
movq 0x10(%rbp), %rax
movl $0x1, (%rax)
jmp 0x11d86
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x11c57
movq -0x8(%rbp), %rax
movq $0x0, 0x40(%rax)
jmp 0x11d86
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x11c71
jmp 0x11d86
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rsi
callq 0x10c40
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x11cc5
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x11a30
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
movl -0x3c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x11d2b
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7e, %eax
je 0x11d1e
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movb (%rax,%rcx), %dl
addb $0x1, %dl
movb %dl, (%rax,%rcx)
jmp 0x11d20
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x11cec
movl -0x40(%rbp), %eax
movl %eax, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x11d59
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movb $0x22, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x11d31
movl -0x3c(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x10(%rax)
jmp 0x11b64
movslq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x44(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)