// File: /workspace/github_c_makefile_star2_O2/lh3[P]fermi2/correct.c
// Function: fmc_correct
void fmc_correct(const fmc_opt_t *opt, fmc_hash_t **h, int n, char **s, char **q, char **name, char **last_name, int64_t *last_id)
{
	for_correct_t f;
	int i, j;
	double tr, tc;
	char *la = *last_name;
	int64_t li = *last_id;

	if (n <= 0) return;
	tr = realtime(), tc = cputime();
	f.a = calloc(opt->n_threads, sizeof(void*));
	f.opt = opt, f.h = h, f.name = name, f.s = s, f.q = q;
	f.ecs = calloc(n, sizeof(fmc_ecstat_t));
	for (i = 0; i < opt->n_threads; ++i)
		f.a[i] = fmc_aux_init();
	if (opt->n_threads == 1) {
		for (i = 0; i < n; ++i)
			correct_func(&f, i, 0);
	} else kt_for(opt->n_threads, correct_func, &f, n);
	for (i = 0; i < n; ++i) {
		fmc_ecstat_t *s = &f.ecs[i];
		int is_same = 0; // whether the current read in the same template as the last one
		int64_t id;
		char *ni = f.name[i];
		if (la) {
			for (j = 0; la[j] && ni[j] && la[j] == ni[j]; ++j);
			if ((la[j] == 0 && ni[j] == 0) || (j > 0 && isdigit(la[j]) && isdigit(ni[j]) && la[j-1] == '/' && la[j+1] == 0 && ni[j+1] == 0))
				is_same = 1;
		}
		id = is_same? li : li + 1;
		la = ni, li = id;
		if (opt->drop_reads && s->to_drop) continue;
		if (opt->show_ori_name) printf("@%s", ni);
		else printf("@%ld", (long)id);
		printf(" ec:Z:%d_%d_%d_%d_%d:%d_%d:%d\n", s->n_si, s->n_diff, s->q_diff, s->n_conflict, s->n_paths[0], s->n_paths[1], s->n_failures[0], s->n_failures[1]);
		puts(f.s[i]); putchar('+'); putchar('\n');
		puts(f.q[i]);
	}
	free(*last_name);
	*last_name = strdup(la); *last_id = li;
	for (i = 0; i < opt->n_threads; ++i)
		fmc_aux_destroy(f.a[i]);
	free(f.a); free(f.ecs);
	fprintf(stderr, "[M::%s] corrected %d reads in %.3f sec (%.3f CPU sec)\n", __func__, n, realtime() - tr, cputime() - tc);
}

// Assembly:
testl %edx, %edx
jg 0x896c
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r12
movq %rdi, %r15
movq 0xb8(%rsp), %rax
movq %rcx, (%rsp)
movq 0xb0(%rsp), %rcx
movq (%rcx), %rbp
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movl %edx, %r14d
movq %r8, 0x10(%rsp)
movq %r9, 0x8(%rsp)
callq 0x3b71
movsd %xmm0, 0x20(%rsp)
callq 0x3b2e
movsd %xmm0, 0x28(%rsp)
movl 0x30(%r15), %ebx
movslq %ebx, %rdi
pushq $0x8
popq %rsi
callq 0x2190
movq %rax, %r13
movq %rax, 0x68(%rsp)
movq %r15, 0x38(%rsp)
movq %r12, 0x40(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq (%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x58(%rsp)
movl %r14d, 0x8(%rsp)
movl %r14d, %edi
pushq $0x28
popq %rsi
movq %rdi, (%rsp)
callq 0x2190
movq %rax, 0x60(%rsp)
xorl %r14d, %r14d
movslq %ebx, %rax
cmpq %rax, %r14
jge 0x8a37
callq 0x7752
movq %rax, (%r13,%r14,8)
incq %r14
movl 0x30(%r15), %ebx
jmp 0x8a1c
cmpl $0x1, %ebx
jne 0x8a5b
xorl %ebx, %ebx
leaq 0x38(%rsp), %r13
cmpq %rbx, (%rsp)
je 0x8a72
movq %r13, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x8ca9
incq %rbx
jmp 0x8a43
leaq 0x247(%rip), %rsi       # 0x8ca9
leaq 0x38(%rsp), %rdx
movl %ebx, %edi
movq (%rsp), %rcx
callq 0x247c
pushq $0x1
popq %rdx
xorl %edi, %edi
movq 0x18(%rsp), %rsi
movq %r15, 0x30(%rsp)
cmpq (%rsp), %rdi
je 0x8bfa
imulq $0x28, %rdi, %r12
addq 0x60(%rsp), %r12
movq 0x48(%rsp), %rax
movq (%rax,%rdi,8), %r13
movq %rdx, %rax
testq %rbp, %rbp
je 0x8b33
xorl %r15d, %r15d
movsbq (%rbp,%r15), %rbx
movsbq (%r13,%r15), %r14
testq %rbx, %rbx
je 0x8ac7
cmpb %r14b, %bl
jne 0x8ace
incq %r15
jmp 0x8aac
testb %r14b, %r14b
je 0x8b31
xorl %ebx, %ebx
movq %rdx, %rax
testl %r15d, %r15d
je 0x8b33
movq %rsi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
callq 0x2360
movq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
movq 0x18(%rsp), %rsi
movq (%rax), %rcx
testb $0x8, 0x1(%rcx,%rbx,2)
movq %rdx, %rax
je 0x8b33
testb $0x8, 0x1(%rcx,%r14,2)
movq %rdx, %rax
je 0x8b33
leal -0x1(%r15), %eax
cmpb $0x2f, (%rbp,%rax)
movq %rdx, %rax
jne 0x8b33
incl %r15d
cmpb $0x0, (%rbp,%r15)
movq %rdx, %rax
jne 0x8b33
cmpb $0x0, (%r13,%r15)
movq %rdx, %rax
jne 0x8b33
xorl %eax, %eax
addq %rax, %rsi
movq 0x30(%rsp), %r15
cmpl $0x0, 0x4c(%r15)
je 0x8b4e
cmpl $0x0, 0x24(%r12)
jne 0x8bef
movq %rdi, %rbp
cmpl $0x0, 0x44(%r15)
je 0x8b67
movq %rsi, %r14
leaq 0x10c58(%rip), %rdi     # 0x197ba
movq %r13, %rsi
jmp 0x8b71
leaq 0x10c50(%rip), %rdi     # 0x197be
movq %rsi, %r14
xorl %eax, %eax
callq 0x2100
movl 0x20(%r12), %esi
movl (%r12), %edx
movl 0x4(%r12), %ecx
movl 0x1c(%r12), %r8d
movl 0x8(%r12), %r9d
movl 0xc(%r12), %r10d
movl 0x10(%r12), %r11d
movl 0x14(%r12), %ebx
subq $0x8, %rsp
leaq 0x10c19(%rip), %rdi     # 0x197c3
xorl %eax, %eax
pushq %rbx
pushq %r11
pushq %r10
callq 0x2100
addq $0x20, %rsp
movq 0x50(%rsp), %rax
movq (%rax,%rbp,8), %rdi
callq 0x2080
pushq $0x2b
popq %rdi
callq 0x2050
pushq $0xa
popq %rdi
callq 0x2050
movq 0x58(%rsp), %rax
movq (%rax,%rbp,8), %rdi
callq 0x2080
movq %rbp, %rdi
movq %r14, %rsi
pushq $0x1
popq %rdx
incq %rdi
movq %r13, %rbp
jmp 0x8a81
movq 0xb0(%rsp), %rbx
movq (%rbx), %rdi
movq %rsi, %r14
callq 0x2040
movq %rbp, %rdi
callq 0x2340
movq %rax, (%rbx)
movq 0xb8(%rsp), %rax
movq %r14, (%rax)
xorl %ebx, %ebx
movslq 0x30(%r15), %rax
movq 0x68(%rsp), %rdi
cmpq %rax, %rbx
jge 0x8c41
movq (%rdi,%rbx,8), %rdi
callq 0x7786
incq %rbx
jmp 0x8c25
callq 0x2040
movq 0x60(%rsp), %rdi
callq 0x2040
movq 0x193a1(%rip), %rax     # 0x21ff8
movq (%rax), %rbx
callq 0x3b71
subsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rsp)
callq 0x3b2e
movapd %xmm0, %xmm1
subsd 0x28(%rsp), %xmm1
leaq 0x10b62(%rip), %rsi     # 0x197e2
leaq 0x10b92(%rip), %rdx     # 0x19819
movq %rbx, %rdi
movl 0x8(%rsp), %ecx
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x21c0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq