// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: bcf_format_gt_v2
int bcf_format_gt_v2(const bcf_hdr_t *hdr, bcf_fmt_t *fmt, int isample, kstring_t *str)
{
    uint32_t e = 0;
    int ploidy = 1, anyunphased = 0;
    int32_t val0 = 0;
    size_t pos = str ? str->l : 0;

    #define BRANCH(type_t, convert, missing, vector_end) { \
        uint8_t *ptr = fmt->p + isample*fmt->size; \
        int i; \
        for (i=0; i<fmt->n; i++, ptr += sizeof(type_t)) \
        { \
            type_t val = convert(ptr); \
            if ( val == vector_end ) break; \
            if (!i) { val0 = val; } \
            if (i) { \
                e |= kputc("/|"[val & 1], str) < 0; \
                anyunphased |= !(val & 1); \
            } \
            if (!(val >> 1)) e |= kputc('.', str) < 0; \
            else e |= kputw((val >> 1) - 1, str) < 0; \
        } \
        if (i == 0) e |= kputc('.', str) < 0; \
        ploidy = i; \
    }
    switch (fmt->type) {
        case BCF_BT_INT8:  BRANCH(int8_t,  le_to_i8,  bcf_int8_missing,
            bcf_int8_vector_end); break;
        case BCF_BT_INT16: BRANCH(int16_t, le_to_i16, bcf_int16_missing,
            bcf_int16_vector_end); break;
        case BCF_BT_INT32: BRANCH(int32_t, le_to_i32, bcf_int32_missing,
            bcf_int32_vector_end); break;
        case BCF_BT_NULL:  e |= kputc('.', str) < 0; break;
        default: hts_log_error("Unexpected type %d", fmt->type); return -2;
    }
    #undef BRANCH

    if (hdr && get_hdr_aux(hdr)->version >= VCF44) {
        //output which supports prefixed phasing

        /* update 1st allele's phasing if required and append rest to it.
        use prefixed phasing only when it is a must. i.e. without which the
        inferred value will be incorrect */
        if (val0 & 1) {
            /* 1st one is phased, if ploidy is > 1 and an unphased allele exists
             need to specify explicitly */
            e |= (ploidy > 1 && anyunphased) ?
                    (kinsert_char('|', pos, str) < 0) :
                        (ploidy <= 1 && !((val0 >> 1)) ? //|. needs explicit o/p
                            (kinsert_char('|', pos, str) < 0) :
                            0);
        } else {
            /* 1st allele is unphased, if ploidy is = 1 or allele is '.' or
             ploidy > 1 and no other unphased allele exist, need to specify
             explicitly */
            e |= ((ploidy <= 1 && val0 != 0) || (ploidy > 1 && !anyunphased)) ?
                    (kinsert_char('/', pos, str) < 0) :
                    0;
        }
    }
    return e == 0 ? 0 : -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x1, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x49efa
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x49f02
xorl %eax, %eax
movq %rax, -0x78(%rbp)
jmp 0x49f02
movq -0x78(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movq %rax, -0x80(%rbp)
subq $0x3, %rax
ja 0x4a31e
movq -0x80(%rbp), %rax
leaq 0xbd096(%rip), %rcx     # 0x106fc0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rdx
imull 0x8(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x4a048
movq -0x48(%rbp), %rdi
callq 0x45340
movb %al, -0x4d(%rbp)
movsbl -0x4d(%rbp), %eax
cmpl $-0x7f, %eax
jne 0x49f81
jmp 0x4a048
cmpl $0x0, -0x4c(%rbp)
jne 0x49f8e
movsbl -0x4d(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x49fdd
movsbl -0x4d(%rbp), %eax
andl $0x1, %eax
movslq %eax, %rcx
leaq 0xbe554(%rip), %rax     # 0x1084f9
movsbl (%rax,%rcx), %edi
movq -0x28(%rbp), %rsi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movsbl -0x4d(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movsbl -0x4d(%rbp), %eax
sarl %eax
cmpl $0x0, %eax
jne 0x4a009
movq -0x28(%rbp), %rsi
movl $0x2e, %edi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a02c
movsbl -0x4d(%rbp), %edi
sarl %edi
subl $0x1, %edi
movq -0x28(%rbp), %rsi
callq 0x3bac0
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a02e
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x49f57
cmpl $0x0, -0x4c(%rbp)
jne 0x4a06d
movq -0x28(%rbp), %rsi
movl $0x2e, %edi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x4a34b
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rdx
imull 0x8(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x4a190
movq -0x58(%rbp), %rdi
callq 0x45390
movw %ax, -0x5e(%rbp)
movswl -0x5e(%rbp), %eax
cmpl $0xffff8001, %eax       # imm = 0xFFFF8001
jne 0x4a0c9
jmp 0x4a190
cmpl $0x0, -0x5c(%rbp)
jne 0x4a0d6
movswl -0x5e(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x4a125
movswl -0x5e(%rbp), %eax
andl $0x1, %eax
movslq %eax, %rcx
leaq 0xbe40c(%rip), %rax     # 0x1084f9
movsbl (%rax,%rcx), %edi
movq -0x28(%rbp), %rsi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movswl -0x5e(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movswl -0x5e(%rbp), %eax
sarl %eax
cmpl $0x0, %eax
jne 0x4a151
movq -0x28(%rbp), %rsi
movl $0x2e, %edi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a174
movswl -0x5e(%rbp), %edi
sarl %edi
subl $0x1, %edi
movq -0x28(%rbp), %rsi
callq 0x3bac0
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a176
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x58(%rbp)
jmp 0x4a09c
cmpl $0x0, -0x5c(%rbp)
jne 0x4a1b5
movq -0x28(%rbp), %rsi
movl $0x2e, %edi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x4a34b
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rdx
imull 0x8(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x4a2d0
movq -0x68(%rbp), %rdi
callq 0x453e0
movl %eax, -0x70(%rbp)
cmpl $0x80000001, -0x70(%rbp) # imm = 0x80000001
jne 0x4a20e
jmp 0x4a2d0
cmpl $0x0, -0x6c(%rbp)
jne 0x4a21a
movl -0x70(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x6c(%rbp)
je 0x4a267
movl -0x70(%rbp), %eax
andl $0x1, %eax
movslq %eax, %rcx
leaq 0xbe2c9(%rip), %rax     # 0x1084f9
movsbl (%rax,%rcx), %edi
movq -0x28(%rbp), %rsi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x70(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x70(%rbp), %eax
sarl %eax
cmpl $0x0, %eax
jne 0x4a292
movq -0x28(%rbp), %rsi
movl $0x2e, %edi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a2b4
movl -0x70(%rbp), %edi
sarl %edi
subl $0x1, %edi
movq -0x28(%rbp), %rsi
callq 0x3bac0
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a2b6
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
movq -0x68(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x68(%rbp)
jmp 0x4a1e4
cmpl $0x0, -0x6c(%rbp)
jne 0x4a2f5
movq -0x28(%rbp), %rsi
movl $0x2e, %edi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x4a34b
movq -0x28(%rbp), %rsi
movl $0x2e, %edi
callq 0x40b10
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a34b
movq -0x18(%rbp), %rax
movl 0xc(%rax), %ecx
movl $0x1, %edi
leaq 0xbe1cb(%rip), %rsi     # 0x1084fc
leaq 0xbd9d8(%rip), %rdx     # 0x107d10
movb $0x0, %al
callq 0x9d90
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x4a46d
cmpq $0x0, -0x10(%rbp)
je 0x4a45a
movq -0x10(%rbp), %rdi
callq 0x3b020
cmpl $0x3d18a0, 0x38(%rax)   # imm = 0x3D18A0
jl 0x4a45a
movl -0x38(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4a405
cmpl $0x1, -0x30(%rbp)
jle 0x4a3ac
cmpl $0x0, -0x34(%rbp)
je 0x4a3ac
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x7c, %edi
callq 0x51460
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x84(%rbp)
jmp 0x4a3f7
cmpl $0x1, -0x30(%rbp)
jg 0x4a3e1
movl -0x38(%rbp), %eax
sarl %eax
cmpl $0x0, %eax
jne 0x4a3e1
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x7c, %edi
callq 0x51460
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x88(%rbp)
jmp 0x4a3eb
xorl %eax, %eax
movl %eax, -0x88(%rbp)
jmp 0x4a3eb
movl -0x88(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a458
cmpl $0x1, -0x30(%rbp)
jg 0x4a411
cmpl $0x0, -0x38(%rbp)
jne 0x4a41d
cmpl $0x1, -0x30(%rbp)
jle 0x4a442
cmpl $0x0, -0x34(%rbp)
jne 0x4a442
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x2f, %edi
callq 0x51460
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x8c(%rbp)
jmp 0x4a44c
xorl %eax, %eax
movl %eax, -0x8c(%rbp)
jmp 0x4a44c
movl -0x8c(%rbp), %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a45a
movl -0x2c(%rbp), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)