// File: /workspace/github_c_makefile_star2_O1/lh3[P]minimap/main.c
// Function: main
int main(int argc, char *argv[])
{
	mm_mapopt_t opt;
	int i, c, k = 15, w = -1, b = MM_IDX_DEF_B, n_threads = 3, keep_name = 1, is_idx = 0;
	int tbatch_size = 100000000;
	uint64_t ibatch_size = 4000000000ULL;
	float f = 0.001;
	bseq_file_t *fp = 0;
	char *fnw = 0;
	FILE *fpr = 0, *fpw = 0;

	liftrlimit();
	mm_realtime0 = realtime();
	mm_mapopt_init(&opt);

	while ((c = getopt(argc, argv, "w:k:B:b:t:r:c:f:Vv:NOg:I:d:lRPST:m:L:Dx:")) >= 0) {
		if (c == 'w') w = atoi(optarg);
		else if (c == 'k') k = atoi(optarg);
		else if (c == 'b') b = atoi(optarg);
		else if (c == 'r') opt.radius = atoi(optarg);
		else if (c == 'c') opt.min_cnt = atoi(optarg);
		else if (c == 'm') opt.merge_frac = atof(optarg);
		else if (c == 'f') f = atof(optarg);
		else if (c == 't') n_threads = atoi(optarg);
		else if (c == 'v') mm_verbose = atoi(optarg);
		else if (c == 'g') opt.max_gap = atoi(optarg);
		else if (c == 'N') keep_name = 0;
		else if (c == 'd') fnw = optarg;
		else if (c == 'l') is_idx = 1;
		else if (c == 'R') opt.flag |= MM_F_WITH_REP;
		else if (c == 'P') opt.flag &= ~MM_F_WITH_REP;
		else if (c == 'D') opt.flag |= MM_F_NO_SELF;
		else if (c == 'O') opt.flag |= MM_F_NO_ISO;
		else if (c == 'S') opt.flag |= MM_F_AVA | MM_F_NO_SELF;
		else if (c == 'T') opt.sdust_thres = atoi(optarg);
		else if (c == 'L') opt.min_match = atoi(optarg);
		else if (c == 'V') {
			puts(MM_VERSION);
			return 0;
		} else if (c == 'B' || c == 'I') {
			double x;
			char *p;
			x = strtod(optarg, &p);
			if (*p == 'G' || *p == 'g') x *= 1e9;
			else if (*p == 'M' || *p == 'm') x *= 1e6;
			else if (*p == 'K' || *p == 'k') x *= 1e3;
			if (c == 'B') tbatch_size = (uint64_t)(x + .499);
			else ibatch_size = (uint64_t)(x + .499);
		} else if (c == 'x') {
			if (strcmp(optarg, "ava10k") == 0) {
				opt.flag |= MM_F_AVA | MM_F_NO_SELF;
				opt.min_match = 100;
				opt.merge_frac = 0.0;
				w = 5;
			}
		}
	}
	if (w < 0) w = (int)(.6666667 * k + .499);

	if (argc == optind) {
		fprintf(stderr, "Usage: minimap [options] <target.fa> [query.fa] [...]\n");
		fprintf(stderr, "Options:\n");
		fprintf(stderr, "  Indexing:\n");
		fprintf(stderr, "    -k INT     k-mer size [%d]\n", k);
		fprintf(stderr, "    -w INT     minizer window size [{-k}*2/3]\n");
		fprintf(stderr, "    -I NUM     split index for every ~NUM input bases [4G]\n");
		fprintf(stderr, "    -d FILE    dump index to FILE []\n");
		fprintf(stderr, "    -l         the 1st argument is a index file (overriding -k, -w and -I)\n");
//		fprintf(stderr, "    -b INT     bucket bits [%d]\n", b); // most users would care about this
		fprintf(stderr, "  Mapping:\n");
		fprintf(stderr, "    -f FLOAT   filter out top FLOAT fraction of repetitive minimizers [%.3f]\n", f);
		fprintf(stderr, "    -r INT     bandwidth [%d]\n", opt.radius);
		fprintf(stderr, "    -m FLOAT   merge two chains if FLOAT fraction of minimizers are shared [%.2f]\n", opt.merge_frac);
		fprintf(stderr, "    -c INT     retain a mapping if it consists of >=INT minimizers [%d]\n", opt.min_cnt);
		fprintf(stderr, "    -L INT     min matching length [%d]\n", opt.min_match);
		fprintf(stderr, "    -g INT     split a mapping if there is a gap longer than INT [%d]\n", opt.max_gap);
		fprintf(stderr, "    -T INT     SDUST threshold; 0 to disable SDUST [%d]\n", opt.sdust_thres);
//		fprintf(stderr, "    -D         skip self mappings but keep dual mappings\n"); // too confusing to expose to end users
		fprintf(stderr, "    -S         skip self and dual mappings\n");
		fprintf(stderr, "    -O         drop isolated hits before chaining (EXPERIMENTAL)\n");
		fprintf(stderr, "    -P         filtering potential repeats after mapping (EXPERIMENTAL)\n");
//		fprintf(stderr, "    -R         skip post-mapping repeat filtering\n"); // deprecated option for backward compatibility
		fprintf(stderr, "    -x STR     preset (recommended to be applied before other options) []\n");
		fprintf(stderr, "               ava10k: -Sw5 -L100 -m0 (PacBio/ONT all-vs-all read mapping)\n");
		fprintf(stderr, "  Input/Output:\n");
		fprintf(stderr, "    -t INT     number of threads [%d]\n", n_threads);
//		fprintf(stderr, "    -B NUM     process ~NUM bp in each batch [100M]\n");
//		fprintf(stderr, "    -v INT     verbose level [%d]\n", mm_verbose);
//		fprintf(stderr, "    -N         use integer as target names\n");
		fprintf(stderr, "    -V         show version number\n");
		fprintf(stderr, "\nSee minimap.1 for detailed description of the command-line options.\n");
		return 1;
	}

	if (is_idx) fpr = fopen(argv[optind], "rb");
	else fp = bseq_open(argv[optind]);
	if (fnw) fpw = fopen(fnw, "wb");
	for (;;) {
		mm_idx_t *mi = 0;
		if (fpr) mi = mm_idx_load(fpr);
		else if (!bseq_eof(fp))
			mi = mm_idx_gen(fp, w, k, b, tbatch_size, n_threads, ibatch_size, keep_name);
		if (mi == 0) break;
		if (mm_verbose >= 3)
			fprintf(stderr, "[M::%s::%.3f*%.2f] loaded/built the index for %d target sequence(s)\n",
					__func__, realtime() - mm_realtime0, cputime() / (realtime() - mm_realtime0), mi->n);
		mm_idx_set_max_occ(mi, f);
		if (mm_verbose >= 3)
			fprintf(stderr, "[M::%s] max occurrences of a minimizer to consider: %d\n", __func__, mi->max_occ);
		if (fpw) mm_idx_dump(fpw, mi);
		for (i = optind + 1; i < argc; ++i)
			mm_map_file(mi, argv[i], &opt, n_threads, tbatch_size);
		mm_idx_destroy(mi);
	}
	if (fpw) fclose(fpw);
	if (fpr) fclose(fpr);
	if (fp)  bseq_close(fp);

	fprintf(stderr, "[M::%s] Version: %s\n", __func__, MM_VERSION);
	fprintf(stderr, "[M::%s] CMD:", __func__);
	for (i = 0; i < argc; ++i)
		fprintf(stderr, " %s", argv[i]);
	fprintf(stderr, "\n[M::%s] Real time: %.3f sec; CPU: %.3f sec\n", __func__, realtime() - mm_realtime0, cputime());
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movl $0xee6b2800, %eax       # imm = 0xEE6B2800
movq %rax, 0x68(%rsp)
leaq 0x38(%rsp), %r14
movl $0x9, %edi
movq %r14, %rsi
callq 0x22a0
movq 0x8(%r14), %rax
movq %rax, (%r14)
movl $0x9, %edi
movq %r14, %rsi
callq 0x21f0
callq 0x2f83
leaq 0x8a0b(%rip), %rax      # 0xb2a8
movsd %xmm0, (%rax)
leaq 0x38(%rsp), %rdi
callq 0x4e9c
leaq 0x5856(%rip), %rdx      # 0x8108
movl %ebp, %edi
movq %rbx, 0x8(%rsp)
movq %rbx, %rsi
callq 0x2270
testl %eax, %eax
js 0x2ef8
movl %eax, %r12d
movq $0x0, 0x28(%rsp)
movl $0xf, 0x14(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0xe, 0x1c(%rsp)
movl $0x3, %r15d
movl $0x1, %eax
movq %rax, 0x60(%rsp)
movl $0x5f5e100, 0x10(%rsp)  # imm = 0x5F5E100
movss 0x56fa(%rip), %xmm0     # 0x8004
movss %xmm0, 0x18(%rsp)
leaq 0x57f1(%rip), %r13      # 0x8108
leaq 0x571a(%rip), %r14      # 0x8038
movq $0x0, 0x20(%rsp)
leal -0x44(%r12), %eax
cmpl $0x33, %eax
ja 0x2acf
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
orb $0x2, 0x4c(%rsp)
jmp 0x2bd9
movq 0x8689(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
movl %eax, %ebx
jmp 0x2bd9
movq 0x8673(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
movl %eax, 0x38(%rsp)
jmp 0x2bd9
movq $0x0, 0x60(%rsp)
jmp 0x2bd9
orb $0x1, 0x4c(%rsp)
jmp 0x2bd9
movq 0x8643(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
movl %eax, %r15d
jmp 0x2bd9
movq 0x862c(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2090
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x50(%rsp)
jmp 0x2bd9
movq 0x860e(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
movl %eax, 0x40(%rsp)
jmp 0x2bd9
movq 0x85f6(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
movl %eax, 0x44(%rsp)
jmp 0x2bd9
orb $0xa, 0x4c(%rsp)
jmp 0x2bd9
movq 0x85d4(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
movl %eax, 0x48(%rsp)
jmp 0x2bd9
movl $0x1, %eax
movq %rax, 0x28(%rsp)
jmp 0x2bd9
orb $0x4, 0x4c(%rsp)
jmp 0x2bd9
movq 0x85a3(%rip), %rax      # 0xafd8
movq (%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x2bd9
andb $-0x2, 0x4c(%rsp)
jmp 0x2bd9
movq 0x8585(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
leaq 0x872e(%rip), %rcx      # 0xb190
movl %eax, (%rcx)
jmp 0x2bd9
movq 0x8568(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
movl %eax, 0x1c(%rsp)
jmp 0x2bd9
movq 0x8550(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
movl %eax, 0x3c(%rsp)
jmp 0x2bd9
movq 0x8538(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2090
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x18(%rsp)
jmp 0x2bd9
movq 0x851a(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x2280
movl %eax, 0x14(%rsp)
jmp 0x2bd9
cmpl $0x42, %r12d
je 0x2ae5
cmpl $0x78, %r12d
je 0x2b4d
cmpl $0x49, %r12d
jne 0x2bd9
movq 0x84ec(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x90(%rsp), %rsi
callq 0x2080
movq 0x90(%rsp), %rax
movzbl (%rax), %eax
addl $-0x47, %eax
cmpl $0x26, %eax
ja 0x2b95
movabsq $0x100000001, %rcx      # imm = 0x100000001
btq %rax, %rcx
jb 0x2b8d
movabsq $0x1000000010, %rcx     # imm = 0x1000000010
btq %rax, %rcx
jb 0x2b83
movabsq $0x4000000040, %rcx     # imm = 0x4000000040
btq %rax, %rcx
jae 0x2b95
mulsd 0x54c5(%rip), %xmm0     # 0x8010
jmp 0x2b95
movq 0x8484(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x55e2(%rip), %rsi      # 0x8140
callq 0x2160
testl %eax, %eax
jne 0x2bd9
orb $0xa, 0x4c(%rsp)
movl $0x64, 0x44(%rsp)
movl $0x0, 0x50(%rsp)
movl $0x5, %ebx
jmp 0x2bd9
mulsd 0x547d(%rip), %xmm0     # 0x8008
jmp 0x2b95
mulsd 0x5483(%rip), %xmm0     # 0x8018
addsd 0x5483(%rip), %xmm0     # 0x8020
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x547b(%rip), %xmm0     # 0x8028
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
cmpl $0x42, %r12d
movl 0x10(%rsp), %eax
cmovel %edx, %eax
movl %eax, 0x10(%rsp)
movq 0x68(%rsp), %rax
cmovneq %rdx, %rax
movq %rax, 0x68(%rsp)
movq 0x8(%rsp), %rsi
movl %ebp, %edi
movq %r13, %rdx
callq 0x2270
movl %eax, %r12d
testl %eax, %eax
jns 0x2927
cmpl $0x0, 0x28(%rsp)
sete %al
movl 0x10(%rsp), %r14d
movl 0x14(%rsp), %r12d
testl %ebx, %ebx
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
mulsd 0x5419(%rip), %xmm0     # 0x8030
addsd 0x5401(%rip), %xmm0     # 0x8020
cvttsd2si %xmm0, %ecx
cmovnsl %ebx, %ecx
movl %ecx, 0x74(%rsp)
movq 0x839f(%rip), %rcx      # 0xafd0
movslq (%rcx), %rcx
cmpl %ebp, %ecx
jne 0x2c6b
leaq 0x38(%rsp), %rsi
movl %r12d, %edi
movss 0x18(%rsp), %xmm0
movl %r15d, %edx
callq 0x23f4
movl $0x1, %ebp
jmp 0x2ee4
leaq 0x54d2(%rip), %rdi      # 0x8131
callq 0x2060
xorl %ebp, %ebp
jmp 0x2ee4
movq 0x8(%rsp), %rdx
movq (%rdx,%rcx,8), %rdi
testb %al, %al
je 0x2c88
callq 0x33bc
movq $0x0, 0x58(%rsp)
jmp 0x2c9b
leaq 0x59b1(%rip), %rsi      # 0x8640
callq 0x2250
movq %rax, 0x58(%rsp)
xorl %eax, %eax
movq %rax, 0x78(%rsp)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
movl %r14d, 0x10(%rsp)
movl %r15d, 0x34(%rsp)
movl %r12d, 0x14(%rsp)
jne 0x2cbe
xorl %r15d, %r15d
jmp 0x2ccd
leaq 0x597e(%rip), %rsi      # 0x8643
callq 0x2250
movq %rax, %r15
movq 0x58(%rsp), %r14
leal -0x1(%rbp), %r12d
movq %rbp, 0x20(%rsp)
movq %r15, 0x88(%rsp)
movq %r12, 0x80(%rsp)
testq %r14, %r14
je 0x2cfd
movq %r14, %rdi
callq 0x4551
movq %rax, %r13
jmp 0x2d15
movq 0x78(%rsp), %rbx
movq %rbx, %rdi
callq 0x3918
testl %eax, %eax
je 0x2ddd
xorl %r13d, %r13d
testq %r13, %r13
je 0x2e26
leaq 0x846b(%rip), %rbx      # 0xb190
cmpl $0x3, (%rbx)
jge 0x2e0c
movq %r13, %rdi
movss 0x18(%rsp), %xmm0
callq 0x3eea
cmpl $0x3, (%rbx)
jge 0x2e19
testq %r15, %r15
je 0x2d55
movq %r15, %rdi
movq %r13, %rsi
callq 0x4355
movq 0x8274(%rip), %rax      # 0xafd0
movslq (%rax), %rbp
leal 0x1(%rbp), %eax
cmpl 0x20(%rsp), %eax
movl 0x10(%rsp), %eax
movl 0x34(%rsp), %r14d
movq 0x8(%rsp), %r15
leaq 0x38(%rsp), %r12
movq %r13, %rbx
movq %r12, %r13
movq 0x80(%rsp), %r12
jge 0x2dbd
movq %rbx, 0x28(%rsp)
movq 0x8(%r15,%rbp,8), %rsi
movq %rbx, %rdi
movq %r13, %rdx
movl %r14d, %ecx
movq %r12, %rbx
movl %eax, %r12d
movl %eax, %r8d
callq 0x63d8
movl %r12d, %eax
movq %rbx, %r12
movq 0x28(%rsp), %rbx
incq %rbp
cmpl %ebp, %r12d
jne 0x2d8e
movq %rbx, %rdi
callq 0x3ba9
testq %rbx, %rbx
movq 0x58(%rsp), %r14
movq 0x88(%rsp), %r15
jne 0x2ceb
jmp 0x2e26
movq %rbx, %rdi
movl 0x74(%rsp), %esi
movl 0x14(%rsp), %edx
movl 0x1c(%rsp), %ecx
movl 0x10(%rsp), %r8d
movl 0x34(%rsp), %r9d
pushq 0x60(%rsp)
pushq 0x70(%rsp)
callq 0x3efd
addq $0x10, %rsp
jmp 0x2cf8
movq %r13, %rdi
callq 0x2310
jmp 0x2d2e
movq %r13, %rdi
callq 0x2385
jmp 0x2d45
testq %r15, %r15
je 0x2e33
movq %r15, %rdi
callq 0x20c0
testq %r14, %r14
movq 0x78(%rsp), %rbx
je 0x2e45
movq %r14, %rdi
callq 0x20c0
testq %rbx, %rbx
je 0x2e52
movq %rbx, %rdi
callq 0x348a
movq 0x819f(%rip), %r15      # 0xaff8
movq (%r15), %rdi
leaq 0x5865(%rip), %rsi      # 0x86c8
leaq 0x5821(%rip), %r14      # 0x868b
leaq 0x52c0(%rip), %rcx      # 0x8131
xorl %ebp, %ebp
movq %r14, %rdx
xorl %eax, %eax
callq 0x2180
movq (%r15), %rdi
leaq 0x5856(%rip), %rsi      # 0x86dd
movq %r14, %rdx
xorl %eax, %eax
callq 0x2180
movq 0x20(%rsp), %rdi
testl %edi, %edi
jle 0x2ea4
movq 0x8(%rsp), %rsi
callq 0x23b0
movq (%r15), %rbx
callq 0x2f83
leaq 0x83f5(%rip), %rax      # 0xb2a8
subsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
callq 0x2f40
movapd %xmm0, %xmm1
leaq 0x5821(%rip), %rsi      # 0x86ee
leaq 0x57b7(%rip), %rdx      # 0x868b
movq %rbx, %rdi
movsd 0x28(%rsp), %xmm0
movb $0x2, %al
callq 0x2180
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movss 0x5104(%rip), %xmm0     # 0x8004
movss %xmm0, 0x18(%rsp)
movl $0x5f5e100, %r14d       # imm = 0x5F5E100
movb $0x1, %al
movl $0x1, %ecx
movq %rcx, 0x60(%rsp)
movl $0x3, %r15d
movl $0xe, 0x1c(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0xf, %r12d
movq $0x0, 0x20(%rsp)
jmp 0x2c05
nop