// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
testb %al, %al
je 0x94857
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 -0x18(%rbp), %rax
movsbl (%rax), %eax
shll $0x8, %eax
movq -0x18(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rsi
movl $0x40, %edi
callq 0x94f50
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x948b4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl $0x2, %esi
callq 0x93750
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x948dd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0xcb620
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x94900
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x60(%rbp), %esi
leaq -0x5c(%rbp), %rdx
callq 0x93970
movl %eax, %ecx
movl %ecx, -0x64(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x9492e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
cmpl $0x0, -0x5c(%rbp)
jne 0x949ca
movq -0x10(%rbp), %rax
movq 0x18(%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 0x9496a
jmp 0x94989
leaq 0x4eec9(%rip), %rdi     # 0xe383a
leaq 0x4eecf(%rip), %rsi     # 0xe3847
movl $0x1ca, %edx            # imm = 0x1CA
leaq 0x4ef2e(%rip), %rcx     # 0xe38b2
callq 0x6450
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)
movq -0x78(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x949ff
movq -0x48(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x18(%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
movl $0x0, 0x18(%rax)
movq $0x0, -0x58(%rbp)
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)
leaq -0x40(%rbp), %rax
movq %rax, -0x170(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x164(%rbp)
cmpl $0x28, %eax
ja 0x94a66
movq -0x170(%rbp), %rcx
movl -0x164(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x178(%rbp)
jmp 0x94a83
movq -0x170(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
jne 0x94a9c
jmp 0x94c7b
leaq -0x40(%rbp), %rax
movq %rax, -0x188(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x17c(%rbp)
cmpl $0x28, %eax
ja 0x94ad7
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 0x94af4
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, -0x88(%rbp)
movq -0x10(%rbp), %rsi
movl $0x9, %edi
callq 0x94f50
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94b2a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0xcb620
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x94b4d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rdi
callq 0x93730
movl %eax, -0x8c(%rbp)
movq -0x80(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x95090
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94b80
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rsi
movl $0x3a, %edi
callq 0x94f50
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94ba5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x95090
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94bcc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rdi
callq 0x93730
movslq -0x8c(%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, -0x198(%rbp)
movq -0x10(%rbp), %rdi
callq 0x938c0
movq -0x198(%rbp), %rdi
movq %rax, %rsi
movslq -0x8c(%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
movq $0x0, (%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x94c4e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
cmpq $0x0, -0x58(%rbp)
je 0x94c62
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
jmp 0x94c6e
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x94a2b
leaq -0x40(%rbp), %rax
movq -0x20(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movl (%rax), %eax
movl %eax, -0x19c(%rbp)
cmpl $0x28, %eax
ja 0x94cb9
movq -0x1a8(%rbp), %rcx
movl -0x19c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x1b0(%rbp)
jmp 0x94cd6
movq -0x1a8(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
jne 0x94cf2
jmp 0x94ed3
movq -0x20(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movl (%rax), %eax
movl %eax, -0x1b4(%rbp)
cmpl $0x28, %eax
ja 0x94d2c
movq -0x1c0(%rbp), %rcx
movl -0x1b4(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x1c8(%rbp)
jmp 0x94d49
movq -0x1c0(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rsi
movl $0x9, %edi
callq 0x94f50
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94d7f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0xcb620
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x94da2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rdi
callq 0x93730
movl %eax, -0xa4(%rbp)
movq -0x98(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x95090
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94dd8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rsi
movl $0x3a, %edi
callq 0x94f50
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94dfd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x95090
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94e24
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x10(%rbp), %rdi
callq 0x93730
movslq -0xa4(%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, -0x1d0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x938c0
movq -0x1d0(%rbp), %rdi
movq %rax, %rsi
movslq -0xa4(%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
movq $0x0, (%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x94ea6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
cmpq $0x0, -0x58(%rbp)
je 0x94eba
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
jmp 0x94ec6
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x94c7f
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rsi
movl $0xa, %edi
callq 0x950d0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94ef9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
shll $0x8, %eax
movq -0x18(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
movl -0xa8(%rbp), %esi
movq -0x48(%rbp), %rdx
callq 0x93cc0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x94f3a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x94f44
movq -0x48(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq