// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/test/test-vcf-api.c
// Function: bcf_to_vcf
void bcf_to_vcf(char *fname)
{
    htsFile *fp    = hts_open(fname,"rb");
    if (!fp) error("Failed to open \"%s\" : %s", fname, strerror(errno));
    bcf_hdr_t *hdr = bcf_hdr_read(fp);
    if (!hdr) error("bcf_hdr_read : %s", strerror(errno));
    bcf1_t *rec    = bcf_init1();
    if (!rec) error("bcf_init1 : %s", strerror(errno));

    char *gz_fname = (char*) malloc(strlen(fname)+4);
    if (!gz_fname) error("malloc : %s", strerror(errno));
    snprintf(gz_fname,strlen(fname)+4,"%s.gz",fname);
    htsFile *out   = hts_open(gz_fname,"wg");
    if (!out) error("Couldn't open \"%s\" : %s\n", gz_fname, strerror(errno));

    bcf_hdr_t *hdr_out = bcf_hdr_dup(hdr);
    if (!bcf_hdr_get_hrec(hdr_out, BCF_HL_STR,"ID","BB","unused"))
        error("Missing header ##unused=<ID=BB, ...>");
    bcf_hdr_remove(hdr_out,BCF_HL_STR,"BB");
    if (bcf_hdr_get_hrec(hdr_out, BCF_HL_STR,"ID","BB","unused"))
        error("Got pointer to deleted header ##unused=<ID=BB, ...>");

    if (!bcf_hdr_get_hrec(hdr_out,BCF_HL_GEN,"unused","unformatted text 1",NULL))
        error("Missing header ##unused=unformatted text 1");
    bcf_hdr_remove(hdr_out,BCF_HL_GEN,"unused");
    if (bcf_hdr_get_hrec(hdr_out,BCF_HL_GEN,"unused","unformatted text 1",NULL))
        error("Got pointer to deleted header ##unused=unformatted text 1");

    if (!bcf_hdr_get_hrec(hdr_out,BCF_HL_FLT,"ID","Flt",NULL))
        error("Missing header ##FILTER=<ID=Flt, ...>");
    bcf_hdr_remove(hdr_out,BCF_HL_FLT,"Flt");
    if (bcf_hdr_get_hrec(hdr_out,BCF_HL_FLT,"ID","Flt",NULL))
        error("Got pointer to deleted header ##FILTER=<ID=Flt, ...>");

    if (!bcf_hdr_get_hrec(hdr_out,BCF_HL_INFO,"ID","UI",NULL))
        error("Missing header ##INFO=<ID=UI, ...>");
    bcf_hdr_remove(hdr_out,BCF_HL_INFO,"UI");
    if (bcf_hdr_get_hrec(hdr_out,BCF_HL_INFO,"ID","UI",NULL))
        error("Got pointer to deleted header ##INFO=<ID=UI, ...>");

    if (!bcf_hdr_get_hrec(hdr_out,BCF_HL_FMT,"ID","UF",NULL))
        error("Missing header ##INFO=<ID=UF, ...>");
    bcf_hdr_remove(hdr_out,BCF_HL_FMT,"UF");
    if (bcf_hdr_get_hrec(hdr_out,BCF_HL_FMT,"ID","UF",NULL))
        error("Got pointer to deleted header ##INFO=<ID=UF, ...>");

    if (!bcf_hdr_get_hrec(hdr_out,BCF_HL_CTG,"ID","Unused",NULL))
        error("Missing header ##contig=<ID=Unused,length=1>");
    bcf_hdr_remove(hdr_out,BCF_HL_CTG,"Unused");
    if (bcf_hdr_get_hrec(hdr_out,BCF_HL_FMT,"ID","Unused",NULL))
        error("Got pointer to header ##contig=<ID=Unused,length=1>");

    if ( bcf_hdr_write(out, hdr_out)!=0 ) error("Failed to write to %s\n", fname);
    int r;
    while ((r = bcf_read1(fp, hdr, rec)) >= 0)
    {
        if ( bcf_write1(out, hdr_out, rec)!=0 ) error("Failed to write to %s\n", fname);

        // Test problems caused by bcf1_sync: the data block
        // may be realloced, also the unpacked structures must
        // get updated.
        check0(bcf_unpack(rec, BCF_UN_STR));
        check0(bcf_update_id(hdr, rec, 0));
        check0(bcf_update_format_int32(hdr, rec, "GQ", NULL, 0));

        bcf1_t *dup = bcf_dup(rec);     // force bcf1_sync call
        if ( bcf_write1(out, hdr_out, dup)!=0 ) error("Failed to write to %s\n", fname);
        bcf_destroy1(dup);

        check0(bcf_update_alleles_str(hdr_out, rec, "G,A"));
        int32_t tmpi = 99;
        check0(bcf_update_info_int32(hdr_out, rec, "DP", &tmpi, 1));
        int32_t tmpia[] = {9,9,9};
        check0(bcf_update_format_int32(hdr_out, rec, "DP", tmpia, 3));

        if ( bcf_write1(out, hdr_out, rec)!=0 ) error("Failed to write to %s\n", fname);
    }
    if (r < -1) error("bcf_read1");

    bcf_destroy1(rec);
    bcf_hdr_destroy(hdr);
    bcf_hdr_destroy(hdr_out);
    int ret;
    if ( (ret=hts_close(fp)) )
    {
        fprintf(stderr,"hts_close(%s): non-zero status %d\n",fname,ret);
        exit(ret);
    }
    if ( (ret=hts_close(out)) )
    {
        fprintf(stderr,"hts_close(%s): non-zero status %d\n",gz_fname,ret);
        exit(ret);
    }


    // read gzip, write stdout
    htsFile *gz_in = hts_open(gz_fname, "r");
    if ( !gz_in )
    {
        fprintf(stderr,"Could not read: %s\n", gz_fname);
        exit(1);
    }

    kstring_t line = {0,0,0};
    while ( hts_getline(gz_in, KS_SEP_LINE, &line)>0 )
    {
        kputc('\n',&line);
        fwrite(line.s,1,line.l,stdout);
    }

    if ( (ret=hts_close(gz_in)) )
    {
        fprintf(stderr,"hts_close(%s): non-zero status %d\n",gz_fname,ret);
        exit(ret);
    }
    free(line.s);
    free(gz_fname);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r15
leaq 0x7e964(%rip), %rsi     # 0x856fb
callq 0xa70f
testq %rax, %rax
je 0x73b8
movq %rax, %rbx
movq %rax, %rdi
callq 0x27ba6
testq %rax, %rax
je 0x73d0
movq %rax, %rbp
callq 0x2849e
testq %rax, %rax
je 0x73e5
movq %rax, %r13
movq %rbx, 0x40(%rsp)
movq %r15, %rdi
callq 0x41c0
movq %rax, %rbx
addq $0x4, %rbx
movq %rbx, %rdi
callq 0x46a0
testq %rax, %rax
je 0x73fa
movq %rax, %r14
leaq 0x7e920(%rip), %rdx     # 0x8571c
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rcx
xorl %eax, %eax
callq 0x4820
leaq 0x7e90f(%rip), %rsi     # 0x85722
movq %r14, 0x8(%rsp)
movq %r14, %rdi
callq 0xa70f
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x7412
movq %r15, 0x10(%rsp)
movq %rbp, %rdi
callq 0x2fa17
movq %rax, %r14
leaq 0x7e8f9(%rip), %rdx     # 0x8573e
leaq 0x7e8f5(%rip), %rcx     # 0x85741
leaq 0x7e8f1(%rip), %r8      # 0x85744
pushq $0x4
popq %rsi
movq %rax, %rdi
callq 0x269dd
testq %rax, %rax
je 0x7434
leaq 0x7e8d3(%rip), %rbx     # 0x85741
pushq $0x4
popq %r15
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x26ff2
leaq 0x7e8b7(%rip), %rdx     # 0x8573e
leaq 0x7e8b6(%rip), %r8      # 0x85744
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rcx
callq 0x269dd
testq %rax, %rax
jne 0x743d
leaq 0x7e898(%rip), %rdx     # 0x85744
leaq 0x7e943(%rip), %rcx     # 0x857f6
pushq $0x5
popq %rsi
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
je 0x7446
leaq 0x7e873(%rip), %rbx     # 0x85744
pushq $0x5
popq %r15
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x26ff2
leaq 0x7e90c(%rip), %rcx     # 0x857f6
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
jne 0x744f
leaq 0x7e833(%rip), %rdx     # 0x8573e
leaq 0x7e8f7(%rip), %rcx     # 0x85809
movq %r14, %rdi
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
je 0x7458
leaq 0x7e8da(%rip), %rbx     # 0x85809
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x26ff2
leaq 0x7e7fb(%rip), %rdx     # 0x8573e
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
jne 0x7461
leaq 0x7e7db(%rip), %rdx     # 0x8573e
leaq 0x7e8fe(%rip), %rcx     # 0x85868
pushq $0x1
popq %rsi
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
je 0x746a
leaq 0x7e8e0(%rip), %rbx     # 0x85868
pushq $0x1
popq %r15
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x26ff2
leaq 0x7e79d(%rip), %rdx     # 0x8573e
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
jne 0x7473
leaq 0x7e77c(%rip), %rdx     # 0x8573e
leaq 0x7e8f7(%rip), %rcx     # 0x858c0
pushq $0x2
popq %rsi
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
je 0x747c
leaq 0x7e8d9(%rip), %rbx     # 0x858c0
pushq $0x2
popq %r15
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x26ff2
leaq 0x7e73e(%rip), %rdx     # 0x8573e
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
jne 0x7485
leaq 0x7e71d(%rip), %rdx     # 0x8573e
leaq 0x7df11(%rip), %rcx     # 0x84f39
pushq $0x3
popq %rsi
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
je 0x748e
leaq 0x7def3(%rip), %rbx     # 0x84f39
pushq $0x3
popq %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x26ff2
leaq 0x7e6e3(%rip), %rdx     # 0x8573e
pushq $0x2
popq %rsi
movq %r14, %rdi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x269dd
testq %rax, %rax
jne 0x7497
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x281c9
testl %eax, %eax
jne 0x71d2
pushq $0x1
popq %rbx
leaq 0x7e293(%rip), %r15     # 0x85327
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x288ae
testl %eax, %eax
js 0x71e3
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x298d5
testl %eax, %eax
jne 0x71d2
movq %r13, %rdi
movl %ebx, %esi
callq 0x2d678
testl %eax, %eax
jne 0x7386
movq %rbp, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x32064
testl %eax, %eax
jne 0x7356
movq %rbp, %rdi
movq %r15, %r12
movq %r13, %rsi
leaq 0x7e378(%rip), %rdx     # 0x85473
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %ebx, %r9d
callq 0x3156c
testl %eax, %eax
jne 0x7376
movq %r13, %rdi
callq 0x298c0
movq %rax, %r15
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x298d5
testl %eax, %eax
jne 0x71d2
movq %r15, %rdi
callq 0x28630
movq %r14, %rdi
movq %r13, %rsi
leaq 0x7e137(%rip), %rdx     # 0x8527f
callq 0x31fcc
testl %eax, %eax
jne 0x7366
movl $0x63, 0x3c(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %r15
movq %r12, %rdx
leaq 0x3c(%rsp), %rcx
movl %ebx, %r8d
movl %ebx, %r9d
callq 0x30f42
testl %eax, %eax
jne 0x7336
movabsq $0x900000009, %rax      # imm = 0x900000009
movq %rax, 0x20(%rsp)
movl $0x9, 0x28(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
leaq 0x20(%rsp), %rcx
pushq $0x3
popq %r8
movl %ebx, %r9d
callq 0x3156c
testl %eax, %eax
jne 0x7346
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x298d5
testl %eax, %eax
je 0x7094
leaq 0x7e05d(%rip), %rdi     # 0x85236
movq 0x10(%rsp), %rsi
jmp 0x7394
cmpl $-0x1, %eax
jne 0x74a0
movq %r13, %rdi
callq 0x28630
movq %rbp, %rdi
callq 0x27a34
movq %r14, %rdi
callq 0x27a34
movq 0x40(%rsp), %rdi
callq 0xb8e5
testl %eax, %eax
jne 0x74ae
movq 0x18(%rsp), %rdi
callq 0xb8e5
testl %eax, %eax
jne 0x739b
leaq 0x822e0(%rip), %rsi     # 0x8950f
movq 0x8(%rsp), %rdi
callq 0xa70f
testq %rax, %rax
je 0x74d6
movq %rax, %rbx
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
pushq $0x2
popq %rbp
movq 0xabd60(%rip), %r13     # 0xb2fc0
pushq $0x1
popq %r15
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0xbe80
testl %eax, %eax
jle 0x7303
movq 0x20(%rsp), %rcx
leaq 0x2(%rcx), %rax
cmpq %rax, 0x28(%rsp)
jae 0x72c8
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %r12
shrq %r12
testq %rcx, %rcx
movl $0x0, %ecx
cmovneq %rcx, %r12
addq %rax, %r12
movq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x4860
testq %rax, %rax
je 0x72e8
movq %rax, 0x30(%rsp)
movq %r12, 0x28(%rsp)
movq 0x20(%rsp), %rcx
jmp 0x72cd
movq 0x30(%rsp), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rsp)
movb $0xa, (%rax,%rcx)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x20(%rsp), %rdx
movq 0x30(%rsp), %rdi
movq (%r13), %rcx
movq %r15, %rsi
callq 0x49b0
jmp 0x7264
movq %rbx, %rdi
callq 0xb8e5
testl %eax, %eax
jne 0x739b
movq 0x30(%rsp), %rdi
callq 0x45c0
movq 0x8(%rsp), %rdi
callq 0x45c0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7cd4c(%rip), %rdi     # 0x84089
leaq 0x7e6c8(%rip), %rsi     # 0x85a0c
jmp 0x7394
leaq 0x7cd3c(%rip), %rdi     # 0x84089
leaq 0x7e6ee(%rip), %rsi     # 0x85a42
jmp 0x7394
leaq 0x7cd2c(%rip), %rdi     # 0x84089
leaq 0x7e628(%rip), %rsi     # 0x8598c
jmp 0x7394
leaq 0x7cd1c(%rip), %rdi     # 0x84089
leaq 0x7e66c(%rip), %rsi     # 0x859e0
jmp 0x7394
leaq 0x7cd0c(%rip), %rdi     # 0x84089
leaq 0x7e623(%rip), %rsi     # 0x859a7
jmp 0x7394
leaq 0x7ccfc(%rip), %rdi     # 0x84089
leaq 0x7e5e5(%rip), %rsi     # 0x85979
xorl %eax, %eax
callq 0x5abc
movl %eax, %ebx
movq 0xabc3c(%rip), %rax     # 0xb2fe0
movq (%rax), %rdi
leaq 0x7e32a(%rip), %rsi     # 0x856d8
movq 0x8(%rsp), %rdx
jmp 0x74c6
callq 0x4050
movl (%rax), %edi
callq 0x4140
leaq 0x7cc84(%rip), %rdi     # 0x8404f
movq %r15, %rsi
jmp 0x742a
callq 0x4050
movl (%rax), %edi
callq 0x4140
leaq 0x7e31b(%rip), %rdi     # 0x856fe
jmp 0x740d
callq 0x4050
movl (%rax), %edi
callq 0x4140
leaq 0x7cc82(%rip), %rdi     # 0x8407a
jmp 0x740d
callq 0x4050
movl (%rax), %edi
callq 0x4140
leaq 0x7e303(%rip), %rdi     # 0x85710
movq %rax, %rsi
jmp 0x7394
callq 0x4050
movl (%rax), %edi
callq 0x4140
leaq 0x7e300(%rip), %rdi     # 0x85725
movq 0x8(%rsp), %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x5abc
leaq 0x7e310(%rip), %rdi     # 0x8574b
jmp 0x74a7
leaq 0x7e32c(%rip), %rdi     # 0x85770
jmp 0x74a7
leaq 0x7e357(%rip), %rdi     # 0x857a4
jmp 0x74a7
leaq 0x7e379(%rip), %rdi     # 0x857cf
jmp 0x74a7
leaq 0x7e3ae(%rip), %rdi     # 0x8580d
jmp 0x74a7
leaq 0x7e3cb(%rip), %rdi     # 0x85833
jmp 0x74a7
leaq 0x7e3fa(%rip), %rdi     # 0x8586b
jmp 0x74a7
leaq 0x7e414(%rip), %rdi     # 0x8588e
jmp 0x74a7
leaq 0x7e440(%rip), %rdi     # 0x858c3
jmp 0x74a7
leaq 0x7e45a(%rip), %rdi     # 0x858e6
jmp 0x74a7
leaq 0x7e483(%rip), %rdi     # 0x85918
jmp 0x74a7
leaq 0x7e4a7(%rip), %rdi     # 0x85945
jmp 0x74a7
leaq 0x7e5d3(%rip), %rdi     # 0x85a7a
xorl %eax, %eax
callq 0x5abc
movl %eax, %ebx
movq 0xabb29(%rip), %rax     # 0xb2fe0
movq (%rax), %rdi
leaq 0x7e217(%rip), %rsi     # 0x856d8
movq 0x10(%rsp), %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4720
movl %ebx, %edi
callq 0x45f0
movq 0xabb03(%rip), %rax     # 0xb2fe0
movq (%rax), %rdi
leaq 0x7e59d(%rip), %rsi     # 0x85a84
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x4720
pushq $0x1
popq %rdi
callq 0x45f0