// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x100391(%rip), %rsi    # 0x1076cb
callq 0xcf30
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x7379
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
callq 0x4050
movl (%rax), %edi
callq 0x4120
movq -0x88(%rbp), %rsi
movq %rax, %rdx
leaq 0xfecad(%rip), %rdi     # 0x10601f
movb $0x0, %al
callq 0x5ae0
movq -0x10(%rbp), %rdi
callq 0x43030
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x73aa
callq 0x4050
movl (%rax), %edi
callq 0x4120
movq %rax, %rsi
leaq 0x10032b(%rip), %rdi    # 0x1076ce
movb $0x0, %al
callq 0x5ae0
callq 0x43c30
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x73d7
callq 0x4050
movl (%rax), %edi
callq 0x4120
movq %rax, %rsi
leaq 0xfec7a(%rip), %rdi     # 0x10604a
movb $0x0, %al
callq 0x5ae0
movq -0x8(%rbp), %rdi
callq 0x41a0
movq %rax, %rdi
addq $0x4, %rdi
callq 0x4680
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x7414
callq 0x4050
movl (%rax), %edi
callq 0x4120
movq %rax, %rsi
leaq 0x1002d3(%rip), %rdi    # 0x1076e0
movb $0x0, %al
callq 0x5ae0
movq -0x28(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rdi
callq 0x41a0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
addq $0x4, %rsi
movq -0x8(%rbp), %rcx
leaq 0x1002ab(%rip), %rdx    # 0x1076ec
movb $0x0, %al
callq 0x4810
movq -0x28(%rbp), %rdi
leaq 0x10029f(%rip), %rsi    # 0x1076f2
callq 0xcf30
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x7492
movq -0x28(%rbp), %rax
movq %rax, -0x98(%rbp)
callq 0x4050
movl (%rax), %edi
callq 0x4120
movq -0x98(%rbp), %rsi
movq %rax, %rdx
leaq 0x10026a(%rip), %rdi    # 0x1076f5
movb $0x0, %al
callq 0x5ae0
movq -0x18(%rbp), %rdi
callq 0x4f500
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl $0x4, %esi
leaq 0x10025f(%rip), %rdx    # 0x10770e
leaq 0x10025b(%rip), %rcx    # 0x107711
leaq 0x100257(%rip), %r8     # 0x107714
callq 0x411e0
cmpq $0x0, %rax
jne 0x74d6
leaq 0x10024c(%rip), %rdi    # 0x10771b
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
movl $0x4, %esi
leaq 0x10022b(%rip), %rdx    # 0x107711
callq 0x41cd0
movq -0x38(%rbp), %rdi
movl $0x4, %esi
leaq 0x100213(%rip), %rdx    # 0x10770e
leaq 0x10020f(%rip), %rcx    # 0x107711
leaq 0x10020b(%rip), %r8     # 0x107714
callq 0x411e0
cmpq $0x0, %rax
je 0x7522
leaq 0x100225(%rip), %rdi    # 0x107740
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
movl $0x5, %esi
leaq 0x1001e2(%rip), %rdx    # 0x107714
leaq 0x10028d(%rip), %rcx    # 0x1077c6
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
jne 0x7557
leaq 0x100224(%rip), %rdi    # 0x107774
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
movl $0x5, %esi
leaq 0x1001ad(%rip), %rdx    # 0x107714
callq 0x41cd0
movq -0x38(%rbp), %rdi
movl $0x5, %esi
leaq 0x100198(%rip), %rdx    # 0x107714
leaq 0x100243(%rip), %rcx    # 0x1077c6
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
je 0x75a1
leaq 0x100205(%rip), %rdi    # 0x10779f
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
xorl %esi, %esi
leaq 0x100160(%rip), %rdx    # 0x10770e
leaq 0x100224(%rip), %rcx    # 0x1077d9
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
jne 0x75d3
leaq 0x100211(%rip), %rdi    # 0x1077dd
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
xorl %esi, %esi
leaq 0x1001f9(%rip), %rdx    # 0x1077d9
callq 0x41cd0
movq -0x38(%rbp), %rdi
xorl %esi, %esi
leaq 0x10011c(%rip), %rdx    # 0x10770e
leaq 0x1001e0(%rip), %rcx    # 0x1077d9
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
je 0x7617
leaq 0x1001f3(%rip), %rdi    # 0x107803
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x1000e7(%rip), %rdx    # 0x10770e
leaq 0x10020a(%rip), %rcx    # 0x107838
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
jne 0x764c
leaq 0x1001f6(%rip), %rdi    # 0x10783b
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x1001dc(%rip), %rdx    # 0x107838
callq 0x41cd0
movq -0x38(%rbp), %rdi
movl $0x1, %esi
leaq 0x10009d(%rip), %rdx    # 0x10770e
leaq 0x1001c0(%rip), %rcx    # 0x107838
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
je 0x7696
leaq 0x1001cf(%rip), %rdi    # 0x10785e
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
movl $0x2, %esi
leaq 0x100068(%rip), %rdx    # 0x10770e
leaq 0x1001e3(%rip), %rcx    # 0x107890
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
jne 0x76cb
leaq 0x1001cf(%rip), %rdi    # 0x107893
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
movl $0x2, %esi
leaq 0x1001b5(%rip), %rdx    # 0x107890
callq 0x41cd0
movq -0x38(%rbp), %rdi
movl $0x2, %esi
leaq 0x10001e(%rip), %rdx    # 0x10770e
leaq 0x100199(%rip), %rcx    # 0x107890
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
je 0x7715
leaq 0x1001a8(%rip), %rdi    # 0x1078b6
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
movl $0x3, %esi
leaq 0xfffe9(%rip), %rdx     # 0x10770e
leaq 0xff7dd(%rip), %rcx     # 0x106f09
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
jne 0x774a
leaq 0x1001a5(%rip), %rdi    # 0x1078e8
movb $0x0, %al
callq 0x5ae0
movq -0x38(%rbp), %rdi
movl $0x3, %esi
leaq 0xff7af(%rip), %rdx     # 0x106f09
callq 0x41cd0
movq -0x38(%rbp), %rdi
movl $0x2, %esi
leaq 0xfff9f(%rip), %rdx     # 0x10770e
leaq 0xff793(%rip), %rcx     # 0x106f09
xorl %eax, %eax
movl %eax, %r8d
callq 0x411e0
cmpq $0x0, %rax
je 0x7794
leaq 0x100188(%rip), %rdi    # 0x107915
movb $0x0, %al
callq 0x5ae0
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x43790
cmpl $0x0, %eax
je 0x77b8
movq -0x8(%rbp), %rsi
leaq 0xffa55(%rip), %rdi     # 0x107206
movb $0x0, %al
callq 0x5ae0
jmp 0x77ba
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x44620
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
jl 0x79c6
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x46180
cmpl $0x0, %eax
je 0x77ff
movq -0x8(%rbp), %rsi
leaq 0xffa0e(%rip), %rdi     # 0x107206
movb $0x0, %al
callq 0x5ae0
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0x4b190
cmpl $0x0, %eax
jne 0x7814
jmp 0x7829
leaq 0xfe83e(%rip), %rdi     # 0x106059
leaq 0x100127(%rip), %rsi    # 0x107949
movb $0x0, %al
callq 0x5ae0
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x52b50
cmpl $0x0, %eax
jne 0x7841
jmp 0x7856
leaq 0xfe811(%rip), %rdi     # 0x106059
leaq 0x10010d(%rip), %rsi    # 0x10795c
movb $0x0, %al
callq 0x5ae0
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xffbde(%rip), %rdx     # 0x107443
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x518f0
cmpl $0x0, %eax
jne 0x787e
jmp 0x7893
leaq 0xfe7d4(%rip), %rdi     # 0x106059
leaq 0x1000eb(%rip), %rsi    # 0x107977
movb $0x0, %al
callq 0x5ae0
movq -0x20(%rbp), %rdi
callq 0x46150
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x46180
cmpl $0x0, %eax
je 0x78c8
movq -0x8(%rbp), %rsi
leaq 0xff945(%rip), %rdi     # 0x107206
movb $0x0, %al
callq 0x5ae0
movq -0x48(%rbp), %rdi
callq 0x44020
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xff96f(%rip), %rdx     # 0x10724f
callq 0x52a70
cmpl $0x0, %eax
jne 0x78ec
jmp 0x7901
leaq 0xfe766(%rip), %rdi     # 0x106059
leaq 0x1000b6(%rip), %rsi    # 0x1079b0
movb $0x0, %al
callq 0x5ae0
movl $0x63, -0x4c(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xff9e0(%rip), %rdx     # 0x1072f7
leaq -0x4c(%rbp), %rcx
movl $0x1, %r9d
movl %r9d, %r8d
callq 0x50f90
cmpl $0x0, %eax
jne 0x7930
jmp 0x7945
leaq 0xfe722(%rip), %rdi     # 0x106059
leaq 0x10009e(%rip), %rsi    # 0x1079dc
movb $0x0, %al
callq 0x5ae0
movq 0x100c24(%rip), %rax    # 0x108570
movq %rax, -0x58(%rbp)
movl 0x100c22(%rip), %eax    # 0x108578
movl %eax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0x58(%rbp), %rcx
leaq 0xff98b(%rip), %rdx     # 0x1072f7
movl $0x3, %r8d
movl $0x1, %r9d
callq 0x518f0
cmpl $0x0, %eax
jne 0x7984
jmp 0x7999
leaq 0xfe6ce(%rip), %rdi     # 0x106059
leaq 0x100080(%rip), %rsi    # 0x107a12
movb $0x0, %al
callq 0x5ae0
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x46180
cmpl $0x0, %eax
je 0x79c1
movq -0x8(%rbp), %rsi
leaq 0xff84c(%rip), %rdi     # 0x107206
movb $0x0, %al
callq 0x5ae0
jmp 0x77ba
cmpl $-0x1, -0x3c(%rbp)
jge 0x79da
leaq 0x100077(%rip), %rdi    # 0x107a4a
movb $0x0, %al
callq 0x5ae0
movq -0x20(%rbp), %rdi
callq 0x44020
movq -0x18(%rbp), %rdi
callq 0x42dd0
movq -0x38(%rbp), %rdi
callq 0x42dd0
movq -0x10(%rbp), %rdi
callq 0xf050
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x7a2d
movq 0x1235cb(%rip), %rax    # 0x12afd8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movl -0x5c(%rbp), %ecx
leaq 0xffc8a(%rip), %rsi     # 0x1076a8
movb $0x0, %al
callq 0x4700
movl -0x5c(%rbp), %edi
callq 0x45d0
movq -0x30(%rbp), %rdi
callq 0xf050
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x7a65
movq 0x123593(%rip), %rax    # 0x12afd8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
movl -0x5c(%rbp), %ecx
leaq 0xffc52(%rip), %rsi     # 0x1076a8
movb $0x0, %al
callq 0x4700
movl -0x5c(%rbp), %edi
callq 0x45d0
movq -0x28(%rbp), %rdi
leaq 0x103d2a(%rip), %rsi    # 0x10b79a
callq 0xcf30
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x7aa6
movq 0x123551(%rip), %rax    # 0x12afd8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0xfffbf(%rip), %rsi     # 0x107a54
movb $0x0, %al
callq 0x4700
movl $0x1, %edi
callq 0x45d0
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4240
movq -0x68(%rbp), %rdi
movl $0x2, %esi
leaq -0x80(%rbp), %rdx
callq 0xfdb0
cmpl $0x0, %eax
jle 0x7af9
movl $0xa, %edi
leaq -0x80(%rbp), %rsi
callq 0x7b50
movq -0x70(%rbp), %rdi
movq -0x80(%rbp), %rdx
movq 0x1234ce(%rip), %rax    # 0x12afb8
movq (%rax), %rcx
movl $0x1, %esi
callq 0x49c0
jmp 0x7ab6
movq -0x68(%rbp), %rdi
callq 0xf050
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x7b31
movq 0x1234c7(%rip), %rax    # 0x12afd8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
movl -0x5c(%rbp), %ecx
leaq 0xffb86(%rip), %rsi     # 0x1076a8
movb $0x0, %al
callq 0x4700
movl -0x5c(%rbp), %edi
callq 0x45d0
movq -0x70(%rbp), %rdi
callq 0x45a0
movq -0x28(%rbp), %rdi
callq 0x45a0
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)