// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/sam_header.c
// Function: sam_hdr_add_lines
int sam_hdr_add_lines(SAM_hdr *sh, const char *lines, int len) {
    int i, lno, text_offset;
    char *hdr;

    if (!len)
	len = strlen(lines);

    text_offset = ks_len(&sh->text);
    if (EOF == kputsn(lines, len, &sh->text))
	return -1;
    hdr = ks_str(&sh->text) + text_offset;

    for (i = 0, lno = 1; i < len && hdr[i] != '\0'; i++, lno++) {
	khint32_t type;
	khint_t k;

	int l_start = i, new;
	SAM_hdr_type *h_type;
	SAM_hdr_tag *h_tag, *last;

	if (hdr[i] != '@') {
	    int j;
	    for (j = i; j < len && hdr[j] != '\0' && hdr[j] != '\n'; j++)
		;
	    sam_hdr_error("Header line does not start with '@'",
			  &hdr[l_start], len - l_start, lno);
	    return -1;
	}

	type = (hdr[i+1]<<8) | hdr[i+2];
	if (hdr[i+1] < 'A' || hdr[i+1] > 'z' ||
	    hdr[i+2] < 'A' || hdr[i+2] > 'z') {
	    sam_hdr_error("Header line does not have a two character key",
			  &hdr[l_start], len - l_start, lno);
	    return -1;
	}

	i += 3;
	if (hdr[i] == '\n')
	    continue;

	// Add the header line type
	if (!(h_type = pool_alloc(sh->type_pool)))
	    return -1;
	if (-1 == (k = kh_put(sam_hdr, sh->h, type, &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;
	}

	// Parse the tags on this line
	last = NULL;
	if ((type>>8) == 'C' && (type&0xff) == 'O') {
	    int j;
	    if (hdr[i] != '\t') {
		sam_hdr_error("Missing tab",
			      &hdr[l_start], len - l_start, lno);
		return -1;
	    }

	    for (j = ++i; j < len && hdr[j] != '\0' && hdr[j] != '\n'; j++)
		;

	    if (!(h_type->tag = h_tag = pool_alloc(sh->tag_pool)))
		return -1;
	    h_tag->str = string_ndup(sh->str_pool, &hdr[i], j-i);
	    h_tag->len = j-i;
	    h_tag->next = NULL;
	    if (!h_tag->str)
		return -1;

	    i = j;

	} else {
	    do {
		int j;
		if (hdr[i] != '\t') {
		    sam_hdr_error("Missing tab",
				  &hdr[l_start], len - l_start, lno);
		    return -1;
		}

		for (j = ++i; j < len && hdr[j] != '\0' && hdr[j] != '\n' && hdr[j] != '\t'; j++)
		    ;
	    
		if (!(h_tag = pool_alloc(sh->tag_pool)))
		    return -1;
		h_tag->str = string_ndup(sh->str_pool, &hdr[i], j-i);
		h_tag->len = j-i;
		h_tag->next = NULL;
		if (!h_tag->str)
		    return -1;

		if (h_tag->len < 3 || h_tag->str[2] != ':') {
		    sam_hdr_error("Malformed key:value pair",
				  &hdr[l_start], len - l_start, lno);
		    return -1;
		}
	    
		if (last)
		    last->next = h_tag;
		else
		    h_type->tag = h_tag;

		last = h_tag;
		i = j;
	    } while (i < len && hdr[i] != '\0' && hdr[i] != '\n');
	}

	/* Update RG/SQ hashes */
	if (-1 == sam_hdr_update_hashes(sh, type, h_type))
	    return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x93098
movq -0x18(%rbp), %rdi
callq 0x62c0
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x93730
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x93750
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x930cb
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movq -0x10(%rbp), %rdi
callq 0x938c0
movslq -0x28(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movl -0x20(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x79(%rbp)
jge 0x9310f
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x9311b
jmp 0x93719
movl -0x20(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x40, %eax
je 0x931b6
movl -0x20(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x7a(%rbp)
jge 0x93174
movq -0x30(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x7a(%rbp)
je 0x93174
movq -0x30(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x7a(%rbp)
movb -0x7a(%rbp), %al
testb $0x1, %al
jne 0x9317d
jmp 0x9318a
jmp 0x9317f
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x9313c
movq -0x30(%rbp), %rsi
movslq -0x3c(%rbp), %rax
addq %rax, %rsi
movl -0x1c(%rbp), %edx
subl -0x3c(%rbp), %edx
movl -0x24(%rbp), %ecx
leaq 0x50643(%rip), %rdi     # 0xe37e8
callq 0x938e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movl -0x20(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movsbl (%rcx,%rdx), %ecx
orl %ecx, %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0x93238
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7a, %eax
jg 0x93238
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0x93238
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7a, %eax
jle 0x93264
movq -0x30(%rbp), %rsi
movslq -0x3c(%rbp), %rax
addq %rax, %rsi
movl -0x1c(%rbp), %edx
subl -0x3c(%rbp), %edx
movl -0x24(%rbp), %ecx
leaq 0x505b9(%rip), %rdi     # 0xe380c
callq 0x938e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movl -0x20(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x20(%rbp)
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x93283
jmp 0x93702
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0xcb620
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x932a6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x34(%rbp), %esi
leaq -0x40(%rbp), %rdx
callq 0x93970
movl %eax, %ecx
movl %ecx, -0x38(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x932d4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
cmpl $0x0, -0x40(%rbp)
jne 0x93370
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq (%rax), %rax
cmpq -0x68(%rbp), %rax
jne 0x93310
jmp 0x9332f
leaq 0x50523(%rip), %rdi     # 0xe383a
leaq 0x50529(%rip), %rsi     # 0xe3847
movl $0x14f, %edx            # imm = 0x14F
leaq 0x5052f(%rip), %rcx     # 0xe3859
callq 0x6450
movq -0x48(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, (%rax)
movq -0x70(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x68(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x70(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x933a5
movq -0x48(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x38(%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)
movl -0x34(%rbp), %eax
shrl $0x8, %eax
cmpl $0x43, %eax
jne 0x934f5
movl -0x34(%rbp), %eax
andl $0xff, %eax
cmpl $0x4f, %eax
jne 0x934f5
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x9, %eax
je 0x9340a
movq -0x30(%rbp), %rsi
movslq -0x3c(%rbp), %rax
addq %rax, %rsi
movl -0x1c(%rbp), %edx
subl -0x3c(%rbp), %edx
movl -0x24(%rbp), %ecx
leaq 0x50494(%rip), %rdi     # 0xe388d
callq 0x938e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x7b(%rbp)
jge 0x9344e
movq -0x30(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x7b(%rbp)
je 0x9344e
movq -0x30(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x7b(%rbp)
movb -0x7b(%rbp), %al
testb $0x1, %al
jne 0x93457
jmp 0x93464
jmp 0x93459
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x93416
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0xcb620
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x9348f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x30(%rbp), %rsi
movslq -0x20(%rbp), %rax
addq %rax, %rsi
movl -0x74(%rbp), %eax
subl -0x20(%rbp), %eax
movslq %eax, %rdx
callq 0x981f0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x74(%rbp), %ecx
subl -0x20(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq $0x0, (%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x934ea
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movl -0x74(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x936dc
jmp 0x934f7
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x9, %eax
je 0x93534
movq -0x30(%rbp), %rsi
movslq -0x3c(%rbp), %rax
addq %rax, %rsi
movl -0x1c(%rbp), %edx
subl -0x3c(%rbp), %edx
movl -0x24(%rbp), %ecx
leaq 0x5036a(%rip), %rdi     # 0xe388d
callq 0x938e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x7c(%rbp)
jge 0x9358e
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x7c(%rbp)
je 0x9358e
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x7c(%rbp)
je 0x9358e
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x9, %eax
setne %al
movb %al, -0x7c(%rbp)
movb -0x7c(%rbp), %al
testb $0x1, %al
jne 0x93597
jmp 0x935a4
jmp 0x93599
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x93540
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0xcb620
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x935c7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x30(%rbp), %rsi
movslq -0x20(%rbp), %rax
addq %rax, %rsi
movl -0x78(%rbp), %eax
subl -0x20(%rbp), %eax
movslq %eax, %rdx
callq 0x981f0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x78(%rbp), %ecx
subl -0x20(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq $0x0, (%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x93622
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
movq -0x50(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jl 0x9363d
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x2(%rax), %eax
cmpl $0x3a, %eax
je 0x93669
movq -0x30(%rbp), %rsi
movslq -0x3c(%rbp), %rax
addq %rax, %rsi
movl -0x1c(%rbp), %edx
subl -0x3c(%rbp), %edx
movl -0x24(%rbp), %ecx
leaq 0x50241(%rip), %rdi     # 0xe3899
callq 0x938e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
cmpq $0x0, -0x58(%rbp)
je 0x9367d
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
jmp 0x93689
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x7d(%rbp)
jge 0x936cf
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x7d(%rbp)
je 0x936cf
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x7d(%rbp)
movb -0x7d(%rbp), %al
testb $0x1, %al
jne 0x934f7
jmp 0x936dc
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x48(%rbp), %rdx
callq 0x93cc0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x93700
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x93720
jmp 0x93702
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x930ed
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)