// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
callq 0x4c90
leaq -0x70(%rbp), %rdi
callq 0x70d0
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x1f509(%rip), %rdx     # 0x2c705
callq 0x2300
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jl 0xd3d0
cmpl $0x6b, -0x14(%rbp)
jne 0xd243
movq 0x25dbe(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
callq 0x2310
movl %eax, %eax
movl %eax, %ecx
movq -0x70(%rbp), %rax
andq $0xffff, %rcx           # imm = 0xFFFF
andq $-0x10000, %rax         # imm = 0xFFFF0000
orq %rcx, %rax
movq %rax, -0x70(%rbp)
jmp 0xd3cb
cmpl $0x64, -0x14(%rbp)
jne 0xd260
movq 0x25d88(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
callq 0x2310
movl %eax, -0x68(%rbp)
jmp 0xd3c9
cmpl $0x6f, -0x14(%rbp)
jne 0xd2d7
movq 0x25d6b(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
callq 0x2310
movl %eax, %eax
movl %eax, %ecx
movq -0x70(%rbp), %rax
andq $0xffff, %rcx           # imm = 0xFFFF
shlq $0x20, %rcx
movabsq $-0xffff00000001, %rdx  # imm = 0xFFFF0000FFFFFFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
shlq $0x10, %rax
sarq $0x30, %rax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x70(%rbp), %rax
andq $0xffff, %rcx           # imm = 0xFFFF
shlq $0x30, %rcx
movabsq $0xffffffffffff, %rdx   # imm = 0xFFFFFFFFFFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, -0x70(%rbp)
jmp 0xd3c7
cmpl $0x70, -0x14(%rbp)
jne 0xd2f6
movq 0x25cf4(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
callq 0x20c0
movsd %xmm0, -0x48(%rbp)
jmp 0xd3c5
cmpl $0x65, -0x14(%rbp)
jne 0xd315
movq 0x25cd5(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
callq 0x20c0
movsd %xmm0, -0x50(%rbp)
jmp 0xd3c3
cmpl $0x74, -0x14(%rbp)
jne 0xd332
movq 0x25cb6(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
callq 0x2310
movl %eax, -0x40(%rbp)
jmp 0xd3c1
cmpl $0x68, -0x14(%rbp)
jne 0xd348
movq 0x25c99(%rip), %rax     # 0x32fd8
movq (%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0xd3bf
cmpl $0x76, -0x14(%rbp)
jne 0xd365
movq 0x25c83(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
callq 0x2310
movl %eax, 0x25e7d(%rip)     # 0x331e0
jmp 0xd3bd
cmpl $0x71, -0x14(%rbp)
jne 0xd37f
movq 0x25c66(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
callq 0x2310
movl %eax, -0x3c(%rbp)
jmp 0xd3bb
cmpl $0x4f, -0x14(%rbp)
jne 0xd38e
movl $0x1, -0x2c(%rbp)
jmp 0xd3b9
cmpl $0x44, -0x14(%rbp)
jne 0xd39d
movl $0x1, -0x24(%rbp)
jmp 0xd3b7
cmpl $0x77, -0x14(%rbp)
jne 0xd3b5
movq 0x25c2e(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
callq 0x2310
movl %eax, -0x28(%rbp)
jmp 0xd3b7
jmp 0xd3b9
jmp 0xd3bb
jmp 0xd3bd
jmp 0xd3bf
jmp 0xd3c1
jmp 0xd3c3
jmp 0xd3c5
jmp 0xd3c7
jmp 0xd3c9
jmp 0xd3cb
jmp 0xd1ee
movq -0x70(%rbp), %rax
shlq $0x30, %rax
sarq $0x30, %rax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xd43c
movq -0x70(%rbp), %rax
shlq $0x30, %rax
sarq $0x30, %rax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x70(%rbp), %rax
andq $0xffff, %rcx           # imm = 0xFFFF
andq $-0x10000, %rax         # imm = 0xFFFF0000
orq %rcx, %rax
movq %rax, -0x70(%rbp)
movq 0x25be2(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
movq -0x70(%rbp), %rax
shlq $0x30, %rax
sarq $0x30, %rax
movl %eax, %ecx
leaq 0x1f2ec(%rip), %rsi     # 0x2c71a
leaq 0x1f318(%rip), %rdx     # 0x2c74d
movb $0x0, %al
callq 0x21d0
movq 0x25b8d(%rip), %rax     # 0x32fd0
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jne 0xd5cf
movq 0x25ba3(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x1f5a5(%rip), %rsi     # 0x2ca04
movb $0x0, %al
callq 0x21d0
movq 0x25b8b(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x1f2e3(%rip), %rsi     # 0x2c75a
movb $0x0, %al
callq 0x21d0
movq 0x25b73(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x1f304(%rip), %rsi     # 0x2c793
movb $0x0, %al
callq 0x21d0
movq 0x25b5b(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
movq -0x70(%rbp), %rax
shlq $0x30, %rax
sarq $0x30, %rax
movl %eax, %edx
leaq 0x1f309(%rip), %rsi     # 0x2c7be
movb $0x0, %al
callq 0x21d0
movq 0x25b35(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
movq -0x70(%rbp), %rax
shlq $0x10, %rax
sarq $0x30, %rax
movl %eax, %edx
leaq 0x1f30a(%rip), %rsi     # 0x2c7e5
movb $0x0, %al
callq 0x21d0
movq 0x25b0f(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
movl -0x68(%rbp), %edx
leaq 0x1f32a(%rip), %rsi     # 0x2c820
movb $0x0, %al
callq 0x21d0
movq 0x25af4(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x1f351(%rip), %rsi     # 0x2c85f
movb $0x0, %al
callq 0x21d0
movq 0x25adc(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
movl -0x3c(%rbp), %edx
leaq 0x1f371(%rip), %rsi     # 0x2c89a
movb $0x0, %al
callq 0x21d0
movq 0x25ac1(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
movl -0x28(%rbp), %edx
leaq 0x1f39b(%rip), %rsi     # 0x2c8df
movb $0x0, %al
callq 0x21d0
movq 0x25aa6(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x1f3ca(%rip), %rsi     # 0x2c926
movb $0x0, %al
callq 0x21d0
movq 0x25a8e(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x1f3de(%rip), %rsi     # 0x2c952
movb $0x0, %al
callq 0x21d0
movq 0x25a76(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x1f478(%rip), %rsi     # 0x2ca04
movb $0x0, %al
callq 0x21d0
movq 0x25a5e(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x1f3e0(%rip), %rsi     # 0x2c984
movb $0x0, %al
callq 0x21d0
movq 0x25a46(%rip), %rax     # 0x32ff8
movq (%rax), %rdi
leaq 0x1f414(%rip), %rsi     # 0x2c9d0
movb $0x0, %al
callq 0x21d0
movl $0x1, -0x4(%rbp)
jmp 0xd8e4
movq -0x70(%rbp), %rax
shlq $0x30, %rax
sarq $0x30, %rax
cmpl $0x12, %eax
jle 0xd5f7
movq -0x70(%rbp), %rax
shlq $0x30, %rax
sarq $0x30, %rax
subl $0x12, %eax
movl %eax, -0xcc(%rbp)
jmp 0xd604
movl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0xd604
movl -0xcc(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x70(%rbp), %rax
andq $0xffff, %rcx           # imm = 0xFFFF
shlq $0x10, %rcx
movabsq $-0xffff0001, %rdx      # imm = 0xFFFFFFFF0000FFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0xd6d6
movq -0x80(%rbp), %rdi
leaq 0x1f4ee(%rip), %rsi     # 0x2cb35
callq 0x21b0
cmpl $0x0, %eax
je 0xd66a
movq -0x80(%rbp), %rdi
leaq 0x1e9e9(%rip), %rsi     # 0x2c045
callq 0x22e0
movq %rax, -0xd8(%rbp)
jmp 0xd67b
movq 0x25957(%rip), %rax     # 0x32fc8
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0xd695
jmp 0xd6b4
leaq 0x1f36a(%rip), %rdi     # 0x2ca06
leaq 0x1ee58(%rip), %rsi     # 0x2c4fb
movl $0x412, %edx            # imm = 0x412
leaq 0x1f35a(%rip), %rcx     # 0x2ca09
callq 0x2140
movq -0x98(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x85e0
movq %rax, -0x78(%rbp)
movq -0x98(%rbp), %rdi
callq 0x20e0
jmp 0xd6f5
movq -0x10(%rbp), %rax
movq 0x258ef(%rip), %rcx     # 0x32fd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x70(%rbp), %rdi
callq 0x81a0
movq %rax, -0x78(%rbp)
movq 0x258d4(%rip), %rax     # 0x32fd0
movl (%rax), %eax
addl $0x2, %eax
cmpl -0x8(%rbp), %eax
jle 0xd78d
movq 0x258af(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
movq -0x78(%rbp), %rdx
leaq -0x70(%rbp), %rsi
callq 0x8500
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movq -0x70(%rbp), %rcx
shlq $0x20, %rcx
sarq $0x30, %rcx
shll %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0xd778
movq -0x78(%rbp), %rax
movslq -0x9c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x2040
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0xd72b
movq -0x78(%rbp), %rdi
callq 0x2040
movl $0x0, -0x4(%rbp)
jmp 0xd8e4
movq -0x78(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x8770
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq 0x25824(%rip), %rcx     # 0x32fd0
movl (%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1f6dc(%rip), %rsi     # 0x2ce9b
callq 0x22c0
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x13c80
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x90a0
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
je 0xd85a
movq -0xa8(%rbp), %rsi
movq -0xc8(%rbp), %rax
movl (%rax), %edx
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0xc8(%rbp), %rax
movq 0x10(%rax), %r8
movq -0xc8(%rbp), %rax
movq 0x18(%rax), %r9
leaq -0x70(%rbp), %rdi
leaq -0x88(%rbp), %r10
leaq -0x90(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xcb80
movq -0xc8(%rbp), %rdi
callq 0x92d0
jmp 0xd7de
movq -0x88(%rbp), %rdi
callq 0x2040
movq -0xb8(%rbp), %rdi
callq 0x13cc0
movq -0xc0(%rbp), %rdi
callq 0x2030
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
movq -0x70(%rbp), %rcx
shlq $0x20, %rcx
sarq $0x30, %rcx
shll %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0xd8d1
movq -0xa8(%rbp), %rax
movslq -0xac(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xd8f0
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0xd888
movq -0xa8(%rbp), %rdi
callq 0x2040
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq