// File: /workspace/github_c_makefile_star2_O2/aokad[P]sequeeze/seqtk.c
// Function: stk_famask
int stk_famask(int argc, char *argv[])
{
	gzFile fp[2];
	kseq_t *seq[2];
	int i, l, c;
	while ((c = getopt(argc, argv, "")) >= 0);
	if (argc - optind < 2) {
		fprintf(stderr, "Usage: seqtk famask <src.fa> <mask.fa>\n");
		return 1;
	}
	for (i = 0; i < 2; ++i) {
		fp[i] = strcmp(argv[optind+i], "-")? gzopen(argv[optind+i], "r") : gzdopen(fileno(stdin), "r");
		seq[i] = kseq_init(fp[i]);
	}
	if (fp[0] == 0 || fp[1] == 0) {
		fprintf(stderr, "[E::%s] failed to open the input file/stream.\n", __func__);
		return 1;
	}
	while (kseq_read(seq[0]) >= 0) {
		int min_l, c[2];
		kseq_read(seq[1]);
		if (strcmp(seq[0]->name.s, seq[1]->name.s))
			fprintf(stderr, "[%s] Different sequence names: %s != %s\n", __func__, seq[0]->name.s, seq[1]->name.s);
		if (seq[0]->seq.l != seq[1]->seq.l)
			fprintf(stderr, "[%s] Unequal sequence length: %ld != %ld\n", __func__, seq[0]->seq.l, seq[1]->seq.l);
		min_l = seq[0]->seq.l < seq[1]->seq.l? seq[0]->seq.l : seq[1]->seq.l;
		printf(">%s", seq[0]->name.s);
		for (l = 0; l < min_l; ++l) {
			c[0] = seq[0]->seq.s[l]; c[1] = seq[1]->seq.s[l];
			if (c[1] == 'x') c[0] = tolower(c[0]);
			else if (c[1] != 'X') c[0] = c[1];
			if (l%60 == 0) putchar('\n');
			putchar(c[0]);
		}
		putchar('\n');
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x4fea(%rip), %r14      # 0x96fe
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2240
testl %eax, %eax
jns 0x4714
movq 0x98a4(%rip), %r15      # 0xdfd0
subl (%r15), %ebp
cmpl $0x2, %ebp
jl 0x48ef
xorl %r12d, %r12d
movq 0x9886(%rip), %r13      # 0xdfc8
leaq 0x4a5f(%rip), %r14      # 0x91a8
cmpq $0x2, %r12
je 0x4798
movslq (%r15), %rax
addq %r12, %rax
movq (%rbx,%rax,8), %rdi
cmpb $0x2d, (%rdi)
jne 0x4764
cmpb $0x0, 0x1(%rdi)
je 0x4783
movq %r14, %rsi
callq 0x2220
movq %rax, 0x20(%rsp,%r12,8)
movq %rax, %rdi
callq 0x3102
movq %rax, 0x10(%rsp,%r12,8)
incq %r12
jmp 0x4749
movq (%r13), %rdi
callq 0x21b0
movl %eax, %edi
movq %r14, %rsi
callq 0x20b0
jmp 0x476c
cmpq $0x0, 0x20(%rsp)
je 0x490d
cmpq $0x0, 0x28(%rsp)
je 0x490d
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r15
movq $0x0, 0x8(%rsp)
movq %r14, %rdi
callq 0x312e
testl %eax, %eax
js 0x4934
movq %r15, %rdi
callq 0x312e
movq 0x10(%r14), %rbx
movq 0x10(%r15), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2170
testl %eax, %eax
jne 0x4896
movq 0x30(%r14), %r13
movq 0x30(%r15), %r8
cmpq %r8, %r13
jne 0x48c0
movq %r13, %rax
cmpq %r13, %rax
cmovbq %rax, %r13
movq 0x10(%r14), %rsi
leaq 0x4c88(%rip), %rdi      # 0x94a4
xorl %eax, %eax
callq 0x20f0
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
xorl %r12d, %r12d
movl %r12d, %eax
xorl %edx, %edx
pushq $0x3c
popq %rcx
divl %ecx
cmpq %r12, %r13
je 0x4889
movl %eax, %ebp
movq 0x40(%r14), %rax
movsbl (%rax,%r12), %ebx
movq 0x40(%r15), %rax
movzbl (%rax,%r12), %eax
cmpl $0x58, %eax
je 0x486d
cmpl $0x78, %eax
jne 0x486a
movl %ebx, %edi
callq 0x21c0
movl %eax, %ebx
jmp 0x486d
movsbl %al, %ebx
imull $-0x3c, %ebp, %eax
addl %r12d, %eax
jne 0x487d
pushq $0xa
popq %rdi
callq 0x2060
movl %ebx, %edi
callq 0x2060
incq %r12
jmp 0x4832
pushq $0xa
popq %rdi
callq 0x2060
jmp 0x47c3
movq 0x975b(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4fcd(%rip), %rsi      # 0x9874
leaq 0x5081(%rip), %rdx      # 0x992f
movq %rbx, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x2190
jmp 0x47f6
movq 0x9731(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4fcc(%rip), %rsi      # 0x989d
leaq 0x5057(%rip), %rdx      # 0x992f
movq %r13, %rcx
xorl %eax, %eax
callq 0x2190
movq 0x30(%r14), %rax
movq 0x30(%r15), %r13
jmp 0x480a
movq 0x9702(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x5007(%rip), %rdi      # 0x9907
pushq $0x27
popq %rsi
pushq $0x1
popq %rdx
callq 0x2260
jmp 0x492c
movq 0x96e4(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4a83(%rip), %rsi      # 0x93a1
leaq 0x500a(%rip), %rdx      # 0x992f
xorl %eax, %eax
callq 0x2190
pushq $0x1
popq %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq