// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi2/correct.c
// Function: kmer_cov
static int kmer_cov(const fmc_opt_t *opt, ecseq_t *seq, fmc_hash_t **h, kmercache_t *cache)
{
	int i, j, l, v, n_si, in_si;
	uint64_t kmer[2], kfirst[2];
	// compute the k-mer coverage for k-mers contained in the read
	kmer[0] = kmer[1] = kfirst[0] = kfirst[1] = 0;
	for (i = 0; i < seq->n; ++i) seq->a[i].cov = 0;
	for (i = l = 0; i < seq->n; ++i) {
		ecbase_t *p = &seq->a[i];
		if (p->b > 3) l = 0, kmer[0] = kmer[1] = 0;
		else ++l, append_to_kmer(opt->c.k, kmer, p->b);
		if (l >= opt->c.k && (v = kmer_lookup(opt->c.k, opt->c.suf_len, kmer, h, cache)) >= 0)
			for (j = 0; j < opt->c.k; ++j)
				++seq->a[i - j].cov;
		if (i == opt->c.k - 1)
			kfirst[0] = kmer[0], kfirst[1] = kmer[1];
	}
	/* // The following gives better k-mer coverage towards the ends of reads, but it is a bit slow and not that useful
	// extend to the 3'-end
	if (l >= opt->c.k && v >= 0) {
		for (i = 0; i < opt->c.k - 1; ++i) {
			if (v < 0 || !fmc_cell_has_b1(v) || fmc_cell_has_b2(v)) break;
			append_to_kmer(opt->c.k, kmer, fmc_cell_get_b1(v));
			v = kmer_lookup(opt->c.k, opt->c.suf_len, kmer, h, cache);
			for (j = 0; j < opt->c.k - i - 1; ++j)
				++seq->a[seq->n - 1 - j].cov;
		}
	}
	// extend to the 5'-end
	if (seq->a[0].cov > 0) {
		kmer[0] = kfirst[1], kmer[1] = kfirst[0]; // we are extending on the reverse strand
		v = kmer_lookup(opt->c.k, opt->c.suf_len, kmer, h, cache);
		for (i = 0; i < opt->c.k - 1; ++i) {
			if (v < 0 || !fmc_cell_has_b1(v) || fmc_cell_has_b2(v)) break;
			append_to_kmer(opt->c.k, kmer, fmc_cell_get_b1(v));
			v = kmer_lookup(opt->c.k, opt->c.suf_len, kmer, h, cache);
			for (j = 0; j < opt->c.k - i - 1; ++j)
				++seq->a[j].cov;
		}
	}
	*/
	// compute n_si
	for (i = 0, n_si = 0, in_si = 0; i < seq->n; ++i) {
		if (seq->a[i].cov >= opt->c.k - FMC_SI_GAP) {
			if (!in_si) ++n_si, in_si = 1;
		} else if (in_si) in_si = 0;
	}
	if (fmc_verbose >= 6) {
		fprintf(stderr, "SI ");
		for (i = 0; i < seq->n; ++i) {
			if (i) fputc(',', stderr);
			fprintf(stderr, "%d", seq->a[i].cov);
		}
		fputc('\n', stderr);
	}
	return n_si;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xc8de
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x5(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc8af
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xca4a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movw (%rax), %ax
andw $0xf, %ax
movzbl %al, %eax
cmpl $0x3, %eax
jle 0xc940
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
jmp 0xc971
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
shlq $0x30, %rax
sarq $0x30, %rax
movl %eax, %edi
leaq -0x50(%rbp), %rsi
movq -0x68(%rbp), %rax
movw (%rax), %ax
andw $0xf, %ax
movzbl %al, %edx
callq 0xdc90
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
shlq $0x30, %rcx
sarq $0x30, %rcx
cmpl %ecx, %eax
jl 0xca11
movq -0x8(%rbp), %rax
movq (%rax), %rax
shlq $0x30, %rax
sarq $0x30, %rax
movl %eax, %edi
movq -0x8(%rbp), %rax
movq (%rax), %rax
shlq $0x20, %rax
sarq $0x30, %rax
movl %eax, %esi
leaq -0x50(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xdd10
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
jl 0xca11
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
shlq $0x30, %rcx
sarq $0x30, %rcx
cmpl %ecx, %eax
jge 0xca0f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x24(%rbp), %ecx
subl -0x28(%rbp), %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb 0x5(%rax), %cl
addb $0x1, %cl
movb %cl, 0x5(%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xc9cd
jmp 0xca11
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
shlq $0x30, %rcx
sarq $0x30, %rcx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0xca3a
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0xca3c
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc8ec
movl $0x0, -0x24(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movslq -0x24(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xcacd
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x5(%rax), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
shlq $0x30, %rcx
sarq $0x30, %rcx
subl $0x3, %ecx
cmpl %ecx, %eax
jl 0xcab1
cmpl $0x0, -0x38(%rbp)
jne 0xcaaf
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl $0x1, -0x38(%rbp)
jmp 0xcac0
cmpl $0x0, -0x38(%rbp)
je 0xcabe
movl $0x0, -0x38(%rbp)
jmp 0xcac0
jmp 0xcac2
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xca5f
cmpl $0x6, 0x2670c(%rip)     # 0x331e0
jl 0xcb6e
movq 0x26517(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x200df(%rip), %rsi     # 0x2cbca
movb $0x0, %al
callq 0x21d0
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xcb5a
cmpl $0x0, -0x24(%rbp)
je 0xcb20
movq 0x264e5(%rip), %rax     # 0x32ff8
movq (%rax), %rsi
movl $0x2c, %edi
callq 0x2190
movq 0x264d1(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x5(%rax), %edx
leaq 0x1ffc6(%rip), %rsi     # 0x2cb0e
movb $0x0, %al
callq 0x21d0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xcaf9
movq 0x26497(%rip), %rax     # 0x32ff8
movq (%rax), %rsi
movl $0xa, %edi
callq 0x2190
movl -0x34(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)