// File: /workspace/github_c_makefile_star2_O1/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 0x9ed3
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, %r13
movq %rsi, %r12
movq %rdi, %r15
movq 0xb8(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq (%rcx), %rbp
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movl %edx, %r14d
movq %r8, 0x18(%rsp)
movq %r9, 0x8(%rsp)
callq 0x515a
movsd %xmm0, 0x68(%rsp)
callq 0x5117
movsd %xmm0, 0x70(%rsp)
movslq 0x30(%r15), %rbx
movl $0x8, %esi
movq %rbx, %rdi
callq 0x2190
movq %rax, 0x58(%rsp)
movq %r15, 0x28(%rsp)
movq %r12, 0x30(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %r13, 0x40(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x48(%rsp)
movl %r14d, 0x4(%rsp)
movl %r14d, %r12d
movl $0x28, %esi
movq %r12, %rdi
callq 0x2190
movq %rax, 0x50(%rsp)
testq %rbx, %rbx
jle 0x9fbc
xorl %r14d, %r14d
movl $0x1, %edi
movl $0xb0, %esi
callq 0x2190
movq %rax, %r13
movl $0x1, %edi
movl $0x28, %esi
callq 0x2190
movq %rax, 0xa8(%r13)
movq 0x58(%rsp), %rax
movq %r13, (%rax,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x9f83
cmpl $0x1, %ebx
jne 0x9ff0
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %r14d
cmovgel %eax, %r14d
xorl %ebx, %ebx
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xa29c
incq %rbx
cmpq %rbx, %r14
jne 0x9fd9
jmp 0xa006
leaq 0x2a5(%rip), %rsi       # 0xa29c
leaq 0x28(%rsp), %rdx
movl %ebx, %edi
movq %r12, %rcx
callq 0x360c
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movq %rcx, 0x18(%rsp)
xorl %r13d, %r13d
movq 0x10(%rsp), %rcx
movq %r15, 0x20(%rsp)
leaq (,%r13,4), %r12
addq %r13, %r12
shlq $0x3, %r12
addq 0x50(%rsp), %r12
movq 0x38(%rsp), %rax
movq (%rax,%r13,8), %rsi
movl $0x1, %edx
testq %rbp, %rbp
je 0xa10d
movb (%rbp), %r15b
testb %r15b, %r15b
sete %al
je 0xa088
cmpb (%rsi), %r15b
jne 0xa08f
movl $0x1, %r14d
movb (%rbp,%r14), %r15b
testb %r15b, %r15b
sete %al
je 0xa09a
leaq 0x1(%r14), %rbx
cmpb (%rsi,%r14), %r15b
movq %rbx, %r14
je 0xa069
decq %rbx
jmp 0xa091
xorl %ebx, %ebx
xorl %r14d, %r14d
jmp 0xa09d
xorl %ebx, %ebx
movq %rbx, %r14
testb %al, %al
jne 0xa09d
jmp 0xa0a4
movl %r14d, %ebx
cmpb $0x0, (%rsi,%r14)
je 0xa10b
testl %ebx, %ebx
je 0xa10d
movq %rsi, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
callq 0x2360
movq (%rax), %rax
movsbq %r15b, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0xa0d6
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rsi
movl $0x1, %edx
jmp 0xa10d
movq 0x8(%rsp), %rsi
movsbq (%rsi,%r14), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
movq 0x10(%rsp), %rcx
movl $0x1, %edx
je 0xa10d
leal -0x1(%rbx), %eax
cmpb $0x2f, (%rbp,%rax)
jne 0xa10d
movl %ebx, %eax
cmpb $0x0, 0x1(%rax,%rbp)
jne 0xa10d
cmpb $0x0, 0x1(%rsi,%rax)
jne 0xa10d
xorl %edx, %edx
addq %rdx, %rcx
movq 0x20(%rsp), %r15
cmpl $0x0, 0x4c(%r15)
je 0xa128
cmpl $0x0, 0x24(%r12)
jne 0xa1cd
cmpl $0x0, 0x44(%r15)
je 0xa13e
movq %rcx, %r14
leaq 0x125b9(%rip), %rdi     # 0x1c6f2
movq %rsi, %rbp
jmp 0xa14e
movq %rsi, %rbp
leaq 0x125ae(%rip), %rdi     # 0x1c6f6
movq %rcx, %r14
movq %rcx, %rsi
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 0x12574(%rip), %rdi     # 0x1c6fb
xorl %eax, %eax
pushq %rbx
pushq %r11
pushq %r10
callq 0x2100
addq $0x20, %rsp
movq 0x40(%rsp), %rax
movq (%rax,%r13,8), %rdi
callq 0x2080
movl $0x2b, %edi
callq 0x2050
movl $0xa, %edi
callq 0x2050
movq 0x48(%rsp), %rax
movq (%rax,%r13,8), %rdi
callq 0x2080
movq %r14, %rcx
movq %rbp, %rsi
incq %r13
movq %rsi, %rbp
cmpq 0x18(%rsp), %r13
jne 0xa027
movq 0xb0(%rsp), %rbx
movq (%rbx), %rdi
movq %rcx, %r14
movq %rsi, %r12
callq 0x2040
movq %r12, %rdi
callq 0x2340
movq %rax, (%rbx)
movq 0xb8(%rsp), %rax
movq %r14, (%rax)
cmpl $0x0, 0x30(%r15)
jle 0xa22d
xorl %ebx, %ebx
movq 0x58(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x8cf6
incq %rbx
movslq 0x30(%r15), %rax
cmpq %rax, %rbx
jl 0xa213
movq 0x58(%rsp), %rdi
callq 0x2040
movq 0x50(%rsp), %rdi
callq 0x2040
movq 0x19db0(%rip), %rax     # 0x23ff8
movq (%rax), %rbx
callq 0x515a
subsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
callq 0x5117
movapd %xmm0, %xmm1
subsd 0x70(%rsp), %xmm1
leaq 0x124a8(%rip), %rsi     # 0x1c71a
leaq 0x124d8(%rip), %rdx     # 0x1c751
movq %rbx, %rdi
movl 0x4(%rsp), %ecx
movsd 0x20(%rsp), %xmm0
movb $0x2, %al
callq 0x21c0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq