// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4327
movq $0x0, -0x8(%rbp)
jmp 0x451e
movq -0x10(%rbp), %rdi
leaq 0xdcfe(%rip), %rsi      # 0x12030
callq 0x3570
cmpl $0x0, %eax
jne 0x435f
movq 0x12c7d(%rip), %rax     # 0x16fc0
movq (%rax), %rdi
callq 0x3400
movl %eax, %edi
leaq 0xdf63(%rip), %rsi      # 0x122b7
callq 0x36b0
movq %rax, -0x68(%rbp)
jmp 0x4373
movq -0x10(%rbp), %rdi
leaq 0xdf4d(%rip), %rsi      # 0x122b7
callq 0x35c0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x438f
movq $0x0, -0x8(%rbp)
jmp 0x451e
callq 0xd1d0
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rdi
callq 0x86e0
movq %rax, -0x38(%rbp)
movl $0x1, %edi
movl $0x18, %esi
callq 0x3210
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rdx
xorl %esi, %esi
leaq -0x20(%rbp), %rcx
callq 0x8730
cmpl $0x0, %eax
jle 0x44a9
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x36d0
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rdx
xorl %esi, %esi
leaq -0x20(%rbp), %rcx
callq 0x8730
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x3610
movl %eax, -0x5c(%rbp)
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0x87a0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x444f
movq 0x12b9d(%rip), %rax     # 0x16fd0
movq (%rax), %rdi
movq -0x58(%rbp), %rdx
leaq 0xdda5(%rip), %rsi      # 0x121e6
movb $0x0, %al
callq 0x3590
movl $0x1, -0x28(%rbp)
movslq -0x5c(%rbp), %rdx
shlq $0x20, %rdx
movslq -0x60(%rbp), %rax
orq %rax, %rdx
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x4c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
cmpl $0xa, -0x20(%rbp)
je 0x44a4
jmp 0x4475
movq -0x38(%rbp), %rdi
callq 0x8ae0
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x69(%rbp)
je 0x4497
cmpl $-0x1, -0x1c(%rbp)
setne %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x44a0
jmp 0x44a2
jmp 0x4475
jmp 0x44a4
jmp 0x43b8
movq -0x38(%rbp), %rdi
callq 0x8770
movq -0x30(%rbp), %rdi
callq 0x3660
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x3490
movq -0x40(%rbp), %rdi
callq 0x3490
movq 0x12af8(%rip), %rax     # 0x16fd0
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movl 0x4(%rax), %edx
leaq 0xdd2e(%rip), %rsi      # 0x12217
movb $0x0, %al
callq 0x3590
cmpl $0x0, -0x28(%rbp)
je 0x4500
movq $0x0, -0x8(%rbp)
jmp 0x451e
movq -0x48(%rbp), %rdi
callq 0x8bb0
movq %rax, -0x18(%rbp)
movq -0x48(%rbp), %rdi
callq 0x8cd0
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)