// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/sam.c
// Function: test_header_ref_altnames
static void test_header_ref_altnames(void) {
    static const char initial_header[] =
        "@SQ\tSN:1\tLN:100\tAN:chr1\n"
        "@SQ\tSN:chr2\tAN:2\tLN:200\n"
        "@SQ\tSN:3\tLN:300\n"
        "@SQ\tSN:chrMT\tLN:16569\tAN:MT,chrM,M\n";

    sam_hdr_t *header = sam_hdr_init();
    if (header == NULL) { fail("sam_hdr_init"); return; }

    if (sam_hdr_add_lines(header, initial_header, 0) < 0)
        fail("sam_hdr_add_lines() for altnames");

    check_ref_lookup(header, "initial",
        "1", 0, "chr1", 0, "2", 1, "chr2", 1, "3", 2,
        "chrMT", 3, "chrM", 3, "M", 3, "fred", -1, "barney", -1,
        NULL);

    if (sam_hdr_add_line(header, "SQ", "AN", "fred", "LN", "500", "SN", "barney", NULL) < 0)
        fail("sam_hdr_add_line() for altnames");

    check_ref_lookup(header, "barney added",
        "1", 0, "chr1", 0, "2", 1, "chr2", 1, "3", 2,
        "chrMT", 3, "chrM", 3, "M", 3, "fred", 4, "barney", 4,
        NULL);

    if (sam_hdr_remove_line_id(header, "SQ", "SN", "chr2") < 0)
        fail("sam_hdr_remove_line_id() for altnames");

    check_ref_lookup(header, "chr2 removed",
        "1", 0, "chr1", 0, "2", -1, "chr2", -1, "3", 1,
        "chrMT", 2, "chrM", 2, "M", 2, "fred", 3, "barney", 3,
        NULL);

    if (sam_hdr_remove_tag_id(header, "SQ", "SN", "1", "AN") < 0)
        fail("sam_hdr_remove_tag_id() for altnames");

    check_ref_lookup(header, "1's AN removed",
        "1", 0, "chr1", -1, "CM000663", -1, "2", -1, "chr2", -1, "3", 1,
        "chrMT", 2, "chrM", 2, "M", 2, "fred", 3, "barney", 3,
        NULL);

    sam_hdr_destroy(header);

    static const char initial_header_duplicates[] =
        "@SQ\tSN:1\tLN:100\tAN:foo,2\n"
        "@SQ\tSN:2\tLN:200\tAN:bar\n"
        "@SQ\tSN:3\tLN:300\tAN:baz,3\n";

    header = sam_hdr_init();
    if (header == NULL) { fail("sam_hdr_init"); return; }

    int old_log_level = hts_get_log_level();
    hts_set_log_level(HTS_LOG_ERROR); // Silence "Duplicate entry AN:2" warning

    if (sam_hdr_add_lines(header, initial_header_duplicates, 0) < 0)
        fail("sam_hdr_add_lines() for altnames with duplicates");

    hts_set_log_level(old_log_level);

    // Check "2" is SN:2 and not AN:2
    check_ref_lookup(header, "initial_header_duplicates",
                     "1", 0, "foo", 0,
                     "2", 1, "bar", 1,
                     "3", 2, "baz", 2, NULL);

    if (sam_hdr_remove_tag_id(header, "SQ", "SN", "1", "AN") < 0)
        fail("sam_hdr_remove_tag_id() for duplicate altnames SN:1");

    // Check "2" still works and "foo" does not
    check_ref_lookup(header, "initial_header_duplicates",
                     "1", 0, "foo", -1,
                     "2", 1, "bar", 1,
                     "3", 2, "baz", 2, NULL);

    if (sam_hdr_remove_tag_id(header, "SQ", "SN", "3", "AN") < 0)
        fail("sam_hdr_remove_tag_id() for duplicate altnames SN:3");

    // Check "3" still works and "baz" does not
    check_ref_lookup(header, "initial_header_duplicates",
                     "1", 0, "foo", -1,
                     "2", 1, "bar", 1,
                     "3", 2, "baz", -1, NULL);

    sam_hdr_destroy(header);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
callq 0x36f00
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x8e77
leaq 0xe9287(%rip), %rdi     # 0xf20f2
movb $0x0, %al
callq 0x5b50
jmp 0x954f
movq -0x30(%rbp), %rdi
leaq 0xe73be(%rip), %rsi     # 0xf0240
xorl %eax, %eax
movl %eax, %edx
callq 0x14230
cmpl $0x0, %eax
jge 0x8e9e
leaq 0xe9268(%rip), %rdi     # 0xf20ff
movb $0x0, %al
callq 0x5b50
movq -0x30(%rbp), %rdi
leaq 0xe9277(%rip), %rsi     # 0xf2120
leaq 0xea1bf(%rip), %rdx     # 0xf306f
xorl %r9d, %r9d
leaq 0xe902c(%rip), %r8      # 0xf1ee6
leaq 0xe7e7b(%rip), %r13     # 0xf0d3c
leaq 0xe912a(%rip), %r12     # 0xf1ff2
leaq 0xeb79a(%rip), %r15     # 0xf4669
leaq 0xe9252(%rip), %r14     # 0xf2128
leaq 0xe9251(%rip), %rbx     # 0xf212e
leaq 0xe867c(%rip), %r11     # 0xf1560
leaq 0xe9248(%rip), %r10     # 0xf2133
leaq 0xe9246(%rip), %rax     # 0xf2138
xorl %ecx, %ecx
movl %r9d, %ecx
movq %r13, (%rsp)
movl $0x1, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movl $0x2, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movl $0x3, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movl $0x3, 0x48(%rsp)
movq %r11, 0x50(%rsp)
movl $0x3, 0x58(%rsp)
movq %r10, 0x60(%rsp)
movl $0xffffffff, 0x68(%rsp) # imm = 0xFFFFFFFF
movq %rax, 0x70(%rsp)
movl $0xffffffff, 0x78(%rsp) # imm = 0xFFFFFFFF
movq $0x0, 0x80(%rsp)
movb $0x0, %al
callq 0xe460
movq -0x30(%rbp), %rdi
leaq 0xe87c6(%rip), %rsi     # 0xf1742
leaq 0xf4d1b(%rip), %rdx     # 0xfdc9e
leaq 0xe91a9(%rip), %rcx     # 0xf2133
leaq 0xe8775(%rip), %r8      # 0xf1706
leaq 0xe91a7(%rip), %r9      # 0xf213f
leaq 0xe8764(%rip), %r10     # 0xf1703
leaq 0xe9192(%rip), %rax     # 0xf2138
xorl %r11d, %r11d
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, %al
callq 0x143a0
cmpl $0x0, %eax
jge 0x8fd5
leaq 0xe9175(%rip), %rdi     # 0xf2143
movb $0x0, %al
callq 0x5b50
movq -0x30(%rbp), %rdi
leaq 0xe9183(%rip), %rsi     # 0xf2163
leaq 0xea088(%rip), %rdx     # 0xf306f
xorl %r9d, %r9d
leaq 0xe8ef5(%rip), %r8      # 0xf1ee6
leaq 0xe7d44(%rip), %r13     # 0xf0d3c
leaq 0xe8ff3(%rip), %r12     # 0xf1ff2
leaq 0xeb663(%rip), %r15     # 0xf4669
leaq 0xe911b(%rip), %r14     # 0xf2128
leaq 0xe911a(%rip), %rbx     # 0xf212e
leaq 0xe8545(%rip), %r11     # 0xf1560
leaq 0xe9111(%rip), %r10     # 0xf2133
leaq 0xe910f(%rip), %rax     # 0xf2138
xorl %ecx, %ecx
movl %r9d, %ecx
movq %r13, (%rsp)
movl $0x1, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movl $0x2, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movl $0x3, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movl $0x3, 0x48(%rsp)
movq %r11, 0x50(%rsp)
movl $0x3, 0x58(%rsp)
movq %r10, 0x60(%rsp)
movl $0x4, 0x68(%rsp)
movq %rax, 0x70(%rsp)
movl $0x4, 0x78(%rsp)
movq $0x0, 0x80(%rsp)
movb $0x0, %al
callq 0xe460
movq -0x30(%rbp), %rdi
leaq 0xe868f(%rip), %rsi     # 0xf1742
leaq 0xe8649(%rip), %rdx     # 0xf1703
leaq 0xe8f31(%rip), %rcx     # 0xf1ff2
callq 0x15580
cmpl $0x0, %eax
jge 0x90d9
leaq 0xe909e(%rip), %rdi     # 0xf2170
movb $0x0, %al
callq 0x5b50
movq -0x30(%rbp), %rdi
leaq 0xe90b2(%rip), %rsi     # 0xf2196
leaq 0xe9f84(%rip), %rdx     # 0xf306f
xorl %r9d, %r9d
leaq 0xe8df1(%rip), %r8      # 0xf1ee6
leaq 0xe7c40(%rip), %r13     # 0xf0d3c
leaq 0xe8eef(%rip), %r12     # 0xf1ff2
leaq 0xeb55f(%rip), %r15     # 0xf4669
leaq 0xe9017(%rip), %r14     # 0xf2128
leaq 0xe9016(%rip), %rbx     # 0xf212e
leaq 0xe8441(%rip), %r11     # 0xf1560
leaq 0xe900d(%rip), %r10     # 0xf2133
leaq 0xe900b(%rip), %rax     # 0xf2138
xorl %ecx, %ecx
movl %r9d, %ecx
movq %r13, (%rsp)
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movq %r12, 0x10(%rsp)
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq %r15, 0x20(%rsp)
movl $0x1, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movl $0x2, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movl $0x2, 0x48(%rsp)
movq %r11, 0x50(%rsp)
movl $0x2, 0x58(%rsp)
movq %r10, 0x60(%rsp)
movl $0x3, 0x68(%rsp)
movq %rax, 0x70(%rsp)
movl $0x3, 0x78(%rsp)
movq $0x0, 0x80(%rsp)
movb $0x0, %al
callq 0xe460
movq -0x30(%rbp), %rdi
leaq 0xe858b(%rip), %rsi     # 0xf1742
leaq 0xe8545(%rip), %rdx     # 0xf1703
leaq 0xe9eaa(%rip), %rcx     # 0xf306f
leaq 0xf4ad2(%rip), %r8      # 0xfdc9e
callq 0x18af0
cmpl $0x0, %eax
jge 0x91e4
leaq 0xe8fc6(%rip), %rdi     # 0xf21a3
movb $0x0, %al
callq 0x5b50
movq -0x30(%rbp), %rdi
leaq 0xe8fd9(%rip), %rsi     # 0xf21c8
leaq 0xe9e79(%rip), %rdx     # 0xf306f
xorl %ecx, %ecx
leaq 0xe8ce7(%rip), %r8      # 0xf1ee6
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
leaq 0xe8fcb(%rip), %rax     # 0xf21d7
movq %rax, -0x48(%rbp)
leaq 0xe7b25(%rip), %r13     # 0xf0d3c
leaq 0xe8dd4(%rip), %r12     # 0xf1ff2
leaq 0xeb444(%rip), %r15     # 0xf4669
leaq 0xe8efc(%rip), %r14     # 0xf2128
leaq 0xe8efb(%rip), %rbx     # 0xf212e
leaq 0xe8326(%rip), %r11     # 0xf1560
leaq 0xe8ef2(%rip), %r10     # 0xf2133
leaq 0xe8ef0(%rip), %rax     # 0xf2138
movq %rax, -0x40(%rbp)
xorl %eax, %eax
movq -0x48(%rbp), %rax
movq %rax, (%rsp)
movq -0x40(%rbp), %rax
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movq %r13, 0x10(%rsp)
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq %r12, 0x20(%rsp)
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
movq %r15, 0x30(%rsp)
movl $0x1, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movl $0x2, 0x48(%rsp)
movq %rbx, 0x50(%rsp)
movl $0x2, 0x58(%rsp)
movq %r11, 0x60(%rsp)
movl $0x2, 0x68(%rsp)
movq %r10, 0x70(%rsp)
movl $0x3, 0x78(%rsp)
movq %rax, 0x80(%rsp)
movl $0x3, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
movb $0x0, %al
callq 0xe460
movq -0x30(%rbp), %rdi
callq 0x36f50
callq 0x36f00
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x930f
leaq 0xe8def(%rip), %rdi     # 0xf20f2
movb $0x0, %al
callq 0x5b50
jmp 0x954f
callq 0x2ee00
movl %eax, -0x34(%rbp)
movl $0x1, %edi
callq 0x2ede0
movq -0x30(%rbp), %rdi
leaq 0xe6f84(%rip), %rsi     # 0xf02b0
xorl %eax, %eax
movl %eax, %edx
callq 0x14230
cmpl $0x0, %eax
jge 0x9348
leaq 0xe8e9f(%rip), %rdi     # 0xf21e0
movb $0x0, %al
callq 0x5b50
movl -0x34(%rbp), %edi
callq 0x2ede0
movq -0x30(%rbp), %rdi
leaq 0xe8eb6(%rip), %rsi     # 0xf2211
leaq 0xe9d0d(%rip), %rdx     # 0xf306f
xorl %r9d, %r9d
leaq 0xe8ebf(%rip), %r8      # 0xf222b
leaq 0xe79c9(%rip), %rbx     # 0xf0d3c
leaq 0xe8eb5(%rip), %r11     # 0xf222f
leaq 0xeb2e8(%rip), %r10     # 0xf4669
leaq 0xe8eab(%rip), %rax     # 0xf2233
xorl %ecx, %ecx
movl %r9d, %ecx
movq %rbx, (%rsp)
movl $0x1, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movl $0x2, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movl $0x2, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
movb $0x0, %al
callq 0xe460
movq -0x30(%rbp), %rdi
leaq 0xe8367(%rip), %rsi     # 0xf1742
leaq 0xe8321(%rip), %rdx     # 0xf1703
leaq 0xe9c86(%rip), %rcx     # 0xf306f
leaq 0xf48ae(%rip), %r8      # 0xfdc9e
callq 0x18af0
cmpl $0x0, %eax
jge 0x9408
leaq 0xe8e36(%rip), %rdi     # 0xf2237
movb $0x0, %al
callq 0x5b50
movq -0x30(%rbp), %rdi
leaq 0xe8dfe(%rip), %rsi     # 0xf2211
leaq 0xe9c55(%rip), %rdx     # 0xf306f
xorl %ecx, %ecx
leaq 0xe8e08(%rip), %r8      # 0xf222b
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
leaq 0xe790c(%rip), %rbx     # 0xf0d3c
leaq 0xe8df8(%rip), %r11     # 0xf222f
leaq 0xeb22b(%rip), %r10     # 0xf4669
leaq 0xe8dee(%rip), %rax     # 0xf2233
xorl %r14d, %r14d
movq %rbx, (%rsp)
movl $0x1, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movl $0x2, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movl $0x2, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
movb $0x0, %al
callq 0xe460
movq -0x30(%rbp), %rdi
leaq 0xe82ac(%rip), %rsi     # 0xf1742
leaq 0xe8266(%rip), %rdx     # 0xf1703
leaq 0xeb1c5(%rip), %rcx     # 0xf4669
leaq 0xf47f3(%rip), %r8      # 0xfdc9e
callq 0x18af0
cmpl $0x0, %eax
jge 0x94c3
leaq 0xe8daf(%rip), %rdi     # 0xf226b
movb $0x0, %al
callq 0x5b50
movq -0x30(%rbp), %rdi
leaq 0xe8d43(%rip), %rsi     # 0xf2211
leaq 0xe9b9a(%rip), %rdx     # 0xf306f
xorl %ecx, %ecx
leaq 0xe8d4d(%rip), %r8      # 0xf222b
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
leaq 0xe7851(%rip), %rbx     # 0xf0d3c
leaq 0xe8d3d(%rip), %r11     # 0xf222f
leaq 0xeb170(%rip), %r10     # 0xf4669
leaq 0xe8d33(%rip), %rax     # 0xf2233
xorl %r14d, %r14d
movq %rbx, (%rsp)
movl $0x1, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movl $0x2, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movl $0xffffffff, 0x38(%rsp) # imm = 0xFFFFFFFF
movq $0x0, 0x40(%rsp)
movb $0x0, %al
callq 0xe460
movq -0x30(%rbp), %rdi
callq 0x36f50
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)