// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/tbx.c
// Function: tbx_parse1
int tbx_parse1(const tbx_conf_t *conf, size_t len, char *line, tbx_intv_t *intv)
{
    size_t i, b = 0;
    int id = 1, getlen = 0, alcnt = 0, haveins = 0, lenpos = -1;
    char *s, *t;
    uint8_t insals[8192];
    int64_t reflen = 0, svlen = 0, fmtlen = 0, tmp = 0;

    intv->ss = intv->se = 0; intv->beg = intv->end = -1;
    for (i = 0; i <= len; ++i) {
        if (line[i] == '\t' || line[i] == 0) {
            if (id == conf->sc) {
                intv->ss = line + b; intv->se = line + i;
            } else if (id == conf->bc) {
                // here ->beg is 0-based.
                if ((conf->preset&0xffff) == TBX_GAF){
                    // if gaf find the smallest and largest node id
                    char *t;
                    int64_t nodeid = -1;
                    for (s = line + b + 1; s < line + i;) {
                        nodeid = strtoll(s, &t, 0);
                        if(intv->beg == -1){
                            intv->beg = intv->end = nodeid;
                        } else {
                            if(nodeid < intv->beg){
                                intv->beg = nodeid;
                            }

                            if(nodeid > intv->end){
                                intv->end = nodeid;
                            }
                        }
                        s = t + 1;
                    }
                } else {
                    intv->beg = strtoll(line + b, &s, 0);

                    if (conf->bc <= conf->ec) // don't overwrite an already set end point
                        intv->end = intv->beg;

                    if ( s==line+b ) return -1; // expected int

                    if (!(conf->preset&TBX_UCSC))
                        --intv->beg;
                    else if (conf->bc <= conf->ec)
                        ++intv->end;

                    if (intv->beg < 0) {
                        hts_log_warning("Coordinate <= 0 detected. "
                                        "Did you forget to use the -0 option?");
                        intv->beg = 0;
                    }
                    if (intv->end < 1) intv->end = 1;
                }
            } else {
                if ((conf->preset&0xffff) == TBX_GENERIC) {
                    if (id == conf->ec)
                    {
                        intv->end = strtoll(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;
                        char *t;
                        for (s = line + b; s < line + i;) {
                            long x = strtol(s, &t, 10);
                            char op = toupper_c(*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) { //ref allele
                        if (b < i) intv->end = intv->beg + (i - b);
                        ++alcnt;
                        reflen = i - b;
                    } if (id == 5) {    //alt allele
                        int lastbyte = 0, c = line[i];
                        insals[lastbyte] = 0;
                        line[i] = 0;
                        s = line + b;
                        do {
                            t = strchr(s, ',');
                            if (alcnt >> 3 != lastbyte) {   //initialize insals
                                lastbyte = alcnt >> 3;
                                insals[lastbyte] = 0;
                            }
                            ++alcnt;
                            if (t) {
                                *t = 0;
                            }
                            if (s[0] == '<') {
                                if (!strcmp("<INS>", s)) {  //note inserts
                                    insals[lastbyte] |= 1 << ((alcnt - 1) & 7);
                                    haveins = 1;
                                } else if (!strcmp("<*>", s) ||
                                    !strcmp("<NON_REF>", s)) {  //note gvcf
                                    getlen = 1;
                                }
                            }
                            if (t) {
                                *t = ',';
                                s = t + 1;
                            }
                        } while (t && alcnt < 65536);   //max allcnt is 65535
                        line[i] = c;
                    } else if (id == 8) { //INFO, look for "END=" / "SVLEN"
                        int c = line[i], d = 1;
                        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 && *s != '.') {
                            long long end = strtoll(s, &s, 0);
                            if (end <= intv->beg) {
                                static int reported = 0;
                                if (!reported) {
                                    int l = intv->ss ? (int) (intv->se - intv->ss) : 0;
                                    hts_log_warning("VCF INFO/END=%lld is smaller than POS at %.*s:%"PRIhts_pos"\n"
                                                    "This tag will be ignored. "
                                                    "Note: only one invalid END tag will be reported.",
                                                    end, l >= 0 ? l : 0,
                                                    intv->ss ? intv->ss : "",
                                                    intv->beg);
                                    reported = 1;
                                }
                            } else {
                                intv->end = end;
                            }
                        }
                        s = strstr(line + b, "SVLEN=");
                        if (s == line + b) s += 6;  //at start of info
                        else if (s) {               //not at the start
                            s = strstr(line + b, ";SVLEN=");
                            if (s) s += 7;
                        }
                        while (s && d < alcnt) {
                            t = strchr(s, ',');
                            if ((haveins) && (insals[d >> 3] & (1 << (d & 7)))) {
                                tmp = 1;    //<INS>
                            } else {
                                tmp = atoll(s);
                                tmp = tmp < 0 ? llabs(tmp) : tmp;
                            }
                            svlen = svlen < tmp ? tmp : svlen;
                            s = t ? t + 1 : NULL;
                            ++d;
                        }
                        line[i] = c;
                    } else if (getlen && id == 9 ) {    //FORMAT
                        int c = line[i], pos = -1;
                        line[i] = 0;
                        s = line + b;
                        while (s) {
                            ++pos;
                            if (!(t = strchr(s, ':'))) {    //no further fields
                                if (!strcmp(s, "LEN")) {
                                    lenpos = pos;
                                }
                                break;  //not present at all!
                            } else {
                                *t = '\0';
                                if (!strcmp(s, "LEN")) {
                                    lenpos = pos;
                                    *t = ':';
                                    break;
                                }
                                *t = ':';
                                s = t + 1;  //check next one
                            }
                        }
                        line[i] = c;
                        if (lenpos == -1) { //not present
                            break;
                        }
                    } else if (id > 9 && getlen && lenpos != -1) {
                        //get LEN from sample
                        int c = line[i], d = 0;
                        line[i] = 0; tmp = 0;
                        s = line + b;
                        for (d = 0; d <= lenpos; ++d) {
                            if (d == lenpos) {
                                tmp = atoll(s);
                                break;
                            }
                            if ((t = strchr(s, ':'))) {
                                s = t + 1;
                            } else {
                                break;    //not in sycn with fmt def!
                            }
                        }
                        fmtlen = fmtlen < tmp ? tmp : fmtlen;
                        line[i] = c;
                    }
                }
            }
            b = i + 1;  //beginning if current field
            ++id;
        }
    }
    if ((conf->preset&0xffff) == TBX_VCF) {
        tmp = reflen < svlen ?
                svlen < fmtlen ? fmtlen : svlen :
                reflen < fmtlen ? fmtlen : reflen ;
        tmp += intv->beg;
        intv->end = intv->end < tmp ? tmp : intv->end;

        //NOTE: 'end' calculation be in sync with end/rlen in vcf.c:get_rlen
    }
    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 $0x2098, %rsp           # imm = 0x2098
movq %rcx, %rbx
movq %rsi, 0x88(%rsp)
movq %rdi, %r13
leaq 0x10(%rcx), %rax
movq %rax, 0x70(%rsp)
leaq 0x8(%rcx), %r14
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rcx)
leaq 0x1(%rdx), %rax
movq %rax, 0x80(%rsp)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rcx)
movl $0xffffffff, 0x30(%rsp) # imm = 0xFFFFFFFF
movl $0x1, %ecx
xorl %r15d, %r15d
xorl %ebp, %ebp
movl $0x0, 0x34(%rsp)
movl $0x0, 0x2c(%rsp)
movl $0x0, 0x4c(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x78(%rsp)
movq %rbx, 0x40(%rsp)
movq %rdi, 0x38(%rsp)
movq %rdx, 0x20(%rsp)
movzbl (%rdx,%r15), %eax
cmpl $0x9, %eax
je 0x9d3d9
testl %eax, %eax
jne 0x9d3f4
leaq (%rdx,%r15), %r12
cmpl 0x4(%r13), %ecx
jne 0x9d406
addq %rdx, %rbp
movq %rbp, 0x10(%rbx)
movq %r12, 0x18(%rbx)
leaq 0x1(%r15), %rbp
incl %ecx
incq %r15
cmpq 0x88(%rsp), %r15
jbe 0x9d3cb
jmp 0x9daeb
movzwl (%r13), %eax
cmpl 0x8(%r13), %ecx
movl %ecx, 0x14(%rsp)
jne 0x9d47a
cmpl $0x3, %eax
jne 0x9d4cc
addq 0x80(%rsp), %rbp
movq %rbp, 0x18(%rsp)
cmpq %r12, %rbp
jae 0x9d3ee
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
xorl %edx, %edx
callq 0x40a0
movq (%rbx), %rcx
cmpq $-0x1, %rcx
je 0x9d45a
cmpq %rcx, %rax
jge 0x9d450
movq %rax, (%rbx)
movq %r14, %rcx
cmpq (%r14), %rax
jg 0x9d460
jmp 0x9d463
movq %rax, (%r14)
movq %rbx, %rcx
movq %rax, (%rcx)
movq 0x68(%rsp), %rbp
incq %rbp
cmpq %r12, %rbp
jb 0x9d430
movq %rbp, 0x18(%rsp)
jmp 0x9dadd
cmpl $0x2, %eax
je 0x9d5a5
cmpl $0x1, %eax
je 0x9d51a
testl %eax, %eax
jne 0x9d3ee
cmpl 0xc(%r13), %ecx
jne 0x9d3ee
addq %rdx, %rbp
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0x40a0
movl 0x14(%rsp), %ecx
movq 0x20(%rsp), %rdx
movq %rax, (%r14)
cmpq %rbp, 0x18(%rsp)
jne 0x9d3ee
jmp 0x9db48
addq %rdx, %rbp
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0x40a0
movq %rax, (%rbx)
movl 0x8(%r13), %ecx
movl 0xc(%r13), %edx
cmpl %edx, %ecx
jg 0x9d4f0
movq %rax, (%r14)
cmpq %rbp, 0x18(%rsp)
je 0x9db48
testb $0x1, 0x2(%r13)
jne 0x9d6eb
decq %rax
movq %rax, (%rbx)
movq 0x20(%rsp), %rdx
movl 0x14(%rsp), %ecx
jmp 0x9d6fb
cmpl $0x6, %ecx
jne 0x9d3ee
leaq (%rdx,%rbp), %r13
xorl %ebx, %ebx
cmpq %rbp, %r15
jle 0x9d581
xorl %ebx, %ebx
callq 0x4090
movq %rax, %rbp
movq %r13, %rdi
leaq 0x68(%rsp), %rsi
movl $0xa, %edx
callq 0x46f0
movq 0x68(%rsp), %r13
movzbl (%r13), %ecx
movq (%rbp), %rdx
movzbl (%rdx,%rcx,4), %ecx
addl $-0x44, %ecx
cmpl $0xa, %ecx
ja 0x9d570
movl $0x601, %edx            # imm = 0x601
btl %ecx, %edx
jae 0x9d570
addl %eax, %ebx
movq 0x20(%rsp), %rdx
movl 0x14(%rsp), %ecx
incq %r13
cmpq %r12, %r13
jb 0x9d538
movq %r13, 0x18(%rsp)
cmpl $0x1, %ebx
adcl $0x0, %ebx
movslq %ebx, %rax
movq 0x40(%rsp), %rbx
addq (%rbx), %rax
movq %rax, 0x8(%rbx)
movq 0x38(%rsp), %r13
jmp 0x9d3ee
cmpl $0x4, %ecx
jne 0x9d5c8
movq %r15, %rax
subq %rbp, %rax
movq %rax, 0x78(%rsp)
jbe 0x9d5c4
movq %r15, %rax
subq %rbp, %rax
addq (%rbx), %rax
movq %rax, 0x8(%rbx)
incl 0x2c(%rsp)
cmpl $0x8, %ecx
je 0x9d741
cmpl $0x5, %ecx
jne 0x9d79d
movq %r14, 0x50(%rsp)
movb (%r12), %al
movb %al, 0x13(%rsp)
xorl %r14d, %r14d
movb %r14b, 0x90(%rsp)
movb %r14b, (%r12)
addq %rdx, %rbp
movq %rbp, 0x18(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, %ebx
movq %rbp, %rdi
movl $0x2c, %esi
callq 0x4180
movq %rax, %r13
movl %ebx, %eax
sarl $0x3, %eax
cmpl %r14d, %eax
je 0x9d62c
movslq %eax, %rcx
movb $0x0, 0x90(%rsp,%rcx)
movl %eax, %r14d
testq %r13, %r13
je 0x9d636
movb $0x0, (%r13)
cmpb $0x3c, (%rbp)
jne 0x9d69d
leaq 0x12aad(%rip), %rdi     # 0xb00f0
movq %rbp, %rsi
callq 0x46e0
testl %eax, %eax
je 0x9d67f
leaq 0x12aa0(%rip), %rdi     # 0xb00f6
movq %rbp, %rsi
callq 0x46e0
testl %eax, %eax
je 0x9d675
leaq 0x12a91(%rip), %rdi     # 0xb00fa
movq %rbp, %rsi
callq 0x46e0
testl %eax, %eax
jne 0x9d69d
movl $0x1, 0x34(%rsp)
jmp 0x9d69d
movl %ebx, %ecx
andb $0x7, %cl
movl $0x1, 0x4c(%rsp)
movl $0x1, %eax
shll %cl, %eax
movslq %r14d, %rcx
orb %al, 0x90(%rsp,%rcx)
movq 0x20(%rsp), %rdx
testq %r13, %r13
je 0x9d6b0
movb $0x2c, (%r13)
leaq 0x1(%r13), %rbp
leal 0x1(%rbx), %eax
cmpl $0xfffe, %ebx           # imm = 0xFFFE
jg 0x9d6c6
movl %eax, %ebx
testq %r13, %r13
jne 0x9d604
movl %eax, 0x2c(%rsp)
movq %rbp, 0x18(%rsp)
movb 0x13(%rsp), %al
movb %al, (%r12)
movq 0x50(%rsp), %r14
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r13
jmp 0x9dae2
cmpl %edx, %ecx
movq 0x20(%rsp), %rdx
movl 0x14(%rsp), %ecx
jg 0x9d6fb
incq (%r14)
cmpq $0x0, (%rbx)
jns 0x9d72b
movl $0x3, %edi
leaq 0x1c5cf(%rip), %rsi     # 0xb9cdc
leaq 0x1c5d3(%rip), %rdx     # 0xb9ce7
xorl %eax, %eax
callq 0x9774
movl 0x14(%rsp), %ecx
movq 0x20(%rsp), %rdx
movq $0x0, (%rbx)
cmpq $0x0, (%r14)
jg 0x9d3ee
movq $0x1, (%r14)
jmp 0x9d3ee
movb (%r12), %al
movb %al, 0x13(%rsp)
movb $0x0, (%r12)
addq %rdx, %rbp
movq %rbp, %rdi
leaq 0x1c5cc(%rip), %rsi     # 0xb9d27
callq 0x40d0
movq %rax, 0x18(%rsp)
cmpq %rbp, %rax
je 0x9d8aa
testq %rax, %rax
je 0x9d8b3
movq %rbp, %rdi
leaq 0x1c5a5(%rip), %rsi     # 0xb9d26
callq 0x40d0
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x9d8b3
addq $0x5, %rax
jmp 0x9d8ae
movl 0x34(%rsp), %esi
testl %esi, %esi
setne %al
cmpl $0x9, %ecx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x9d82d
addq %rdx, %rbp
movb (%r12), %bl
movb $0x0, (%r12)
testq %rdx, %rdx
movq %r14, 0x50(%rsp)
je 0x9d8e6
movq %rbp, %rdi
movl $0x3a, %esi
callq 0x4180
testq %rax, %rax
je 0x9d94b
movq %rax, %r13
xorl %r14d, %r14d
movb $0x0, (%r13)
movq %rbp, %rdi
leaq 0x11a03(%rip), %rsi     # 0xaf1fb
callq 0x46e0
testl %eax, %eax
je 0x9d96c
movb $0x3a, (%r13)
movq %r13, %rbp
incq %rbp
incl %r14d
movq %rbp, %rdi
movl $0x3a, %esi
callq 0x4180
movq %rax, %r13
testq %rax, %rax
jne 0x9d7e9
jmp 0x9d94e
testl %esi, %esi
je 0x9d6dc
movl 0x14(%rsp), %ecx
cmpl $0xa, %ecx
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r13
jl 0x9d3ee
movl 0x30(%rsp), %eax
cmpl $-0x1, %eax
je 0x9d3ee
movq %r14, %r13
movb (%r12), %bl
movb $0x0, (%r12)
addq %rdx, %rbp
movq %rbp, 0x18(%rsp)
testl %eax, %eax
js 0x9d91f
movl %eax, %r14d
je 0x9d89b
movq %rbp, %rdi
movl $0x3a, %esi
callq 0x4180
testq %rax, %rax
je 0x9d91f
incq %rax
movq %rax, %rbp
decl %r14d
jne 0x9d87a
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
callq 0x4350
jmp 0x9d926
addq $0x4, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x9d9ec
cmpb $0x2e, (%rdi)
je 0x9d9ec
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0x40a0
movq (%rbx), %rcx
cmpq %rcx, %rax
jle 0x9d8f5
movq %rax, (%r14)
jmp 0x9d9ec
movq %rbp, 0x18(%rsp)
movl 0x30(%rsp), %r14d
jmp 0x9d97b
cmpb $0x0, 0x325dc(%rip)     # 0xcfed8
jne 0x9d9ec
movq 0x70(%rsp), %rdx
movq (%rdx), %r9
testq %r9, %r9
je 0x9d9ae
movl 0x18(%rbx), %r8d
subl %r9d, %r8d
jmp 0x9d9b8
movq %rbp, 0x18(%rsp)
xorl %eax, %eax
movq 0x58(%rsp), %rcx
cmpq %rax, %rcx
cmovleq %rax, %rcx
movq %rcx, 0x58(%rsp)
movb %bl, (%r12)
movl $0x1, 0x34(%rsp)
movq %r13, %r14
jmp 0x9dad3
xorl %r14d, %r14d
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
leaq 0x1189e(%rip), %rsi     # 0xaf1fb
callq 0x46e0
testl %eax, %eax
cmovnel 0x30(%rsp), %r14d
jmp 0x9d976
movq %rbp, 0x18(%rsp)
movb $0x3a, (%r13)
movq 0x20(%rsp), %rdx
movb %bl, (%r12)
movl $0x1, 0x34(%rsp)
movl %r14d, 0x30(%rsp)
cmpl $-0x1, %r14d
movq 0x50(%rsp), %r14
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r13
movl 0x14(%rsp), %ecx
jne 0x9d3ee
jmp 0x9daeb
xorl %r8d, %r8d
leaq 0xcfd5(%rip), %r9       # 0xaa98d
testl %r8d, %r8d
movl $0x0, %edx
cmovlel %edx, %r8d
movq %rcx, (%rsp)
movl $0x3, %edi
leaq 0x1c308(%rip), %rsi     # 0xb9cdc
leaq 0x1c351(%rip), %rdx     # 0xb9d2c
movq %rax, %rcx
xorl %eax, %eax
callq 0x9774
movb $0x1, 0x324ec(%rip)     # 0xcfed8
movq %rbp, %rdi
leaq 0x1c3b4(%rip), %rsi     # 0xb9daa
callq 0x40d0
movq %rax, 0x18(%rsp)
cmpq %rbp, %rax
je 0x9da36
testq %rax, %rax
movl 0x2c(%rsp), %ecx
je 0x9da43
movq %rbp, %rdi
leaq 0x1c391(%rip), %rsi     # 0xb9da9
callq 0x40d0
movl 0x2c(%rsp), %ecx
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x9da43
addq $0x7, %rax
movq %rax, 0x18(%rsp)
jmp 0x9da43
addq $0x6, %rax
movq %rax, 0x18(%rsp)
movl 0x2c(%rsp), %ecx
movq 0x18(%rsp), %r13
testq %r13, %r13
je 0x9dac6
cmpl $0x2, %ecx
jl 0x9dac6
movl $0x2, %ebx
movq %r13, %rdi
movl $0x2c, %esi
callq 0x4180
movq %rax, %rbp
cmpl $0x0, 0x4c(%rsp)
je 0x9da8b
leal -0x1(%rbx), %eax
movl %eax, %ecx
shrl $0x3, %ecx
movzbl 0x90(%rsp,%rcx), %edx
andl $0x7, %eax
movl $0x1, %ecx
btl %eax, %edx
jb 0x9da9d
movq %r13, %rdi
callq 0x4350
movq %rax, %rcx
negq %rcx
cmovsq %rax, %rcx
movq 0x60(%rsp), %rax
cmpq %rcx, %rax
cmovleq %rcx, %rax
movq %rax, 0x60(%rsp)
leaq 0x1(%rbp), %r13
testq %rbp, %rbp
cmoveq %rbp, %r13
je 0x9dac6
leal 0x1(%rbx), %eax
cmpl 0x2c(%rsp), %ebx
movl %eax, %ebx
jl 0x9da57
movq %r13, 0x18(%rsp)
movb 0x13(%rsp), %al
movb %al, (%r12)
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r13
movq 0x20(%rsp), %rdx
movl 0x14(%rsp), %ecx
jmp 0x9d3ee
cmpw $0x2, (%r13)
jne 0x9db22
movq 0x60(%rsp), %rcx
movq 0x78(%rsp), %rax
cmpq %rcx, %rax
cmovgq %rax, %rcx
movq 0x58(%rsp), %rax
cmpq %rax, %rcx
cmovleq %rax, %rcx
addq (%rbx), %rcx
movq 0x8(%rbx), %rax
cmpq %rcx, %rax
cmovgq %rax, %rcx
movq %rcx, 0x8(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x70(%rsp), %rcx
cmpq $0x0, (%rcx)
je 0x9db4d
cmpq $0x0, 0x18(%rbx)
je 0x9db4d
cmpq $0x0, (%rbx)
js 0x9db4d
movq (%r14), %rax
sarq $0x3f, %rax
jmp 0x9db4d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x2098, %rsp           # imm = 0x2098
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq