// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: vcf_parse_format
static int vcf_parse_format(kstring_t *s, const bcf_hdr_t *h, bcf1_t *v,
                            char *p, char *q)
{
    if ( !bcf_hdr_nsamples(h) ) return 0;
    kstring_t *mem = (kstring_t*)&h->mem;
    mem->l = 0;

    fmt_aux_t fmt[MAX_N_FMT];

    // detect FORMAT "."
    int ret; // +ve = ok, -ve = err
    if ((ret = vcf_parse_format_empty1(s, h, v, p, q)))
        return ret ? 0 : -1;

    // get format information from the dictionary
    if (vcf_parse_format_dict2(s, h, v, p, q, fmt) < 0)
        return -1;

    // FORMAT data is per-sample A:B:C A:B:C A:B:C ... but in memory it is
    // stored as per-type arrays AAA... BBB... CCC...  This is basically
    // a data rotation or pivot.

    // The size of elements in the array grow to their maximum needed,
    // permitting fast random access.  This means however we have to first
    // scan the whole FORMAT line to find the maximum of each type, and
    // then scan it again to find the store the data.
    // We break this down into compute-max, allocate, fill-out-buffers

    // TODO: ?
    // The alternative would be to pivot on the first pass, with fixed
    // size entries for numerics and concatenated strings otherwise, also
    // tracking maximum sizes.  Then on a second pass we reallocate and
    // copy the data again to a uniformly sized array.  Two passes through
    // memory, but without doubling string parsing.

    // compute max
    if (vcf_parse_format_max3(s, h, v, p, q, fmt) < 0)
        return -1;

    // allocate memory for arrays
    if (vcf_parse_format_alloc4(s, h, v, p, q, fmt) < 0)
        return -1;

    // fill the sample fields; at beginning of the loop
    if (vcf_parse_format_fill5(s, h, v, p, q, fmt) < 0)
        return -1;

    // write individual genotype information
    if (vcf_parse_format_gt6(s, h, v, p, q, fmt) < 0)
        return -1;

    // validity checking
    if (vcf_parse_format_check7(h, v) < 0)
        return -1;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2820, %rsp           # imm = 0x2820
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x46cc5
movl $0x0, -0x4(%rbp)
jmp 0x46e2b
movq -0x18(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x52bf0
movl %eax, -0x2814(%rbp)
cmpl $0x0, %eax
je 0x46d1d
movl -0x2814(%rbp), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x46e2b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
leaq -0x2810(%rbp), %r9
callq 0x52d00
cmpl $0x0, %eax
jge 0x46d4e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46e2b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
leaq -0x2810(%rbp), %r9
callq 0x531a0
cmpl $0x0, %eax
jge 0x46d7f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46e2b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
leaq -0x2810(%rbp), %r9
callq 0x53580
cmpl $0x0, %eax
jge 0x46dad
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46e2b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
leaq -0x2810(%rbp), %r9
callq 0x53a70
cmpl $0x0, %eax
jge 0x46ddb
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46e2b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
leaq -0x2810(%rbp), %r9
callq 0x549b0
cmpl $0x0, %eax
jge 0x46e09
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46e2b
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x54cd0
cmpl $0x0, %eax
jge 0x46e24
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46e2b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2820, %rsp           # imm = 0x2820
popq %rbp
retq
nopw (%rax,%rax)