// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.c
// Function: sam_header_read2
bam_header_t *sam_header_read2(const char *fn)
{
	bam_header_t *header;
	int c, dret, ret, error = 0;
	gzFile fp;
	kstream_t *ks;
	kstring_t *str;
	kh_ref_t *hash;
	khiter_t k;
	if (fn == 0) return 0;
	fp = (strcmp(fn, "-") == 0)? gzdopen(fileno(stdin), "r") : gzopen(fn, "r");
	if (fp == 0) return 0;
	hash = kh_init(ref);
	ks = ks_init(fp);
	str = (kstring_t*)calloc(1, sizeof(kstring_t));
	while (ks_getuntil(ks, 0, str, &dret) > 0) {
		char *s = strdup(str->s);
		int len, i;
		i = kh_size(hash);
		ks_getuntil(ks, 0, str, &dret);
		len = atoi(str->s);
		k = kh_put(ref, hash, s, &ret);
		if (ret == 0) {
			fprintf(stderr, "[sam_header_read2] duplicated sequence name: %s\n", s);
			error = 1;
		}
		kh_value(hash, k) = (uint64_t)len<<32 | i;
		if (dret != '\n')
			while ((c = ks_getc(ks)) != '\n' && c != -1);
	}
	ks_destroy(ks);
	gzclose(fp);
	free(str->s); free(str);
	fprintf(stderr, "[sam_header_read2] %d sequences loaded.\n", kh_size(hash));
	if (error) return 0;
	header = hash2header(hash);
	kh_destroy(ref, hash);
	return header;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
testq %rdi, %rdi
je 0x45f7
cmpb $0x2d, (%rdi)
jne 0x3fb5
cmpb $0x0, 0x1(%rdi)
je 0x4585
leaq 0x73e6(%rip), %rsi      # 0xb3a2
callq 0x34f0
movq %rax, %r12
xorl %r14d, %r14d
testq %rax, %rax
je 0x45fa
pushq $0x1
popq %rbx
pushq $0x28
popq %rsi
movq %rbx, %rdi
callq 0x31c0
movq %rax, %r15
movq %r12, -0xb8(%rbp)
movq %r12, %rdi
callq 0x6e39
movq %rax, %r12
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x31c0
movq %r12, %rdi
movq %r15, %r8
movq %rax, %rbx
pushq $0x2
popq %r15
movq $0x0, -0x38(%rbp)
xorl %r12d, %r12d
movq $0x0, -0x50(%rbp)
movl $0x0, -0x88(%rbp)
movl $0x0, -0x78(%rbp)
xorl %eax, %eax
movq $0x0, -0x60(%rbp)
movl $0x0, -0x7c(%rbp)
movq %rbx, -0x90(%rbp)
movq %r8, -0x30(%rbp)
movq %rdi, -0xa0(%rbp)
movq %rax, -0x48(%rbp)
xorl %esi, %esi
movq %rbx, %rdx
leaq -0xac(%rbp), %r13
movq %r13, %rcx
callq 0x6e6a
movl -0x50(%rbp), %ecx
movq %rcx, -0x98(%rbp)
testl %eax, %eax
jle 0x45a7
movq 0x10(%rbx), %rdi
callq 0x3600
movq %rax, -0x70(%rbp)
movq -0xa0(%rbp), %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x6e6a
movq 0x10(%rbx), %rdi
callq 0x3540
movl %eax, %r13d
movl -0x78(%rbp), %eax
cmpl -0x88(%rbp), %eax
jb 0x432e
movq %r13, -0x68(%rbp)
movq -0x48(%rbp), %rdi
leal (%rdi,%rdi), %eax
movq -0x50(%rbp), %rcx
cmpl %ecx, %eax
movl $0x0, %eax
sbbl %eax, %eax
orl $0x1, %eax
addl %ecx, %eax
pushq $0x21
popq %rcx
leaq 0x6fd1(%rip), %rsi      # 0xb0b0
leal -0x2(%rcx), %edx
decl %ecx
cmpl %eax, (%rsi,%rdx,4)
ja 0x40df
movl %ecx, %eax
movl (%rsi,%rax,4), %r13d
cvtsi2sd %r13, %xmm0
mulsd 0x6f0c(%rip), %xmm0     # 0xb008
addsd 0x6f0c(%rip), %xmm0     # 0xb010
cvttsd2si %xmm0, %rax
cmpl %eax, %edi
jae 0x432a
movq %rax, -0x88(%rbp)
movl %r13d, %eax
shrl $0x4, %eax
leaq 0x4(,%rax,4), %rbx
movq %rbx, %rdi
callq 0x3470
movq %rax, %r12
movq %rax, %rdi
movl $0xaa, %esi
movq %rbx, %rdx
callq 0x3170
movq -0x50(%rbp), %r9
cmpl %r13d, %r9d
jae 0x4185
leaq (,%r13,8), %rsi
movq %rsi, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3590
movq -0x30(%rbp), %rbx
movq %rax, -0x38(%rbp)
movq %rax, 0x18(%rbx)
movq 0x20(%rbx), %rdi
movq -0x40(%rbp), %rsi
callq 0x3590
movq -0x50(%rbp), %r9
movq %rbx, %rdi
movq %rax, 0x20(%rbx)
jmp 0x4189
movq -0x30(%rbp), %rdi
movq -0x98(%rbp), %r8
leal -0x1(%r13), %eax
movl %eax, -0x54(%rbp)
xorl %r10d, %r10d
cmpq %r8, %r10
je 0x42b9
movq 0x10(%rdi), %r11
movl %r10d, %edx
shrl $0x4, %edx
movl (%r11,%rdx,4), %eax
leal (%r10,%r10), %ecx
andl $0x1e, %ecx
movl %eax, %esi
shrl %cl, %esi
testb $0x3, %sil
jne 0x42b1
movq %r11, -0x60(%rbp)
leaq (%r11,%rdx,4), %rdx
movq -0x38(%rbp), %rsi
movq (%rsi,%r10,8), %rbx
movq 0x20(%rdi), %rsi
movq %r10, -0x78(%rbp)
movq %rsi, -0xa8(%rbp)
movq (%rsi,%r10,8), %rsi
movq %rsi, -0x40(%rbp)
btsl %ecx, %eax
movl %eax, (%rdx)
movq %rbx, %rdi
callq 0x910c
movl %eax, %ecx
xorl %edx, %edx
divl %r13d
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl -0x54(%rbp)
incl %edx
movq -0x50(%rbp), %r9
movl %esi, %edi
shrl $0x4, %edi
movl (%r12,%rdi,4), %eax
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl %r15d, %r8d
shll %cl, %r8d
testl %eax, %r8d
jne 0x423a
addl %edx, %esi
cmpl %r13d, %esi
movl %r13d, %eax
cmovbl %r14d, %eax
subl %eax, %esi
jmp 0x4210
notl %r8d
andl %r8d, %eax
movl %eax, (%r12,%rdi,4)
movl %esi, %r8d
cmpl %r9d, %esi
movq -0x60(%rbp), %rsi
jae 0x428b
movl (%rsi,%rdi,4), %eax
movl %eax, %edx
shrl %cl, %edx
testb $0x3, %dl
jne 0x428b
leaq (%rsi,%rdi,4), %rdx
movq -0x38(%rbp), %rdi
movq (%rdi,%r8,8), %rsi
movq %rbx, (%rdi,%r8,8)
movq -0xa8(%rbp), %r9
movq (%r9,%r8,8), %rdi
movq -0x40(%rbp), %r10
movq %r10, (%r9,%r8,8)
movq %rsi, %rbx
movq %rdi, -0x40(%rbp)
jmp 0x41ed
movq -0x38(%rbp), %rax
movq %rbx, (%rax,%r8,8)
movq -0xa8(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%rax,%r8,8)
movq -0x30(%rbp), %rdi
movq -0x98(%rbp), %r8
movq -0x78(%rbp), %r10
incq %r10
jmp 0x419a
cmpl %r13d, %r9d
jbe 0x42f9
leaq (,%r13,8), %rbx
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
callq 0x3590
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x38(%rbp)
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movq %rbx, %rsi
callq 0x3590
movq -0x30(%rbp), %rdi
movq %rax, 0x20(%rdi)
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0x33d0
movq %r12, 0x10(%rbx)
movl %r13d, (%rbx)
movq -0x48(%rbp), %rax
movl %eax, 0x8(%rbx)
movq -0x88(%rbp), %rcx
movl %ecx, 0xc(%rbx)
movq %r13, -0x50(%rbp)
movl %ecx, -0x88(%rbp)
movl %eax, -0x78(%rbp)
movq -0x68(%rbp), %r13
movq -0x70(%rbp), %rdi
callq 0x910c
movl %eax, %esi
xorl %edx, %edx
movq -0x50(%rbp), %rdi
divl %edi
movl %edx, %r10d
movl %edx, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %eax
leal (%r10,%r10), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x4367
movl %r10d, %r11d
movq -0x30(%rbp), %r8
movq -0x48(%rbp), %r9
jmp 0x4436
movq %r13, -0x68(%rbp)
leal -0x1(%rdi), %ecx
movl %esi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %r10d, %ebx
movl %edi, %r11d
movq %r10, -0xa8(%rbp)
movl %edx, -0x54(%rbp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %esi
leal (%rbx,%rbx), %r13d
andl $0x1e, %r13d
movl %esi, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x4409
testb $0x1, %al
jne 0x43d9
movl %ebx, %eax
movq -0x38(%rbp), %rcx
movq (%rcx,%rax,8), %rdi
movl %esi, -0x60(%rbp)
movq -0x70(%rbp), %rsi
movq %r11, -0x40(%rbp)
callq 0x34a0
movl -0x60(%rbp), %esi
movl -0x54(%rbp), %edx
movq -0x40(%rbp), %r11
movq -0xa8(%rbp), %r10
movq -0x50(%rbp), %rdi
testl %eax, %eax
je 0x4409
btl %r13d, %esi
cmovbl %ebx, %r11d
addl %edx, %ebx
cmpl %edi, %ebx
movl %edi, %eax
cmovbl %r14d, %eax
subl %eax, %ebx
cmpl %r10d, %ebx
jne 0x4386
movb $0x1, %al
movl %edi, %ecx
cmpl %edi, %r11d
movq -0x30(%rbp), %r8
movq -0x48(%rbp), %r9
movq -0x68(%rbp), %r13
je 0x4427
jmp 0x4436
movq -0x30(%rbp), %r8
movq -0x48(%rbp), %r9
movl %r13d, %ecx
shrl %cl, %esi
testb $0x2, %sil
sete %al
movl %r11d, %ecx
movl %ebx, %r10d
movq -0x68(%rbp), %r13
cmpl %edi, %ecx
cmovel %r10d, %ecx
testb %al, %al
cmovnel %r10d, %ecx
movl %ecx, %r11d
movl %r11d, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %edx
leal (%r11,%r11), %ecx
andl $0x1e, %ecx
movl %edx, %esi
shrl %cl, %esi
movl %r11d, %ebx
testb $0x2, %sil
jne 0x4481
testb $0x1, %sil
je 0x4553
movq -0x38(%rbp), %rsi
movq -0x70(%rbp), %rdi
movq %rdi, (%rsi,%rbx,8)
pushq $0x3
popq %rsi
shll %cl, %esi
notl %esi
andl %esi, %edx
movl %edx, (%r12,%rax,4)
leal 0x1(%r9), %esi
movl %esi, 0x4(%r8)
jmp 0x44af
movq -0x38(%rbp), %rsi
movq -0x70(%rbp), %rdi
movq %rdi, (%rsi,%rbx,8)
pushq $0x3
popq %rsi
shll %cl, %esi
notl %esi
andl %esi, %edx
movl %edx, (%r12,%rax,4)
leal 0x1(%r9), %esi
movl %esi, 0x4(%r8)
movl 0x8(%r8), %eax
incl %eax
movl %eax, -0x78(%rbp)
movl %eax, 0x8(%r8)
shlq $0x20, %r13
movslq %r9d, %rax
orq %r13, %rax
movq 0x20(%r8), %rdx
movq %rdx, -0x60(%rbp)
movq %rax, (%rdx,%rbx,8)
cmpl $0xa, -0xac(%rbp)
movl %esi, -0x40(%rbp)
movl %esi, %eax
movq -0xa0(%rbp), %rdi
movq -0x90(%rbp), %rbx
je 0x4052
movl 0x10(%rdi), %r13d
movl 0x8(%rdi), %ecx
movl 0xc(%rdi), %eax
testl %r13d, %r13d
je 0x44f8
cmpl %eax, %ecx
jge 0x4544
movq (%rdi), %rbx
cmpl %eax, %ecx
jl 0x4536
andl $0x0, 0x8(%rdi)
movq 0x18(%rdi), %rdi
movq %rbx, %rsi
movl $0x4000, %edx           # imm = 0x4000
callq 0x3620
movq -0xa0(%rbp), %rdi
movl %eax, 0xc(%rdi)
xorl %ecx, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
jg 0x4536
movl $0x1, 0x10(%rdi)
pushq $0x1
popq %r13
testl %eax, %eax
je 0x4544
movslq %ecx, %rdx
incl %ecx
movl %ecx, 0x8(%rdi)
cmpb $0xa, (%rbx,%rdx)
jne 0x44ef
movl -0x40(%rbp), %eax
movq -0x90(%rbp), %rbx
jmp 0x4052
movq 0xaa76(%rip), %rax      # 0xefd0
movq (%rax), %rdi
leaq 0x6d6f(%rip), %rsi      # 0xb2d3
movq -0x70(%rbp), %rdx
xorl %eax, %eax
callq 0x34c0
movq -0x48(%rbp), %r9
movq -0x30(%rbp), %r8
movl %r9d, %esi
pushq $0x1
popq %rax
movl %eax, -0x7c(%rbp)
jmp 0x44af
movq 0xaa34(%rip), %rax      # 0xefc0
movq (%rax), %rdi
callq 0x3360
leaq 0x6e07(%rip), %rsi      # 0xb3a2
movl %eax, %edi
callq 0x35e0
jmp 0x3fc1
movq -0xa0(%rbp), %rdi
callq 0x7115
movq -0xb8(%rbp), %rdi
callq 0x35a0
movq 0x10(%rbx), %rdi
callq 0x33d0
movq %rbx, %rdi
callq 0x33d0
movq 0xa9f9(%rip), %rax      # 0xefd0
movq (%rax), %rdi
leaq 0x6d23(%rip), %rsi      # 0xb304
xorl %r13d, %r13d
movq -0x48(%rbp), %rbx
movl %ebx, %edx
xorl %eax, %eax
callq 0x34c0
cmpl $0x0, -0x7c(%rbp)
je 0x460f
xorl %r14d, %r14d
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x58dd
movq %rax, %r14
movl %ebx, (%rax)
movl %ebx, %r15d
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x31c0
movq %rax, %rbx
movq %rax, 0x8(%r14)
pushq $0x4
popq %rsi
movq %r15, %rdi
callq 0x31c0
movq %rax, 0x10(%r14)
xorl %edx, %edx
movq -0x98(%rbp), %r8
movq -0x60(%rbp), %r9
cmpq %rdx, %r8
je 0x4689
movl %edx, %ecx
shrl $0x4, %ecx
movl (%r12,%rcx,4), %esi
movl %r13d, %ecx
andb $0x1e, %cl
shrl %cl, %esi
testb $0x3, %sil
jne 0x4680
movq (%r9,%rdx,8), %rcx
movq -0x38(%rbp), %rsi
movq (%rsi,%rdx,8), %rsi
movslq %ecx, %rdi
movq %rsi, (%rbx,%rdi,8)
shrq $0x20, %rcx
movl %ecx, (%rax,%rdi,4)
incq %rdx
addl $0x2, %r13d
jmp 0x464a
movq %r14, %rdi
callq 0x6403
movq -0x38(%rbp), %rdi
callq 0x33d0
movq -0x30(%rbp), %rbx
movq 0x10(%rbx), %rdi
callq 0x33d0
movq 0x20(%rbx), %rdi
callq 0x33d0
movq %rbx, %rdi
callq 0x33d0
jmp 0x45fa