// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi2/correct.c
// Function: fmc_correct1
void fmc_correct1(const fmc_opt_t *opt, fmc_hash_t **h, char **s, char **q, fmc_aux_t *a, fmc_ecstat_t *ecs)
{
	fmc_aux_t *_a = 0;
	int i;
	correct1_stat_t st[2];

	memset(ecs, 0, sizeof(fmc_ecstat_t));
	if (a == 0) a = _a = fmc_aux_init();
	kh_clear(kache, a->cache);
	fmc_seq_conv(*s, *q, opt->defQ, &a->ori);
	// forward strand
	fmc_seq_cpy_no_del(&a->seq, &a->ori);
	st[0] = fmc_correct1_aux(opt, h, a);
	fmc_seq_cpy_no_del(&a->ec_for, &a->seq);
	// reverse strand
	fmc_seq_cpy_no_del(&a->seq, &a->ori);
	fmc_seq_revcomp(&a->seq);
	st[1] = fmc_correct1_aux(opt, h, a);
	fmc_seq_revcomp(&a->seq);
	ecs->n_conflict = fmc_cns_ungap(&a->ec_for, &a->seq);
	fmc_seq_cpy_no_del(&a->seq, &a->ec_for);
	// generate final stats
	ecs->n_paths[0] = st[0].n_paths; ecs->n_failures[0] = st[0].n_failures;
	ecs->n_paths[1] = st[1].n_paths; ecs->n_failures[1] = st[1].n_failures;
	ecs->penalty = st[0].penalty + st[1].penalty;
	if (a->seq.n > a->ori.n) {
		*s = realloc(*s, a->seq.n + 1);
		*q = realloc(*q, a->seq.n + 1);
	} else if (!*q) *q = calloc(a->seq.n + 1, 1);
	ecs->n_si = kmer_cov(opt, &a->seq, h, a->cache);
	ecs->to_drop = (ecs->n_si == 0 || ecs->n_failures[0] > a->seq.n || ecs->n_failures[1] > a->seq.n);
	// write the sequence
	for (i = 0; i < a->seq.n; ++i) {
		ecbase_t *b = &a->seq.a[i];
		int qual;
		if (b->f || a->ori.a[b->i].b < 4) { // FIXME: this block is not quite right in the presence of gaps.
			if (b->b != a->ori.a[b->i].b)
				++ecs->n_diff, ecs->q_diff += a->ori.a[b->i].q;
			(*s)[i] = b->b == a->ori.a[b->i].b? "ACGTN"[b->b] : "acgtn"[b->b];
			qual = b->f? b->min_diff : b->q;
			(*q)[i] = (qual < FMC_Q_MAX_OUT? qual : FMC_Q_MAX_OUT) + 33;
		} else (*s)[i] = 'N', (*q)[i] = 33;
	}
	(*s)[i] = (*q)[i] = 0;
	if (_a) fmc_aux_destroy(_a);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x2160
cmpq $0x0, -0x28(%rbp)
jne 0xb21f
callq 0xae80
movq %rax, -0x38(%rbp)
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0xa8(%rax), %rdi
callq 0xb6f0
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x38(%rax), %edx
movq -0x28(%rbp), %rcx
callq 0x9370
movq -0x28(%rbp), %rsi
movq %rsi, %rdi
addq $0x48, %rdi
callq 0x95e0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xb770
movl %edx, -0x78(%rbp)
movq %rax, -0x80(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rsi
movq %rsi, %rdi
addq $0x60, %rdi
addq $0x48, %rsi
callq 0x95e0
movq -0x28(%rbp), %rsi
movq %rsi, %rdi
addq $0x48, %rdi
callq 0x95e0
movq -0x28(%rbp), %rdi
addq $0x48, %rdi
callq 0x9790
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xb770
movl %edx, -0x98(%rbp)
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x8c(%rbp)
movl -0x98(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x8c(%rbp), %rax
movq %rax, -0x54(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rdi
addq $0x48, %rdi
callq 0x9790
movq -0x28(%rbp), %rdi
addq $0x60, %rdi
movq -0x28(%rbp), %rsi
addq $0x48, %rsi
callq 0xafb0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x28(%rbp), %rdi
addq $0x48, %rdi
movq -0x28(%rbp), %rsi
addq $0x60, %rsi
callq 0x95e0
movl -0x5c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x58(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x50(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x4c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x60(%rbp), %ecx
addl -0x54(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
jbe 0xb3da
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rsi
addq $0x1, %rsi
callq 0x2270
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rsi
addq $0x1, %rsi
callq 0x2270
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0xb406
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xb404
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x21a0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0xb406
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x48, %rsi
movq -0x10(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0xa8(%rax), %rcx
callq 0xc870
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x30(%rbp), %rcx
movb $0x1, %al
cmpl $0x0, 0x20(%rcx)
movb %al, -0xad(%rbp)
je 0xb474
movq -0x30(%rbp), %rax
movslq 0x10(%rax), %rcx
movq -0x28(%rbp), %rdx
movb $0x1, %al
cmpq 0x48(%rdx), %rcx
movb %al, -0xad(%rbp)
ja 0xb474
movq -0x30(%rbp), %rax
movslq 0x14(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x48(%rcx), %rax
seta %al
movb %al, -0xad(%rbp)
movb -0xad(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x24(%rax)
movl $0x0, -0x3c(%rbp)
movslq -0x3c(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0xb6b4
movq -0x28(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movw (%rax), %ax
shrw $0xc, %ax
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xb4fc
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xa8(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movw (%rax), %ax
andw $0xf, %ax
movzbl %al, %eax
cmpl $0x4, %eax
jge 0xb686
movq -0xa8(%rbp), %rax
movw (%rax), %ax
andw $0xf, %ax
movzbl %al, %eax
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0xa8(%rbp), %rdx
movslq 0x8(%rdx), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movw (%rcx), %cx
andw $0xf, %cx
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0xb568
movq -0x30(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xa8(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x2(%rax), %ecx
movq -0x30(%rbp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq -0xa8(%rbp), %rax
movw (%rax), %ax
andw $0xf, %ax
movzbl %al, %eax
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0xa8(%rbp), %rdx
movslq 0x8(%rdx), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movw (%rcx), %cx
andw $0xf, %cx
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0xb5c7
movq -0xa8(%rbp), %rax
movw (%rax), %ax
andw $0xf, %ax
movzbl %al, %eax
movl %eax, %ecx
leaq 0x20de0(%rip), %rax     # 0x2c39b
movsbl (%rax,%rcx), %eax
movl %eax, -0xb4(%rbp)
jmp 0xb5eb
movq -0xa8(%rbp), %rax
movw (%rax), %ax
andw $0xf, %ax
movzbl %al, %eax
movl %eax, %ecx
leaq 0x210b3(%rip), %rax     # 0x2c694
movsbl (%rax,%rcx), %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0xa8(%rbp), %rax
movw (%rax), %ax
shrw $0xc, %ax
movzbl %al, %eax
cmpl $0x0, %eax
je 0xb62a
movq -0xa8(%rbp), %rax
movzbl 0x4(%rax), %eax
movl %eax, -0xb8(%rbp)
jmp 0xb63b
movq -0xa8(%rbp), %rax
movzbl 0x2(%rax), %eax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0xac(%rbp)
cmpl $0x21, -0xac(%rbp)
jge 0xb65e
movl -0xac(%rbp), %eax
movl %eax, -0xbc(%rbp)
jmp 0xb66b
movl $0x21, %eax
movl %eax, -0xbc(%rbp)
jmp 0xb66b
movl -0xbc(%rbp), %eax
addl $0x21, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0xb6a4
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movb $0x4e, (%rax,%rcx)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movb $0x21, (%rax,%rcx)
jmp 0xb6a6
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xb48d
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
cmpq $0x0, -0x38(%rbp)
je 0xb6e2
movq -0x38(%rbp), %rdi
callq 0xaee0
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)