// File: /workspace/github_c_makefile_star2_O0/DReichLab[P]adna/sam.c
// Function: sam_hdr_parse
bam_hdr_t *sam_hdr_parse(int l_text, const char *text)
{
	const char *q, *r, *p;
	khash_t(s2i) *d;
	d = kh_init(s2i);
	for (p = text; *p; ++p) {
		if (strncmp(p, "@SQ", 3) == 0) {
			char *sn = 0;
			int ln = -1;
			for (q = p + 4;; ++q) {
				if (strncmp(q, "SN:", 3) == 0) {
					q += 3;
					for (r = q; *r != '\t' && *r != '\n'; ++r);
					sn = (char*)calloc(r - q + 1, 1);
					strncpy(sn, q, r - q);
					q = r;
				} else if (strncmp(q, "LN:", 3) == 0)
					ln = strtol(q + 3, (char**)&q, 10);
				while (*q != '\t' && *q != '\n') ++q;
				if (*q == '\n') break;
			}
			p = q;
			if (sn && ln >= 0) {
				khint_t k;
				int absent;
				k = kh_put(s2i, d, sn, &absent);
				if (!absent) {
					if (hts_verbose >= 2)
						fprintf(stderr, "[W::%s] duplicated sequence '%s'\n", __func__, sn);
					free(sn);
				} else kh_val(d, k) = (int64_t)(kh_size(d) - 1)<<32 | ln;
			}
		}
		while (*p != '\n') ++p;
	}
	return hdr_from_dict(d);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, %al
callq 0x6cf0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpb $0x0, (%rax)
je 0xde1b
movq -0x28(%rbp), %rdi
leaq 0x5876(%rip), %rsi      # 0x13460
movl $0x3, %edx
callq 0x2080
cmpl $0x0, %eax
jne 0xddec
movq $0x0, -0x38(%rbp)
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x587a(%rip), %rsi      # 0x1349d
movl $0x3, %edx
callq 0x2080
cmpl $0x0, %eax
jne 0xdcc3
movq -0x18(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x9, %ecx
movb %al, -0x45(%rbp)
je 0xdc6b
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x45(%rbp)
movb -0x45(%rbp), %al
testb $0x1, %al
jne 0xdc74
jmp 0xdc84
jmp 0xdc76
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xdc4a
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
subq %rax, %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x2200
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rax
subq %rax, %rdx
callq 0x2070
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0xdcf8
movq -0x18(%rbp), %rdi
leaq 0x57d4(%rip), %rsi      # 0x134a2
movl $0x3, %edx
callq 0x2080
cmpl $0x0, %eax
jne 0xdcf6
movq -0x18(%rbp), %rdi
addq $0x3, %rdi
leaq -0x18(%rbp), %rsi
movl $0xa, %edx
callq 0x2240
movl %eax, -0x3c(%rbp)
jmp 0xdcf8
jmp 0xdcfa
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x9, %ecx
movb %al, -0x46(%rbp)
je 0xdd1b
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x46(%rbp)
movb -0x46(%rbp), %al
testb $0x1, %al
jne 0xdd24
jmp 0xdd32
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xdcfa
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0xdd40
jmp 0xdd53
jmp 0xdd42
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xdc18
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xddea
cmpl $0x0, -0x3c(%rbp)
jl 0xddea
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x44(%rbp), %rdx
callq 0x7400
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0xddc0
leaq 0x94a3(%rip), %rax      # 0x17230
cmpl $0x2, (%rax)
jl 0xddb5
movq 0x925f(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
movq -0x38(%rbp), %rcx
leaq 0x56bd(%rip), %rsi      # 0x13464
leaq 0x56d8(%rip), %rdx      # 0x13486
movb $0x0, %al
callq 0x2230
movq -0x38(%rbp), %rdi
callq 0x2040
jmp 0xdde8
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
shlq $0x20, %rdx
movslq -0x3c(%rbp), %rax
orq %rax, %rdx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x40(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0xddea
jmp 0xddec
jmp 0xddee
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0xde08
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xddee
jmp 0xde0a
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xdbd2
movq -0x30(%rbp), %rdi
callq 0xde30
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)