// File: /workspace/github_c_makefile_star2_O3/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 0x5f7f
movq 0x8(%rsi), %r13
jmp 0x5f86
leaq 0xa107e(%rip), %r13     # 0xa7004
leaq 0xa3474(%rip), %rbx     # 0xa9401
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9530
movq %rax, %rbp
movq %rbx, %rdi
callq 0x2df79
movq %rax, %r15
movq %rbx, %rdi
callq 0x2df79
movq %rax, %r12
leaq 0xa1056(%rip), %rbx     # 0xa700e
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2d739
leaq 0xa1054(%rip), %r14     # 0xa701e
movq %r15, %rdi
movq %r14, %rsi
callq 0x2d739
movq %r12, %rdi
movq %r14, %rsi
callq 0x2d739
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2d739
leaq 0xa103c(%rip), %rsi     # 0xa702e
movq %r15, %rdi
callq 0x2d739
leaq 0xa1057(%rip), %rbx     # 0xa7058
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2d739
leaq 0xa106f(%rip), %r14     # 0xa7082
movq %r15, %rdi
movq %r14, %rsi
callq 0x2d739
leaq 0xa1087(%rip), %rsi     # 0xa70ac
movq %r12, %rdi
callq 0x2d739
movq %r12, %rdi
movq %r14, %rsi
callq 0x2d739
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2d739
leaq 0xa108c(%rip), %rsi     # 0xa70d6
movq %r15, %rdi
callq 0x2d739
leaq 0xa10b9(%rip), %rbx     # 0xa7112
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2d739
leaq 0xa10e3(%rip), %r14     # 0xa714e
movq %r15, %rdi
movq %r14, %rsi
callq 0x2d739
leaq 0xa110d(%rip), %rsi     # 0xa718a
movq %r12, %rdi
callq 0x2d739
movq %r12, %rdi
movq %r14, %rsi
callq 0x2d739
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2d739
leaq 0xa1124(%rip), %rsi     # 0xa71c6
movq %r15, %rdi
callq 0x2d739
leaq 0xa1152(%rip), %rbx     # 0xa7203
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2d739
leaq 0xa117d(%rip), %r14     # 0xa7240
movq %r15, %rdi
movq %r14, %rsi
callq 0x2d739
leaq 0xa11a8(%rip), %rsi     # 0xa727d
movq %r12, %rdi
callq 0x2d739
movq %r12, %rdi
movq %r14, %rsi
callq 0x2d739
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2d739
leaq 0xa11c0(%rip), %rbx     # 0xa72ba
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2a908
leaq 0xa11b4(%rip), %r14     # 0xa72c0
movq %r15, %rdi
movq %r14, %rsi
callq 0x2a908
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2a908
movq %r12, %rdi
movq %r14, %rsi
callq 0x2a908
movq %r15, %rdi
callq 0x2ab97
testl %eax, %eax
js 0x63d9
movq %r12, %rdi
callq 0x2ab97
testl %eax, %eax
js 0x63e2
movq %r12, %rdi
movq %r15, %rsi
callq 0x3bbed
movq %rax, %r12
movq %rax, %rdi
callq 0x2ab97
testl %eax, %eax
js 0x63eb
movq %r13, 0x8(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2f2ea
testl %eax, %eax
movq %rbp, 0x10(%rsp)
jne 0x63c6
callq 0x2f69e
movq %rax, %r13
leaq 0xa38e0(%rip), %rdx     # 0xa9a77
movq %r15, %rdi
movl $0x1, %esi
callq 0x2d3d9
movl %eax, 0x10(%r13)
movq $0x0, (%r13)
leaq 0xa116b(%rip), %rdx     # 0xa7322
movq %r15, %rdi
movq %r13, %rsi
callq 0x3ffbb
leaq 0xa115d(%rip), %rdx     # 0xa7326
movq %r15, %rdi
xorl %esi, %esi
callq 0x2d3d9
leaq 0x1c(%rsp), %rbx
movl %eax, (%rbx)
leaq 0xa114a(%rip), %rdx     # 0xa732b
movq %r15, %rdi
xorl %esi, %esi
callq 0x2d3d9
movl %eax, 0x4(%rbx)
leaq 0xa113b(%rip), %rdx     # 0xa7330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2d3d9
movl %eax, 0x8(%rbx)
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movl $0x3, %ecx
callq 0x3fa83
movl $0x1, (%rbx)
leaq 0xa1113(%rip), %rdx     # 0xa7335
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x3e8d0
movl $0x2, (%rbx)
leaq 0xa10f1(%rip), %r14     # 0xa733a
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbx, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x3e8d0
movl $0x3, (%rbx)
leaq 0xa10cc(%rip), %rdx     # 0xa733f
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x3e8d0
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%rbx)
leaq 0xa10a3(%rip), %rdx     # 0xa7344
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x3f00f
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, (%rbx)
leaq 0xa107a(%rip), %rbp     # 0xa7349
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x3f00f
movabsq $0x300000003, %rax      # imm = 0x300000003
movq %rax, (%rbx)
leaq 0xa104e(%rip), %rdx     # 0xa734e
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x3f00f
movq %r15, %rdi
xorl %esi, %esi
leaq 0xa1005(%rip), %rdx     # 0xa732b
callq 0x2d3d9
movq %r15, %rdi
movq %r13, %rsi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x3fbcd
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x3e8d0
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x3f00f
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3c165
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x315e6
testl %eax, %eax
jne 0x63c6
movq %r13, %rdi
callq 0x2f849
movq %r15, %rdi
callq 0x2e474
movq %r12, %rdi
callq 0x2e474
movq %rbx, %rdi
callq 0xa792
testl %eax, %eax
jne 0x63f9
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa0f3e(%rip), %rdi     # 0xa730b
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x5ecc
leaq 0xa0ee6(%rip), %rdi     # 0xa72c6
jmp 0x63f2
leaq 0xa0ef0(%rip), %rdi     # 0xa72d9
jmp 0x63f2
leaq 0xa0efa(%rip), %rdi     # 0xa72ec
xorl %eax, %eax
callq 0x5ecc
movq 0x8(%rsp), %rdi
movl %eax, %esi
callq 0x49e0
nopl (%rax)