// File: /workspace/github_c_makefile_star2_O2/lh3[P]ksw2/cli.c
// Function: main
int main(int argc, char *argv[])
{
	void *km = 0;
	int8_t a = 2, b = 4, q = 4, e = 2, q2 = 13, e2 = 1;
	int c, i, pair = 1, w = -1, flag = 0, rep = 1, zdrop = -1, no_kalloc = 0;
	char *algo = "extd", *s;
	int8_t mat[25];
	ksw_extz_t ez;
	gzFile fp[2];

	while ((c = getopt(argc, argv, "t:w:R:rsgz:A:B:O:E:Ka")) >= 0) {
		if (c == 't') algo = optarg;
		else if (c == 'w') w = atoi(optarg);
		else if (c == 'R') rep = atoi(optarg);
		else if (c == 'z') zdrop = atoi(optarg);
		else if (c == 'r') flag |= KSW_EZ_RIGHT;
		else if (c == 's') flag |= KSW_EZ_SCORE_ONLY;
		else if (c == 'g') flag |= KSW_EZ_APPROX_MAX | KSW_EZ_APPROX_DROP;
		else if (c == 'K') no_kalloc = 1;
		else if (c == 'A') a = atoi(optarg);
		else if (c == 'B') b = atoi(optarg);
		else if (c == 'a') pair = 0;
		else if (c == 'O') {
			q = q2 = strtol(optarg, &s, 10);
			if (*s == ',') q2 = strtol(s+1, &s, 10);
		} else if (c == 'E') {
			e = e2 = strtol(optarg, &s, 10);
			if (*s == ',') e2 = strtol(s+1, &s, 10);
		}
	}
	if (argc - optind < 2) {
		fprintf(stderr, "Usage: ksw2-test [options] <DNA-target> <DNA-query>\n");
		fprintf(stderr, "Options:\n");
		fprintf(stderr, "  -t STR        algorithm: gg, gg2, gg2_sse, extz, extz2_sse, extd, extd2_sse [%s]\n", algo);
		fprintf(stderr, "  -R INT        repeat INT times (for benchmarking) [1]\n");
		fprintf(stderr, "  -w INT        band width [inf]\n");
		fprintf(stderr, "  -z INT        Z-drop [%d]\n", zdrop);
		fprintf(stderr, "  -r            gap right alignment\n");
		fprintf(stderr, "  -s            score only\n");
		fprintf(stderr, "  -A INT        match score [%d]\n", a);
		fprintf(stderr, "  -B INT        mismatch penalty [%d]\n", b);
		fprintf(stderr, "  -O INT[,INT]  gap open penalty [%d,%d]\n", q, q2);
		fprintf(stderr, "  -E INT[,INT]  gap extension penalty [%d,%d]\n", e, e2);
		fprintf(stderr, "  -a            all vs all\n");
		return 1;
	}
#ifdef HAVE_KALLOC
	km = no_kalloc? 0 : km_init();
#endif
	memset(&ez, 0, sizeof(ksw_extz_t));
	ksw_gen_simple_mat(5, mat, a, -b);
	fp[0] = gzopen(argv[optind], "r");
	fp[1] = gzopen(argv[optind+1], "r");

	if (fp[0] == 0 && fp[1] == 0) {
		global_aln(algo, km, argv[optind+1], argv[optind], 5, mat, q, e, q2, e2, w, zdrop, flag, &ez);
		print_aln("first", "second", &ez);
	} else if (fp[0] && fp[1]) {
		kseq_t *ks[2];
		ks[0] = kseq_init(fp[0]);
		ks[1] = kseq_init(fp[1]);
		if (pair) {
			while (kseq_read(ks[0]) > 0) {
				if (kseq_read(ks[1]) <= 0) break;
				for (i = 0; i < rep; ++i)
					global_aln(algo, km, ks[1]->seq.s, ks[0]->seq.s, 5, mat, q, e, q2, e2, w, zdrop, flag, &ez);
				print_aln(ks[0]->name.s, ks[1]->name.s, &ez);
			}
		} else {
			int i, m_seq = 0, n_seq = 0;
			named_seq_t *seq = 0;
			while (kseq_read(ks[0]) > 0) {
				named_seq_t *s;
				if (n_seq == m_seq) EXPAND(seq, m_seq);
				s = &seq[n_seq++];
				s->name = strdup(ks[0]->name.s);
				s->seq = strdup(ks[0]->seq.s);
			}
			while (kseq_read(ks[1]) > 0) {
				for (i = 0; i < n_seq; ++i) {
					global_aln(algo, km, ks[1]->seq.s, seq[i].seq, 5, mat, q, e, q2, e2, w, zdrop, flag, &ez);
					print_aln(seq[i].name, ks[1]->name.s, &ez);
				}
			}
			for (i = 0; i < n_seq; ++i) {
				free(seq[i].name);
				free(seq[i].seq);
			}
			free(seq);
		}
		kseq_destroy(ks[0]);
		kseq_destroy(ks[1]);
		gzclose(fp[0]);
		gzclose(fp[1]);
	}
	kfree(km, ez.cigar);
#ifdef HAVE_KALLOC
	km_destroy(km);
#endif
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %r12
movl %edi, %r13d
movb $0x4, %al
movq %rax, 0x40(%rsp)
leaq 0x9d8f(%rip), %rax      # 0xb040
movq %rax, 0x58(%rsp)
movq $0x0, 0x20(%rsp)
pushq $-0x1
popq %rax
pushq $0x1
popq %rdx
movb $0x2, %cl
movq %rcx, 0x48(%rsp)
movb $0x1, %cl
movq %rcx, 0x30(%rsp)
movb $0xd, %cl
movq %rcx, 0x28(%rsp)
leaq 0x9d64(%rip), %rbp      # 0xb045
movq 0xccf0(%rip), %r15      # 0xdfd8
leaq 0x9d15(%rip), %r14      # 0xb004
movl %edx, 0x10(%rsp)
movl %edx, 0x38(%rsp)
movq %rax, 0x70(%rsp)
movq %rax, 0x60(%rsp)
xorl %ecx, %ecx
movb $0x4, %al
movq %rax, 0x8(%rsp)
movb $0x2, %al
movq %rax, 0x18(%rsp)
movl %ecx, %ebx
movl %r13d, %edi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x1130
testl %eax, %eax
js 0x148f
leal -0x72(%rax), %ecx
cmpl $0x8, %ecx
jbe 0x137c
cmpl $0x41, %eax
je 0x147b
cmpl $0x42, %eax
je 0x142b
cmpl $0x45, %eax
je 0x143a
pushq $0x1
popq %rcx
cmpl $0x4b, %eax
je 0x1311
cmpl $0x4f, %eax
je 0x13d2
cmpl $0x52, %eax
je 0x141d
cmpl $0x61, %eax
je 0x1413
movl %ebx, %ecx
cmpl $0x67, %eax
jne 0x1311
movq 0x20(%rsp), %rax
orl $0x18, %eax
jmp 0x1397
movslq (%r14,%rcx,4), %rax
addq %r14, %rax
jmpq *%rax
movq 0x20(%rsp), %rax
orl $0x2, %eax
jmp 0x1397
movq 0x20(%rsp), %rax
orl $0x1, %eax
movq %rax, 0x20(%rsp)
jmp 0x1488
movq (%r15), %rax
movq %rax, 0x58(%rsp)
jmp 0x1488
movq (%r15), %rdi
callq 0x1140
movq %rax, 0x70(%rsp)
jmp 0x1488
movq (%r15), %rdi
callq 0x1140
movq %rax, 0x60(%rsp)
jmp 0x1488
movq (%r15), %rdi
leaq 0x68(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x10e0
movq 0x68(%rsp), %rdi
cmpb $0x2c, (%rdi)
movq %rax, 0x40(%rsp)
movq %rax, 0x28(%rsp)
movl %ebx, %ecx
jne 0x1311
incq %rdi
leaq 0x68(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x10e0
movq %rax, 0x28(%rsp)
jmp 0x1488
movl $0x0, 0x10(%rsp)
jmp 0x1488
movq (%r15), %rdi
callq 0x1140
movl %eax, 0x38(%rsp)
jmp 0x1488
movq (%r15), %rdi
callq 0x1140
movq %rax, 0x8(%rsp)
jmp 0x1488
movq (%r15), %rdi
leaq 0x68(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x10e0
movq 0x68(%rsp), %rdi
cmpb $0x2c, (%rdi)
movq %rax, 0x48(%rsp)
movq %rax, 0x30(%rsp)
movl %ebx, %ecx
jne 0x1311
incq %rdi
leaq 0x68(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x10e0
movq %rax, 0x30(%rsp)
jmp 0x1488
movq (%r15), %rdi
callq 0x1140
movq %rax, 0x18(%rsp)
movl %ebx, %ecx
jmp 0x1311
movq 0xcb3a(%rip), %r14      # 0xdfd0
movl (%r14), %ebp
subl %ebp, %r13d
cmpl $0x1, %r13d
jle 0x189e
testl %ebx, %ebx
je 0x14b5
movq $0x0, 0x50(%rsp)
jmp 0x14c2
callq 0x26e8
movq %rax, 0x50(%rsp)
movl (%r14), %ebp
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
andq $0x0, 0xc0(%rsp)
negb %al
movsbl %cl, %esi
movsbl %al, %edx
leaq 0xd0(%rsp), %rdi
callq 0x19d5
movslq %ebp, %rax
movq (%r12,%rax,8), %rdi
leaq 0x9d52(%rip), %rbx      # 0xb265
movq %rbx, %rsi
callq 0x1120
movq %rax, %r13
movslq (%r14), %rax
movq 0x8(%r12,%rax,8), %rdi
movq %rbx, %rsi
callq 0x1120
movq %rax, %rbx
movq %r13, %rax
orq %rbx, %rax
jne 0x15b3
movslq (%r14), %rax
movq (%r12,%rax,8), %rcx
movq 0x8(%r12,%rax,8), %rdx
subq $0x8, %rsp
leaq 0x98(%rsp), %rbx
movsbl 0x38(%rsp), %eax
movsbl 0x30(%rsp), %r10d
movsbl 0x50(%rsp), %r11d
movsbl 0x48(%rsp), %r9d
leaq 0xd8(%rsp), %r8
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
pushq %rbx
pushq 0x30(%rsp)
pushq 0x78(%rsp)
pushq 0x90(%rsp)
pushq %rax
pushq %r10
pushq %r11
callq 0x1a42
addq $0x40, %rsp
leaq 0x9cc8(%rip), %rdi      # 0xb267
leaq 0x9cc7(%rip), %rsi      # 0xb26d
movq %rbx, %rdx
callq 0x20db
jmp 0x186d
testq %r13, %r13
je 0x186d
testq %rbx, %rbx
je 0x186d
movq %r13, %rdi
callq 0x2177
movq %rax, %rbp
movq %rbx, 0x78(%rsp)
movq %rbx, %rdi
callq 0x2177
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x10(%rsp)
movq %rbp, 0x18(%rsp)
movq %r13, 0x80(%rsp)
je 0x16c5
xorl %ecx, %ecx
movl 0x38(%rsp), %eax
testl %eax, %eax
cmovgl %eax, %ecx
movl %ecx, 0x10(%rsp)
movsbl 0x30(%rsp), %r12d
movsbl 0x28(%rsp), %ebx
movsbl 0x48(%rsp), %r13d
movsbl 0x40(%rsp), %r14d
leaq 0xd0(%rsp), %r15
movq %rbp, %rdi
callq 0x21bd
testl %eax, %eax
jle 0x1844
movq 0x8(%rsp), %rdi
callq 0x21bd
testl %eax, %eax
jle 0x1844
movl 0x10(%rsp), %ebp
subl $0x1, %ebp
jb 0x16a1
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rdx
movq 0x18(%rsp), %rax
movq 0x40(%rax), %rcx
subq $0x8, %rsp
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq %r15, %r8
movl %r14d, %r9d
leaq 0x98(%rsp), %rax
pushq %rax
pushq 0x30(%rsp)
pushq 0x78(%rsp)
pushq 0x90(%rsp)
pushq %r12
pushq %rbx
pushq %r13
callq 0x1a42
addq $0x40, %rsp
jmp 0x164e
movq 0x18(%rsp), %rbp
movq 0x10(%rbp), %rdi
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x90(%rsp), %rdx
callq 0x20db
jmp 0x1628
xorl %r12d, %r12d
pushq $0x8
popq %rbx
xorl %r15d, %r15d
movq $0x0, 0x10(%rsp)
movq %rbp, %rdi
callq 0x21bd
testl %eax, %eax
jle 0x1748
movl %r15d, %eax
cmpq %rax, %r12
jne 0x171a
movl %r15d, %ebp
sarl %ebp
addl %r15d, %ebp
testl %r15d, %r15d
pushq $0x10
popq %rax
cmovel %eax, %ebp
movslq %ebp, %rsi
shlq $0x4, %rsi
movq 0x10(%rsp), %rdi
callq 0x1110
movq %rax, %r14
movl %ebp, %r15d
movq 0x18(%rsp), %rbp
jmp 0x171f
movq 0x10(%rsp), %r14
incq %r12
movq 0x10(%rbp), %rdi
callq 0x1170
movq %rax, -0x8(%r14,%rbx)
movq 0x40(%rbp), %rdi
callq 0x1170
movq %r14, 0x10(%rsp)
movq %rax, (%r14,%rbx)
addq $0x10, %rbx
jmp 0x16d7
movq %r12, 0x38(%rsp)
movq 0x10(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movsbl 0x30(%rsp), %eax
movq %rax, 0x30(%rsp)
movsbl 0x28(%rsp), %eax
movq %rax, 0x28(%rsp)
movsbl 0x48(%rsp), %r15d
movsbl 0x40(%rsp), %r14d
movq 0x8(%rsp), %r13
movq 0x8(%rsp), %rdi
callq 0x21bd
movq 0x88(%rsp), %rbp
movq 0x38(%rsp), %rbx
testl %eax, %eax
jg 0x1801
jmp 0x180c
movq 0x40(%r13), %rdx
movq (%rbp), %rcx
subq $0x8, %rsp
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0xd8(%rsp), %r8
movl %r14d, %r9d
leaq 0x98(%rsp), %r12
pushq %r12
pushq 0x30(%rsp)
pushq 0x78(%rsp)
pushq 0x90(%rsp)
pushq 0x58(%rsp)
pushq 0x58(%rsp)
pushq %r15
callq 0x1a42
addq $0x40, %rsp
movq -0x8(%rbp), %rdi
movq 0x10(%r13), %rsi
movq %r12, %rdx
callq 0x20db
addq $0x10, %rbp
subq $0x1, %rbx
jae 0x17a0
jmp 0x1783
movq 0x10(%rsp), %r15
leaq 0x8(%r15), %rbx
movq 0x18(%rsp), %rbp
movq 0x38(%rsp), %r14
subq $0x1, %r14
jb 0x183c
movq -0x8(%rbx), %rdi
callq 0x1040
movq (%rbx), %rdi
callq 0x1040
addq $0x10, %rbx
jmp 0x181f
movq %r15, %rdi
callq 0x1040
movq %rbp, %rdi
callq 0x23b0
movq 0x8(%rsp), %rdi
callq 0x23b0
movq 0x80(%rsp), %rdi
callq 0x1030
movq 0x78(%rsp), %rdi
callq 0x1030
movq 0xc0(%rsp), %rsi
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x2768
movq %rbx, %rdi
callq 0x26f3
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xc753(%rip), %r14      # 0xdff8
movq (%r14), %rcx
leaq 0x97ac(%rip), %rdi      # 0xb05b
pushq $0x34
popq %rsi
pushq $0x1
popq %r15
movq %r15, %rdx
callq 0x1160
movq (%r14), %rcx
leaq 0x97c8(%rip), %rdi      # 0xb090
pushq $0x9
popq %rsi
movq %r15, %rdx
callq 0x1160
movq (%r14), %rdi
leaq 0x97bd(%rip), %rsi      # 0xb09a
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rcx
leaq 0x97fb(%rip), %rdi      # 0xb0ee
pushq $0x38
popq %rsi
movq %r15, %rdx
callq 0x1160
movq (%r14), %rcx
leaq 0x981f(%rip), %rdi      # 0xb127
pushq $0x21
popq %rsi
movq %r15, %rdx
callq 0x1160
movq (%r14), %rdi
leaq 0x982c(%rip), %rsi      # 0xb149
movq 0x60(%rsp), %rdx
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rcx
leaq 0x9833(%rip), %rdi      # 0xb166
pushq $0x24
popq %rsi
movq %r15, %rdx
callq 0x1160
movq (%r14), %rcx
leaq 0x9843(%rip), %rdi      # 0xb18b
pushq $0x1b
popq %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1160
movq (%r14), %rdi
movsbl 0x18(%rsp), %edx
leaq 0x9842(%rip), %rsi      # 0xb1a7
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rdi
movsbl 0x8(%rsp), %edx
leaq 0x984e(%rip), %rsi      # 0xb1c9
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rdi
movsbl 0x40(%rsp), %edx
movsbl 0x28(%rsp), %ecx
leaq 0x985a(%rip), %rsi      # 0xb1f0
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rdi
movsbl 0x48(%rsp), %edx
movsbl 0x30(%rsp), %ecx
leaq 0x9869(%rip), %rsi      # 0xb21a
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rcx
leaq 0x9887(%rip), %rdi      # 0xb249
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1160
pushq $0x1
popq %rax
jmp 0x188c