// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hrecs_vupdate
int sam_hrecs_vupdate(sam_hrecs_t *hrecs, sam_hrec_type_t *type, va_list ap) {
    if (!hrecs)
        return -1;

    for (;;) {
        char *k, *v, *str;
        sam_hrec_tag_t *tag, *prev = NULL;

        if (!(k = (char *)va_arg(ap, char *)))
            break;
        if (!(v = va_arg(ap, char *)))
            v = "";

        tag = sam_hrecs_find_key(type, k, &prev);
        if (!tag) {
            if (!(tag = pool_alloc(hrecs->tag_pool)))
                return -1;
            if (prev)
                prev->next = tag;
            else
                type->tag = tag;

            tag->next = NULL;
        }

        tag->len = 3 + strlen(v);
        str = string_alloc(hrecs->str_pool, tag->len+1);
        if (!str)
            return -1;

        if (snprintf(str, tag->len+1, "%2.2s:%s", k, v) < 0)
            return -1;

        tag->str = str;
    }

    hrecs->dirty = 1; //mark text as dirty and force a rebuild

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rdi, 0x8(%rsp)
testq %rdi, %rdi
je 0x8990f
movq %rdx, %r15
leaq 0x20(%rsi), %rax
movq %rax, 0x10(%rsp)
movq %rsi, (%rsp)
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x897c1
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x897cd
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %rbp
testq %rbp, %rbp
je 0x897ed
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x897f8
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x89804
movl $0x2, %r12d
jmp 0x898e8
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %r13
testq %r13, %r13
leaq 0xf4bc(%rip), %rax      # 0x98ccd
cmoveq %rax, %r13
testq %rsi, %rsi
je 0x8984c
movq 0x20(%rsi), %rcx
testq %rcx, %rcx
je 0x8984c
movb (%rbp), %al
xorl %r14d, %r14d
movq %rcx, %rbx
movq 0x8(%rcx), %rcx
cmpb %al, (%rcx)
jne 0x8983c
movb 0x1(%rcx), %cl
cmpb 0x1(%rbp), %cl
je 0x89851
movq (%rbx), %rcx
movq %rbx, %r14
testq %rcx, %rcx
jne 0x89829
movq %rbx, %r14
jmp 0x8984f
xorl %r14d, %r14d
xorl %ebx, %ebx
testq %rbx, %rbx
jne 0x8987f
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x5a822
testq %rax, %rax
je 0x898de
movq %rax, %rbx
testq %r14, %r14
cmoveq 0x10(%rsp), %r14
movq %rax, (%r14)
movq $0x0, (%rax)
movq %r13, %rdi
callq 0x41d0
leal 0x3(%rax), %ecx
movl %ecx, 0x10(%rbx)
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rdi
addl $0x4, %eax
movslq %eax, %rsi
callq 0x5a98c
movl $0x1, %r12d
testq %rax, %rax
je 0x898e4
movq %rax, %r14
movslq 0x10(%rbx), %rsi
incq %rsi
movq %rax, %rdi
leaq 0x1b411(%rip), %rdx     # 0xa4cd1
movq %rbp, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x4800
testl %eax, %eax
movq (%rsp), %rsi
js 0x898e8
movq %r14, 0x8(%rbx)
xorl %r12d, %r12d
jmp 0x898e8
movl $0x1, %r12d
movq (%rsp), %rsi
testl %r12d, %r12d
je 0x897a9
cmpl $0x1, %r12d
jne 0x898fe
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x8990f
movq 0x8(%rsp), %rax
movl $0x1, 0x90(%rax)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq