// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/test/test-bcf-translate.c
// Function: main
int main(int argc, char **argv)
{
    char *fname = argc>1 ? argv[1] : "/dev/null";
    htsFile *fp = hts_open(fname, "w");
    bcf_hdr_t *hdr1, *hdr2;

    hdr1 = bcf_hdr_init("w");
    hdr2 = bcf_hdr_init("w");

    // Add two shared and two private annotations
    bcf_hdr_append(hdr1, "##contig=<ID=1>");
    bcf_hdr_append(hdr1, "##contig=<ID=2>");
    bcf_hdr_append(hdr2, "##contig=<ID=2>");
    bcf_hdr_append(hdr2, "##contig=<ID=1>");
    bcf_hdr_append(hdr1, "##FILTER=<ID=FLT1,Description=\"Filter 1\">");
    bcf_hdr_append(hdr1, "##FILTER=<ID=FLT2,Description=\"Filter 2\">");
    bcf_hdr_append(hdr1, "##FILTER=<ID=FLT3,Description=\"Filter 3\">");
    bcf_hdr_append(hdr2, "##FILTER=<ID=FLT4,Description=\"Filter 4\">");
    bcf_hdr_append(hdr2, "##FILTER=<ID=FLT3,Description=\"Filter 3\">");
    bcf_hdr_append(hdr2, "##FILTER=<ID=FLT2,Description=\"Filter 2\">");
    bcf_hdr_append(hdr1, "##INFO=<ID=INF1,Number=.,Type=Integer,Description=\"Info 1\">");
    bcf_hdr_append(hdr1, "##INFO=<ID=INF2,Number=.,Type=Integer,Description=\"Info 2\">");
    bcf_hdr_append(hdr1, "##INFO=<ID=INF3,Number=.,Type=Integer,Description=\"Info 3\">");
    bcf_hdr_append(hdr2, "##INFO=<ID=INF4,Number=.,Type=Integer,Description=\"Info 4\">");
    bcf_hdr_append(hdr2, "##INFO=<ID=INF3,Number=.,Type=Integer,Description=\"Info 3\">");
    bcf_hdr_append(hdr2, "##INFO=<ID=INF2,Number=.,Type=Integer,Description=\"Info 2\">");
    bcf_hdr_append(hdr1, "##FORMAT=<ID=FMT1,Number=.,Type=Integer,Description=\"FMT 1\">");
    bcf_hdr_append(hdr1, "##FORMAT=<ID=FMT2,Number=.,Type=Integer,Description=\"FMT 2\">");
    bcf_hdr_append(hdr1, "##FORMAT=<ID=FMT3,Number=.,Type=Integer,Description=\"FMT 3\">");
    bcf_hdr_append(hdr2, "##FORMAT=<ID=FMT4,Number=.,Type=Integer,Description=\"FMT 4\">");
    bcf_hdr_append(hdr2, "##FORMAT=<ID=FMT3,Number=.,Type=Integer,Description=\"FMT 3\">");
    bcf_hdr_append(hdr2, "##FORMAT=<ID=FMT2,Number=.,Type=Integer,Description=\"FMT 2\">");
    bcf_hdr_add_sample(hdr1,"SMPL1");
    bcf_hdr_add_sample(hdr1,"SMPL2");
    bcf_hdr_add_sample(hdr2,"SMPL1");
    bcf_hdr_add_sample(hdr2,"SMPL2");
    if (bcf_hdr_sync(hdr1) < 0) error("bcf_hdr_sync(hdr1)");
    if (bcf_hdr_sync(hdr2) < 0) error("bcf_hdr_sync(hdr2)");

    hdr2 = bcf_hdr_merge(hdr2,hdr1);
    if (bcf_hdr_sync(hdr2) < 0) error("bcf_hdr_sync(hdr2) after merge");
    if ( bcf_hdr_write(fp, hdr2)!=0 ) error("Failed to write to %s\n", fname);

    bcf1_t *rec = bcf_init1();
    rec->rid = bcf_hdr_name2id(hdr1, "1");
    rec->pos = 0;
    bcf_update_alleles_str(hdr1, rec, "G,A");
    int32_t tmpi[3];
    tmpi[0] = bcf_hdr_id2int(hdr1, BCF_DT_ID, "FLT1");
    tmpi[1] = bcf_hdr_id2int(hdr1, BCF_DT_ID, "FLT2");
    tmpi[2] = bcf_hdr_id2int(hdr1, BCF_DT_ID, "FLT3");
    bcf_update_filter(hdr1, rec, tmpi, 3);
    tmpi[0] = 1; bcf_update_info_int32(hdr1, rec, "INF1", tmpi, 1);
    tmpi[0] = 2; bcf_update_info_int32(hdr1, rec, "INF2", tmpi, 1);
    tmpi[0] = 3; bcf_update_info_int32(hdr1, rec, "INF3", tmpi, 1);
    tmpi[0] = tmpi[1] = 1; bcf_update_format_int32(hdr1, rec, "FMT1", tmpi, 2);
    tmpi[0] = tmpi[1] = 2; bcf_update_format_int32(hdr1, rec, "FMT2", tmpi, 2);
    tmpi[0] = tmpi[1] = 3; bcf_update_format_int32(hdr1, rec, "FMT3", tmpi, 2);

    bcf_remove_filter(hdr1, rec, bcf_hdr_id2int(hdr1, BCF_DT_ID, "FLT2"), 0);
    bcf_update_info_int32(hdr1, rec, "INF2", NULL, 0);
    bcf_update_format_int32(hdr1, rec, "FMT2", NULL, 0);

    bcf_translate(hdr2, hdr1, rec);
    if ( bcf_write(fp, hdr2, rec)!=0 ) error("Failed to write to %s\n", fname);

    // Clean
    bcf_destroy1(rec);
    bcf_hdr_destroy(hdr1);
    bcf_hdr_destroy(hdr2);
    int ret;
    if ( (ret=hts_close(fp)) )
    {
        fprintf(stderr,"hts_close(%s): non-zero status %d\n",fname,ret);
        exit(ret);
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x2, %edi
jl 0x5f6f
movq 0x8(%rsi), %r13
jmp 0x5f76
leaq 0xa408e(%rip), %r13     # 0xaa004
leaq 0xa64d4(%rip), %rbx     # 0xac451
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9877
movq %rax, %rbp
movq %rbx, %rdi
callq 0x2f149
movq %rax, %r15
movq %rbx, %rdi
callq 0x2f149
movq %rax, %r12
leaq 0xa4066(%rip), %rbx     # 0xaa00e
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2e8ff
leaq 0xa4064(%rip), %r14     # 0xaa01e
movq %r15, %rdi
movq %r14, %rsi
callq 0x2e8ff
movq %r12, %rdi
movq %r14, %rsi
callq 0x2e8ff
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2e8ff
leaq 0xa404c(%rip), %rsi     # 0xaa02e
movq %r15, %rdi
callq 0x2e8ff
leaq 0xa4067(%rip), %rbx     # 0xaa058
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2e8ff
leaq 0xa407f(%rip), %r14     # 0xaa082
movq %r15, %rdi
movq %r14, %rsi
callq 0x2e8ff
leaq 0xa4097(%rip), %rsi     # 0xaa0ac
movq %r12, %rdi
callq 0x2e8ff
movq %r12, %rdi
movq %r14, %rsi
callq 0x2e8ff
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2e8ff
leaq 0xa409c(%rip), %rsi     # 0xaa0d6
movq %r15, %rdi
callq 0x2e8ff
leaq 0xa40c9(%rip), %rbx     # 0xaa112
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2e8ff
leaq 0xa40f3(%rip), %r14     # 0xaa14e
movq %r15, %rdi
movq %r14, %rsi
callq 0x2e8ff
leaq 0xa411d(%rip), %rsi     # 0xaa18a
movq %r12, %rdi
callq 0x2e8ff
movq %r12, %rdi
movq %r14, %rsi
callq 0x2e8ff
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2e8ff
leaq 0xa4134(%rip), %rsi     # 0xaa1c6
movq %r15, %rdi
callq 0x2e8ff
leaq 0xa4162(%rip), %rbx     # 0xaa203
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2e8ff
leaq 0xa418d(%rip), %r14     # 0xaa240
movq %r15, %rdi
movq %r14, %rsi
callq 0x2e8ff
leaq 0xa41b8(%rip), %rsi     # 0xaa27d
movq %r12, %rdi
callq 0x2e8ff
movq %r12, %rdi
movq %r14, %rsi
callq 0x2e8ff
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2e8ff
leaq 0xa41d0(%rip), %rbx     # 0xaa2ba
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2b98c
leaq 0xa41c4(%rip), %r14     # 0xaa2c0
movq %r15, %rdi
movq %r14, %rsi
callq 0x2b98c
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2b98c
movq %r12, %rdi
movq %r14, %rsi
callq 0x2b98c
movq %r15, %rdi
callq 0x2bc46
testl %eax, %eax
js 0x63c9
movq %r12, %rdi
callq 0x2bc46
testl %eax, %eax
js 0x63d2
movq %r12, %rdi
movq %r15, %rsi
callq 0x3c995
movq %rax, %r12
movq %rax, %rdi
callq 0x2bc46
testl %eax, %eax
js 0x63db
movq %r13, 0x8(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x30474
testl %eax, %eax
movq %rbp, 0x10(%rsp)
jne 0x63b6
callq 0x30833
movq %rax, %r13
leaq 0xa693d(%rip), %rdx     # 0xacac4
movq %r15, %rdi
movl $0x1, %esi
callq 0x2e585
movl %eax, 0x10(%r13)
movq $0x0, (%r13)
leaq 0xa417b(%rip), %rdx     # 0xaa322
movq %r15, %rdi
movq %r13, %rsi
callq 0x40e2f
leaq 0xa416d(%rip), %rdx     # 0xaa326
movq %r15, %rdi
xorl %esi, %esi
callq 0x2e585
leaq 0x1c(%rsp), %rbx
movl %eax, (%rbx)
leaq 0xa415a(%rip), %rdx     # 0xaa32b
movq %r15, %rdi
xorl %esi, %esi
callq 0x2e585
movl %eax, 0x4(%rbx)
leaq 0xa414b(%rip), %rdx     # 0xaa330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2e585
movl %eax, 0x8(%rbx)
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movl $0x3, %ecx
callq 0x408b1
movl $0x1, (%rbx)
leaq 0xa4123(%rip), %rdx     # 0xaa335
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x3f68d
movl $0x2, (%rbx)
leaq 0xa4101(%rip), %r14     # 0xaa33a
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbx, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x3f68d
movl $0x3, (%rbx)
leaq 0xa40dc(%rip), %rdx     # 0xaa33f
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x3f68d
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%rbx)
leaq 0xa40b3(%rip), %rdx     # 0xaa344
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x3fe23
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, (%rbx)
leaq 0xa408a(%rip), %rbp     # 0xaa349
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x3fe23
movabsq $0x300000003, %rax      # imm = 0x300000003
movq %rax, (%rbx)
leaq 0xa405e(%rip), %rdx     # 0xaa34e
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x3fe23
movq %r15, %rdi
xorl %esi, %esi
leaq 0xa4015(%rip), %rdx     # 0xaa32b
callq 0x2e585
movq %r15, %rdi
movq %r13, %rsi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x40a13
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x3f68d
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x3fe23
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3cfd3
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x32763
testl %eax, %eax
jne 0x63b6
movq %r13, %rdi
callq 0x309d6
movq %r15, %rdi
callq 0x2f696
movq %r12, %rdi
callq 0x2f696
movq %rbx, %rdi
callq 0xaae1
testl %eax, %eax
jne 0x63e9
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa3f4e(%rip), %rdi     # 0xaa30b
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x5ebc
leaq 0xa3ef6(%rip), %rdi     # 0xaa2c6
jmp 0x63e2
leaq 0xa3f00(%rip), %rdi     # 0xaa2d9
jmp 0x63e2
leaq 0xa3f0a(%rip), %rdi     # 0xaa2ec
xorl %eax, %eax
callq 0x5ebc
movq 0x8(%rsp), %rdi
movl %eax, %esi
callq 0x49e0
nopl (%rax)