// File: /workspace/github_c_makefile_star2_O1/aokad[P]sequeeze/seqtk.c
// Function: stk_mask
void stk_mask(kseq_t *seq, const khash_t(reg) *h, int is_complement, int mask_chr)
{
	unsigned i, j;
	khiter_t k;
	k = kh_get(reg, h, seq->name.s);
	if (k == kh_end(h)) { // not found in the hash table
		if (is_complement) {
			if (mask_chr) {
				for (j = 0; j < seq->seq.l; ++j)
					seq->seq.s[j] = mask_chr;
			} else {
				for (j = 0; j < seq->seq.l; ++j)
					seq->seq.s[j] = tolower(seq->seq.s[j]);
			}
		}
	} else {
		reglist_t *p = &kh_val(h, k);
		if (!is_complement) {
			for (i = 0; i < p->n; ++i) {
				unsigned beg = p->a[i]>>32, end = p->a[i];
				if (beg >= seq->seq.l) continue;
				if (end > seq->seq.l) end = seq->seq.l;
				if (!mask_chr) for (j = beg; j < end; ++j) seq->seq.s[j] = tolower(seq->seq.s[j]);
				else for (j = beg; j < end; ++j) seq->seq.s[j] = mask_chr;
			}
		} else {
			int8_t *mask = calloc(seq->seq.l, 1);
			for (i = 0; i < p->n; ++i) {
				unsigned beg = p->a[i]>>32, end = p->a[i];
				if (end >= seq->seq.l) end = seq->seq.l;
				for (j = beg; j < end; ++j) mask[j] = 1;
			}
			if (mask_chr) {
				for (j = 0; j < seq->seq.l; ++j)
					if (mask[j] == 0) seq->seq.s[j] = mask_chr;
			} else {
				for (j = 0; j < seq->seq.l; ++j)
					if (mask[j] == 0) seq->seq.s[j] = tolower(seq->seq.s[j]);
			}
			free(mask);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq %rsi, 0x8(%rsp)
movl (%rsi), %eax
testl %eax, %eax
movl %ecx, (%rsp)
je 0x6f88
movq 0x10(%rbx), %rsi
leal -0x1(%rax), %edi
movsbl (%rsi), %r15d
testl %r15d, %r15d
movl %edx, 0x4(%rsp)
movq %rax, 0x18(%rsp)
je 0x6f92
movb 0x1(%rsi), %al
testb %al, %al
je 0x6f95
leaq 0x2(%rsi), %rcx
movl %r15d, %edx
shll $0x5, %edx
subl %r15d, %edx
movsbl %al, %r15d
addl %edx, %r15d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x6f6d
jmp 0x6f95
movl %ecx, %ebp
xorl %r12d, %r12d
jmp 0x704a
xorl %r15d, %r15d
movl %r15d, %edx
andl %edi, %edx
movl %r15d, %eax
shrl $0x3, %eax
shll $0x3, %r15d
xorl %eax, %r15d
orl $0x1, %r15d
andl %edi, %r15d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %r8
movl %edx, %r12d
movq %rbx, 0x20(%rsp)
movl %edi, 0x14(%rsp)
movl %edx, 0x10(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %r14d
leal (%r12,%r12), %r13d
andl $0x1e, %r13d
movl %r14d, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x7030
testb $0x1, %al
jne 0x701b
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rsi, %rbp
movq %r8, %rbx
callq 0x2170
movq %rbx, %r8
movl 0x10(%rsp), %edx
movl 0x14(%rsp), %edi
movq 0x20(%rsp), %rbx
movq %rbp, %rsi
testl %eax, %eax
je 0x7030
addl %r15d, %r12d
andl %edi, %r12d
cmpl %edx, %r12d
jne 0x6fc7
movq 0x18(%rsp), %rax
movl %eax, %r12d
jmp 0x7043
movl %r13d, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x18(%rsp), %rax
cmovnel %eax, %r12d
movl (%rsp), %ebp
movl 0x4(%rsp), %edx
cmpl %eax, %r12d
jne 0x708a
testl %edx, %edx
je 0x71ed
movq 0x30(%rbx), %rax
testl %ebp, %ebp
je 0x71bd
testq %rax, %rax
je 0x71ed
movl $0x1, %eax
xorl %ecx, %ecx
movq 0x40(%rbx), %rdx
movb %bpl, (%rdx,%rcx)
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x30(%rbx)
ja 0x7073
jmp 0x71ed
movl %r12d, %r12d
shlq $0x4, %r12
movq 0x8(%rsp), %rax
addq 0x20(%rax), %r12
testl %edx, %edx
je 0x7138
movq 0x30(%rbx), %r15
movl $0x1, %esi
movq %r15, %rdi
callq 0x2160
movq %rax, %r14
movl (%r12), %r13d
testq %r13, %r13
je 0x70fb
movq 0x8(%r12), %r12
xorl %ebp, %ebp
movq (%r12,%rbp,8), %rdx
movq %rdx, %rax
shrq $0x20, %rax
movl %edx, %ecx
cmpq %r15, %rcx
cmovaeq %r15, %rdx
cmpl %edx, %eax
jae 0x70f3
leaq (%r14,%rax), %rdi
notl %eax
addl %eax, %edx
incq %rdx
movl $0x1, %esi
callq 0x2120
incq %rbp
cmpq %rbp, %r13
jne 0x70c6
movq 0x30(%rbx), %rax
movl (%rsp), %esi
testl %esi, %esi
je 0x71fc
testq %rax, %rax
je 0x7233
movl $0x1, %eax
xorl %ecx, %ecx
cmpb $0x0, (%r14,%rcx)
jne 0x7129
movq 0x40(%rbx), %rdx
movb %sil, (%rdx,%rcx)
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x30(%rbx)
ja 0x711a
jmp 0x7233
cmpl $0x0, (%r12)
je 0x71ed
xorl %r14d, %r14d
movq 0x8(%r12), %rax
movq (%rax,%r14,8), %r13
movq %r13, %r15
shrq $0x20, %r15
movq 0x30(%rbx), %rax
cmpq %rax, %r15
jae 0x71af
movl %r13d, %ecx
cmpq %rax, %rcx
cmovaq %rax, %r13
testl %ebp, %ebp
je 0x7187
cmpl %r13d, %r15d
jae 0x71af
movl %r13d, %eax
movq 0x40(%rbx), %rcx
movb %bpl, (%rcx,%r15)
incq %r15
cmpq %r15, %rax
jne 0x7175
jmp 0x71af
cmpl %r13d, %r15d
jae 0x71af
callq 0x2280
movl %r13d, %ecx
movq (%rax), %rdx
movq 0x40(%rbx), %rsi
movsbq (%rsi,%r15), %rdi
movb (%rdx,%rdi,4), %dl
movb %dl, (%rsi,%r15)
incq %r15
cmpq %r15, %rcx
jne 0x7194
incq %r14
movl (%r12), %eax
cmpq %rax, %r14
jb 0x7146
jmp 0x71ed
testq %rax, %rax
je 0x71ed
movl $0x1, %ebp
xorl %r14d, %r14d
callq 0x2280
movq (%rax), %rcx
movq 0x40(%rbx), %rdx
movsbq (%rdx,%r14), %rsi
movb (%rcx,%rsi,4), %cl
movb %cl, (%rdx,%r14)
movl %ebp, %r14d
incl %ebp
cmpq %r14, 0x30(%rbx)
ja 0x71cf
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rax, %rax
je 0x7233
movl $0x1, %ebp
xorl %r15d, %r15d
cmpb $0x0, (%r14,%r15)
jne 0x7228
callq 0x2280
movq (%rax), %rax
movq 0x40(%rbx), %rcx
movsbq (%rcx,%r15), %rdx
movb (%rax,%rdx,4), %al
movb %al, (%rcx,%r15)
movl %ebp, %r15d
incl %ebp
cmpq %r15, 0x30(%rbx)
ja 0x7209
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050