// File: /workspace/github_c_makefile_star2_O1/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 $0x78, %rsp
movq %rsi, %rbx
movl %edi, %ebp
xorl %r14d, %r14d
movq %r14, 0x60(%rsp)
movq %r14, 0x70(%rsp)
callq 0x50e8
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x40(%rsp)
movl $0x11, 0x8(%rsp)
movabsq $0x2000300010011, %rax  # imm = 0x2000300010011
movq %rax, (%rsp)
movabsq $0x3fa999999999999a, %rax # imm = 0x3FA999999999999A
movq %rax, 0x10(%rsp)
movabsq $0x4024000000000000, %rax # imm = 0x4024000000000000
movq %rax, 0x18(%rsp)
movabsq $0x3f747ae147ae147b, %rax # imm = 0x3F747AE147AE147B
movq %rax, 0x20(%rsp)
movabsq $0x3fefae147ae147ae, %rax # imm = 0x3FEFAE147AE147AE
movq %rax, 0x28(%rsp)
movaps 0x12032(%rip), %xmm0    # 0x1c3c0
movaps %xmm0, 0x30(%rsp)
movl $0x3c, 0x40(%rsp)
movq $0xff00000, 0x50(%rsp)  # imm = 0xFF00000
movl $0x8, 0x48(%rsp)
leaq 0x123aa(%rip), %rdx     # 0x1c75d
movl %ebp, %edi
movq %rbx, %rsi
callq 0x22f0
testl %eax, %eax
js 0xa4ed
xorl %r14d, %r14d
leaq 0x1238e(%rip), %r15     # 0x1c75d
leaq 0x120f2(%rip), %r12     # 0x1c4c8
movq 0x19bfb(%rip), %r13     # 0x23fd8
leal -0x64(%rax), %ecx
cmpl $0x13, %ecx
ja 0xa400
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x8(%rsp)
jmp 0xa4d8
cmpl $0x44, %eax
je 0xa4d0
cmpl $0x4f, %eax
jne 0xa4d8
movl $0x1, 0x44(%rsp)
jmp 0xa4d8
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x30(%rsp)
jmp 0xa4d8
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x19d90(%rip)     # 0x241d0
jmp 0xa4d8
movq (%r13), %rdi
callq 0x2300
movw %ax, (%rsp)
jmp 0xa4d8
movq (%r13), %rdi
callq 0x20b0
movsd %xmm0, 0x20(%rsp)
jmp 0xa4d8
movq (%r13), %r14
jmp 0xa4d8
movq (%r13), %rdi
callq 0x2300
movl (%rsp), %ecx
movzwl %ax, %eax
movq %rax, %rdx
shlq $0x20, %rdx
orq %rcx, %rdx
shlq $0x30, %rax
orq %rdx, %rax
movabsq $-0x1000000000000, %rcx # imm = 0xFFFF000000000000
addq %rcx, %rax
movq %rax, (%rsp)
jmp 0xa4d8
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x34(%rsp)
jmp 0xa4d8
movq (%r13), %rdi
callq 0x20b0
movsd %xmm0, 0x28(%rsp)
jmp 0xa4d8
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x48(%rsp)
jmp 0xa4d8
movl $0x1, 0x4c(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x22f0
testl %eax, %eax
jns 0xa3dd
movq (%rsp), %rdi
testb $0x1, %dil
je 0xa5fc
movq 0x19ace(%rip), %r13     # 0x23fd0
movslq (%r13), %rax
cmpl %ebp, %eax
je 0xa609
movq (%rsp), %rcx
movl %ecx, %edx
shll $0x10, %edx
addl $0xffee0000, %edx       # imm = 0xFFEE0000
cmpw $0x13, %cx
movl $0x10000, %ecx          # imm = 0x10000
cmovgel %edx, %ecx
shrl $0x10, %ecx
movw %cx, 0x2(%rsp)
testq %r14, %r14
je 0xa55d
leaq 0x12650(%rip), %rsi     # 0x1cb8d
movq %r14, %rdi
callq 0x21a0
testl %eax, %eax
je 0xa56e
leaq 0x11af5(%rip), %rsi     # 0x1c045
movq %r14, %rdi
callq 0x22d0
movq %rax, %r15
jmp 0xa578
movq (%rbx,%rax,8), %rsi
movq %rsp, %rdi
callq 0x7266
movq %rax, %r14
jmp 0xa597
movq 0x19a53(%rip), %rax     # 0x23fc8
movq (%rax), %r15
testq %r15, %r15
je 0xa722
movq %rsp, %rsi
movq %r15, %rdi
callq 0x755f
movq %rax, %r14
movq %r15, %rdi
callq 0x20d0
movl (%r13), %eax
addl $0x2, %eax
cmpl %ebp, %eax
jle 0xa627
movq 0x19a13(%rip), %rax     # 0x23fc0
movq (%rax), %rdi
movq %rsp, %rsi
movq %r14, %rdx
callq 0x74cd
leaq 0x10(%r14), %rbx
movl $0x1, %ebp
movq (%rbx), %rdi
callq 0x2040
movl (%rsp), %ecx
shrl $0xf, %ecx
andb $-0x2, %cl
movl %ebp, %eax
shrl %cl, %eax
addq $0x18, %rbx
incl %ebp
testl %eax, %eax
je 0xa5c4
movq %r14, %rdi
callq 0x2040
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rsi
callq 0x28ff
jmp 0xa4fb
leaq 0x8(%rsp), %rsi
leaq 0x34(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %rsp, %rdi
callq 0x292b
movl $0x1, %eax
jmp 0xa5ed
movq %rsp, %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x2462
movq %rax, %r14
movslq (%r13), %rax
movq 0x8(%rbx,%rax,8), %rdi
leaq 0x11d3c(%rip), %rsi     # 0x1c384
callq 0x22b0
movq %rax, 0x68(%rsp)
movq %rax, %rdi
callq 0xd8f7
movq %rax, %r15
movq 0x50(%r12), %rsi
movq %rax, %rdi
callq 0x788f
testq %rax, %rax
je 0xa6bd
movq %rax, %r13
leaq 0x70(%rsp), %rbp
leaq 0x60(%rsp), %rbx
movq %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 0x9ece
addq $0x10, %rsp
movq %r13, %rdi
callq 0x79ac
movq 0x50(%rsp), %rsi
movq %r15, %rdi
callq 0x788f
movq %rax, %r13
testq %rax, %rax
jne 0xa67f
movq 0x60(%rsp), %rdi
callq 0x2040
movq %r15, %rdi
callq 0xd951
movq 0x68(%rsp), %rdi
callq 0x2030
xorl %r15d, %r15d
movq (%r14,%r15,8), %rbx
testq %rbx, %rbx
je 0xa708
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 (%rsp), %ecx
shrl $0xf, %ecx
andb $-0x2, %cl
movl %r15d, %eax
shrl %cl, %eax
testl %eax, %eax
je 0xa6dc
jmp 0xa5e3
leaq 0x12335(%rip), %rdi     # 0x1ca5e
leaq 0x11e23(%rip), %rsi     # 0x1c553
leaq 0x1232a(%rip), %rcx     # 0x1ca61
movl $0x412, %edx            # imm = 0x412
callq 0x2120