// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %rdx, %r14
movq %rsi, %r15
orl $-0x1, (%rdx)
movq %rdi, %rbx
orl $-0x1, (%rsi)
callq 0x2150
movq %rax, %r13
movl %r13d, %eax
leal -0x1(%r13), %ecx
movslq %ecx, %r12
incq %r12
decq %rax
testl %r12d, %r12d
jle 0x726a
movl %eax, %ecx
decq %r12
decq %rax
cmpb $0x3a, (%rbx,%rcx)
jne 0x7138
cmpl %r13d, %r12d
jge 0x71c6
movq %r15, -0x48(%rbp)
movq %r14, -0x50(%rbp)
movq %r13, -0x40(%rbp)
movslq %r13d, %r14
movl $0x0, -0x2c(%rbp)
movq %r12, %r15
incq %r15
movq %r15, %rcx
movq %rcx, %r15
cmpq %r14, %rcx
jge 0x71ab
movsbq (%rbx,%r15), %r13
cmpq $0x2d, %r13
je 0x71a6
callq 0x2420
leaq 0x1(%r15), %rcx
cmpb $0x2c, %r13b
je 0x7173
movq (%rax), %rax
movzwl (%rax,%r13,2), %eax
andl $0x800, %eax            # imm = 0x800
jne 0x7173
jmp 0x71ab
incl -0x2c(%rbp)
jmp 0x716d
cmpl $0x2, -0x2c(%rbp)
movq -0x40(%rbp), %r13
cmovael %r13d, %r12d
cmpq %r14, %r15
cmovll %r13d, %r12d
movq -0x50(%rbp), %r14
movq -0x48(%rbp), %r15
cmpl %r13d, %r12d
jge 0x7262
movl %r13d, %eax
subl %r12d, %eax
incl %eax
cltq
addq $0xf, %rax
andq $-0x10, %rax
movq %rsp, %rdi
subq %rax, %rdi
movq %rdi, %rsp
movq %rdi, -0x38(%rbp)
movslq %r12d, %rcx
movslq %r13d, %rax
xorl %edx, %edx
movq %rcx, %r8
leaq 0x1(%r8), %rcx
movl %edx, %esi
cmpq %rax, %rcx
jge 0x721a
movb 0x1(%rbx,%r8), %r9b
movq %rcx, %r8
cmpb $0x2c, %r9b
je 0x71f9
incl %edx
movb %r9b, (%rdi,%rsi)
jmp 0x71f6
movb $0x0, (%rdi,%rsi)
leaq -0x38(%rbp), %rsi
pushq $0xa
popq %rdx
callq 0x2230
decl %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
movl %ecx, (%r15)
leaq -0x38(%rbp), %rax
movq (%rax), %rdi
cmpb $0x0, (%rdi)
je 0x7253
incq %rdi
leaq -0x38(%rbp), %rsi
pushq $0xa
popq %rdx
callq 0x2230
jmp 0x7258
movl $0x20000000, %eax       # imm = 0x20000000
movl %eax, (%r14)
cmpl %eax, (%r15)
cmovgl %r13d, %r12d
cmpl %r13d, %r12d
movl %r12d, %r13d
jne 0x7278
andl $0x0, (%r15)
movl $0x20000000, (%r14)     # imm = 0x20000000
movl %r13d, %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