// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, 0x40(%rsp)
movabsq $0x2000300010011, %r12  # imm = 0x2000300010011
andq $0x0, 0x48(%rsp)
callq 0x3afc
andq $0x0, 0x58(%rsp)
movq %r12, 0x50(%rsp)
movaps 0x10658(%rip), %xmm0    # 0x193e0
movups %xmm0, 0x60(%rsp)
movabsq $0x10000000011, %rax    # imm = 0x10000000011
movq %rax, 0x88(%rsp)
movl $0x3c, 0x90(%rsp)
movq $0xff00000, 0xa0(%rsp) # imm = 0xFF00000
pushq $0x8
popq %rax
movl %eax, 0x1c(%rsp)
pushq $0x1e
popq %rax
movl %eax, 0x8(%rsp)
pushq $0x1
popq %rcx
movsd 0x107b1(%rip), %xmm0    # 0x19580
movsd %xmm0, 0x30(%rsp)
movsd 0x107ab(%rip), %xmm0    # 0x19588
movsd %xmm0, 0x38(%rsp)
pushq $0x11
popq %rax
movl %eax, 0x4(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x10a2b(%rip), %r14     # 0x19825
leaq 0x1078f(%rip), %r15     # 0x19590
movq 0x191d0(%rip), %r13     # 0x21fd8
movl $0x0, 0x14(%rsp)
movl %ecx, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x22f0
testl %eax, %eax
js 0x8f41
leal -0x64(%rax), %ecx
cmpl $0x13, %ecx
ja 0x8e52
movslq (%r15,%rcx,4), %rax
addq %r15, %rax
jmpq *%rax
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x4(%rsp)
jmp 0x8e1d
cmpl $0x44, %eax
je 0x8f35
cmpl $0x4f, %eax
jne 0x8e1d
pushq $0x1
popq %rax
movq %rax, 0x20(%rsp)
jmp 0x8e1d
movq (%r13), %rdi
callq 0x2300
movl %r12d, %ecx
movzwl %ax, %r12d
movq %r12, %rax
shlq $0x20, %rax
orq %rax, %rcx
shlq $0x30, %r12
orq %rcx, %r12
movabsq $-0x1000000000000, %rax # imm = 0xFFFF000000000000
addq %rax, %r12
jmp 0x8e1d
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x1c(%rsp)
jmp 0x8e1d
movq (%r13), %rax
movq %rax, 0x28(%rsp)
jmp 0x8e1d
movq (%r13), %rdi
callq 0x2300
movzwl %ax, %eax
andq $-0x10000, %r12         # imm = 0xFFFF0000
orq %rax, %r12
jmp 0x8e1d
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x18(%rsp)
jmp 0x8e1d
movq (%r13), %rdi
callq 0x20b0
movsd %xmm0, 0x30(%rsp)
jmp 0x8e1d
movq (%r13), %rdi
callq 0x20b0
movsd %xmm0, 0x38(%rsp)
jmp 0x8e1d
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x8(%rsp)
jmp 0x8e1d
movq (%r13), %rdi
callq 0x2300
movl %eax, 0x192a0(%rip)     # 0x221d0
jmp 0x8e1d
pushq $0x1
popq %rax
movl %eax, 0x14(%rsp)
jmp 0x8e1d
movl 0x14(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0x20(%rsp), %rax
movl %eax, 0x94(%rsp)
movl 0x1c(%rsp), %r15d
movl %r15d, 0x98(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x84(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x80(%rsp)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x58(%rsp)
testb $0x1, %r12b
je 0x91a0
movq 0x19024(%rip), %r13     # 0x21fd0
movslq (%r13), %rax
cmpl %ebp, %eax
je 0x91cc
movl %r12d, %ecx
shll $0x10, %ecx
addl $0xffee0000, %ecx       # imm = 0xFFEE0000
cmpw $0x13, %r12w
movl $0x10000, %edx          # imm = 0x10000
cmovgeq %rcx, %rdx
movabsq $-0xffff0001, %rcx      # imm = 0xFFFFFFFF0000FFFF
andq %r12, %rcx
orq %rdx, %rcx
movq %rcx, 0x50(%rsp)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x9032
cmpb $0x2d, (%rdi)
jne 0x9000
cmpb $0x0, 0x1(%rdi)
je 0x9191
leaq 0x1005a(%rip), %rsi     # 0x19061
callq 0x22d0
movq %rax, %r15
testq %r15, %r15
je 0x92f4
leaq 0x50(%rsp), %rsi
movq %r15, %rdi
callq 0x5efc
movq %rax, %r14
movq %r15, %rdi
callq 0x20d0
jmp 0x9043
movq (%rbx,%rax,8), %rsi
leaq 0x50(%rsp), %rdi
callq 0x5c09
movq %rax, %r14
movl (%r13), %eax
addl $0x2, %eax
cmpl %ebp, %eax
jle 0x9091
movq 0x18f6b(%rip), %rax     # 0x21fc0
movq (%rax), %rdi
leaq 0x50(%rsp), %rsi
movq %r14, %rdx
callq 0x5e68
leaq 0x10(%r14), %rbx
xorl %ebp, %ebp
movl 0x50(%rsp), %ecx
shrl $0xf, %ecx
andb $-0x2, %cl
movl %ebp, %eax
shrl %cl, %eax
testl %eax, %eax
jne 0x9175
movq (%rbx), %rdi
callq 0x2040
addq $0x18, %rbx
incl %ebp
jmp 0x906b
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x5ff6
movq %rax, %r14
movslq (%r13), %rax
movq 0x8(%rbx,%rax,8), %rdi
leaq 0x102f0(%rip), %rsi     # 0x193a4
callq 0x22b0
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0xc26c
movq %rax, %r12
leaq 0x48(%rsp), %rbp
leaq 0x40(%rsp), %rbx
movq 0xa0(%rsp), %rsi
movq %r12, %rdi
callq 0x64ae
testq %rax, %rax
je 0x9112
movq %rax, %r13
movl (%rax), %edx
movq 0x8(%rax), %rcx
movq 0x10(%rax), %r8
movq 0x18(%rax), %r9
movq %r15, %rdi
movq %r14, %rsi
pushq %rbp
pushq %rbx
callq 0x8967
popq %rax
popq %rcx
movq %r13, %rdi
callq 0x661b
jmp 0x90d3
movq 0x40(%rsp), %rdi
callq 0x2040
movq %r12, %rdi
callq 0xc298
movq 0x8(%rsp), %rdi
callq 0x2030
xorl %r15d, %r15d
movl 0x50(%rsp), %ecx
shrl $0xf, %ecx
andb $-0x2, %cl
movl %r15d, %eax
shrl %cl, %eax
testl %eax, %eax
jne 0x9175
movq (%r14,%r15,8), %rbx
testq %rbx, %rbx
je 0x9170
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
jmp 0x9131
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 0x18e30(%rip), %rax     # 0x21fc8
movq (%rax), %r15
jmp 0x900f
orq $0x1, %r12
movq 0x18e4d(%rip), %rax     # 0x21ff8
movq (%rax), %rdi
movswl %r12w, %ecx
leaq 0x10681(%rip), %rsi     # 0x1983a
leaq 0x106ad(%rip), %rdx     # 0x1986d
xorl %eax, %eax
callq 0x21c0
jmp 0x8fa5
movq 0x18e25(%rip), %r14     # 0x21ff8
movq (%r14), %rsi
pushq $0xa
popq %rbp
movl %ebp, %edi
callq 0x2170
movq (%r14), %rcx
leaq 0x10690(%rip), %rdi     # 0x1987a
pushq $0x38
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x2310
movq (%r14), %rcx
leaq 0x106b1(%rip), %rdi     # 0x198b3
pushq $0x2a
popq %rsi
movq %rbx, %rdx
callq 0x2310
movq (%r14), %rdi
movswl %r12w, %edx
leaq 0x106c3(%rip), %rsi     # 0x198de
xorl %eax, %eax
callq 0x21c0
movq (%r14), %rdi
shrq $0x20, %r12
movswl %r12w, %edx
leaq 0x106d1(%rip), %rsi     # 0x19905
xorl %eax, %eax
callq 0x21c0
movq (%r14), %rdi
leaq 0x106fb(%rip), %rsi     # 0x19940
movl 0x4(%rsp), %edx
xorl %eax, %eax
callq 0x21c0
movq (%r14), %rcx
leaq 0x10725(%rip), %rdi     # 0x1997f
pushq $0x3a
popq %rsi
movq %rbx, %rdx
callq 0x2310
movq (%r14), %rdi
leaq 0x1074b(%rip), %rsi     # 0x199ba
movl 0x8(%rsp), %edx
xorl %eax, %eax
callq 0x21c0
movq (%r14), %rdi
leaq 0x1077b(%rip), %rsi     # 0x199ff
movl %r15d, %edx
xorl %eax, %eax
callq 0x21c0
movq (%r14), %rcx
leaq 0x107ae(%rip), %rdi     # 0x19a46
pushq $0x2b
popq %rsi
movq %rbx, %rdx
callq 0x2310
movq (%r14), %rcx
leaq 0x107c5(%rip), %rdi     # 0x19a72
pushq $0x31
popq %rsi
movq %rbx, %rdx
callq 0x2310
movq (%r14), %rsi
movl %ebp, %edi
callq 0x2170
movq (%r14), %rcx
leaq 0x107d8(%rip), %rdi     # 0x19aa4
pushq $0x4b
popq %rsi
movq %rbx, %rdx
callq 0x2310
movq (%r14), %rcx
leaq 0x1080f(%rip), %rdi     # 0x19af0
pushq $0x35
popq %rsi
movq %rbx, %rdx
callq 0x2310
pushq $0x1
popq %rax
jmp 0x917f
leaq 0x1082b(%rip), %rdi     # 0x19b26
leaq 0x10319(%rip), %rsi     # 0x1961b
leaq 0x10820(%rip), %rcx     # 0x19b29
movl $0x412, %edx            # imm = 0x412
callq 0x2120