// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq 0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq 0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
cmpl $0x0, -0x14(%rbp)
jg 0xcbd1
jmp 0xd09c
callq 0x4d30
movsd %xmm0, -0x80(%rbp)
callq 0x4cd0
movsd %xmm0, -0x88(%rbp)
movq -0x8(%rbp), %rax
movslq 0x30(%rax), %rdi
movl $0x8, %esi
callq 0x21a0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movslq -0x14(%rbp), %rdi
movl $0x28, %esi
callq 0x21a0
movq %rax, -0x48(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0xcc6a
callq 0xae80
movq %rax, %rdx
movq -0x40(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xcc3f
movq -0x8(%rbp), %rax
cmpl $0x1, 0x30(%rax)
jne 0xcc9f
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xcc9d
movslq -0x74(%rbp), %rsi
leaq -0x70(%rbp), %rdi
xorl %edx, %edx
callq 0xd0b0
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xcc7b
jmp 0xccba
movq -0x8(%rbp), %rax
movl 0x30(%rax), %edi
movslq -0x14(%rbp), %rcx
leaq 0x3ff(%rip), %rsi       # 0xd0b0
leaq -0x70(%rbp), %rdx
callq 0x2490
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xcfc5
movq -0x48(%rbp), %rax
movslq -0x74(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movl $0x0, -0xa4(%rbp)
movq -0x60(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0xce6c
movl $0x0, -0x78(%rbp)
movq -0x90(%rbp), %rax
movslq -0x78(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xb9(%rbp)
je 0xcd76
movq -0xb8(%rbp), %rax
movslq -0x78(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xb9(%rbp)
je 0xcd76
movq -0x90(%rbp), %rax
movslq -0x78(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movq -0xb8(%rbp), %rcx
movslq -0x78(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0xb9(%rbp)
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0xcd82
jmp 0xcd8f
jmp 0xcd84
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0xcd15
movq -0x90(%rbp), %rax
movslq -0x78(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0xcdbb
movq -0xb8(%rbp), %rax
movslq -0x78(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xce60
cmpl $0x0, -0x78(%rbp)
jle 0xce6a
callq 0x2370
movq (%rax), %rax
movq -0x90(%rbp), %rcx
movslq -0x78(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xce6a
callq 0x2370
movq (%rax), %rax
movq -0xb8(%rbp), %rcx
movslq -0x78(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xce6a
movq -0x90(%rbp), %rax
movl -0x78(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0xce6a
movq -0x90(%rbp), %rax
movl -0x78(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0xce6a
movq -0xb8(%rbp), %rax
movl -0x78(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0xce6a
movl $0x1, -0xa4(%rbp)
jmp 0xce6c
cmpl $0x0, -0xa4(%rbp)
je 0xce85
movq -0x98(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0xce97
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x4c(%rax)
je 0xcedd
movq -0xa0(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0xcedd
jmp 0xcfb7
movq -0x8(%rbp), %rax
cmpl $0x0, 0x44(%rax)
je 0xcefe
movq -0xb8(%rbp), %rsi
leaq 0x1f7a5(%rip), %rdi     # 0x2c69a
movb $0x0, %al
callq 0x2120
jmp 0xcf13
movq -0xb0(%rbp), %rsi
leaq 0x1f792(%rip), %rdi     # 0x2c69e
movb $0x0, %al
callq 0x2120
movq -0xa0(%rbp), %rax
movl 0x20(%rax), %esi
movq -0xa0(%rbp), %rax
movl (%rax), %edx
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0xa0(%rbp), %rax
movl 0x1c(%rax), %r8d
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %r9d
movq -0xa0(%rbp), %rax
movl 0xc(%rax), %r11d
movq -0xa0(%rbp), %rax
movl 0x10(%rax), %r10d
movq -0xa0(%rbp), %rax
movl 0x14(%rax), %eax
leaq 0x1f736(%rip), %rdi     # 0x2c6a3
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x2120
movq -0x58(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2090
movl $0x2b, %edi
callq 0x2050
movl $0xa, %edi
callq 0x2050
movq -0x50(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2090
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xccc1
movq 0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2040
movq -0x90(%rbp), %rdi
callq 0x2350
movq %rax, %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x98(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0xd024
movq -0x40(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xaee0
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xcffc
movq -0x40(%rbp), %rdi
callq 0x2040
movq -0x48(%rbp), %rdi
callq 0x2040
movq 0x25fbb(%rip), %rax     # 0x32ff8
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xd4(%rbp)
callq 0x4d30
subsd -0x80(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
callq 0x4cd0
movq -0xe0(%rbp), %rdi
movl -0xd4(%rbp), %ecx
movaps %xmm0, %xmm1
movsd -0xd0(%rbp), %xmm0
subsd -0x88(%rbp), %xmm1
leaq 0x1f634(%rip), %rsi     # 0x2c6c2
leaq 0x1f664(%rip), %rdx     # 0x2c6f9
movb $0x2, %al
callq 0x21d0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)