// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/bfc.c
// Function: bfc_ec1
ecstat_t bfc_ec1(bfc_ec1buf_t *e, char *seq, char *qual)
{
	int i, start = 0, end = 0, n_n = 0, rv[2], max_heap[2];
	uint64_t r;
	ecstat_t s;

	s.ec_code = ECCODE_MISC, s.brute = 0, s.n_ec = s.n_ec_high = 0, s.n_absent = s.max_heap = 0;
	bfc_seq_conv(seq, qual, e->opt->q, &e->seq);
	for (i = 0; i < e->seq.n; ++i)
		if (e->seq.a[i].ob > 3) ++n_n;
	if (n_n > e->seq.n * .05) {
		s.ec_code = ECCODE_MANY_N;
		return s;
	}
	bfc_ec_kcov(e->opt->k, e->opt->min_cov, &e->seq, e->ch);
	r = bfc_ec_best_island(e->opt->k, &e->seq);
	if (r == 0) { // no solid k-mer
		bfc_kmer_t x;
		int ec = -1;
		while ((end = bfc_ec_first_kmer(e->opt->k, &e->seq, start, &x)) < e->seq.n) {
			ec = bfc_ec_greedy_k(e->opt->k, e->mode, &x, e->ch);
			if (ec >= 0) break;
			if (end + (e->opt->k>>1) >= e->seq.n) break;
			start = end - (e->opt->k>>1);
		}
		if (ec >= 0) {
			e->seq.a[end - (ec>>2)].b = ec&3;
			++end; start = end - e->opt->k;
			s.brute = 1;
		} else {
			s.ec_code = ECCODE_NO_SOLID;
			return s;
		}
	} else start = r>>32, end = (uint32_t)r;
	if ((rv[0] = bfc_ec1dir(e, &e->seq, &e->ec[0], start, e->seq.n, &max_heap[0])) < 0) {
		s.ec_code = rv[0] == -2? ECCODE_UNCORR_N : rv[0] == -3? ECCODE_MANY_FAIL : ECCODE_MISC;
		return s;
	}
	bfc_seq_revcomp(&e->seq);
	if ((rv[1] = bfc_ec1dir(e, &e->seq, &e->ec[1], e->seq.n - end, e->seq.n, &max_heap[1])) < 0) {
		s.ec_code = rv[1] == -2? ECCODE_UNCORR_N : rv[1] == -3? ECCODE_MANY_FAIL : ECCODE_MISC;
		return s;
	}
	s.max_heap = max_heap[0] > max_heap[1]? max_heap[0] : max_heap[1];
	s.ec_code = 0, s.n_absent = rv[0] + rv[1];
	bfc_seq_revcomp(&e->ec[1]);
	bfc_seq_revcomp(&e->seq);
	for (i = 0; i < e->seq.n; ++i) {
		ecbase_t *c = &e->seq.a[i];
		if (e->ec[0].a[i].b == e->ec[1].a[i].b)
			c->b = e->ec[0].a[i].b > 3? e->seq.a[i].b : e->ec[0].a[i].b;
		else if (e->ec[1].a[i].b > 3) c->b = e->ec[0].a[i].b;
		else if (e->ec[0].a[i].b > 3) c->b = e->ec[1].a[i].b;
		else c->b = e->seq.a[i].ob;
	}
	for (i = 0; i < e->seq.n; ++i) {
		int is_diff = !(e->seq.a[i].b == e->seq.a[i].ob);
		if (is_diff) {
			++s.n_ec;
			if (e->seq.a[i].q) ++s.n_ec_high;
		}
		seq[i] = (is_diff? "acgtn" : "ACGTN")[e->seq.a[i].b];
		if (qual) qual[i] = is_diff? 34 + e->seq.a[i].ob : "+?"[e->seq.a[i].q];
	}
	return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rax
andq $-0x8, %rax
orq $0x1, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
andq $-0x9, %rax
orq $0x0, %rax
movq %rax, -0x8(%rbp)
movabsq $-0xfffc0001, %rax      # imm = 0xFFFFFFFF0003FFFF
andq -0x8(%rbp), %rax
orq $0x0, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
andq $-0x3fff1, %rax         # imm = 0xFFFC000F
orq $0x0, %rax
movq %rax, -0x8(%rbp)
movabsq $0xffffffffffffff, %rax # imm = 0xFFFFFFFFFFFFFF
andq -0x8(%rbp), %rax
orq $0x0, %rax
movq %rax, -0x8(%rbp)
movabsq $-0xffffff00000001, %rax # imm = 0xFF000000FFFFFFFF
andq -0x8(%rbp), %rax
orq $0x0, %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rcx
addq $0x40, %rcx
callq 0x7600
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jae 0x6f36
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
shrb $0x4, %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x3, %eax
jle 0x6f29
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6f2b
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x6ef6
cvtsi2sdl -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x40(%rax), %xmm1
movaps 0x1e3e5(%rip), %xmm2    # 0x25330
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x1e3e9(%rip), %xmm2    # 0x25340
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movsd 0x1e492(%rip), %xmm2    # 0x25400
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x6f8d
movq -0x8(%rbp), %rax
andq $-0x8, %rax
orq $0x2, %rax
movq %rax, -0x8(%rbp)
jmp 0x75ef
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %edi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x10(%rax), %esi
movq -0x10(%rbp), %rdx
addq $0x40, %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
callq 0x5620
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %edi
movq -0x10(%rbp), %rsi
addq $0x40, %rsi
callq 0x5890
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x70ef
movl $0xffffffff, -0x6c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %edi
movq -0x10(%rbp), %rsi
addq $0x40, %rsi
movl -0x28(%rbp), %edx
leaq -0x68(%rbp), %rcx
callq 0x5440
movl %eax, -0x2c(%rbp)
cltq
movq -0x10(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jae 0x7078
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %edi
movq -0x10(%rbp), %rax
movl 0xa0(%rax), %esi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
leaq -0x68(%rbp), %rdx
callq 0x51c0
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jl 0x7040
jmp 0x7078
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movl 0x8(%rcx), %ecx
sarl %ecx
addl %ecx, %eax
cltq
movq -0x10(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jb 0x705f
jmp 0x7078
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movl 0x8(%rcx), %ecx
sarl %ecx
subl %ecx, %eax
movl %eax, -0x28(%rbp)
jmp 0x6fe3
cmpl $0x0, -0x6c(%rbp)
jl 0x70d8
movl -0x6c(%rbp), %eax
andl $0x3, %eax
movb %al, %sil
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl -0x2c(%rbp), %ecx
movl -0x6c(%rbp), %edx
sarl $0x2, %edx
subl %edx, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx,8), %dl
andb $0x7, %sil
andb $-0x8, %dl
orb %sil, %dl
movb %dl, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
subl 0x8(%rcx), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
andq $-0x9, %rax
orq $0x8, %rax
movq %rax, -0x8(%rbp)
jmp 0x70ed
movq -0x8(%rbp), %rax
andq $-0x8, %rax
orq $0x3, %rax
movq %rax, -0x8(%rbp)
jmp 0x75ef
jmp 0x7101
movq -0x48(%rbp), %rax
shrq $0x20, %rax
movl %eax, -0x28(%rbp)
movq -0x48(%rbp), %rax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x40, %rsi
movq -0x10(%rbp), %rdx
addq $0x70, %rdx
movl -0x28(%rbp), %ecx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl %eax, %r8d
leaq -0x40(%rbp), %r9
callq 0x7830
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
jge 0x7179
cmpl $-0x2, -0x38(%rbp)
jne 0x7144
movl $0x4, %eax
movl %eax, -0x80(%rbp)
jmp 0x715a
movl -0x38(%rbp), %edx
movl $0x1, %eax
movl $0x5, %ecx
cmpl $-0x3, %edx
cmovel %ecx, %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
andq $0x7, %rcx
andq $-0x8, %rax
orq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x75ef
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
callq 0x8740
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x40, %rsi
movq -0x10(%rbp), %rdx
addq $0x70, %rdx
addq $0x18, %rdx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x2c(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl %eax, %r8d
leaq -0x40(%rbp), %r9
addq $0x4, %r9
callq 0x7830
movl %eax, -0x34(%rbp)
cmpl $0x0, %eax
jge 0x721d
cmpl $-0x2, -0x34(%rbp)
jne 0x71e2
movl $0x4, %eax
movl %eax, -0x84(%rbp)
jmp 0x71fb
movl -0x34(%rbp), %edx
movl $0x1, %eax
movl $0x5, %ecx
cmpl $-0x3, %edx
cmovel %ecx, %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
andq $0x7, %rcx
andq $-0x8, %rax
orq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x75ef
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jle 0x7230
movl -0x40(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x7239
movl -0x3c(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
andq $0xff, %rcx
shlq $0x38, %rcx
movabsq $0xffffffffffffff, %rdx # imm = 0xFFFFFFFFFFFFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
andq $-0x8, %rax
orq $0x0, %rax
movq %rax, -0x8(%rbp)
movl -0x38(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
andq $0xffffff, %rcx         # imm = 0xFFFFFF
shlq $0x20, %rcx
movabsq $-0xffffff00000001, %rdx # imm = 0xFF000000FFFFFFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x70, %rdi
addq $0x18, %rdi
callq 0x8740
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
callq 0x8740
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jae 0x7455
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
andb $0x7, %al
movzbl %al, %eax
movq -0x10(%rbp), %rcx
movq 0x98(%rcx), %rcx
movslq -0x24(%rbp), %rdx
movb (%rcx,%rdx,8), %cl
andb $0x7, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x7396
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x3, %eax
jle 0x735c
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
andb $0x7, %al
movzbl %al, %eax
movl %eax, -0x8c(%rbp)
jmp 0x7379
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
andb $0x7, %al
movzbl %al, %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movb %al, %dl
movq -0x78(%rbp), %rax
movb (%rax), %cl
andb $0x7, %dl
andb $-0x8, %cl
orb %dl, %cl
movb %cl, (%rax)
jmp 0x7445
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x3, %eax
jle 0x73d9
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %dl
andb $0x7, %dl
movq -0x78(%rbp), %rax
movb (%rax), %cl
andb $0x7, %dl
andb $-0x8, %cl
orb %dl, %cl
movb %cl, (%rax)
jmp 0x7443
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x3, %eax
jle 0x741c
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %dl
andb $0x7, %dl
movq -0x78(%rbp), %rax
movb (%rax), %cl
andb $0x7, %dl
andb $-0x8, %cl
orb %dl, %cl
movb %cl, (%rax)
jmp 0x7441
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %dl
shrb $0x4, %dl
andb $0x7, %dl
movq -0x78(%rbp), %rax
movb (%rax), %cl
andb $0x7, %dl
andb $-0x8, %cl
orb %dl, %cl
movb %cl, (%rax)
jmp 0x7443
jmp 0x7445
jmp 0x7447
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x72c8
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jae 0x75ed
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
andb $0x7, %al
movzbl %al, %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movslq -0x24(%rbp), %rdx
movb (%rcx,%rdx,8), %cl
shrb $0x4, %cl
andb $0x7, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
sete %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
je 0x7536
movq -0x8(%rbp), %rax
shrq $0x4, %rax
andq $0x3fff, %rax           # imm = 0x3FFF
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
andq $0x3fff, %rcx           # imm = 0x3FFF
shlq $0x4, %rcx
andq $-0x3fff1, %rax         # imm = 0xFFFC000F
orq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
shrb $0x3, %al
andb $0x1, %al
cmpb $0x0, %al
je 0x7534
movq -0x8(%rbp), %rax
shrq $0x12, %rax
andq $0x3fff, %rax           # imm = 0x3FFF
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
andq $0x3fff, %rcx           # imm = 0x3FFF
shlq $0x12, %rcx
movabsq $-0xfffc0001, %rdx      # imm = 0xFFFFFFFF0003FFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x7536
movl -0x7c(%rbp), %edx
leaq 0x1de11(%rip), %rax     # 0x25351
leaq 0x1dec9(%rip), %rcx     # 0x25410
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movslq -0x24(%rbp), %rdx
movb (%rcx,%rdx,8), %cl
andb $0x7, %cl
movzbl %cl, %ecx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
cmpq $0x0, -0x20(%rbp)
je 0x75dd
cmpl $0x0, -0x7c(%rbp)
je 0x75a0
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
shrb $0x4, %al
andb $0x7, %al
movzbl %al, %eax
addl $0x22, %eax
movl %eax, -0x90(%rbp)
jmp 0x75ca
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx,8), %al
shrb $0x3, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, %ecx
leaq 0x1de56(%rip), %rax     # 0x25416
movsbl (%rax,%rcx), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x75df
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x745c
jmp 0x75ef
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)