// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/sam_header.c
// Function: sam_hdr_update
int sam_hdr_update(SAM_hdr *hdr, SAM_hdr_type *type, ...) {
    va_list ap;

    va_start(ap, type);
    
    for (;;) {
	char *k, *v;
	int idx;
	SAM_hdr_tag *tag, *prev;

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

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

	    tag->next = NULL;
	}

	idx = ks_len(&hdr->text);
	if (ksprintf(&hdr->text, "%2.2s:%s", k, v) < 0)
	    return -1;
	tag->len = ks_len(&hdr->text) - idx;
	tag->str = string_ndup(hdr->str_pool,
			       ks_str(&hdr->text) + idx,
			       tag->len);
	if (!tag->str)
	    return -1;
    }

    va_end(ap);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
testb %al, %al
je 0x95a81
movaps %xmm0, -0xe0(%rbp)
movaps %xmm1, -0xd0(%rbp)
movaps %xmm2, -0xc0(%rbp)
movaps %xmm3, -0xb0(%rbp)
movaps %xmm4, -0xa0(%rbp)
movaps %xmm5, -0x90(%rbp)
movaps %xmm6, -0x80(%rbp)
movaps %xmm7, -0x70(%rbp)
movq %r9, -0xe8(%rbp)
movq %r8, -0xf0(%rbp)
movq %rcx, -0xf8(%rbp)
movq %rdx, -0x100(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x30(%rbp), %rax
leaq -0x110(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
leaq -0x30(%rbp), %rax
movq %rax, -0x120(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x114(%rbp)
cmpl $0x28, %eax
ja 0x95b04
movq -0x120(%rbp), %rcx
movl -0x114(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x128(%rbp)
jmp 0x95b21
movq -0x120(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x95b3a
jmp 0x95cb5
leaq -0x30(%rbp), %rax
movq %rax, -0x138(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x12c(%rbp)
cmpl $0x28, %eax
ja 0x95b75
movq -0x138(%rbp), %rcx
movl -0x12c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x140(%rbp)
jmp 0x95b92
movq -0x138(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x95990
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x95c0e
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0xcb620
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x95be3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x95cc0
cmpq $0x0, -0x58(%rbp)
je 0x95bf7
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
jmp 0x95c03
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
callq 0x93730
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
leaq 0x4dccc(%rip), %rsi     # 0xe38f9
movb $0x0, %al
callq 0x9a250
cmpl $0x0, %eax
jge 0x95c42
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x95cc0
movq -0x10(%rbp), %rdi
callq 0x93730
movslq -0x44(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x148(%rbp)
movq -0x10(%rbp), %rdi
callq 0x938c0
movq -0x148(%rbp), %rdi
movq %rax, %rsi
movslq -0x44(%rbp), %rax
addq %rax, %rsi
movq -0x50(%rbp), %rax
movslq 0x10(%rax), %rdx
callq 0x981f0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x95cb0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x95cc0
jmp 0x95ac9
leaq -0x30(%rbp), %rax
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopl (%rax)