// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
testb %al, %al
je 0xd9037
movaps %xmm0, -0x130(%rbp)
movaps %xmm1, -0x120(%rbp)
movaps %xmm2, -0x110(%rbp)
movaps %xmm3, -0x100(%rbp)
movaps %xmm4, -0xf0(%rbp)
movaps %xmm5, -0xe0(%rbp)
movaps %xmm6, -0xd0(%rbp)
movaps %xmm7, -0xc0(%rbp)
movq %r9, -0x138(%rbp)
movq %r8, -0x140(%rbp)
movq %rcx, -0x148(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0xdabd0
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x19959(%rip), %rsi     # 0xf29d0
movl $0x2, %edx
callq 0x4200
cmpl $0x0, %eax
jne 0xd90c0
movq -0x10(%rbp), %rdi
leaq 0x1993f(%rip), %rsi     # 0xf29d0
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0xd9960
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
je 0xd90c0
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xdac00
movl %eax, -0x4(%rbp)
jmp 0xd9877
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x82110
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0xd90e3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9877
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x60(%rbp), %esi
leaq -0x5c(%rbp), %rdx
callq 0xdeb70
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x5c(%rbp)
jge 0xd910b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9877
movl -0x60(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x28(%rax)
cmpl $0x0, -0x5c(%rbp)
jne 0xd919f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movl -0x64(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq (%rax), %rax
cmpq -0x70(%rbp), %rax
jne 0xd9150
jmp 0xd916f
leaq 0x1f3c4(%rip), %rdi     # 0xf851b
leaq 0x1efe9(%rip), %rsi     # 0xf8147
movl $0x23c, %edx            # imm = 0x23C
leaq 0x1f4e5(%rip), %rcx     # 0xf864f
callq 0x42e0
movq -0x48(%rbp), %rcx
movq -0x78(%rbp), %rax
movq %rcx, (%rax)
movq -0x78(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x70(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
jmp 0xd91c8
movq -0x48(%rbp), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movl -0x64(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x168(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0xd9201
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x178(%rbp)
jmp 0xd920c
xorl %eax, %eax
movq %rax, -0x178(%rbp)
jmp 0xd920c
movq -0x168(%rbp), %rsi
movq -0x170(%rbp), %rdi
movq -0x178(%rbp), %rdx
callq 0xdeec0
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
cmpq -0x48(%rbp), %rax
jne 0xd9239
jmp 0xd9258
leaq 0x1f45c(%rip), %rdi     # 0xf869c
leaq 0x1ef00(%rip), %rsi     # 0xf8147
movl $0x24d, %edx            # imm = 0x24D
leaq 0x1f3fc(%rip), %rcx     # 0xf864f
callq 0x42e0
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpq -0x48(%rbp), %rax
jne 0xd926b
jmp 0xd928a
leaq 0x1f447(%rip), %rdi     # 0xf86b9
leaq 0x1eece(%rip), %rsi     # 0xf8147
movl $0x24e, %edx            # imm = 0x24E
leaq 0x1f3ca(%rip), %rcx     # 0xf864f
callq 0x42e0
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rax
cmpq -0x48(%rbp), %rax
jne 0xd929e
jmp 0xd92bd
leaq 0x1f431(%rip), %rdi     # 0xf86d6
leaq 0x1ee9b(%rip), %rsi     # 0xf8147
movl $0x24f, %edx            # imm = 0x24F
leaq 0x1f397(%rip), %rcx     # 0xf864f
callq 0x42e0
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
cmpq -0x48(%rbp), %rax
jne 0xd92d1
jmp 0xd92f0
leaq 0x1f429(%rip), %rdi     # 0xf8701
leaq 0x1ee68(%rip), %rsi     # 0xf8147
movl $0x250, %edx            # imm = 0x250
leaq 0x1f364(%rip), %rcx     # 0xf864f
callq 0x42e0
leaq -0x40(%rbp), %rax
leaq -0x160(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x18, (%rax)
movq $0x0, -0x88(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x188(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x17c(%rbp)
cmpl $0x28, %eax
ja 0xd935a
movq -0x188(%rbp), %rcx
movl -0x17c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x190(%rbp)
jmp 0xd9377
movq -0x188(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x190(%rbp)
movq -0x190(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
jne 0xd9390
jmp 0xd958d
movq -0x18(%rbp), %rdi
leaq 0x19483(%rip), %rsi     # 0xf281e
movl $0x2, %edx
callq 0x4200
cmpl $0x0, %eax
je 0xd941e
leaq -0x40(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x194(%rbp)
cmpl $0x28, %eax
ja 0xd93e5
movq -0x1a0(%rbp), %rcx
movl -0x194(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x1a8(%rbp)
jmp 0xd9402
movq -0x1a0(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x1a8(%rbp)
movq -0x1a8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
jne 0xd941e
jmp 0xd958d
movq -0x88(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xd9432
jmp 0xd9314
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x82110
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0xd9455
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9877
movq -0x18(%rbp), %rdi
leaq 0x193be(%rip), %rsi     # 0xf281e
movl $0x2, %edx
callq 0x4200
cmpl $0x0, %eax
je 0xd9506
movq -0x88(%rbp), %rdi
callq 0x41b0
addq $0x3, %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x82420
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0xd94e9
movq -0x90(%rbp), %rdi
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
movq -0x80(%rbp), %rcx
movq -0x88(%rbp), %r8
leaq 0x1f24f(%rip), %rdx     # 0xf872c
movb $0x0, %al
callq 0x47e0
cmpl $0x0, %eax
jge 0xd94f5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9877
movq -0x90(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xd9555
movq -0x80(%rbp), %rdi
callq 0x41b0
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x80(%rbp), %rsi
movq -0x50(%rbp), %rax
movslq 0x10(%rax), %rdx
callq 0x82650
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xd9553
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9877
jmp 0xd9555
movq -0x50(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x58(%rbp)
je 0xd9574
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
jmp 0xd9580
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0xd9314
leaq -0x40(%rbp), %rax
movq $0x0, -0xa0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movl (%rax), %eax
movl %eax, -0x1ac(%rbp)
cmpl $0x28, %eax
ja 0xd95d6
movq -0x1b8(%rbp), %rcx
movl -0x1ac(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x1c0(%rbp)
jmp 0xd95f3
movq -0x1b8(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
jne 0xd960f
jmp 0xd9800
movq -0x18(%rbp), %rdi
leaq 0x19204(%rip), %rsi     # 0xf281e
movl $0x2, %edx
callq 0x4200
cmpl $0x0, %eax
je 0xd969c
movq -0x20(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movl (%rax), %eax
movl %eax, -0x1c4(%rbp)
cmpl $0x28, %eax
ja 0xd9663
movq -0x1d0(%rbp), %rcx
movl -0x1c4(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x1d8(%rbp)
jmp 0xd9680
movq -0x1d0(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x1d8(%rbp)
movq -0x1d8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
jne 0xd969c
jmp 0xd9800
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x82110
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0xd96bf
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9877
movq -0x18(%rbp), %rdi
leaq 0x19154(%rip), %rsi     # 0xf281e
movl $0x2, %edx
callq 0x4200
cmpl $0x0, %eax
je 0xd9773
movq -0xa0(%rbp), %rdi
callq 0x41b0
addq $0x3, %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x82420
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0xd9756
movq -0xa8(%rbp), %rdi
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %r8
leaq 0x1efe2(%rip), %rdx     # 0xf872c
movb $0x0, %al
callq 0x47e0
cmpl $0x0, %eax
jge 0xd9762
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9877
movq -0xa8(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xd97c8
movq -0x98(%rbp), %rdi
callq 0x41b0
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x98(%rbp), %rsi
movq -0x50(%rbp), %rax
movslq 0x10(%rax), %rdx
callq 0x82650
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xd97c6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9877
jmp 0xd97c8
movq -0x50(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x58(%rbp)
je 0xd97e7
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
jmp 0xd97f3
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0xd9591
movq -0x10(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x18(%rbp), %rdi
callq 0xdabd0
movq -0x1e0(%rbp), %rdi
movl %eax, %esi
movq -0x48(%rbp), %rdx
callq 0xdb3f0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0xd983a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9877
movq -0x18(%rbp), %rdi
leaq 0x1e831(%rip), %rsi     # 0xf8076
movl $0x2, %edx
callq 0x4200
cmpl $0x0, %eax
jne 0xd9862
movq -0x10(%rbp), %rax
movl $0x1, 0x98(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x90(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nopw %cs:(%rax,%rax)