// File: /workspace/github_c_makefile_star2_O3/lh3[P]fermi2/correct.c
// Function: main_correct
int main_correct(int argc, char *argv[])
{
	int c;
	fmc_opt_t opt;
	fmc64_v *kmer;
	char *fn_kmer = 0, *last_name = 0;
	int64_t last_id = 0;

	liftrlimit();

	fmc_opt_init(&opt);
	while ((c = getopt(argc, argv, "DOk:o:t:h:v:p:e:q:w:")) >= 0) {
		if (c == 'k') opt.c.k = atoi(optarg);
		else if (c == 'd') opt.c.q1_depth = atoi(optarg);
		else if (c == 'o') opt.c.min_occ = atoi(optarg), opt.c.max_ec_depth = opt.c.min_occ - 1;
		else if (c == 'p') opt.c.prior = atof(optarg);
		else if (c == 'e') opt.c.err = atof(optarg);
		else if (c == 't') opt.n_threads = atoi(optarg);
		else if (c == 'h') fn_kmer = optarg;
		else if (c == 'v') fmc_verbose = atoi(optarg);
		else if (c == 'q') opt.ecQ = atoi(optarg);
		else if (c == 'O') opt.show_ori_name = 1;
		else if (c == 'D') opt.drop_reads = 1;
		else if (c == 'w') opt.max_dist4 = atoi(optarg);
	}
	if (!(opt.c.k&1)) {
		++opt.c.k;
		fprintf(stderr, "[W::%s] -k must be an odd number; change -k to %d\n", __func__, opt.c.k);
	}
	if (optind == argc) {
		fprintf(stderr, "\n");
		fprintf(stderr, "Usage:   fermi2 correct [options] index.fmd [reads.fq]\n\n");
		fprintf(stderr, "Options: -t INT     number of threads [1]\n");
		fprintf(stderr, "         -k INT     k-mer length [%d]\n", opt.c.k);
		fprintf(stderr, "         -o INT     min occurrence for a solid k-mer [%d]\n", opt.c.min_occ);
		fprintf(stderr, "         -d INT     correct singletons out of INT bases [%d]\n\n", opt.c.q1_depth);
		fprintf(stderr, "         -h FILE    get solid k-mer list from FILE [null]\n");
		fprintf(stderr, "         -q INT     protect Q>INT bases unless they occur once [%d]\n", opt.ecQ);
		fprintf(stderr, "         -w INT     no more than 4 corrections per INT-bp window [%d]\n", opt.max_dist4);
		fprintf(stderr, "         -D         drop error-prone reads\n");
		fprintf(stderr, "         -O         print the original read name\n");
		fprintf(stderr, "\n");
		fprintf(stderr, "Notes: If reads.fq is absent, this command dumps the list of solid k-mers.\n");
		fprintf(stderr, "       The dump can be loaded later with option -h.\n\n");
		return 1;
	}
	opt.c.suf_len = opt.c.k > 18? opt.c.k - 18 : 1;

	if (fn_kmer) {
		FILE *fp;
		fp = strcmp(fn_kmer, "-")? fopen(fn_kmer, "rb") : stdin;
		assert(fp);
		kmer = fmc_kmer_read(fp, &opt);
		fclose(fp);
	} else kmer = fmc_collect(&opt, argv[optind]);

	if (optind + 2 > argc) {
		int i;
		fmc_kmer_write(stdout, &opt, kmer);
		for (i = 0; i < 1<<opt.c.suf_len*2; ++i)
			free(kmer[i].a);
		free(kmer);
		return 0;
	} else {
		fmc_hash_t **h;
		int i;
		kseq_t *ks;
		gzFile fp;
		fmc_batch_t *b;

		h = fmc_kmer2hash(&opt, kmer); // kmer is deallocated here
		fp = gzopen(argv[optind+1], "r");
		ks = kseq_init(fp);
		while ((b = fmc_batch_read(ks, opt.batch_size)) != 0) {
			fmc_correct(&opt, h, b->n, b->s, b->q, b->name, &last_name, &last_id);
			fmc_batch_destroy(b);
		}
		free(last_name);
		kseq_destroy(ks);
		gzclose(fp);
		for (i = 0; i < 1<<opt.c.suf_len*2; ++i)
			kh_destroy(fmc, h[i]);
		free(h);
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movabsq $0x2000300010011, %r15  # imm = 0x2000300010011
xorl %r14d, %r14d
movq %r14, 0x40(%rsp)
movq %r14, 0xa0(%rsp)
callq 0x4fb8
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rsp)
movups %xmm0, 0x50(%rsp)
movups %xmm0, 0x80(%rsp)
movq %r14, 0x90(%rsp)
movups %xmm0, 0x70(%rsp)
movq %r15, 0x48(%rsp)
movaps 0x12ccc(%rip), %xmm0    # 0x1d400
movups %xmm0, 0x58(%rsp)
movabsq $0x10000000011, %rax    # imm = 0x10000000011
movq %rax, 0x80(%rsp)
movl $0x3c, 0x88(%rsp)
movq $0xff00000, 0x98(%rsp) # imm = 0xFF00000
leaq 0x1316c(%rip), %rdx     # 0x1d8d5
movl %ebp, %edi
movq %rbx, %rsi
callq 0x22f0
testl %eax, %eax
js 0xa932
movq $0x0, 0x28(%rsp)
movl $0x11, 0x18(%rsp)
movsd 0x12ea4(%rip), %xmm0    # 0x1d638
movsd 0x12e94(%rip), %xmm1    # 0x1d630
movl $0x1, 0x14(%rsp)
movl $0x1e, 0xc(%rsp)
movl $0x8, 0x1c(%rsp)
leaq 0x1311a(%rip), %r12     # 0x1d8d5
leaq 0x12e7e(%rip), %r13     # 0x1d640
movq 0x1a80f(%rip), %r14     # 0x24fd8
movl $0x0, 0x10(%rsp)
movq $0x0, 0x30(%rsp)
leal -0x64(%rax), %ecx
cmpl $0x13, %ecx
movsd %xmm0, 0x20(%rsp)
movsd %xmm1, 0x38(%rsp)
ja 0xa809
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movq (%r14), %rdi
callq 0x2300
movl %eax, 0x18(%rsp)
jmp 0xa8e2
cmpl $0x44, %eax
je 0xa8da
cmpl $0x4f, %eax
jne 0xa8e2
movl $0x1, %eax
movq %rax, 0x28(%rsp)
jmp 0xa8e2
movq (%r14), %rdi
callq 0x2300
movl %eax, 0x14(%rsp)
jmp 0xa8e2
movq (%r14), %rdi
callq 0x2300
movl %eax, 0x1a987(%rip)     # 0x251d0
jmp 0xa8e2
movq (%r14), %rdi
callq 0x2300
movzwl %ax, %eax
andq $-0x10000, %r15         # imm = 0xFFFF0000
orq %rax, %r15
jmp 0xa8e2
movq (%r14), %rdi
callq 0x20b0
movsd %xmm0, 0x38(%rsp)
jmp 0xa8e2
movq (%r14), %rax
movq %rax, 0x30(%rsp)
jmp 0xa8e2
movq (%r14), %rdi
callq 0x2300
movl %r15d, %ecx
movzwl %ax, %r15d
movq %r15, %rax
shlq $0x20, %rax
orq %rax, %rcx
shlq $0x30, %r15
orq %rcx, %r15
movabsq $-0x1000000000000, %rax # imm = 0xFFFF000000000000
addq %rax, %r15
jmp 0xa8e2
movq (%r14), %rdi
callq 0x2300
movl %eax, 0xc(%rsp)
jmp 0xa8e2
movq (%r14), %rdi
callq 0x20b0
movsd %xmm0, 0x20(%rsp)
jmp 0xa8e2
movq (%r14), %rdi
callq 0x2300
movl %eax, 0x1c(%rsp)
jmp 0xa8e2
movl $0x1, 0x10(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x22f0
testl %eax, %eax
movsd 0x20(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
jns 0xa7da
movl 0x10(%rsp), %eax
movl %eax, 0x94(%rsp)
movq 0x28(%rsp), %rax
movl %eax, 0x8c(%rsp)
movq 0x30(%rsp), %r14
movl 0x1c(%rsp), %r12d
movl 0xc(%rsp), %edx
movl 0x18(%rsp), %esi
movl 0x14(%rsp), %eax
jmp 0xa957
movl $0x8, %r12d
movl $0x1e, %edx
movl $0x1, %eax
movsd 0x12ce6(%rip), %xmm1    # 0x1d630
movsd 0x12ce6(%rip), %xmm0    # 0x1d638
movl $0x11, %esi
movl %r12d, 0x90(%rsp)
movl %edx, 0x7c(%rsp)
movl %eax, 0x78(%rsp)
movsd %xmm1, 0x68(%rsp)
movsd %xmm0, 0x70(%rsp)
movl %esi, 0x50(%rsp)
testb $0x1, %r15b
je 0xaa99
movq 0x1a648(%rip), %r13     # 0x24fd0
movslq (%r13), %rax
cmpl %ebp, %eax
je 0xaad3
movl %r15d, %ecx
shll $0x10, %ecx
addl $0xffee0000, %ecx       # imm = 0xFFEE0000
cmpw $0x13, %r15w
movl $0x10000, %edx          # imm = 0x10000
cmovgeq %rcx, %rdx
movabsq $-0xffff0001, %rcx      # imm = 0xFFFFFFFF0000FFFF
andq %r15, %rcx
orq %rdx, %rcx
movq %rcx, 0x48(%rsp)
testq %r14, %r14
je 0xaa0e
cmpb $0x2d, (%r14)
jne 0xa9d9
cmpb $0x0, 0x1(%r14)
je 0xaa8a
leaq 0x126b1(%rip), %rsi     # 0x1d091
movq %r14, %rdi
callq 0x22d0
movq %rax, %r15
testq %r15, %r15
je 0xabf5
leaq 0x48(%rsp), %rsi
movq %r15, %rdi
callq 0x72ab
movq %rax, %r14
movq %r15, %rdi
callq 0x20d0
jmp 0xaa1f
movq (%rbx,%rax,8), %rsi
leaq 0x48(%rsp), %rdi
callq 0x6fb2
movq %rax, %r14
movl (%r13), %eax
addl $0x2, %eax
cmpl %ebp, %eax
jle 0xaae5
movq 0x1a58b(%rip), %rax     # 0x24fc0
movq (%rax), %rdi
leaq 0x48(%rsp), %rsi
movq %r14, %rdx
callq 0x7219
leaq 0x10(%r14), %rbx
movl $0x1, %ebp
movq (%rbx), %rdi
callq 0x2040
movl 0x48(%rsp), %ecx
shrl $0xf, %ecx
andb $-0x2, %cl
movl %ebp, %eax
shrl %cl, %eax
addq $0x18, %rbx
incl %ebp
testl %eax, %eax
je 0xaa4e
movq %r14, %rdi
callq 0x2040
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a537(%rip), %rax     # 0x24fc8
movq (%rax), %r15
jmp 0xa9eb
orq $0x1, %r15
movq 0x1a554(%rip), %rax     # 0x24ff8
movq (%rax), %rdi
movl %edx, 0xc(%rsp)
movl %esi, %r13d
movswl %r15w, %ecx
leaq 0x12e31(%rip), %rsi     # 0x1d8ea
leaq 0x12e5d(%rip), %rdx     # 0x1d91d
xorl %eax, %eax
callq 0x21c0
movl %r13d, %esi
movl 0xc(%rsp), %edx
jmp 0xa981
movq %r15, %rdi
movl %r12d, %ecx
callq 0x28cc
movl $0x1, %eax
jmp 0xaa78
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x2462
movq %rax, %r14
movslq (%r13), %rax
movq 0x8(%rbx,%rax,8), %rdi
leaq 0x128b4(%rip), %rsi     # 0x1d3bc
callq 0x22b0
movq %rax, %rbx
movq %rax, %rdi
callq 0xde96
movq %rax, %r15
movq 0x50(%r12), %rsi
movq %rax, %rdi
callq 0x75ba
testq %rax, %rax
je 0xab94
movq %rax, %r13
movq %rbx, 0x20(%rsp)
leaq 0xa0(%rsp), %rbp
leaq 0x40(%rsp), %rbx
leaq 0x48(%rsp), %r12
movl (%r13), %edx
movq 0x8(%r13), %rcx
movq 0x10(%r13), %r8
movq 0x18(%r13), %r9
movq %r12, %rdi
movq %r14, %rsi
pushq %rbp
pushq %rbx
callq 0xa2a6
addq $0x10, %rsp
movq %r13, %rdi
callq 0x7731
movq 0x98(%rsp), %rsi
movq %r15, %rdi
callq 0x75ba
movq %rax, %r13
testq %rax, %rax
jne 0xab47
movq 0x40(%rsp), %rdi
movq 0x20(%rsp), %rbx
jmp 0xab96
xorl %edi, %edi
callq 0x2040
movq %r15, %rdi
callq 0xdee8
movq %rbx, %rdi
callq 0x2030
xorl %r15d, %r15d
movq (%r14,%r15,8), %rbx
testq %rbx, %rbx
je 0xabda
movq 0x18(%rbx), %rdi
callq 0x2040
movq 0x10(%rbx), %rdi
callq 0x2040
movq 0x20(%rbx), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
incq %r15
movl 0x48(%rsp), %ecx
shrl $0xf, %ecx
andb $-0x2, %cl
movl %r15d, %eax
shrl %cl, %eax
testl %eax, %eax
je 0xabae
jmp 0xaa6e
leaq 0x12fda(%rip), %rdi     # 0x1dbd6
leaq 0x12ac8(%rip), %rsi     # 0x1d6cb
leaq 0x12fcf(%rip), %rcx     # 0x1dbd9
movl $0x412, %edx            # imm = 0x412
callq 0x2120