// File: /workspace/github_c_makefile_star2_O2/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 %rdx, %r15
leaq 0x10(%rcx), %rax
movq %rax, 0x28(%rsp)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rcx)
movslq %esi, %rbx
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rcx)
xorl %r12d, %r12d
pushq $0x1
popq %rsi
pushq $-0x1
popq %r14
xorl %eax, %eax
movq %rcx, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
cmpq %rbx, %r12
jg 0x4b1cd
movzbl (%r15,%r12), %r13d
testl %r13d, %r13d
je 0x4afa4
cmpl $0x9, %r13d
je 0x4afa4
incq %r12
jmp 0x4af86
leaq (%r15,%r12), %r8
movslq %eax, %rbp
cmpl 0x4(%rdi), %esi
jne 0x4afc0
addq %r15, %rbp
movq %rbp, 0x10(%rcx)
movq %r8, 0x18(%rcx)
jmp 0x4b1c0
cmpl 0x8(%rdi), %esi
movl %esi, 0x4(%rsp)
jne 0x4b008
addq %r15, %rbp
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x6a60
movq 0x10(%rsp), %rcx
movq %rax, 0x8(%rcx)
movq %rax, (%rcx)
cmpq %rbp, 0x8(%rsp)
je 0x4b1ed
movq 0x18(%rsp), %rdi
testb $0x1, 0x2(%rdi)
jne 0x4b063
movq %rax, %rdx
decq %rax
movq %rax, (%rcx)
jmp 0x4b06d
movzwl (%rdi), %edx
cmpl $0x2, %edx
movq %r8, 0x20(%rsp)
je 0x4b0fd
cmpl $0x1, %edx
je 0x4b090
testl %edx, %edx
jne 0x4b1c0
cmpl 0xc(%rdi), %esi
jne 0x4b1c0
addq %r15, %rbp
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x6a60
movl 0x4(%rsp), %esi
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rcx
movq %rax, 0x8(%rcx)
cmpq %rbp, 0x8(%rsp)
jne 0x4b1c0
jmp 0x4b1ed
movq %rax, %rdx
incq %rdx
movq %rdx, 0x8(%rcx)
movl 0x4(%rsp), %esi
testq %rax, %rax
jns 0x4b07a
andq $0x0, (%rcx)
testq %rdx, %rdx
jg 0x4b1c0
movq $0x1, 0x8(%rcx)
jmp 0x4b1c0
cmpl $0x6, %esi
jne 0x4b1c0
addq %r15, %rbp
xorl %r14d, %r14d
cmpq %r8, %rbp
jae 0x4b128
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x6a60
movq %rax, %r13
callq 0x6100
movq (%rax), %rax
movq 0x30(%rsp), %rbp
movsbq (%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl $-0x44, %eax
cmpl $0xa, %eax
ja 0x4b0e5
movl $0x601, %ecx            # imm = 0x601
btl %eax, %ecx
jae 0x4b0e5
addl %r13d, %r14d
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdi
movl 0x4(%rsp), %esi
movq 0x20(%rsp), %r8
incq %rbp
jmp 0x4b09f
cmpl $0x8, %esi
je 0x4b145
cmpl $0x4, %esi
jne 0x4b1c0
cmpq %rbp, %r12
jle 0x4b1c0
movl %r12d, %edx
subl %eax, %edx
movslq %edx, %rax
addq (%rcx), %rax
movq %rax, 0x8(%rcx)
jmp 0x4b1c0
movq %rbp, 0x8(%rsp)
cmpl $0x1, %r14d
adcl $0x0, %r14d
movslq %r14d, %rax
addq (%rcx), %rax
movq %rax, 0x8(%rcx)
pushq $-0x1
popq %r14
jmp 0x4b1c0
movb $0x0, (%r8)
addq %r15, %rbp
movq %rbp, %rdi
leaq 0x3c673(%rip), %rsi     # 0x877c9
callq 0x6180
movq %rax, 0x8(%rsp)
cmpq %rbp, %rax
je 0x4b189
testq %rax, %rax
je 0x4b1aa
movq %rbp, %rdi
leaq 0x3c654(%rip), %rsi     # 0x877c8
callq 0x6180
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x4b1aa
addq $0x5, %rax
jmp 0x4b18d
addq $0x4, %rax
movq %rax, 0x8(%rsp)
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x6a60
movq 0x10(%rsp), %rcx
movq %rax, 0x8(%rcx)
movq 0x20(%rsp), %rax
movb %r13b, (%rax)
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdi
movl 0x4(%rsp), %esi
incq %r12
incl %esi
movl %r12d, %eax
jmp 0x4af86
movq 0x28(%rsp), %rax
cmpq $0x0, (%rax)
je 0x4b1ed
cmpq $0x0, 0x18(%rcx)
je 0x4b1ed
cmpq $0x0, (%rcx)
js 0x4b1ed
movq 0x8(%rcx), %r14
sarq $0x3f, %r14
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq