// File: /workspace/github_c_makefile_star2_O1/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, %r12d      # imm = 0xFFFFFFFE
orb %cl, %al
jne 0x34854
movq %rdi, %rbp
movq 0x10(%rdi), %rdi
testq %rdi, %rdi
je 0x34854
movq %rdx, %r14
movq %rsi, %r15
movq (%rbp), %rax
addq $0x4, %rax
cmpq %rax, 0x8(%rbp)
jae 0x343e3
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %r13d, %r13d
testq %rcx, %rcx
cmoveq %rdx, %r13
addq %rax, %r13
movq %r13, %rsi
callq 0x4860
testq %rax, %rax
je 0x34854
movq %rax, 0x10(%rbp)
movq %r13, 0x8(%rbp)
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
xorl %ebx, %ebx
movb %bl, (%rcx,%rax)
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
movb %bl, 0x1(%rcx,%rax)
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
movb %bl, 0x2(%rcx,%rax)
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
movb %bl, 0x3(%rcx,%rax)
movq %r14, %rdi
callq 0x30842
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdx
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
movq 0x10(%rbp), %rdi
leaq 0x78fbd(%rip), %rsi     # 0xad3f7
callq 0x8b5b7
testq %rax, %rax
je 0x34854
movq %rax, %r8
movq 0x58(%rsp), %rax
movb $0x0, (%rax)
movq 0x30(%r15), %rdx
movl (%rdx), %eax
testl %eax, %eax
movq %r8, 0x18(%rsp)
movq %rdx, 0x8(%rsp)
movq %rbp, 0x60(%rsp)
je 0x34544
movq %rax, 0x20(%rsp)
leal -0x1(%rax), %esi
movb (%r8), %cl
testb %cl, %cl
movq %r14, 0x10(%rsp)
movq %r15, (%rsp)
je 0x344aa
leaq 0x1(%r8), %rax
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r13d, %ecx
imull $0x1000193, %ecx, %r13d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x34492
jmp 0x344b0
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
andl %esi, %r13d
movq 0x10(%rdx), %rdi
movl $0x1, %r12d
movl %r13d, %ebx
movq %rdi, 0x28(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r15d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r15d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x34524
testb $0x1, %al
jne 0x3450e
movq 0x18(%rdx), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movl %esi, %r14d
movq %r8, %rsi
callq 0x46e0
movq 0x28(%rsp), %rdi
movl %r14d, %esi
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %r8
testl %eax, %eax
je 0x34524
addl %r12d, %ebx
andl %esi, %ebx
incl %r12d
cmpl %r13d, %ebx
jne 0x344c5
movq 0x20(%rsp), %rax
movl %eax, %ebx
jmp 0x34535
movl %ebp, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x20(%rsp), %rax
cmovnel %eax, %ebx
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
movq 0x10(%rsp), %r14
movq (%rsp), %r15
cmpl %eax, %ebx
jne 0x3471f
leaq 0x7a753(%rip), %rsi     # 0xaeca6
leaq 0x7a756(%rip), %rdx     # 0xaecb0
movl $0x3, %edi
movq %r8, %rcx
xorl %eax, %eax
movq %r8, %rbx
callq 0x9774
movl $0x1, 0xcc(%r14)
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x7b3f0(%rip), %rsi     # 0xaf981
movq %rbx, %rdx
xorl %eax, %eax
callq 0x8b533
testl %eax, %eax
js 0x345d5
movq 0x80(%rsp), %rsi
leaq 0x6c(%rsp), %rdx
callq 0x2c456
movq %rax, %rbp
movq 0x80(%rsp), %rdi
callq 0x45c0
testq %rbp, %rbp
je 0x345de
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2ce41
movl %eax, %ebx
jmp 0x345e3
movq 0x8(%rsp), %rdx
movl (%rdx), %ebx
jmp 0x3464e
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %ebx, %ebx
movq 0x8(%rsp), %rdx
jns 0x345f9
movq %rbp, %rdi
callq 0x2bd39
movq 0x8(%rsp), %rdx
testl %ebx, %ebx
jle 0x3460a
movq %r15, %rdi
callq 0x2bc46
movq 0x8(%rsp), %rdx
movl (%rdx), %ebx
testl %ebx, %ebx
je 0x3464c
movq %r15, (%rsp)
leal -0x1(%rbx), %esi
movq 0x18(%rsp), %r8
movb (%r8), %cl
testb %cl, %cl
movq %r14, 0x10(%rsp)
je 0x34658
movq %r8, %rax
incq %rax
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r15d, %ecx
imull $0x1000193, %ecx, %r15d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x34634
jmp 0x3465e
xorl %ebx, %ebx
movq 0x18(%rsp), %r8
jmp 0x346f1
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
andl %esi, %r15d
movq 0x10(%rdx), %rdi
movl $0x1, %r12d
movl %r15d, %r13d
movl %esi, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
movl %r13d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r14d
leal (,%r13,2), %ebp
andl $0x1e, %ebp
movl %r14d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x346d5
testb $0x1, %al
jne 0x346c5
movq 0x18(%rdx), %rax
movl %r13d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
callq 0x46e0
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %esi
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %r8
testl %eax, %eax
je 0x346d5
addl %r12d, %r13d
andl %esi, %r13d
incl %r12d
cmpl %r15d, %r13d
jne 0x34677
jmp 0x346e2
movl %ebp, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
cmovel %r13d, %ebx
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
movq 0x10(%rsp), %r14
movq (%rsp), %r15
cmpl (%rdx), %ebx
jne 0x3471f
leaq 0x7a5aa(%rip), %rsi     # 0xaeca6
leaq 0x7a606(%rip), %rdx     # 0xaed09
movl $0x1, %edi
movq %r8, %rcx
xorl %eax, %eax
callq 0x9774
orb $0x20, 0xcc(%r14)
jmp 0x34854
movq 0x20(%rdx), %rax
movl %ebx, %ecx
imulq $0x38, %rcx, %rcx
movl 0x30(%rax,%rcx), %eax
movl %eax, 0x10(%r14)
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x8b5b7
testq %rax, %rax
je 0x34854
movq 0x58(%rsp), %rcx
movb $0x0, (%rcx)
xorl %esi, %esi
cmpb $0x2b, (%rax)
sete %sil
leaq (%rax,%rsi), %rcx
movb (%rax,%rsi), %r9b
leal -0x30(%r9), %edi
movb $0x1, %dl
cmpb $0x9, %dil
ja 0x347ab
leaq (%rax,%rsi), %rdi
addq $0x12, %rdi
xorl %r8d, %r8d
xorl %esi, %esi
leaq (%rsi,%rsi,4), %rsi
movzbl %r9b, %r9d
leaq (%r9,%rsi,2), %rsi
addq $-0x30, %rsi
cmpl $0x11, %r8d
setne %r10b
je 0x347b2
movb 0x1(%rcx,%r8), %r9b
leal -0x30(%r9), %r11d
incq %r8
cmpb $0x9, %r11b
jbe 0x3477a
addq %r8, %rcx
jmp 0x347b5
xorl %esi, %esi
movb $0x1, %r10b
jmp 0x347b5
movq %rdi, %rcx
testb %r10b, %r10b
jne 0x3481b
movzbl (%rcx), %edi
leal -0x3a(%rdi), %r8d
cmpl $-0xa, %r8d
jb 0x3481b
addl $-0x30, %edi
cmpl $0x9, %edi
ja 0x3481b
movabsq $0x666666666666666, %r8 # imm = 0x666666666666666
cmpq %r8, %rsi
jb 0x347e5
jne 0x34800
cmpl $0x4, %edi
jae 0x34800
leaq (%rsi,%rsi,4), %rsi
movl %edi, %edi
leaq (%rdi,%rsi,2), %rsi
movzbl 0x1(%rcx), %edi
incq %rcx
addl $-0x30, %edi
cmpl $0xa, %edi
jb 0x347d9
jmp 0x3481b
movzbl 0x1(%rcx), %edx
incq %rcx
addl $-0x30, %edx
cmpl $0xa, %edx
jb 0x34800
movabsq $0x3fffffffffffffff, %rsi # imm = 0x3FFFFFFFFFFFFFFF
xorl %edx, %edx
movq %rsi, (%r14)
testb %dl, %dl
je 0x34837
cmpb $0x0, (%rcx)
je 0x34869
leaq 0x7a478(%rip), %rsi     # 0xaeca6
leaq 0x7a520(%rip), %rdx     # 0xaed55
jmp 0x34845
leaq 0x7a468(%rip), %rsi     # 0xaeca6
leaq 0x7a4ef(%rip), %rdx     # 0xaed34
movl $0x1, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x9774
movl %r12d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x1(%rsi), %rax
movq %rax, (%r14)
movl $0x80000000, %eax       # imm = 0x80000000
cmpq %rax, %rsi
jl 0x34882
orb $0x40, 0xbf(%r14)
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x8b5b7
testq %rax, %rax
je 0x34854
leaq 0x20(%r14), %r13
movq 0x58(%rsp), %rsi
movb $0x0, (%rsi)
cmpw $0x2e, (%rax)
je 0x348b6
subl %eax, %esi
movq %r13, %rdi
movq %rax, %rdx
callq 0x338fe
jmp 0x348c5
movq %r13, %rdi
xorl %esi, %esi
movl $0x7, %edx
callq 0x33722
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x8b5b7
testq %rax, %rax
je 0x34854
leaq 0x30(%rsp), %rbx
movq 0x28(%rbx), %rbp
movb $0x0, (%rbp)
subq %rax, %rbp
movq %r13, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x338fe
movw $0x1, 0x1a(%r14)
movq %rbp, 0x8(%r14)
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x8b5b7
testq %rax, %rax
je 0x34854
movq %rax, %rdx
movq %r13, 0x8(%rsp)
movq %r15, (%rsp)
movq %r14, %r13
movq 0x58(%rsp), %rbx
movb $0x0, (%rbx)
cmpw $0x2e, (%rax)
je 0x349a2
movq %rdx, %r15
incq %r15
movl %edx, %ebp
movzbl -0x1(%r15), %eax
cmpl $0x2c, %eax
je 0x3494c
testl %eax, %eax
jne 0x34991
movq %r13, %r14
movl 0x18(%r13), %eax
notl %eax
testl $0xffff0000, %eax       # imm = 0xFFFF0000
je 0x349db
movl %ebp, %esi
subl %edx, %esi
movq 0x8(%rsp), %rdi
callq 0x338fe
movq 0x18(%r14), %rax
leal 0x10000(%rax), %ecx
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
movabsq $-0xffff0001, %rdx      # imm = 0xFFFFFFFF0000FFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, 0x18(%r14)
movq %r15, %rdx
leaq 0x1(%r15), %rax
decq %r15
incl %ebp
cmpq %rbx, %r15
movq %rax, %r15
jne 0x3493e
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x8b5b7
testq %rax, %rax
je 0x34854
movq 0x58(%rsp), %rcx
movb $0x0, (%rcx)
cmpw $0x2e, (%rax)
je 0x34a03
movq %rax, %rdi
callq 0x4630
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x14(%r13)
jmp 0x34a0d
movslq 0x10(%r14), %rax
testq %rax, %rax
js 0x34a78
movq (%rsp), %rcx
cmpl %eax, 0x4(%rcx)
jle 0x34a78
movq 0x18(%rcx), %rcx
shlq $0x4, %rax
movq (%rcx,%rax), %rax
jmp 0x34a7a
movl 0x9ab07(%rip), %eax     # 0xcf510
movl %eax, 0x14(%r13)
movq (%rsp), %r14
cmpl $0x1, 0xb8(%r13)
movq 0x8(%rsp), %r15
jne 0x34a37
movq %r14, %rdi
movq %r13, %rsi
callq 0x37d95
movq %rax, 0x8(%r13)
xorl %r12d, %r12d
jmp 0x34854
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x8b5b7
testq %rax, %rax
je 0x34854
movq 0x58(%rsp), %r8
movb $0x0, (%r8)
cmpw $0x2e, (%rax)
je 0x34ab5
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x34b69
testl %eax, %eax
jne 0x34854
jmp 0x34ac6
xorl %eax, %eax
testq %rax, %rax
leaq 0x7aedb(%rip), %rcx     # 0xaf95f
cmovneq %rax, %rcx
movq (%r14), %r8
incq %r8
leaq 0x7a211(%rip), %rsi     # 0xaeca6
leaq 0x7a2db(%rip), %rdx     # 0xaed77
movl $0x1, %edi
xorl %eax, %eax
callq 0x9774
orb $0x8, 0xcc(%r14)
jmp 0x34854
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x3321b
movl 0xb8(%r13), %eax
decl %eax
cmpl $0x3, %eax
jb 0x34a20
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x8b5b7
testq %rax, %rax
je 0x34854
movq 0x58(%rsp), %r8
movb $0x0, (%r8)
cmpw $0x2e, (%rax)
je 0x34b17
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x35013
testl %eax, %eax
jne 0x34854
movl 0xb8(%r13), %eax
decl %eax
cmpl $0x7, %eax
jb 0x34a20
leaq 0x30(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x8b5b7
testq %rax, %rax
je 0x34a20
movq 0x58(%rsp), %r8
movb $0x0, (%r8)
movq 0x60(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x35d18
testl %eax, %eax
jne 0x34854
jmp 0x34a20