// File: /workspace/github_c_makefile_star2_O2/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 0x5b6d
movq 0x8(%rsi), %r13
jmp 0x5b74
leaq 0x7c490(%rip), %r13     # 0x82004
leaq 0x7e846(%rip), %rbx     # 0x843c1
movq %r13, %rdi
movq %rbx, %rsi
callq 0x8233
movq %rax, %rbp
movq %rbx, %rdi
callq 0x250c7
movq %rax, %r15
movq %rbx, %rdi
callq 0x250c7
movq %rax, %r12
leaq 0x7c468(%rip), %rbx     # 0x8200e
movq %r15, %rdi
movq %rbx, %rsi
callq 0x24ae2
leaq 0x7c466(%rip), %r14     # 0x8201e
movq %r15, %rdi
movq %r14, %rsi
callq 0x24ae2
movq %r12, %rdi
movq %r14, %rsi
callq 0x24ae2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x24ae2
leaq 0x7c44e(%rip), %rsi     # 0x8202e
movq %r15, %rdi
callq 0x24ae2
leaq 0x7c469(%rip), %rbx     # 0x82058
movq %r15, %rdi
movq %rbx, %rsi
callq 0x24ae2
leaq 0x7c481(%rip), %r14     # 0x82082
movq %r15, %rdi
movq %r14, %rsi
callq 0x24ae2
leaq 0x7c499(%rip), %rsi     # 0x820ac
movq %r12, %rdi
callq 0x24ae2
movq %r12, %rdi
movq %r14, %rsi
callq 0x24ae2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x24ae2
leaq 0x7c49e(%rip), %rsi     # 0x820d6
movq %r15, %rdi
callq 0x24ae2
leaq 0x7c4cb(%rip), %rbx     # 0x82112
movq %r15, %rdi
movq %rbx, %rsi
callq 0x24ae2
leaq 0x7c4f5(%rip), %r14     # 0x8214e
movq %r15, %rdi
movq %r14, %rsi
callq 0x24ae2
leaq 0x7c51f(%rip), %rsi     # 0x8218a
movq %r12, %rdi
callq 0x24ae2
movq %r12, %rdi
movq %r14, %rsi
callq 0x24ae2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x24ae2
leaq 0x7c536(%rip), %rsi     # 0x821c6
movq %r15, %rdi
callq 0x24ae2
leaq 0x7c564(%rip), %rbx     # 0x82203
movq %r15, %rdi
movq %rbx, %rsi
callq 0x24ae2
leaq 0x7c58f(%rip), %r14     # 0x82240
movq %r15, %rdi
movq %r14, %rsi
callq 0x24ae2
leaq 0x7c5ba(%rip), %rsi     # 0x8227d
movq %r12, %rdi
callq 0x24ae2
movq %r12, %rdi
movq %r14, %rsi
callq 0x24ae2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x24ae2
leaq 0x7c5d2(%rip), %rbx     # 0x822ba
movq %r15, %rdi
movq %rbx, %rsi
callq 0x224fc
leaq 0x7c5c6(%rip), %r14     # 0x822c0
movq %r15, %rdi
movq %r14, %rsi
callq 0x224fc
movq %r12, %rdi
movq %rbx, %rsi
callq 0x224fc
movq %r12, %rdi
movq %r14, %rsi
callq 0x224fc
movq %r15, %rdi
callq 0x2276e
testl %eax, %eax
js 0x5fa3
movq %r12, %rdi
callq 0x2276e
testl %eax, %eax
js 0x5fac
movq %r12, %rdi
movq %r15, %rsi
callq 0x2cd04
movq %rax, %r12
movq %rax, %rdi
callq 0x2276e
testl %eax, %eax
js 0x5fb5
movq %r13, 0x8(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x25ce9
testl %eax, %eax
movq %rbp, 0x10(%rsp)
jne 0x5f90
callq 0x25fbe
movq %rax, %r13
leaq 0x7ecbd(%rip), %rdx     # 0x84a42
pushq $0x1
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
callq 0x2489c
movl %eax, 0x10(%r13)
andq $0x0, (%r13)
leaq 0x7c580(%rip), %rdx     # 0x82322
movq %r15, %rdi
movq %r13, %rsi
callq 0x2faec
leaq 0x7c572(%rip), %rdx     # 0x82326
movq %r15, %rdi
xorl %esi, %esi
callq 0x2489c
leaq 0x1c(%rsp), %r14
movl %eax, (%r14)
leaq 0x7c55e(%rip), %rdx     # 0x8232b
movq %r15, %rdi
xorl %esi, %esi
callq 0x2489c
movl %eax, 0x4(%r14)
leaq 0x7c54e(%rip), %rdx     # 0x82330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2489c
movl %eax, 0x8(%r14)
pushq $0x3
popq %rcx
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2f5bf
movl $0x1, (%r14)
leaq 0x7c526(%rip), %rdx     # 0x82335
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rcx
movl %ebp, %r8d
movl %ebp, %r9d
callq 0x2ea62
movl $0x2, (%r14)
leaq 0x7c509(%rip), %rdx     # 0x8233a
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rcx
movl %ebp, %r8d
movl %ebp, %r9d
callq 0x2ea62
movl $0x3, (%r14)
leaq 0x7c4ec(%rip), %rdx     # 0x8233f
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rcx
movl %ebp, %r8d
movl %ebp, %r9d
callq 0x2ea62
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%r14)
leaq 0x7c4c9(%rip), %rdx     # 0x82344
pushq $0x2
popq %rbx
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rcx
movl %ebx, %r8d
movl %ebp, %r9d
callq 0x2f08c
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, (%r14)
leaq 0x7c4a3(%rip), %rdx     # 0x82349
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rcx
movl %ebx, %r8d
movl %ebp, %r9d
callq 0x2f08c
movabsq $0x300000003, %rax      # imm = 0x300000003
movq %rax, (%r14)
leaq 0x7c480(%rip), %rdx     # 0x8234e
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rcx
movl %ebx, %r8d
movl %ebp, %r9d
callq 0x2f08c
movq %r15, %rdi
xorl %esi, %esi
leaq 0x7c43d(%rip), %rdx     # 0x8232b
callq 0x2489c
movq %r15, %rdi
movq %r13, %rsi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x2f70c
movq %r15, %rdi
movq %r13, %rsi
leaq 0x7c42b(%rip), %rdx     # 0x8233a
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %ebp, %r9d
callq 0x2ea62
movq %r15, %rdi
movq %r13, %rsi
leaq 0x7c420(%rip), %rdx     # 0x82349
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %ebp, %r9d
callq 0x2f08c
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2d081
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x273f5
testl %eax, %eax
jne 0x5f90
movq %r13, %rdi
callq 0x26150
movq %r15, %rdi
callq 0x25554
movq %r12, %rdi
callq 0x25554
movq %rbx, %rdi
callq 0x9409
testl %eax, %eax
jne 0x5fc3
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7c374(%rip), %rdi     # 0x8230b
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x5abc
leaq 0x7c31c(%rip), %rdi     # 0x822c6
jmp 0x5fbc
leaq 0x7c326(%rip), %rdi     # 0x822d9
jmp 0x5fbc
leaq 0x7c330(%rip), %rdi     # 0x822ec
xorl %eax, %eax
callq 0x5abc
movl %eax, %ebx
movq 0xa9014(%rip), %rax     # 0xaefe0
movq (%rax), %rdi
leaq 0x7c37d(%rip), %rsi     # 0x82353
movq 0x8(%rsp), %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4720
movl %ebx, %edi
callq 0x45f0
nop