// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/htslib/cram/sam_header.c
// Function: sam_hdr_vadd
int sam_hdr_vadd(SAM_hdr *sh, const char *type, va_list ap, ...) {
    va_list args;
    SAM_hdr_type *h_type;
    SAM_hdr_tag *h_tag, *last;
    int new;
    khint32_t type_i = (type[0]<<8) | type[1], k;

    if (EOF == kputc_('@', &sh->text))
	return -1;
    if (EOF == kputsn(type, 2, &sh->text))
	return -1;

    if (!(h_type = pool_alloc(sh->type_pool)))
	return -1;
    if (-1 == (k = kh_put(sam_hdr, sh->h, type_i, &new)))
	return -1;

    // Form the ring, either with self or other lines of this type
    if (!new) {
	SAM_hdr_type *t = kh_val(sh->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;
	h_type->order = p->order + 1;
    } else {
	kh_val(sh->h, k) = h_type;
	h_type->prev = h_type->next = h_type;
	h_type->order = 0;
    }

    last = NULL;

    // Any ... varargs
    va_start(args, ap);
    for (;;) {
	char *k, *v;
	int idx;
	
	if (!(k = (char *)va_arg(args, char *)))
	    break;
	v = va_arg(args, char *);

	if (EOF == kputc_('\t', &sh->text))
	    return -1;

	if (!(h_tag = pool_alloc(sh->tag_pool)))
	    return -1;
	idx = ks_len(&sh->text);
	
	if (EOF == kputs(k, &sh->text))
	    return -1;
	if (EOF == kputc_(':', &sh->text))
	    return -1;
	if (EOF == kputs(v, &sh->text))
	    return -1;

	h_tag->len = ks_len(&sh->text) - idx;
	h_tag->str = string_ndup(sh->str_pool,
				 ks_str(&sh->text) + idx,
				 h_tag->len);
	h_tag->next = NULL;
	if (!h_tag->str)
	    return -1;

	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 *k, *v;
	int idx;
	
	if (!(k = (char *)va_arg(ap, char *)))
	    break;
	v = va_arg(ap, char *);

	if (EOF == kputc_('\t', &sh->text))
	    return -1;

	if (!(h_tag = pool_alloc(sh->tag_pool)))
	    return -1;
	idx = ks_len(&sh->text);
	
	if (EOF == kputs(k, &sh->text))
	    return -1;
	if (EOF == kputc_(':', &sh->text))
	    return -1;
	if (EOF == kputs(v, &sh->text))
	    return -1;

	h_tag->len = ks_len(&sh->text) - idx;
	h_tag->str = string_ndup(sh->str_pool,
				 ks_str(&sh->text) + idx,
				 h_tag->len);
	h_tag->next = NULL;
	if (!h_tag->str)
	    return -1;

	if (last)
	    last->next = h_tag;
	else
	    h_type->tag = h_tag;
	
	last = h_tag;
    }
    va_end(ap);

    if (EOF == kputc('\n', &sh->text))
	return -1;

    int itype = (type[0]<<8) | type[1];
    if (-1 == sam_hdr_update_hashes(sh, itype, h_type))
	return -1;

    return h_type->order;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdx, 0x8(%rsp)
movq %rdi, %rbx
movq %rcx, 0x68(%rsp)
movq %r8, 0x70(%rsp)
movq %r9, 0x78(%rsp)
testb %al, %al
je 0x62398
movaps %xmm0, 0x80(%rsp)
movaps %xmm1, 0x90(%rsp)
movaps %xmm2, 0xa0(%rsp)
movaps %xmm3, 0xb0(%rsp)
movaps %xmm4, 0xc0(%rsp)
movaps %xmm5, 0xd0(%rsp)
movaps %xmm6, 0xe0(%rsp)
movaps %xmm7, 0xf0(%rsp)
movsbl (%rsi), %ebp
movq %rsi, 0x48(%rsp)
movsbl 0x1(%rsi), %r14d
movq (%rdi), %rcx
leaq 0x1(%rcx), %rdx
cmpq 0x8(%rdi), %rdx
jbe 0x62409
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
jmp 0x6240d
movq 0x10(%rbx), %rax
movq %rdx, (%rbx)
movb $0x40, (%rax,%rcx)
movq (%rbx), %rcx
leaq 0x3(%rcx), %rax
cmpq 0x8(%rbx), %rax
jae 0x62427
movq 0x10(%rbx), %rax
jmp 0x62478
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
movq 0x48(%rsp), %rdx
movzwl (%rdx), %edx
movw %dx, (%rax,%rcx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x2(%rax), %rdx
movq %rdx, (%rbx)
movb $0x0, 0x2(%rcx,%rax)
movq 0x28(%rbx), %rdi
callq 0x86942
movq %rax, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x62bd5
movq %rcx, 0x28(%rsp)
shll $0x8, %ebp
orl %r14d, %ebp
movq 0x18(%rbx), %rdi
leaq 0x3c(%rsp), %rdx
movl %ebp, %esi
callq 0x61afa
cmpl $-0x1, %eax
je 0x62bd0
cmpl $0x0, 0x3c(%rsp)
movq 0x18(%rbx), %rcx
movq 0x20(%rcx), %rcx
movl %eax, %eax
je 0x624fd
movq 0x28(%rsp), %rdx
movq %rdx, (%rcx,%rax,8)
movq %rdx, %rcx
movq %rdx, (%rdx)
movq %rdx, 0x8(%rdx)
xorl %eax, %eax
jmp 0x62529
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rcx
cmpq %rax, (%rcx)
jne 0x62be7
movq 0x28(%rsp), %rdx
movq %rdx, (%rcx)
movq %rcx, 0x8(%rdx)
movq %rdx, 0x8(%rax)
movq %rax, (%rdx)
movl 0x18(%rcx), %eax
movq %rdx, %rcx
incl %eax
movl %eax, 0x18(%rcx)
leaq 0x50(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x140(%rsp), %rax
movq %rax, 0x18(%rsp)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, 0x10(%rsp)
addq $0x10, %rcx
movq %rcx, 0x40(%rsp)
xorl %r14d, %r14d
movl 0x10(%rsp), %eax
cmpq $0x28, %rax
ja 0x62579
movq %rax, %rcx
addq 0x20(%rsp), %rcx
addl $0x8, %eax
movl %eax, 0x10(%rsp)
jmp 0x62587
movq 0x18(%rsp), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq (%rcx), %r15
testq %r15, %r15
je 0x62af1
cmpl $0x28, %eax
ja 0x625a8
movl %eax, %ecx
addq 0x20(%rsp), %rcx
addl $0x8, %eax
movl %eax, 0x10(%rsp)
jmp 0x625b6
movq 0x18(%rsp), %rcx
leaq 0x8(%rcx), %rax
movq %rax, 0x18(%rsp)
movq (%rcx), %r12
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
cmpq 0x8(%rbx), %rdx
jbe 0x6261d
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
jmp 0x62621
movq 0x10(%rbx), %rax
movq %rdx, (%rbx)
movb $0x9, (%rax,%rcx)
movq 0x30(%rbx), %rdi
callq 0x86942
testq %rax, %rax
je 0x62bd0
movq %rax, %rbp
movq %r12, (%rsp)
movq %r14, 0x30(%rsp)
movq (%rbx), %r13
movq %r15, %rdi
callq 0x62d0
movq %rax, %r12
movslq %r12d, %r14
leaq (%r14,%r13), %rax
incq %rax
cmpq 0x8(%rbx), %rax
jae 0x6266d
movq 0x10(%rbx), %rax
movq %r13, %rdi
jmp 0x626be
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rdi
addq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6570
addq (%rbx), %r14
movq %r14, (%rbx)
movq 0x10(%rbx), %rax
movb $0x0, (%rax,%r14)
cmpl $-0x1, %r12d
je 0x62bd0
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
cmpq 0x8(%rbx), %rdx
jbe 0x6274d
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
movq (%rsp), %r12
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
jmp 0x62755
movq 0x10(%rbx), %rax
movq (%rsp), %r12
movq %rdx, (%rbx)
movb $0x3a, (%rax,%rcx)
movq %r12, %rdi
callq 0x62d0
movq %rax, %r15
movq (%rbx), %rdi
movslq %r15d, %r14
leaq (%rdi,%r14), %rax
incq %rax
cmpq 0x8(%rbx), %rax
jae 0x62780
movq 0x10(%rbx), %rax
jmp 0x627d1
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rdi
addq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x6570
addq (%rbx), %r14
movq %r14, (%rbx)
movq 0x10(%rbx), %rax
movb $0x0, (%rax,%r14)
cmpl $-0x1, %r15d
je 0x62bd0
movq (%rbx), %rax
movslq %r13d, %rsi
subq %r13, %rax
movl %eax, 0x10(%rbp)
movq 0x20(%rbx), %rdi
addq 0x10(%rbx), %rsi
movslq %eax, %rdx
callq 0x651d9
movq %rax, 0x8(%rbp)
movq $0x0, (%rbp)
testq %rax, %rax
je 0x62bd0
movq 0x30(%rsp), %rax
testq %rax, %rax
cmoveq 0x40(%rsp), %rax
movq %rbp, (%rax)
movq %rbp, %r14
jmp 0x6255e
cmpl $0x28, %eax
ja 0x62859
movl %eax, %ecx
movq 0x8(%rsp), %rdx
addq 0x10(%rdx), %rcx
addl $0x8, %eax
movl %eax, (%rdx)
jmp 0x6286a
movq 0x8(%rsp), %rdx
movq 0x8(%rdx), %rcx
leaq 0x8(%rcx), %rax
movq %rax, 0x8(%rdx)
movq (%rcx), %r12
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
cmpq 0x8(%rbx), %rdx
jbe 0x628d1
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
jmp 0x628d5
movq 0x10(%rbx), %rax
movq %rdx, (%rbx)
movb $0x9, (%rax,%rcx)
movq 0x30(%rbx), %rdi
callq 0x86942
testq %rax, %rax
je 0x62bd0
movq %rax, %rbp
movq %r12, (%rsp)
movq %r14, 0x30(%rsp)
movq (%rbx), %r13
movq %r15, %rdi
callq 0x62d0
movq %rax, %r12
movslq %r12d, %r14
leaq (%r14,%r13), %rax
incq %rax
cmpq 0x8(%rbx), %rax
jae 0x62921
movq 0x10(%rbx), %rax
movq %r13, %rdi
jmp 0x62972
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rdi
addq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6570
addq (%rbx), %r14
movq %r14, (%rbx)
movq 0x10(%rbx), %rax
movb $0x0, (%rax,%r14)
cmpl $-0x1, %r12d
je 0x62bd0
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
cmpq 0x8(%rbx), %rdx
jbe 0x62a01
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
movq (%rsp), %r12
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
jmp 0x62a09
movq 0x10(%rbx), %rax
movq (%rsp), %r12
movq %rdx, (%rbx)
movb $0x3a, (%rax,%rcx)
movq %r12, %rdi
callq 0x62d0
movq %rax, %r15
movq (%rbx), %rdi
movslq %r15d, %r14
leaq (%rdi,%r14), %rax
incq %rax
cmpq 0x8(%rbx), %rax
jae 0x62a34
movq 0x10(%rbx), %rax
jmp 0x62a85
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rdi
addq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x6570
addq (%rbx), %r14
movq %r14, (%rbx)
movq 0x10(%rbx), %rax
movb $0x0, (%rax,%r14)
cmpl $-0x1, %r15d
je 0x62bd0
movq (%rbx), %rax
movslq %r13d, %rsi
subq %r13, %rax
movl %eax, 0x10(%rbp)
movq 0x20(%rbx), %rdi
addq 0x10(%rbx), %rsi
movslq %eax, %rdx
callq 0x651d9
movq %rax, 0x8(%rbp)
movq $0x0, (%rbp)
testq %rax, %rax
je 0x62bd0
movq 0x30(%rsp), %rax
testq %rax, %rax
cmoveq 0x40(%rsp), %rax
movq %rbp, (%rax)
movq %rbp, %r14
movq 0x8(%rsp), %rcx
movl (%rcx), %eax
cmpq $0x28, %rax
ja 0x62b0f
movq %rcx, %rdx
movq %rax, %rcx
addq 0x10(%rdx), %rcx
addl $0x8, %eax
movl %eax, (%rdx)
jmp 0x62b1e
movq %rcx, %rsi
movq 0x8(%rcx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movq (%rcx), %r15
testq %r15, %r15
jne 0x62842
movq (%rbx), %rdx
leaq 0x1(%rdx), %rcx
cmpq 0x8(%rbx), %rcx
jae 0x62b3d
movq 0x10(%rbx), %rax
jmp 0x62b8e
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x6c80
testq %rax, %rax
je 0x62bd0
movq %rax, 0x10(%rbx)
movq (%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, (%rbx)
movb $0xa, (%rax,%rdx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x48(%rsp), %rcx
movsbl (%rcx), %eax
shll $0x8, %eax
movsbl 0x1(%rcx), %esi
orl %eax, %esi
movq %rbx, %rdi
movq 0x28(%rsp), %rbx
movq %rbx, %rdx
callq 0x61c68
cmpl $-0x1, %eax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
je 0x62bd5
movl 0x18(%rbx), %eax
jmp 0x62bd5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x36e8f(%rip), %rdi     # 0x99a7d
leaq 0x36e95(%rip), %rsi     # 0x99a8a
leaq 0x36ef9(%rip), %rcx     # 0x99af5
movl $0x1ca, %edx            # imm = 0x1CA
callq 0x6460