// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %rbx
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rcx)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rcx)
testl %esi, %esi
js 0x52977
movq %rdx, %r14
incl %esi
movl $0x1, %r15d
xorl %r12d, %r12d
xorl %eax, %eax
movq %rsi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movzbl (%r14,%r12), %r13d
cmpl $0x9, %r13d
je 0x52736
testl %r13d, %r13d
jne 0x5296b
leaq (%r14,%r12), %rbp
cmpl 0x4(%rdi), %r15d
jne 0x52752
cltq
addq %r14, %rax
movq %rax, 0x10(%rbx)
movq %rbp, 0x18(%rbx)
jmp 0x52963
cmpl 0x8(%rdi), %r15d
jne 0x527d0
movslq %eax, %r13
addq %r14, %r13
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x6a60
movq %rax, 0x8(%rbx)
movq %rax, (%rbx)
cmpq %r13, 0x8(%rsp)
je 0x5299d
movq 0x10(%rsp), %rdi
movl (%rdi), %ecx
movl $0x10000, %edx          # imm = 0x10000
andl %edx, %ecx
cmpl $0x1, %ecx
movl $0x0, %edx
sbbq %rdx, %rdx
orq $0x1, %rdx
shrl $0xd, %ecx
addq %rdx, %rax
movq %rax, (%rbx,%rcx)
cmpq $0x0, (%rbx)
jns 0x527b3
movq $0x0, (%rbx)
cmpq $0x0, 0x8(%rbx)
movq 0x18(%rsp), %rsi
jg 0x52963
movq $0x1, 0x8(%rbx)
jmp 0x52963
movzwl (%rdi), %ecx
cmpl $0x2, %ecx
je 0x528ba
cmpl $0x1, %ecx
je 0x52826
testl %ecx, %ecx
jne 0x52963
cmpl 0xc(%rdi), %r15d
jne 0x52963
movslq %eax, %r13
addq %r14, %r13
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x6a60
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %rax, 0x8(%rbx)
cmpq %r13, 0x8(%rsp)
jne 0x52963
jmp 0x5299d
cmpl $0x6, %r15d
jne 0x52963
movq %rbx, 0x28(%rsp)
cltq
leaq (%r14,%rax), %r13
xorl %ebx, %ebx
cmpq %rax, %r12
jle 0x52896
xorl %ebx, %ebx
callq 0x6100
movq %rax, 0x20(%rsp)
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
movl $0xa, %edx
callq 0x6a60
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rsp), %r13
movsbq (%r13), %rdx
movl (%rcx,%rdx,4), %ecx
addl $-0x44, %ecx
cmpl $0xa, %ecx
ja 0x52889
movl $0x601, %edx            # imm = 0x601
btl %ecx, %edx
jae 0x52889
addl %eax, %ebx
movq 0x10(%rsp), %rdi
incq %r13
cmpq %rbp, %r13
jb 0x5284e
movq %r13, 0x8(%rsp)
cmpl $0x1, %ebx
adcl $0x0, %ebx
movslq %ebx, %rax
movq 0x28(%rsp), %rbx
addq (%rbx), %rax
movq %rax, 0x8(%rbx)
movq 0x18(%rsp), %rsi
jmp 0x52963
cmpl $0x8, %r15d
je 0x528e7
cmpl $0x4, %r15d
jne 0x52963
movslq %eax, %rcx
cmpq %rcx, %r12
jle 0x52963
movl %r12d, %ecx
subl %eax, %ecx
movslq %ecx, %rax
addq (%rbx), %rax
movq %rax, 0x8(%rbx)
jmp 0x52963
movb $0x0, (%rbp)
movslq %eax, %rdi
addq %r14, %rdi
movq %rdi, 0x20(%rsp)
leaq 0x45eaa(%rip), %rsi     # 0x987a7
callq 0x6180
movq 0x20(%rsp), %rdi
movq %rax, 0x8(%rsp)
cmpq %rdi, %rax
je 0x52932
testq %rax, %rax
je 0x5293b
leaq 0x45e89(%rip), %rsi     # 0x987a6
callq 0x6180
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x5293b
addq $0x5, %rax
jmp 0x52936
addq $0x4, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x52955
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x6a60
movq %rax, 0x8(%rbx)
movb %r13b, (%rbp)
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
incl %r15d
leal 0x1(%r12), %eax
incq %r12
cmpq %rsi, %r12
jne 0x52722
leaq 0x10(%rbx), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq $0x0, (%rcx)
je 0x529a2
cmpq $0x0, 0x18(%rbx)
je 0x529a2
cmpq $0x0, (%rbx)
js 0x529a2
movq 0x8(%rbx), %rax
sarq $0x3f, %rax
jmp 0x529a2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq