// File: /workspace/github_c_makefile_star2_O3/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 0xa2ab
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, %rbp
movq %rsi, %r12
movq %rdi, %r15
movq 0xb8(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq (%rcx), %r13
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movl %edx, %r14d
movq %r8, 0x8(%rsp)
movq %r9, (%rsp)
callq 0x502a
movsd %xmm0, 0x60(%rsp)
callq 0x4fe7
movsd %xmm0, 0x68(%rsp)
movslq 0x30(%r15), %rbx
movl $0x8, %esi
movq %rbx, %rdi
callq 0x2190
movq %rax, 0x50(%rsp)
movq %r15, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movq (%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbp, 0x38(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
movl %r14d, 0x1c(%rsp)
movl %r14d, %r12d
movl $0x28, %esi
movq %r12, %rdi
callq 0x2190
movq %rax, 0x48(%rsp)
testq %rbx, %rbx
jle 0xa3b5
xorl %r14d, %r14d
movl $0x1, %edi
movl $0xb0, %esi
callq 0x2190
movq %rax, %rbp
movl $0x1, %edi
movl $0x28, %esi
callq 0x2190
movq %rax, 0xa8(%rbp)
movq 0x50(%rsp), %rax
movq %rbp, (%rax,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0xa359
cmpl $0x1, %ebx
jne 0xa3b5
xorl %ebx, %ebx
leaq 0x20(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xa62e
incq %rbx
cmpq %rbx, %r12
jne 0xa39e
jmp 0xa3cb
leaq 0x272(%rip), %rsi       # 0xa62e
leaq 0x20(%rsp), %rdx
movl %ebx, %edi
movq %r12, %rcx
callq 0x340c
xorl %ebx, %ebx
movq %r15, (%rsp)
movq 0x10(%rsp), %rsi
movq %r12, 0x8(%rsp)
leaq (%rbx,%rbx,4), %r12
shlq $0x3, %r12
addq 0x48(%rsp), %r12
movq 0x30(%rsp), %rax
movq (%rax,%rbx,8), %rbp
movl $0x1, %edx
testq %r13, %r13
je 0xa4ac
movb (%r13), %cl
testb %cl, %cl
je 0xa423
xorl %eax, %eax
movb (%rbp,%rax), %r14b
cmpb %r14b, %cl
jne 0xa436
movb 0x1(%r13,%rax), %cl
incq %rax
testb %cl, %cl
jne 0xa409
movl %eax, %ecx
jmp 0xa427
xorl %ecx, %ecx
xorl %eax, %eax
movb (%rbp,%rax), %r14b
testb %r14b, %r14b
je 0xa4aa
xorl %r15d, %r15d
jmp 0xa43c
movsbq %cl, %r15
movl %eax, %ecx
testl %ecx, %ecx
je 0xa46a
movq %rcx, 0x70(%rsp)
movq %rsi, 0x10(%rsp)
callq 0x2360
movq (%rax), %rax
testb $0x8, 0x1(%rax,%r15,2)
jne 0xa470
movq (%rsp), %r15
movq 0x10(%rsp), %rsi
movl $0x1, %edx
jmp 0xa4ac
movq (%rsp), %r15
jmp 0xa4ac
movsbq %r14b, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
movq (%rsp), %r15
movq 0x10(%rsp), %rsi
movl $0x1, %edx
je 0xa4ac
movq 0x70(%rsp), %rcx
leal -0x1(%rcx), %eax
cmpb $0x2f, (%r13,%rax)
jne 0xa4ac
movl %ecx, %eax
cmpb $0x0, 0x1(%rax,%r13)
jne 0xa4ac
cmpb $0x0, 0x1(%rbp,%rax)
jne 0xa4ac
xorl %edx, %edx
addq %rdx, %rsi
cmpl $0x0, 0x4c(%r15)
je 0xa4c2
cmpl $0x0, 0x24(%r12)
jne 0xa55f
cmpl $0x0, 0x44(%r15)
je 0xa4d8
movq %rsi, %r13
leaq 0x13397(%rip), %rdi     # 0x1d86a
movq %rbp, %rsi
jmp 0xa4e2
leaq 0x1338f(%rip), %rdi     # 0x1d86e
movq %rsi, %r13
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), %r14d
subq $0x8, %rsp
leaq 0x13358(%rip), %rdi     # 0x1d873
xorl %eax, %eax
pushq %r14
pushq %r11
pushq %r10
callq 0x2100
addq $0x20, %rsp
movq 0x38(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x2080
movl $0x2b, %edi
callq 0x2050
movl $0xa, %edi
callq 0x2050
movq 0x40(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x2080
movq %r13, %rsi
incq %rbx
movq %rbp, %r13
movq 0x8(%rsp), %r12
cmpq %r12, %rbx
jne 0xa3db
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)
cmpl $0x0, 0x30(%r15)
jle 0xa5bf
xorl %ebx, %ebx
movq 0x50(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x8a8e
incq %rbx
movslq 0x30(%r15), %rax
cmpq %rax, %rbx
jl 0xa5a5
movq 0x50(%rsp), %rdi
callq 0x2040
movq 0x48(%rsp), %rdi
callq 0x2040
movq 0x1aa1e(%rip), %rax     # 0x24ff8
movq (%rax), %rbx
callq 0x502a
subsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x4fe7
movapd %xmm0, %xmm1
subsd 0x68(%rsp), %xmm1
leaq 0x1328e(%rip), %rsi     # 0x1d892
leaq 0x132be(%rip), %rdx     # 0x1d8c9
movq %rbx, %rdi
movl 0x1c(%rsp), %ecx
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x21c0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq