// File: /workspace/github_cpp_makefile_star2_O3/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/bam_import.c
// Function: sam_header_read
bam_header_t *sam_header_read(tamFile fp)
{
	int ret, dret;
	bam_header_t *header = bam_header_init();
	kstring_t *str = fp->str;
	while ((ret = ks_getuntil(fp->ks, KS_SEP_TAB, str, &dret)) >= 0 && str->s[0] == '@') { // skip header
		str->s[str->l] = dret; // note that str->s is NOT null terminated!!
		append_text(header, str);
		if (dret != '\n') {
			ret = ks_getuntil(fp->ks, '\n', str, &dret);
			str->s[str->l] = '\n'; // NOT null terminated!!
			append_text(header, str);
		}
		++fp->n_lines;
	}
	sam_header_parse(header);
	bam_init_header_hash(header);
	fp->is_first = 1;
	return header;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %eax, %eax
callq 0x122e6
movq %rax, %r14
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %r15
leaq 0x4(%rsp), %rcx
movl $0x1, %esi
movq %r15, %rdx
callq 0x136ff
testl %eax, %eax
js 0x13cf9
leaq 0x4(%rsp), %r12
movq 0x10(%r15), %rax
cmpb $0x40, (%rax)
jne 0x13cf9
movb 0x4(%rsp), %cl
movq (%r15), %rdx
movb %cl, (%rax,%rdx)
movl 0x30(%r14), %ecx
movq (%r15), %rdx
leal 0x1(%rcx), %eax
movd %ecx, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movd %edx, %xmm1
movdqa 0x119eb(%rip), %xmm2    # 0x25530
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
paddd %xmm0, %xmm2
movdqa %xmm2, %xmm0
psrad $0x1, %xmm0
por %xmm2, %xmm0
movdqa %xmm0, %xmm1
psrad $0x2, %xmm1
por %xmm0, %xmm1
movdqa %xmm1, %xmm0
psrad $0x4, %xmm0
por %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrad $0x8, %xmm1
por %xmm0, %xmm1
movdqa %xmm1, %xmm0
psrad $0x10, %xmm0
por %xmm1, %xmm0
movd %xmm0, %esi
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
cmpl %eax, %esi
jge 0x13bba
incl %eax
movq 0x38(%r14), %rdi
movslq %eax, %rsi
callq 0x3610
movq %rax, 0x38(%r14)
movl 0x30(%r14), %ecx
movq (%r15), %rdx
jmp 0x13bbe
movq 0x38(%r14), %rax
movslq %ecx, %rdi
addq %rax, %rdi
movq 0x10(%r15), %rsi
incq %rdx
callq 0x3580
movl (%r15), %eax
movl 0x30(%r14), %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x30(%r14)
movq 0x38(%r14), %rcx
cltq
movb $0x0, (%rcx,%rax)
cmpl $0xa, 0x4(%rsp)
je 0x13cd9
movq 0x8(%rbx), %rdi
movl $0xa, %esi
movq %r15, %rdx
movq %r12, %rcx
callq 0x136ff
movq (%r15), %rax
movq 0x10(%r15), %rcx
movb $0xa, (%rcx,%rax)
movl 0x30(%r14), %ecx
movq (%r15), %rdx
leal 0x1(%rcx), %eax
movd %ecx, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movd %edx, %xmm1
movdqa 0x118fb(%rip), %xmm2    # 0x25530
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
paddd %xmm0, %xmm2
movdqa %xmm2, %xmm0
psrad $0x1, %xmm0
por %xmm2, %xmm0
movdqa %xmm0, %xmm1
psrad $0x2, %xmm1
por %xmm0, %xmm1
movdqa %xmm1, %xmm0
psrad $0x4, %xmm0
por %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrad $0x8, %xmm1
por %xmm0, %xmm1
movdqa %xmm1, %xmm0
psrad $0x10, %xmm0
por %xmm1, %xmm0
movd %xmm0, %esi
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
cmpl %eax, %esi
jge 0x13caa
incl %eax
movq 0x38(%r14), %rdi
movslq %eax, %rsi
callq 0x3610
movq %rax, 0x38(%r14)
movl 0x30(%r14), %ecx
movq (%r15), %rdx
jmp 0x13cae
movq 0x38(%r14), %rax
movslq %ecx, %rdi
addq %rax, %rdi
movq 0x10(%r15), %rsi
incq %rdx
callq 0x3580
movl (%r15), %eax
movl 0x30(%r14), %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x30(%r14)
movq 0x38(%r14), %rcx
cltq
movb $0x0, (%rcx,%rax)
incq 0x18(%rbx)
movq 0x8(%rbx), %rdi
movl $0x1, %esi
movq %r15, %rdx
movq %r12, %rcx
callq 0x136ff
testl %eax, %eax
jns 0x13b0c
movq %r14, %rdi
callq 0x139af
movq %r14, %rdi
callq 0x11941
movl $0x1, 0x20(%rbx)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq