// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, (%rdx)
movl %eax, (%rsi)
callq 0x2150
movq %rbx, %rdx
movq %rax, %rsi
movl %esi, %eax
decq %rax
movl %esi, %r12d
testl %r12d, %r12d
jle 0x7f58
movl %eax, %ecx
decl %r12d
decq %rax
cmpb $0x3a, (%rdx,%rcx)
jne 0x7f43
jmp 0x7f5b
movl %esi, %r12d
cmpl %esi, %r12d
movq %rdx, -0x40(%rbp)
jge 0x800d
leal 0x1(%r12), %eax
cmpl %esi, %eax
setl %r13b
jge 0x8005
movq %r14, -0x58(%rbp)
movq %r15, -0x60(%rbp)
movslq %r12d, %r15
movslq %esi, %rax
addq $0x2, %r15
movl %r12d, %r14d
notl %r14d
movq %rsi, -0x38(%rbp)
addl %esi, %r14d
xorl %ecx, %ecx
movq %rax, -0x48(%rbp)
movsbq -0x1(%rdx,%r15), %rbx
cmpq $0x2d, %rbx
jne 0x7fae
incl %ecx
jmp 0x7fe1
movl %ecx, -0x2c(%rbp)
callq 0x2410
cmpb $0x2c, %bl
je 0x7fd6
movq (%rax), %rax
movzwl (%rax,%rbx,2), %eax
andl $0x800, %eax            # imm = 0x800
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rax
movl -0x2c(%rbp), %ecx
jne 0x7fe1
jmp 0x7ff0
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rax
movl -0x2c(%rbp), %ecx
cmpq %rax, %r15
setl %r13b
incq %r15
decl %r14d
jne 0x7f9e
cmpl $0x2, %ecx
setge %al
orb %al, %r13b
movq -0x60(%rbp), %r15
movq -0x58(%rbp), %r14
movq -0x38(%rbp), %rsi
testb $0x1, %r13b
cmovnel %esi, %r12d
movl %esi, %eax
subl %r12d, %eax
jle 0x80ca
movq %r14, %rbx
leal 0x1(%rax), %ecx
movslq %ecx, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, %rsp
movq %rdi, -0x50(%rbp)
leal 0x1(%r12), %ecx
xorl %r14d, %r14d
movq %rsi, -0x38(%rbp)
cmpl %esi, %ecx
jge 0x8072
movslq %r12d, %rcx
addq %rdx, %rcx
movl $0x1, %edx
xorl %esi, %esi
movb (%rcx,%rdx), %r8b
cmpb $0x2c, %r8b
je 0x8066
movslq %esi, %r9
incl %esi
movb %r8b, (%rdi,%r9)
incq %rdx
cmpl %edx, %eax
jne 0x8053
movslq %esi, %rax
jmp 0x8074
xorl %eax, %eax
movb $0x0, (%rdi,%rax)
leaq -0x50(%rbp), %r13
movq %r13, %rsi
movl $0xa, %edx
callq 0x2230
decl %eax
testl %eax, %eax
cmovgl %eax, %r14d
movl %r14d, (%rbx)
movq %rbx, %r14
movq (%r13), %rdi
cmpb $0x0, (%rdi)
je 0x80b3
incq %rdi
leaq -0x50(%rbp), %rsi
movl $0xa, %edx
callq 0x2230
jmp 0x80b8
movl $0x20000000, %eax       # imm = 0x20000000
movq -0x38(%rbp), %rsi
movl %eax, (%r15)
cmpl %eax, (%r14)
cmovgl %esi, %r12d
movq -0x40(%rbp), %rdx
cmpl %esi, %r12d
jne 0x80dd
movl $0x0, (%r14)
movl $0x20000000, (%r15)     # imm = 0x20000000
movslq %r12d, %rax
addq %rax, %rdx
movq %rdx, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq