// File: /workspace/github_c_makefile_star2_O3/DReichLab[P]adna/hts.c
// Function: hts_parse_reg
const char *hts_parse_reg(const char *s, int *beg, int *end)
{
	int i, k, l, name_end;
	*beg = *end = -1;
	name_end = l = strlen(s);
	// determine the sequence name
	for (i = l - 1; i >= 0; --i) if (s[i] == ':') break; // look for colon from the end
	if (i >= 0) name_end = i;
	if (name_end < l) { // check if this is really the end
		int n_hyphen = 0;
		for (i = name_end + 1; i < l; ++i) {
			if (s[i] == '-') ++n_hyphen;
			else if (!isdigit(s[i]) && s[i] != ',') break;
		}
		if (i < l || n_hyphen > 1) name_end = l; // malformated region string; then take str as the name
	}
	// parse the interval
	if (name_end < l) {
		char *tmp;
		tmp = (char*)alloca(l - name_end + 1);
		for (i = name_end + 1, k = 0; i < l; ++i)
			if (s[i] != ',') tmp[k++] = s[i];
		tmp[k] = 0;
		if ((*beg = strtol(tmp, &tmp, 10) - 1) < 0) *beg = 0;
		*end = *tmp? strtol(tmp + 1, &tmp, 10) : 1<<29;
		if (*beg > *end) name_end = l;
	}
	if (name_end == l) *beg = 0, *end = 1<<29;
	return s + name_end;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %rbx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, (%rdx)
movl %eax, (%rsi)
callq 0x2150
movq %rax, %r12
movl %r12d, %eax
decq %rax
xorl %r14d, %r14d
movq %r12, -0x30(%rbp)
testl %r12d, %r12d
jle 0x8297
leal (%rax,%r14), %ecx
decq %r14
decl %r12d
cmpb $0x3a, (%rbx,%rcx)
jne 0x814f
movq -0x30(%rbp), %rdx
cmpl %edx, %r12d
setl %al
leal 0x1(%r12), %ecx
cmpl %edx, %ecx
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x8239
movq %r13, -0x60(%rbp)
movq %r15, -0x68(%rbp)
movslq %edx, %rcx
leal -0x1(%rdx), %eax
movslq %eax, %rdx
leaq (%rdx,%rbx), %rdi
addq $0x2, %rdi
addq $0x3, %rdx
xorl %esi, %esi
movb $0x1, %r15b
movq %rbx, -0x58(%rbp)
movq %rdx, -0x50(%rbp)
movq %rdi, -0x48(%rbp)
movsbq (%rdi,%r14), %r13
cmpq $0x2d, %r13
jne 0x81c4
incl %esi
jmp 0x820a
movl %esi, -0x34(%rbp)
movq %rcx, %rbx
callq 0x2410
cmpb $0x2c, %r13b
je 0x81f8
movq (%rax), %rax
movzwl (%rax,%r13,2), %eax
andl $0x800, %eax            # imm = 0x800
movq %rbx, %rcx
movq -0x58(%rbp), %rbx
movq -0x50(%rbp), %rdx
movl -0x34(%rbp), %esi
movq -0x48(%rbp), %rdi
jne 0x820a
jmp 0x821e
movq %rbx, %rcx
movq -0x58(%rbp), %rbx
movq -0x50(%rbp), %rdx
movl -0x34(%rbp), %esi
movq -0x48(%rbp), %rdi
leaq (%rdx,%r14), %rax
cmpq %rcx, %rax
setl %r15b
incq %r14
cmpl $-0x1, %r14d
jne 0x81b5
cmpl $0x2, %esi
movq -0x30(%rbp), %rdx
cmovgel %edx, %r12d
testb $0x1, %r15b
cmovnel %edx, %r12d
movq -0x68(%rbp), %r15
movq -0x60(%rbp), %r13
movl %edx, %eax
subl %r12d, %eax
jle 0x82f0
leal 0x1(%rax), %ecx
movslq %ecx, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, %rsp
movq %rdi, -0x40(%rbp)
leal 0x1(%r12), %ecx
xorl %r14d, %r14d
cmpl %edx, %ecx
jge 0x829d
movslq %r12d, %rcx
addq %rbx, %rcx
movl $0x1, %edx
xorl %esi, %esi
movb (%rcx,%rdx), %r8b
cmpb $0x2c, %r8b
je 0x828b
movslq %esi, %r9
incl %esi
movb %r8b, (%rdi,%r9)
incq %rdx
cmpl %edx, %eax
jne 0x8278
movslq %esi, %rax
jmp 0x829f
movq -0x30(%rbp), %rax
jmp 0x82f8
xorl %eax, %eax
movb $0x0, (%rdi,%rax)
leaq -0x40(%rbp), %rsi
movl $0xa, %edx
callq 0x2230
decl %eax
testl %eax, %eax
cmovgl %eax, %r14d
movl %r14d, (%r13)
leaq -0x40(%rbp), %rax
movq (%rax), %rdi
cmpb $0x0, (%rdi)
je 0x82dc
incq %rdi
leaq -0x40(%rbp), %rsi
movl $0xa, %edx
callq 0x2230
jmp 0x82e1
movl $0x20000000, %eax       # imm = 0x20000000
movq -0x30(%rbp), %rdx
movl %eax, (%r15)
cmpl %eax, (%r13)
cmovgl %edx, %r12d
cmpl %edx, %r12d
movl %r12d, %eax
jne 0x830a
movl $0x0, (%r13)
movl $0x20000000, (%r15)     # imm = 0x20000000
movl %eax, %r12d
movslq %r12d, %rax
addq %rax, %rbx
movq %rbx, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq