// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/vcf.c
// Function: vcf_parse
int vcf_parse(kstring_t *s, const bcf_hdr_t *h, bcf1_t *v)
{
    int ret = -2, overflow = 0;
    char *p, *q, *r, *t;
    kstring_t *str;
    khint_t k;
    ks_tokaux_t aux;

//#define NOT_DOT(p) strcmp((p), ".")
//#define NOT_DOT(p) (!(*p == '.' && !p[1]))
//#define NOT_DOT(p) ((*p) != '.' || (p)[1])
//#define NOT_DOT(p) (q-p != 1 || memcmp(p, ".\0", 2))
#define NOT_DOT(p) (memcmp(p, ".\0", 2))

    if (!s || !h || !v || !(s->s))
        return ret;

    // Assumed in lots of places, but we may as well spot this early
    assert(sizeof(float) == sizeof(int32_t));

    // Ensure string we parse has space to permit some over-flow when during
    // parsing.  Eg to do memcmp(key, "END", 4) in vcf_parse_info over
    // the more straight forward looking strcmp, giving a speed advantage.
    if (ks_resize(s, s->l+4) < 0)
        return -2;

    // Force our memory to be initialised so we avoid the technicality of
    // undefined behaviour in using a 4-byte memcmp.  (The reality is this
    // almost certainly is never detected by the compiler so has no impact,
    // but equally so this code has minimal (often beneficial) impact on
    // performance too.)
    s->s[s->l+0] = 0;
    s->s[s->l+1] = 0;
    s->s[s->l+2] = 0;
    s->s[s->l+3] = 0;

    bcf_clear1(v);
    str = &v->shared;
    memset(&aux, 0, sizeof(ks_tokaux_t));

    // CHROM
    if (!(p = kstrtok(s->s, "\t", &aux)))
        goto err;
    *(q = (char*)aux.p) = 0;

    vdict_t *d = (vdict_t*)h->dict[BCF_DT_CTG];
    k = kh_get(vdict, d, p);
    if (k == kh_end(d)) {
        hts_log_warning("Contig '%s' is not defined in the header. (Quick workaround: index the file with tabix.)", p);
        v->errcode = BCF_ERR_CTG_UNDEF;
        if ((k = fix_chromosome(h, d, p)) == kh_end(d)) {
            hts_log_error("Could not add dummy header for contig '%s'", p);
            v->errcode |= BCF_ERR_CTG_INVALID;
            goto err;
        }
    }
    v->rid = kh_val(d, k).id;

    // POS
    if (!(p = kstrtok(0, 0, &aux)))
        goto err;
    *(q = (char*)aux.p) = 0;

    overflow = 0;
    char *tmp = p;
    v->pos = hts_str2uint(p, &p, 62, &overflow);
    if (overflow) {
        hts_log_error("Position value '%s' is too large", tmp);
        goto err;
    } else if ( *p ) {
        hts_log_error("Could not parse the position '%s'", tmp);
        goto err;
    } else {
        v->pos -= 1;
    }
    if (v->pos >= INT32_MAX)
        v->unpacked |= BCF_IS_64BIT;

    // ID
    if (!(p = kstrtok(0, 0, &aux)))
        goto err;
    *(q = (char*)aux.p) = 0;

    if (NOT_DOT(p)) bcf_enc_vchar(str, q - p, p);
    else bcf_enc_size(str, 0, BCF_BT_CHAR);

    // REF
    if (!(p = kstrtok(0, 0, &aux)))
        goto err;
    *(q = (char*)aux.p) = 0;

    bcf_enc_vchar(str, q - p, p);
    v->n_allele = 1, v->rlen = q - p;

    // ALT
    if (!(p = kstrtok(0, 0, &aux)))
        goto err;
    *(q = (char*)aux.p) = 0;

    if (NOT_DOT(p)) {
        for (r = t = p;; ++r) {
            if (*r == ',' || *r == 0) {
                if (v->n_allele == UINT16_MAX) {
                    hts_log_error("Too many ALT alleles at %s:%"PRIhts_pos,
                                  bcf_seqname_safe(h,v), v->pos+1);
                    v->errcode |= BCF_ERR_LIMITS;
                    goto err;
                }
                bcf_enc_vchar(str, r - t, t);
                t = r + 1;
                ++v->n_allele;
            }
            if (r == q) break;
        }
    }

    // QUAL
    if (!(p = kstrtok(0, 0, &aux)))
        goto err;
    *(q = (char*)aux.p) = 0;

    if (NOT_DOT(p)) v->qual = atof(p);
    else bcf_float_set_missing(v->qual);
    if ( v->max_unpack && !(v->max_unpack>>1) ) goto end; // BCF_UN_STR

    // FILTER
    if (!(p = kstrtok(0, 0, &aux)))
        goto err;
    *(q = (char*)aux.p) = 0;

    if (NOT_DOT(p)) {
        if (vcf_parse_filter(str, h, v, p, q)) {
            goto err;
        }
    } else bcf_enc_vint(str, 0, 0, -1);
    if ( v->max_unpack && !(v->max_unpack>>2) ) goto end; // BCF_UN_FLT

    // INFO
    if (!(p = kstrtok(0, 0, &aux)))
        goto err;
    *(q = (char*)aux.p) = 0;

    if (NOT_DOT(p)) {
        if (vcf_parse_info(str, h, v, p, q)) {
            goto err;
        }
    }
    if ( v->max_unpack && !(v->max_unpack>>3) ) goto end;

    // FORMAT; optional
    p = kstrtok(0, 0, &aux);
    if (p) {
        *(q = (char*)aux.p) = 0;

        if (vcf_parse_format(s, h, v, p, q)) {
            goto err;
        }
    }

 end:
    v->rlen = get_rlen(h, v);    //set rlen based on version
    ret = 0;

 err:
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testq %rdx, %rdx
sete %al
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
orb %cl, %al
jne 0x33be9
movq %rdi, %rbp
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x33be9
movq %rdx, %r14
movq %rsi, %r12
movq (%rbp), %rcx
leaq 0x4(%rcx), %rdx
cmpq %rdx, 0x8(%rbp)
jae 0x33664
movq %rdx, %rcx
shrq $0x3e, %rcx
movq %rdx, %rsi
shrq %rsi
xorl %r13d, %r13d
testq %rcx, %rcx
cmoveq %rsi, %r13
addq %rdx, %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x4860
testq %rax, %rax
je 0x33be9
movq %rax, 0x10(%rbp)
movq %r13, 0x8(%rbp)
movq (%rbp), %rcx
xorl %r15d, %r15d
movb %r15b, (%rax,%rcx)
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
movb %r15b, 0x1(%rcx,%rax)
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
movb %r15b, 0x2(%rcx,%rax)
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
movb %r15b, 0x3(%rcx,%rax)
movq %r14, %rdi
callq 0x2f6ad
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdx
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
movq 0x10(%rbp), %rdi
leaq 0x76cea(%rip), %rsi     # 0xaa3a2
callq 0x895db
testq %rax, %rax
je 0x33be9
movq %rax, %r8
movq 0x58(%rsp), %rax
movb $0x0, (%rax)
movq 0x30(%r12), %rdx
movl (%rdx), %eax
testl %eax, %eax
movq %r14, 0x20(%rsp)
movq %r12, (%rsp)
movq %r8, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %rbp, 0x60(%rsp)
je 0x337a9
movq %rax, 0x18(%rsp)
leal -0x1(%rax), %r13d
movb (%r8), %cl
testb %cl, %cl
je 0x33727
leaq 0x1(%r8), %rax
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %ebx, %ecx
imull $0x1000193, %ecx, %ebx  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x33711
jmp 0x3372c
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
andl %r13d, %ebx
movq 0x10(%rdx), %rdi
movl $0x1, %r12d
movl %ebx, %r15d
movq %rdi, 0x28(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r14d
leal (%r15,%r15), %ebp
andl $0x1e, %ebp
movl %r14d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x33797
testb $0x1, %al
jne 0x33787
movq 0x18(%rdx), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
callq 0x46e0
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %r8
testl %eax, %eax
je 0x33797
addl %r12d, %r15d
andl %r13d, %r15d
incl %r12d
cmpl %ebx, %r15d
jne 0x33741
jmp 0x337b2
movl %ebp, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x18(%rsp), %rax
cmovnel %eax, %r15d
cmpl %eax, %r15d
jne 0x33967
leaq 0x7849d(%rip), %rsi     # 0xabc56
leaq 0x784a0(%rip), %rdx     # 0xabc60
movl $0x3, %edi
movq %r8, %rcx
xorl %eax, %eax
movq %r8, %rbx
callq 0x942d
movq 0x20(%rsp), %rax
movl $0x1, 0xcc(%rax)
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x79136(%rip), %rsi     # 0xac931
movq %rbx, %rdx
xorl %eax, %eax
callq 0x89557
testl %eax, %eax
js 0x33899
movq 0x80(%rsp), %rsi
leaq 0x6c(%rsp), %rdx
callq 0x2b376
movq %rax, %rbp
movq 0x80(%rsp), %rdi
callq 0x45c0
testq %rbp, %rbp
movq (%rsp), %rbx
je 0x33853
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2bd95
testl %eax, %eax
js 0x33853
je 0x3385b
movq %rbx, %rdi
callq 0x2ab97
jmp 0x3385b
movq %rbp, %rdi
callq 0x2ac82
movq 0x10(%rsp), %rdx
movl (%rdx), %r15d
testl %r15d, %r15d
je 0x338a3
leal -0x1(%r15), %esi
movq 0x8(%rsp), %r8
movb (%r8), %cl
testb %cl, %cl
je 0x338b0
movq %r8, %rax
incq %rax
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %ebx, %ecx
imull $0x1000193, %ecx, %ebx  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x33883
jmp 0x338b5
movq 0x10(%rsp), %rdx
movl (%rdx), %r15d
jmp 0x338a6
xorl %r15d, %r15d
movq 0x8(%rsp), %r8
jmp 0x33934
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
andl %esi, %ebx
movq 0x10(%rdx), %rdi
movl $0x1, %r12d
movl %ebx, %r14d
movl %esi, 0x28(%rsp)
movq %rdi, 0x18(%rsp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r13d
leal (%r14,%r14), %ebp
andl $0x1e, %ebp
movl %r13d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x33927
testb $0x1, %al
jne 0x33917
movq 0x18(%rdx), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
callq 0x46e0
movq 0x18(%rsp), %rdi
movl 0x28(%rsp), %esi
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %r8
testl %eax, %eax
je 0x33927
addl %r12d, %r14d
andl %esi, %r14d
incl %r12d
cmpl %ebx, %r14d
jne 0x338cd
jmp 0x33934
movl %ebp, %ecx
shrl %cl, %r13d
testb $0x3, %r13b
cmovel %r14d, %r15d
cmpl (%rdx), %r15d
jne 0x33967
leaq 0x78316(%rip), %rsi     # 0xabc56
leaq 0x78372(%rip), %rdx     # 0xabcb9
movl $0x1, %edi
movq %r8, %rcx
xorl %eax, %eax
callq 0x942d
movq 0x20(%rsp), %rax
orb $0x20, 0xcc(%rax)
jmp 0x33be4
movq 0x20(%rdx), %rax
movl %r15d, %ecx
imulq $0x38, %rcx, %rcx
movl 0x30(%rax,%rcx), %eax
movq 0x20(%rsp), %r12
movl %eax, 0x10(%r12)
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x895db
testq %rax, %rax
je 0x33be4
leaq 0x20(%r12), %r13
movq 0x58(%rsp), %rcx
movb $0x0, (%rcx)
xorl %ecx, %ecx
cmpb $0x2b, (%rax)
sete %cl
leaq (%rax,%rcx), %rsi
leaq (%rax,%rcx), %rdx
addq $0x12, %rdx
xorl %edi, %edi
xorl %ecx, %ecx
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
movzbl (%rsi,%rdi), %r8d
leal -0x30(%r8), %r9d
cmpb $0x9, %r9b
ja 0x33a2b
leaq (%rcx,%rcx,4), %rcx
leaq (%r8,%rcx,2), %rcx
addq $-0x30, %rcx
incq %rdi
cmpl $0x12, %edi
jne 0x339c1
movzbl (%rdx), %esi
leal -0x3a(%rsi), %edi
cmpl $-0xa, %edi
jb 0x33a31
movabsq $0x666666666666666, %rdi # imm = 0x666666666666666
addl $-0x30, %esi
cmpq %rdi, %rcx
jb 0x33a10
jne 0x33aab
cmpl $0x4, %esi
jae 0x33aab
movl %esi, %esi
leaq (%rcx,%rcx,4), %rcx
leaq (%rsi,%rcx,2), %rcx
movzbl 0x1(%rdx), %esi
incq %rdx
addl $-0x30, %esi
cmpl $0xa, %esi
jb 0x339fc
jmp 0x33a31
addq %rdi, %rsi
movq %rsi, %rdx
movq %rcx, (%r12)
cmpb $0x0, (%rdx)
je 0x33a5c
leaq 0x78215(%rip), %rsi     # 0xabc56
leaq 0x782bd(%rip), %rdx     # 0xabd05
movl $0x1, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x942d
jmp 0x33be9
leaq -0x1(%rcx), %rax
movq %rax, (%r12)
movl $0x80000000, %eax       # imm = 0x80000000
cmpq %rax, %rcx
jl 0x33a77
orb $0x40, 0xbf(%r12)
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x895db
testq %rax, %rax
je 0x33be9
movq 0x58(%rsp), %rsi
movb $0x0, (%rsi)
cmpw $0x2e, (%rax)
je 0x33acc
subl %eax, %esi
movq %r13, %rdi
movq %rax, %rdx
callq 0x32aea
jmp 0x33adb
movabsq $0x3fffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFFF
movq %rcx, (%r12)
leaq 0x78196(%rip), %rsi     # 0xabc56
leaq 0x7821d(%rip), %rdx     # 0xabce4
jmp 0x33a48
movq %r13, %rdi
xorl %esi, %esi
movl $0x7, %edx
callq 0x32835
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x895db
testq %rax, %rax
je 0x33be9
leaq 0x30(%rsp), %r14
movq 0x28(%r14), %rbp
movb $0x0, (%rbp)
subq %rax, %rbp
movq %r13, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x32aea
movw $0x1, 0x1a(%r12)
movq %rbp, 0x8(%r12)
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
callq 0x895db
testq %rax, %rax
je 0x33be9
movq %rax, %rdx
movq 0x58(%rsp), %rbx
movb $0x0, (%rbx)
cmpw $0x2e, (%rax)
je 0x33bb0
movabsq $-0xffff0001, %r14      # imm = 0xFFFFFFFF0000FFFF
movq %rdx, %r15
incq %r15
movl %edx, %ebp
movzbl -0x1(%r15), %eax
cmpl $0x2c, %eax
je 0x33b62
testl %eax, %eax
jne 0x33b9f
movl 0x18(%r12), %eax
notl %eax
testl $0xffff0000, %eax       # imm = 0xFFFF0000
je 0x33bfd
movl %ebp, %esi
subl %edx, %esi
movq %r13, %rdi
callq 0x32aea
movq 0x18(%r12), %rax
leal 0x10000(%rax), %ecx
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
andq %r14, %rax
orq %rcx, %rax
movq %rax, 0x18(%r12)
movq %r15, %rdx
leaq 0x1(%r15), %rax
decq %r15
incl %ebp
cmpq %rbx, %r15
movq %rax, %r15
jne 0x33b54
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x895db
testq %rax, %rax
je 0x33be4
movq 0x58(%rsp), %rcx
movb $0x0, (%rcx)
cmpw $0x2e, (%rax)
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
je 0x33c2b
movq %rax, %rdi
callq 0x4630
cvtsd2ss %xmm0, %xmm0
jmp 0x33c33
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x10(%r12), %rax
testq %rax, %rax
js 0x33c9c
movq (%rsp), %rcx
cmpl %eax, 0x4(%rcx)
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
jle 0x33ca5
movq 0x18(%rcx), %rcx
shlq $0x4, %rax
movq (%rcx,%rax), %rax
jmp 0x33ca7
movss 0x998dd(%rip), %xmm0    # 0xcd510
movss %xmm0, 0x14(%r12)
cmpl $0x1, 0xb8(%r12)
jne 0x33c5a
movq (%rsp), %rdi
movq %r12, %rsi
callq 0x370a7
movq %rax, 0x8(%r12)
xorl %ebx, %ebx
jmp 0x33be9
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x895db
testq %rax, %rax
je 0x33be9
movq 0x58(%rsp), %r8
movb $0x0, (%r8)
cmpw $0x2e, (%rax)
je 0x33ce4
movq %r13, %rdi
movq (%rsp), %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0x33d9c
testl %eax, %eax
jne 0x33be9
jmp 0x33cf5
xorl %eax, %eax
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
jmp 0x33ca7
xorl %eax, %eax
testq %rax, %rax
leaq 0x78c5e(%rip), %rcx     # 0xac90f
cmovneq %rax, %rcx
movq (%r12), %r8
incq %r8
leaq 0x77f93(%rip), %rsi     # 0xabc56
leaq 0x7805d(%rip), %rdx     # 0xabd27
movl $0x1, %edi
xorl %eax, %eax
callq 0x942d
orb $0x8, 0xcc(%r12)
jmp 0x33be9
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x32025
movl 0xb8(%r12), %eax
decl %eax
cmpl $0x3, %eax
jb 0x33c45
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x895db
testq %rax, %rax
je 0x33be9
movq 0x58(%rsp), %r8
movb $0x0, (%r8)
cmpw $0x2e, (%rax)
je 0x33d48
movq %r13, %rdi
movq (%rsp), %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0x34228
testl %eax, %eax
jne 0x33be9
movl 0xb8(%r12), %eax
decl %eax
cmpl $0x7, %eax
jb 0x33c45
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x895db
testq %rax, %rax
je 0x33c45
movq 0x58(%rsp), %r8
movb $0x0, (%r8)
movq 0x60(%rsp), %rdi
movq (%rsp), %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0x34d9c
testl %eax, %eax
jne 0x33be9
jmp 0x33c45