// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hrecs_vadd
static int sam_hrecs_vadd(sam_hrecs_t *hrecs, const char *type, va_list ap, ...) {
    va_list args;
    sam_hrec_type_t *h_type;
    sam_hrec_tag_t *h_tag, *last=NULL;
    int new;
    khint32_t type_i = TYPEKEY(type), k;

    if (!strncmp(type, "HD", 2) && (h_type = sam_hrecs_find_type_id(hrecs, "HD", NULL, NULL)))
        return sam_hrecs_vupdate(hrecs, h_type, ap);

    if (!(h_type = pool_alloc(hrecs->type_pool)))
        return -1;
    k = kh_put(sam_hrecs_t, hrecs->h, type_i, &new);
    if (new < 0)
        return -1;

    h_type->type = type_i;

    // Form the ring, either with self or other lines of this type
    if (!new) {
        sam_hrec_type_t *t = kh_val(hrecs->h, k), *p;
        p = t->prev;

        assert(p->next == t);
        p->next = h_type;
        h_type->prev = p;

        t->prev = h_type;
        h_type->next = t;
    } else {
        kh_val(hrecs->h, k) = h_type;
        h_type->prev = h_type->next = h_type;
    }
    h_type->tag = NULL;

    // Add to global line ordering after any existing line of the same type,
    // or at the end if no line of this type exists yet.
    sam_hrecs_global_list_add(hrecs, h_type, !new ? h_type->prev : NULL);

    // Check linked-list invariants
    assert(h_type->prev->next == h_type);
    assert(h_type->next->prev == h_type);
    assert(h_type->global_prev->global_next == h_type);
    assert(h_type->global_next->global_prev == h_type);

    // Any ... varargs
    va_start(args, ap);
    for (;;) {
        char *key, *val = NULL, *str;

        if (!(key = (char *)va_arg(args, char *)))
            break;
        if (strncmp(type, "CO", 2) && !(val = (char *)va_arg(args, char *)))
            break;
        if (*val == '\0')
            continue;

        if (!(h_tag = pool_alloc(hrecs->tag_pool)))
            return -1;

        if (strncmp(type, "CO", 2)) {
            h_tag->len = 3 + strlen(val);
            str = string_alloc(hrecs->str_pool, h_tag->len+1);
            if (!str || snprintf(str, h_tag->len+1, "%2.2s:%s", key, val) < 0)
                return -1;
            h_tag->str = str;
        } else {
            h_tag->len = strlen(key);
            h_tag->str = string_ndup(hrecs->str_pool, key, h_tag->len);
            if (!h_tag->str)
                return -1;
        }

        h_tag->next = NULL;
        if (last)
            last->next = h_tag;
        else
            h_type->tag = h_tag;

        last = h_tag;
    }
    va_end(args);

    // Plus the specified va_list params
    for (;;) {
        char *key, *val = NULL, *str;

        if (!(key = (char *)va_arg(ap, char *)))
            break;
        if (strncmp(type, "CO", 2) && !(val = (char *)va_arg(ap, char *)))
            break;

        if (!(h_tag = pool_alloc(hrecs->tag_pool)))
            return -1;

        if (strncmp(type, "CO", 2)) {
            h_tag->len = 3 + strlen(val);
            str = string_alloc(hrecs->str_pool, h_tag->len+1);
            if (!str || snprintf(str, h_tag->len+1, "%2.2s:%s", key, val) < 0)
                return -1;
            h_tag->str = str;
        } else {
            h_tag->len = strlen(key);
            h_tag->str = string_ndup(hrecs->str_pool, key, h_tag->len);
            if (!h_tag->str)
                return -1;
        }

        h_tag->next = NULL;
        if (last)
            last->next = h_tag;
        else
            h_type->tag = h_tag;

        last = h_tag;
    }

    if (-1 == sam_hrecs_update_hashes(hrecs, TYPEKEY(type), h_type))
        return -1;

    if (!strncmp(type, "PG", 2))
        hrecs->pgs_changed = 1;

    hrecs->dirty = 1;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, 0x40(%rsp)
movq %rsi, %r14
movq %rdi, %r13
movq %rcx, 0x78(%rsp)
movq %r8, 0x80(%rsp)
movq %r9, 0x88(%rsp)
testb %al, %al
je 0x87bb0
movaps %xmm0, 0x90(%rsp)
movaps %xmm1, 0xa0(%rsp)
movaps %xmm2, 0xb0(%rsp)
movaps %xmm3, 0xc0(%rsp)
movaps %xmm4, 0xd0(%rsp)
movaps %xmm5, 0xe0(%rsp)
movaps %xmm6, 0xf0(%rsp)
movaps %xmm7, 0x100(%rsp)
movzwl (%rsi), %ebx
leaq 0x138e9(%rip), %rsi     # 0x9b4a3
movl $0x2, %edx
movq %r14, %rdi
callq 0x4210
testl %eax, %eax
je 0x87c3c
movq 0x18(%r13), %rdi
callq 0x5a822
movq %rax, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rcx, 0x48(%rsp)
testq %rcx, %rcx
je 0x880ba
movq %r14, 0x8(%rsp)
rolw $0x8, %bx
movzwl %bx, %ebx
movq (%r13), %rdi
leaq 0x5c(%rsp), %r12
movl %ebx, %esi
movq %r12, %rdx
callq 0x8cdad
movl (%r12), %ecx
testl %ecx, %ecx
js 0x880b5
movq 0x48(%rsp), %r14
movl %ebx, 0x28(%r14)
movq (%r13), %rdx
movq 0x20(%rdx), %rdx
movl %eax, %eax
je 0x87c79
movq %r14, (%rdx,%rax,8)
movq %r14, (%r14)
movq %r14, 0x8(%r14)
movq 0x8(%rsp), %r12
jmp 0x87c9d
leaq 0x13860(%rip), %rsi     # 0x9b4a3
movq %r13, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x881f0
testq %rax, %rax
je 0x87bcb
movq %r13, %rdi
movq %rax, %rsi
movq 0x40(%rsp), %rdx
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x89778
movq (%rdx,%rax,8), %rax
movq 0x8(%rax), %rdx
cmpq %rax, (%rdx)
movq 0x8(%rsp), %r12
jne 0x88148
movq %r14, (%rdx)
movq %rdx, 0x8(%r14)
movq %r14, 0x8(%rax)
movq %rax, (%r14)
movq $0x0, 0x20(%r14)
testl %ecx, %ecx
je 0x87cad
xorl %edx, %edx
jmp 0x87cb1
movq 0x8(%r14), %rdx
movq %r13, %rdi
movq %r14, %rsi
callq 0x8cf08
movq 0x8(%r14), %rax
cmpq %r14, (%rax)
jne 0x880cc
movq (%r14), %rax
cmpq %r14, 0x8(%rax)
jne 0x880eb
movq 0x18(%r14), %rax
cmpq %r14, 0x10(%rax)
jne 0x8810a
movq 0x10(%r14), %rax
cmpq %r14, 0x18(%rax)
jne 0x88129
addq $0x20, %r14
movq %r14, 0x50(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x150(%rsp), %rax
movq %rax, 0x28(%rsp)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, 0x20(%rsp)
leaq 0x1c870(%rip), %r14     # 0xa4598
movq $0x0, 0x10(%rsp)
movq %r13, 0x18(%rsp)
movl 0x20(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x87d51
movq %rcx, %rax
addq 0x30(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x20(%rsp)
jmp 0x87d5f
movq 0x28(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq (%rax), %rbp
movl $0x2, %r15d
testq %rbp, %rbp
je 0x87ec1
movl $0x2, %edx
movq %r12, %rdi
leaq 0x13571(%rip), %rsi     # 0x9b2f1
callq 0x4210
testl %eax, %eax
je 0x87da4
movl 0x20(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x87da8
movq %rcx, %rax
addq 0x30(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x20(%rsp)
jmp 0x87db6
xorl %ebx, %ebx
jmp 0x87dc2
movq 0x28(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq (%rax), %rbx
testq %rbx, %rbx
je 0x87ec1
cmpb $0x0, (%rbx)
je 0x87e66
movq 0x20(%r13), %rdi
callq 0x5a822
movl $0x1, %r15d
testq %rax, %rax
je 0x87ebc
movq %rax, %r12
movl $0x2, %edx
movq 0x8(%rsp), %rdi
leaq 0x134fa(%rip), %rsi     # 0x9b2f1
callq 0x4210
testl %eax, %eax
je 0x87e75
movq %rbx, %rdi
callq 0x41d0
leal 0x3(%rax), %ecx
movl %ecx, 0x10(%r12)
movq 0x10(%r13), %rdi
shlq $0x20, %rax
movabsq $0x400000000, %rcx      # imm = 0x400000000
leaq (%rax,%rcx), %rsi
sarq $0x20, %rsi
callq 0x5a98c
testq %rax, %rax
je 0x87e6e
movq %rax, %r13
movslq 0x10(%r12), %rsi
incq %rsi
movq %rax, %rdi
leaq 0x1ce88(%rip), %rdx     # 0xa4cd1
movq %rbp, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x4800
testl %eax, %eax
js 0x87e6e
movq %r13, 0x8(%r12)
movq 0x18(%rsp), %r13
jmp 0x87e9b
movl $0x3, %r15d
jmp 0x87ec1
movq 0x18(%rsp), %r13
jmp 0x87ebc
movq %rbp, %rdi
callq 0x41d0
movl %eax, 0x10(%r12)
movq 0x10(%r13), %rdi
movslq %eax, %rdx
movq %rbp, %rsi
callq 0x5aab0
movq %rax, 0x8(%r12)
testq %rax, %rax
je 0x87ebc
movq 0x10(%rsp), %rax
testq %rax, %rax
cmoveq 0x50(%rsp), %rax
movq $0x0, (%r12)
movq %r12, (%rax)
xorl %r15d, %r15d
movq %r12, 0x10(%rsp)
movq 0x8(%rsp), %r12
movl %r15d, %eax
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
leaq 0x1341d(%rip), %r15     # 0x9b2f1
movq 0x40(%rsp), %rdx
movl (%rdx), %ecx
cmpq $0x28, %rcx
ja 0x87eef
movq %rcx, %rax
addq 0x10(%rdx), %rax
addl $0x8, %ecx
movl %ecx, (%rdx)
jmp 0x87efb
movq 0x8(%rdx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rdx)
movq (%rax), %rbp
movl $0x4, %r14d
testq %rbp, %rbp
je 0x88042
movl $0x2, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x4210
testl %eax, %eax
je 0x87f3c
movq 0x40(%rsp), %rdx
movl (%rdx), %ecx
cmpq $0x28, %rcx
ja 0x87f40
movq %rcx, %rax
addq 0x10(%rdx), %rax
addl $0x8, %ecx
movl %ecx, (%rdx)
jmp 0x87f4c
xorl %ebx, %ebx
jmp 0x87f58
movq 0x8(%rdx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rdx)
movq (%rax), %rbx
testq %rbx, %rbx
je 0x88042
movq 0x20(%r13), %rdi
callq 0x5a822
movl $0x1, %r14d
testq %rax, %rax
je 0x88042
movq %rax, %r13
movl $0x2, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x4210
testl %eax, %eax
je 0x87ffb
movq %rbx, %rdi
callq 0x41d0
leal 0x3(%rax), %ecx
movl %ecx, 0x10(%r13)
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rdi
shlq $0x20, %rax
movabsq $0x400000000, %rcx      # imm = 0x400000000
leaq (%rax,%rcx), %rsi
sarq $0x20, %rsi
callq 0x5a98c
testq %rax, %rax
je 0x87fef
movq %rax, %r12
movslq 0x10(%r13), %rsi
incq %rsi
movq %rax, %rdi
leaq 0x1ccfe(%rip), %rdx     # 0xa4cd1
movq %rbp, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x4800
testl %eax, %eax
js 0x87fef
movq %r12, 0x8(%r13)
movq 0x8(%rsp), %r12
jmp 0x88024
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r12
jmp 0x88047
movq %rbp, %rdi
callq 0x41d0
movl %eax, 0x10(%r13)
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rdi
movslq %eax, %rdx
movq %rbp, %rsi
callq 0x5aab0
movq %rax, 0x8(%r13)
testq %rax, %rax
je 0x88042
movq $0x0, (%r13)
movq 0x10(%rsp), %rax
testq %rax, %rax
cmoveq 0x50(%rsp), %rax
movq %r13, (%rax)
xorl %r14d, %r14d
jmp 0x88047
movq 0x10(%rsp), %r13
movq %r13, 0x10(%rsp)
testl %r14d, %r14d
movq 0x18(%rsp), %r13
je 0x87ed4
cmpl $0x4, %r14d
jne 0x880b5
movzwl (%r12), %eax
rolw $0x8, %ax
movzwl %ax, %esi
movq %r13, %rdi
movq 0x48(%rsp), %rdx
callq 0x89c4a
cmpl $-0x1, %eax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
je 0x880ba
leaq 0x1c591(%rip), %rsi     # 0xa461b
movl $0x2, %edx
movq %r12, %rdi
callq 0x4210
testl %eax, %eax
jne 0x880a6
movl $0x1, 0x98(%r13)
movl $0x1, 0x90(%r13)
xorl %eax, %eax
jmp 0x880ba
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cb6e(%rip), %rdi     # 0xa4c41
leaq 0x1c612(%rip), %rsi     # 0xa46ec
leaq 0x1cb13(%rip), %rcx     # 0xa4bf4
movl $0x24d, %edx            # imm = 0x24D
callq 0x42f0
leaq 0x1cb6c(%rip), %rdi     # 0xa4c5e
leaq 0x1c5f3(%rip), %rsi     # 0xa46ec
leaq 0x1caf4(%rip), %rcx     # 0xa4bf4
movl $0x24e, %edx            # imm = 0x24E
callq 0x42f0
leaq 0x1cb6a(%rip), %rdi     # 0xa4c7b
leaq 0x1c5d4(%rip), %rsi     # 0xa46ec
leaq 0x1cad5(%rip), %rcx     # 0xa4bf4
movl $0x24f, %edx            # imm = 0x24F
callq 0x42f0
leaq 0x1cb76(%rip), %rdi     # 0xa4ca6
leaq 0x1c5b5(%rip), %rsi     # 0xa46ec
leaq 0x1cab6(%rip), %rcx     # 0xa4bf4
movl $0x250, %edx            # imm = 0x250
callq 0x42f0
leaq 0x1c971(%rip), %rdi     # 0xa4ac0
leaq 0x1c596(%rip), %rsi     # 0xa46ec
leaq 0x1ca97(%rip), %rcx     # 0xa4bf4
movl $0x23c, %edx            # imm = 0x23C
callq 0x42f0