// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/htslib/tbx.c
// Function: tbx_parse1
int tbx_parse1(const tbx_conf_t *conf, int len, char *line, tbx_intv_t *intv)
{
    int i, b = 0, id = 1, ncols = 0;
    char *s;
    intv->ss = intv->se = 0; intv->beg = intv->end = -1;
    for (i = 0; i <= len; ++i) {
        if (line[i] == '\t' || line[i] == 0) {
            ++ncols;
            if (id == conf->sc) {
                intv->ss = line + b; intv->se = line + i;
            } else if (id == conf->bc) {
                // here ->beg is 0-based.
                intv->beg = intv->end = strtol(line + b, &s, 0);
                if ( s==line+b ) return -1; // expected int
                if (!(conf->preset&TBX_UCSC)) --intv->beg;
                else ++intv->end;
                if (intv->beg < 0) intv->beg = 0;
                if (intv->end < 1) intv->end = 1;
            } else {
                if ((conf->preset&0xffff) == TBX_GENERIC) {
                    if (id == conf->ec)
                    {
                        intv->end = strtol(line + b, &s, 0);
                        if ( s==line+b ) return -1; // expected int
                    }
                } else if ((conf->preset&0xffff) == TBX_SAM) {
                    if (id == 6) { // CIGAR
                        int l = 0, op;
                        char *t;
                        for (s = line + b; s < line + i;) {
                            long x = strtol(s, &t, 10);
                            op = toupper(*t);
                            if (op == 'M' || op == 'D' || op == 'N') l += x;
                            s = t + 1;
                        }
                        if (l == 0) l = 1;
                        intv->end = intv->beg + l;
                    }
                } else if ((conf->preset&0xffff) == TBX_VCF) {
                    if (id == 4) {
                        if (b < i) intv->end = intv->beg + (i - b);
                    } else if (id == 8) { // look for "END="
                        int c = line[i];
                        line[i] = 0;
                        s = strstr(line + b, "END=");
                        if (s == line + b) s += 4;
                        else if (s) {
                            s = strstr(line + b, ";END=");
                            if (s) s += 5;
                        }
                        if (s) intv->end = strtol(s, &s, 0);
                        line[i] = c;
                    }
                }
            }
            b = i + 1;
            ++id;
        }
    }
    if (intv->ss == 0 || intv->se == 0 || intv->beg < 0 || intv->end < 0) return -1;
    return 0;
}

// Assembly:
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rcx)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rcx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %esi, %esi
js 0x52c17
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
leaq 0x10(%rcx), %rax
movq %rax, 0x20(%rsp)
incl %esi
movl $0x1, %r12d
xorl %r13d, %r13d
xorl %eax, %eax
movq %rcx, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
movzbl (%r15,%r13), %ebp
testl %ebp, %ebp
je 0x529a3
cmpl $0x9, %ebp
jne 0x52a07
leaq (%r15,%r13), %r14
cmpl 0x4(%rdi), %r12d
jne 0x529bf
cltq
addq %r15, %rax
movq %rax, 0x10(%rcx)
movq %r14, 0x18(%rcx)
jmp 0x52bcb
cmpl 0x8(%rdi), %r12d
jne 0x52a0f
movq %rcx, %r14
movslq %eax, %rbx
addq %r15, %rbx
movq %rbx, %rdi
movq %rsp, %rsi
xorl %edx, %edx
callq 0x6a60
movq %rax, 0x8(%r14)
movq %rax, (%r14)
cmpq %rbx, (%rsp)
je 0x52c04
movq 0x18(%rsp), %rdi
testb $0x1, 0x2(%rdi)
jne 0x52a70
movq %rax, %rdx
decq %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
jmp 0x52a7f
incq %r13
jmp 0x52bd4
movzwl (%rdi), %edx
cmpl $0x2, %edx
je 0x52b29
cmpl $0x1, %edx
je 0x52aa6
testl %edx, %edx
jne 0x52bcb
cmpl 0xc(%rdi), %r12d
jne 0x52bcb
movslq %eax, %rbx
addq %r15, %rbx
movq %rbx, %rdi
movq %rsp, %rsi
xorl %edx, %edx
callq 0x6a60
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx)
cmpq %rbx, (%rsp)
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rcx
jne 0x52bcb
jmp 0x52c04
movq %rax, %rdx
incq %rdx
movq 0x8(%rsp), %rcx
movq %rdx, 0x8(%rcx)
movq 0x10(%rsp), %rsi
testq %rax, %rax
jns 0x52a90
movq $0x0, (%rcx)
testq %rdx, %rdx
jg 0x52bcb
movq $0x1, 0x8(%rcx)
jmp 0x52bcb
cmpl $0x6, %r12d
jne 0x52bcb
cltq
leaq (%r15,%rax), %rbx
xorl %ebp, %ebp
cmpq %rax, %r13
jle 0x52b0b
xorl %ebp, %ebp
callq 0x6100
movq %rax, 0x28(%rsp)
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movl $0xa, %edx
callq 0x6a60
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rsp), %rbx
movsbq (%rbx), %rdx
movl (%rcx,%rdx,4), %ecx
addl $-0x44, %ecx
cmpl $0xa, %ecx
ja 0x52b03
movl $0x601, %edx            # imm = 0x601
btl %ecx, %edx
jae 0x52b03
addl %eax, %ebp
incq %rbx
cmpq %r14, %rbx
jb 0x52ac9
movq %rbx, (%rsp)
cmpl $0x1, %ebp
adcl $0x0, %ebp
movslq %ebp, %rax
movq 0x8(%rsp), %rcx
addq (%rcx), %rax
movq %rax, 0x8(%rcx)
jmp 0x52bc1
cmpl $0x8, %r12d
je 0x52b56
cmpl $0x4, %r12d
jne 0x52bcb
movslq %eax, %rdx
cmpq %rdx, %r13
jle 0x52bcb
movl %r13d, %edx
subl %eax, %edx
movslq %edx, %rax
addq (%rcx), %rax
movq %rax, 0x8(%rcx)
jmp 0x52bcb
movb $0x0, (%r14)
movslq %eax, %rbx
addq %r15, %rbx
movq %rbx, %rdi
leaq 0x45d31(%rip), %rsi     # 0x9889b
callq 0x6180
movq %rax, (%rsp)
cmpq %rbx, %rax
je 0x52b9b
testq %rax, %rax
je 0x52bb9
movq %rbx, %rdi
leaq 0x45d13(%rip), %rsi     # 0x9889a
callq 0x6180
movq %rax, (%rsp)
testq %rax, %rax
je 0x52bb9
addq $0x5, %rax
jmp 0x52b9f
addq $0x4, %rax
movq %rax, (%rsp)
movq %rax, %rdi
movq %rsp, %rsi
xorl %edx, %edx
callq 0x6a60
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx)
movb %bpl, (%r14)
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdi
incq %r13
incl %r12d
movl %r13d, %eax
cmpq %rsi, %r13
jne 0x52995
movq 0x20(%rsp), %rax
cmpq $0x0, (%rax)
je 0x52c04
cmpq $0x0, 0x18(%rcx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
je 0x52c09
cmpq $0x0, (%rcx)
js 0x52c09
movq 0x8(%rcx), %rax
sarq $0x3f, %rax
jmp 0x52c09
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq