// File: /workspace/github_c_makefile_star2_O1/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 $0x128, %rsp            # imm = 0x128
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
movq %rcx, 0x88(%rsp)
movq %r8, 0x90(%rsp)
movq %r9, 0x98(%rsp)
testb %al, %al
je 0x6221b
movaps %xmm0, 0xa0(%rsp)
movaps %xmm1, 0xb0(%rsp)
movaps %xmm2, 0xc0(%rsp)
movaps %xmm3, 0xd0(%rsp)
movaps %xmm4, 0xe0(%rsp)
movaps %xmm5, 0xf0(%rsp)
movaps %xmm6, 0x100(%rsp)
movaps %xmm7, 0x110(%rsp)
movsbl (%rsi), %ebp
movsbl 0x1(%rsi), %r14d
movq (%rdi), %rax
leaq 0x1(%rax), %rcx
cmpq 0x8(%rdi), %rcx
jbe 0x6227e
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 0x62a7e
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movb $0x40, (%rcx,%rax)
movq (%rbx), %rax
addq $0x3, %rax
cmpq 0x8(%rbx), %rax
jb 0x622eb
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 0x62a7e
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movzwl (%r15), %edx
movw %dx, (%rcx,%rax)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x2(%rax), %rdx
movq %rdx, (%rbx)
movb $0x0, 0x2(%rcx,%rax)
movq 0x28(%rbx), %rdi
callq 0x86da2
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x62a84
shll $0x8, %ebp
orl %r14d, %ebp
movq 0x18(%rbx), %rdi
leaq 0x54(%rsp), %rdx
movl %ebp, %esi
callq 0x61984
cmpl $-0x1, %eax
je 0x62a84
cmpl $0x0, 0x54(%rsp)
movq 0x18(%rbx), %rcx
movq 0x20(%rcx), %rcx
movl %eax, %eax
movq %r12, 0x68(%rsp)
movq %r15, 0x60(%rsp)
je 0x62378
movq 0x30(%rsp), %rdx
movq %rdx, (%rcx,%rax,8)
movq %rdx, (%rdx)
movq %rdx, 0x8(%rdx)
xorl %eax, %eax
jmp 0x623a1
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rcx
cmpq %rax, (%rcx)
movq 0x30(%rsp), %rdx
jne 0x62a99
movq %rdx, (%rcx)
movq %rcx, 0x8(%rdx)
movq %rdx, 0x8(%rax)
movq %rax, (%rdx)
movl 0x18(%rcx), %eax
incl %eax
movl %eax, 0x18(%rdx)
leaq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x160(%rsp), %rax
movq %rax, 0x18(%rsp)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, 0x10(%rsp)
addq $0x10, %rdx
movq %rdx, 0x58(%rsp)
movq $0x0, 0x8(%rsp)
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x623f7
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x62405
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq (%rax), %r12
testq %r12, %r12
je 0x62428
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x62433
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x62441
movl $0x2, %r13d
jmp 0x626cb
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq (%rax), %r14
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
cmpq 0x8(%rbx), %rcx
jbe 0x6249f
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 0x626c5
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movb $0x9, (%rcx,%rax)
movq 0x30(%rbx), %rdi
callq 0x86da2
movl $0x1, %r13d
testq %rax, %rax
je 0x626cb
movq %rax, 0x38(%rsp)
movq %r14, 0x48(%rsp)
movq (%rbx), %rbp
movq %r12, %rdi
callq 0x62d0
movq %rax, %r14
movslq %r14d, %r15
movq %rbp, 0x40(%rsp)
leaq (%r15,%rbp), %rax
incq %rax
cmpq 0x8(%rbx), %rax
jb 0x62544
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 0x626cb
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
addq (%rbx), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6570
addq (%rbx), %r15
movq %r15, (%rbx)
movq 0x10(%rbx), %rax
movb $0x0, (%rax,%r15)
cmpl $-0x1, %r14d
je 0x626cb
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
cmpq 0x8(%rbx), %rcx
movq 0x48(%rsp), %r15
jbe 0x625cf
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 0x626cb
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movb $0x3a, (%rcx,%rax)
movq %r15, %rdi
callq 0x62d0
movq %rax, %r12
movq (%rbx), %rax
movslq %r12d, %r14
addq %r14, %rax
incq %rax
cmpq 0x8(%rbx), %rax
jb 0x6264c
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 0x626cb
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
addq (%rbx), %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 0x626cb
movq (%rbx), %rax
movq 0x40(%rsp), %rcx
movslq %ecx, %rsi
subq %rcx, %rax
movq 0x38(%rsp), %rbp
movl %eax, 0x10(%rbp)
movq 0x20(%rbx), %rdi
addq 0x10(%rbx), %rsi
movslq %eax, %rdx
callq 0x651bb
movq %rax, 0x8(%rbp)
movq $0x0, (%rbp)
testq %rax, %rax
je 0x626cb
movq 0x8(%rsp), %rax
testq %rax, %rax
cmoveq 0x58(%rsp), %rax
movq %rbp, (%rax)
xorl %r13d, %r13d
movq %rbp, 0x8(%rsp)
jmp 0x626cb
movl $0x1, %r13d
testl %r13d, %r13d
je 0x623dc
cmpl $0x2, %r13d
jne 0x62a7e
movq 0x68(%rsp), %rdx
movl (%rdx), %ecx
cmpq $0x28, %rcx
ja 0x626f9
movq %rcx, %rax
addq 0x10(%rdx), %rax
addl $0x8, %ecx
movl %ecx, (%rdx)
jmp 0x62705
movq 0x8(%rdx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rdx)
movq (%rax), %r12
testq %r12, %r12
je 0x62723
movl (%rdx), %ecx
cmpq $0x28, %rcx
ja 0x6272e
movq %rcx, %rax
addq 0x10(%rdx), %rax
addl $0x8, %ecx
movl %ecx, (%rdx)
jmp 0x6273a
movl $0x4, %r13d
jmp 0x629c4
movq 0x8(%rdx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rdx)
movq (%rax), %r14
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
cmpq 0x8(%rbx), %rcx
jbe 0x62798
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 0x629be
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movb $0x9, (%rcx,%rax)
movq 0x30(%rbx), %rdi
callq 0x86da2
movl $0x1, %r13d
testq %rax, %rax
je 0x629c4
movq %rax, 0x38(%rsp)
movq %r14, 0x48(%rsp)
movq (%rbx), %rbp
movq %r12, %rdi
callq 0x62d0
movq %rax, %r14
movslq %r14d, %r15
movq %rbp, 0x40(%rsp)
leaq (%r15,%rbp), %rax
incq %rax
cmpq 0x8(%rbx), %rax
jb 0x6283d
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 0x629c4
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
addq (%rbx), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6570
addq (%rbx), %r15
movq %r15, (%rbx)
movq 0x10(%rbx), %rax
movb $0x0, (%rax,%r15)
cmpl $-0x1, %r14d
je 0x629c4
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
cmpq 0x8(%rbx), %rcx
movq 0x48(%rsp), %r15
jbe 0x628c8
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 0x629c4
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movb $0x3a, (%rcx,%rax)
movq %r15, %rdi
callq 0x62d0
movq %rax, %r12
movq (%rbx), %rax
movslq %r12d, %r14
addq %r14, %rax
incq %rax
cmpq 0x8(%rbx), %rax
jb 0x62945
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 0x629c4
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
addq (%rbx), %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 0x629c4
movq (%rbx), %rax
movq 0x40(%rsp), %rcx
movslq %ecx, %rsi
subq %rcx, %rax
movq 0x38(%rsp), %rbp
movl %eax, 0x10(%rbp)
movq 0x20(%rbx), %rdi
addq 0x10(%rbx), %rsi
movslq %eax, %rdx
callq 0x651bb
movq %rax, 0x8(%rbp)
movq $0x0, (%rbp)
testq %rax, %rax
je 0x629c4
movq 0x8(%rsp), %rax
testq %rax, %rax
cmoveq 0x58(%rsp), %rax
movq %rbp, (%rax)
xorl %r13d, %r13d
movq %rbp, 0x8(%rsp)
jmp 0x629c4
movl $0x1, %r13d
testl %r13d, %r13d
je 0x626de
cmpl $0x4, %r13d
jne 0x62a7e
movq (%rbx), %rax
incq %rax
cmpq 0x8(%rbx), %rax
movq 0x60(%rsp), %r14
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jb 0x62a38
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 0x62a84
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movb $0xa, (%rcx,%rax)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movsbl (%r14), %eax
shll $0x8, %eax
movsbl 0x1(%r14), %esi
orl %eax, %esi
movq %rbx, %rdi
movq 0x30(%rsp), %rbx
movq %rbx, %rdx
callq 0x61adf
cmpl $-0x1, %eax
je 0x62a84
movl 0x18(%rbx), %r13d
jmp 0x62a84
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r13d, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x36db4(%rip), %rdi     # 0x99854
leaq 0x36dba(%rip), %rsi     # 0x99861
leaq 0x36e1e(%rip), %rcx     # 0x998cc
movl $0x1ca, %edx            # imm = 0x1CA
callq 0x6460