// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %rsi, 0x18(%rsp)
movl (%rsi), %r8d
testl %r8d, %r8d
movq %rdi, 0x8(%rsp)
movl %ecx, 0x4(%rsp)
movl %edx, 0x14(%rsp)
je 0x7294
movq 0x10(%rdi), %r14
leal -0x1(%r8), %ebp
movsbl (%r14), %r15d
testl %r15d, %r15d
movq %r8, 0x28(%rsp)
je 0x729c
movb 0x1(%r14), %al
testb %al, %al
je 0x729f
leaq 0x2(%r14), %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 0x7279
jmp 0x729f
xorl %r12d, %r12d
jmp 0x7330
xorl %r15d, %r15d
movl %r15d, %edx
andl %ebp, %edx
movl %r15d, %eax
shrl $0x3, %eax
shll $0x3, %r15d
xorl %eax, %r15d
orl $0x1, %r15d
andl %ebp, %r15d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdi
movl %edx, %r12d
movl %edx, 0x24(%rsp)
movq %rdi, 0x30(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %ebx
leal (%r12,%r12), %r13d
andl $0x1e, %r13d
movl %ebx, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x731f
testb $0x1, %al
jne 0x7312
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r14, %rsi
callq 0x2170
movq 0x30(%rsp), %rdi
movl 0x24(%rsp), %edx
testl %eax, %eax
je 0x731f
addl %r15d, %r12d
andl %ebp, %r12d
cmpl %edx, %r12d
jne 0x72cd
jmp 0x7335
movl %r13d, %ecx
shrl %cl, %ebx
testb $0x3, %bl
movq 0x28(%rsp), %r8
cmovnel %r8d, %r12d
cmpl %r8d, %r12d
jne 0x737c
cmpl $0x0, 0x14(%rsp)
movq 0x8(%rsp), %r15
movl 0x4(%rsp), %esi
je 0x74f5
movq 0x30(%r15), %rax
testl %esi, %esi
je 0x7437
testq %rax, %rax
je 0x74f5
movl $0x1, %eax
xorl %ecx, %ecx
movq 0x40(%r15), %rdx
movb %sil, (%rdx,%rcx)
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x30(%r15)
ja 0x7365
jmp 0x74f5
movl %r12d, %r12d
shlq $0x4, %r12
movq 0x18(%rsp), %rax
addq 0x20(%rax), %r12
cmpl $0x0, 0x14(%rsp)
je 0x7470
movq 0x8(%rsp), %rax
movq 0x30(%rax), %r15
movl $0x1, %esi
movq %r15, %rdi
callq 0x2160
movq %rax, %r14
movl (%r12), %r13d
testq %r13, %r13
je 0x73f5
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 0x73ed
leaq (%r14,%rax), %rdi
notl %eax
addl %eax, %edx
incq %rdx
movl $0x1, %esi
callq 0x2120
incq %rbp
cmpq %rbp, %r13
jne 0x73c0
movl 0x4(%rsp), %edi
testl %edi, %edi
je 0x7504
testq %r15, %r15
movq 0x8(%rsp), %rsi
je 0x7543
movl $0x1, %eax
xorl %ecx, %ecx
cmpb $0x0, (%r14,%rcx)
jne 0x7429
movq 0x40(%rsi), %rdx
movb %dil, (%rdx,%rcx)
movq 0x30(%rsi), %r15
movl %eax, %ecx
incl %eax
cmpq %rcx, %r15
ja 0x7416
jmp 0x7543
testq %rax, %rax
je 0x74f5
movl $0x1, %ebx
xorl %r14d, %r14d
callq 0x2280
movq (%rax), %rcx
movq 0x40(%r15), %rdx
movsbq (%rdx,%r14), %rsi
movb (%rcx,%rsi,4), %cl
movb %cl, (%rdx,%r14)
movl %ebx, %r14d
incl %ebx
cmpq %r14, 0x30(%r15)
ja 0x744d
jmp 0x74f5
cmpl $0x0, (%r12)
movq 0x8(%rsp), %r13
movl 0x4(%rsp), %ebp
je 0x74f5
xorl %r14d, %r14d
movq 0x8(%r12), %rax
movq (%rax,%r14,8), %rbx
movq %rbx, %r15
shrq $0x20, %r15
movq 0x30(%r13), %rax
cmpq %rax, %r15
jae 0x74e9
movl %ebx, %ecx
cmpq %rax, %rcx
cmovaq %rax, %rbx
testl %ebp, %ebp
je 0x74c2
cmpl %ebx, %r15d
jae 0x74e9
movl %ebx, %eax
movq 0x40(%r13), %rcx
movb %bpl, (%rcx,%r15)
incq %r15
cmpq %r15, %rax
jne 0x74b0
jmp 0x74e9
cmpl %ebx, %r15d
jae 0x74e9
callq 0x2280
movl %ebx, %ecx
movq (%rax), %rdx
movq 0x40(%r13), %rsi
movsbq (%rsi,%r15), %rdi
movb (%rdx,%rdi,4), %dl
movb %dl, (%rsi,%r15)
incq %r15
cmpq %r15, %rcx
jne 0x74ce
incq %r14
movl (%r12), %eax
cmpq %rax, %r14
jb 0x7483
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r15, %r15
movq 0x8(%rsp), %r13
je 0x7543
movl $0x1, %ebx
xorl %r12d, %r12d
cmpb $0x0, (%r14,%r12)
jne 0x7539
callq 0x2280
movq (%rax), %rax
movq 0x40(%r13), %rcx
movsbq (%rcx,%r12), %rdx
movb (%rax,%rdx,4), %al
movb %al, (%rcx,%r12)
movq 0x30(%r13), %r15
movl %ebx, %r12d
incl %ebx
cmpq %r12, %r15
ja 0x7516
movq %r14, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050