// File: /workspace/github_c_makefile_star2_O2/lh3[P]bgt/bedidx.c
// Function: bed_read
void *bed_read(const char *fn)
{
	reghash_t *h = kh_init(reg);
	gzFile fp;
	kstream_t *ks;
	int dret;
	kstring_t *str;
	// read the list
	fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
	if (fp == 0) return 0;
	str = (kstring_t*)calloc(1, sizeof(kstring_t));
	ks = ks_init(fp);
	while (ks_getuntil(ks, 0, str, &dret) >= 0) { // read the chr name
		int beg = -1, end = -1;
		bed_reglist_t *p;
		khint_t k = kh_get(reg, h, str->s);
		if (k == kh_end(h)) { // absent from the hash table
			int ret;
			char *s = strdup(str->s);
			k = kh_put(reg, h, s, &ret);
			memset(&kh_val(h, k), 0, sizeof(bed_reglist_t));
		}
		p = &kh_val(h, k);
		if (dret != '\n') { // if the lines has other characters
			if (ks_getuntil(ks, 0, str, &dret) > 0 && isdigit(str->s[0])) {
				beg = atoi(str->s); // begin
				if (dret != '\n') {
					if (ks_getuntil(ks, 0, str, &dret) > 0 && isdigit(str->s[0])) {
						end = atoi(str->s); // end
						if (end < beg) end = -1;
					}
				}
			}
		}
		if (dret != '\n') while ((dret = ks_getc(ks)) > 0 && dret != '\n'); // skip the rest of the line
		if (end < 0 && beg > 0) end = beg, beg = beg - 1; // if there is only one column
		if (beg >= 0 && end > beg) {
			if (p->n == p->m) {
				p->m = p->m? p->m<<1 : 4;
				p->a = (uint64_t*)realloc(p->a, p->m * 8);
			}
			p->a[p->n++] = (uint64_t)beg<<32 | end;
		}
	}
	ks_destroy(ks);
	gzclose(fp);
	free(str->s); free(str);
	bed_index(h);
	return h;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %r14
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x2220
movq %rax, %r12
cmpb $0x2d, (%r14)
jne 0xf7fb
cmpb $0x0, 0x1(%r14)
je 0xffd4
leaq 0x99f6(%rip), %rsi      # 0x191f8
movq %r14, %rdi
callq 0x2380
movq %rax, %rbx
testq %rax, %rax
je 0xffbc
movq $0x0, 0x20(%rsp)
pushq $0x1
popq %r14
pushq $0x18
popq %rsi
movq %r14, %rdi
callq 0x2220
movq %rax, 0x68(%rsp)
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x2220
movq %rbx, 0x88(%rsp)
movq %rbx, 0x10(%rax)
movq %rax, %rbx
movl $0x8000, 0x8(%rax)      # imm = 0x8000
movl $0x2000, %edi           # imm = 0x2000
callq 0x22e0
movq %rax, 0x18(%rbx)
pushq $0x2
popq %r13
xorl %ebp, %ebp
movq $0x0, 0x18(%rsp)
xorl %r14d, %r14d
movq $0x0, 0x58(%rsp)
movl $0x0, 0x50(%rsp)
movl $0x0, 0x40(%rsp)
movq %r12, 0x28(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
movq 0x68(%rsp), %rbx
movq %rbx, %rsi
leaq 0xc(%rsp), %rdx
callq 0xfff6
testl %eax, %eax
js 0xff79
movq 0x10(%rbx), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0xf6f8
cmpl 0x20(%rsp), %eax
jne 0xf8ef
movq %r15, %rdi
callq 0x2430
movq %rax, 0x30(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x50(%rsp), %eax
movq 0x10(%rsp), %rbx
jae 0xf903
movq 0x20(%rsp), %rsi
jmp 0xfbde
movl %eax, %eax
movq %rax, 0x38(%rsp)
movq 0x10(%rsp), %rbx
pushq $-0x1
popq %rdi
jmp 0xfd8e
movq 0x58(%rsp), %rdi
leal (%rdi,%rdi), %eax
movq 0x20(%rsp), %rsi
cmpl %esi, %eax
movl $0x0, %eax
sbbl %eax, %eax
orl $0x1, %eax
addl %esi, %eax
decl %eax
movl %eax, %ecx
shrl %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
shrl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %edx
shrl $0x8, %edx
orl %ecx, %edx
movl %edx, %eax
shrl $0x10, %eax
orl %edx, %eax
incl %eax
cmpl $0x5, %eax
pushq $0x4
popq %rcx
movl %ecx, %ebp
cmovael %eax, %ebp
cvtsi2sd %rbp, %xmm0
mulsd 0x94dc(%rip), %xmm0     # 0x18e38
addsd 0x94dc(%rip), %xmm0     # 0x18e40
cvttsd2si %xmm0, %rdx
cmpl %edx, %edi
jae 0xfbde
movq %rdx, 0x40(%rsp)
movl %ebp, %r15d
shrl $0x2, %r15d
andl $-0x4, %r15d
cmpl $0x10, %eax
cmovbl %ecx, %r15d
movq %r15, %rdi
callq 0x22e0
movq %rax, %r14
movq %rax, %rdi
movl $0xaa, %esi
movq %r15, %rdx
callq 0x21e0
movq 0x20(%rsp), %rdi
movl %ebp, %ebx
cmpl %ebp, %edi
movq %rbx, 0x50(%rsp)
jae 0xf9e7
leaq (,%rbx,8), %rsi
movq 0x18(%rsp), %rdi
callq 0x2340
movq %rax, 0x18(%rsp)
movq %rax, 0x18(%r12)
movq 0x20(%r12), %rdi
imulq $0x18, %rbx, %rsi
callq 0x2340
movq 0x20(%rsp), %rdi
movq %rax, 0x20(%r12)
movq %rbp, 0x60(%rsp)
leal -0x1(%rbp), %ebx
movl %edi, %r8d
xorl %r9d, %r9d
movq %r8, 0x48(%rsp)
cmpq %r8, %r9
je 0xfb6b
movq 0x10(%r12), %rbp
movl %r9d, %eax
shrl $0x4, %eax
movl (%rbp,%rax,4), %edx
leal (%r9,%r9), %ecx
andl $0x1e, %ecx
movl %edx, %esi
shrl %cl, %esi
testb $0x3, %sil
jne 0xfb63
movq 0x18(%rsp), %rsi
movq (%rsi,%r9,8), %r15
movq 0x20(%r12), %r12
movq %r9, 0x38(%rsp)
imulq $0x18, %r9, %rsi
movq 0x10(%r12,%rsi), %rdi
movq %rdi, 0x80(%rsp)
movupd (%r12,%rsi), %xmm0
movapd %xmm0, 0x70(%rsp)
btsl %ecx, %edx
movl %edx, (%rbp,%rax,4)
movq %r15, %rdi
callq 0x10254
movl %eax, %ecx
shrl $0x3, %ecx
movl %eax, %esi
shll $0x3, %esi
xorl %ecx, %esi
orl $0x1, %esi
andl %ebx, %esi
movl %eax, %edi
andl %ebx, %edi
movl %edi, %edx
leal (%rdi,%rdi), %ecx
andl $0x1e, %ecx
movl %r13d, %r8d
shll %cl, %r8d
shrl $0x4, %edx
movl (%r14,%rdx,4), %r9d
leal (%rdi,%rsi), %eax
testl %r9d, %r8d
je 0xfa77
notl %r8d
andl %r8d, %r9d
movl %r9d, (%r14,%rdx,4)
movl %edi, %eax
movq 0x20(%rsp), %rsi
cmpl %esi, %edi
movq %rsi, %rdi
jae 0xfb2e
movl (%rbp,%rdx,4), %esi
shrl %cl, %esi
testb $0x3, %sil
jne 0xfb2e
movq 0x18(%rsp), %rdi
movq (%rdi,%rax,8), %rsi
movq %r15, (%rdi,%rax,8)
imulq $0x18, %rax, %rax
movq 0x10(%r12,%rax), %rdi
movq %rdi, 0xa0(%rsp)
movups (%r12,%rax), %xmm0
movaps %xmm0, 0x90(%rsp)
movq 0x80(%rsp), %rdi
movq %rdi, 0x10(%r12,%rax)
movaps 0x70(%rsp), %xmm0
movups %xmm0, (%r12,%rax)
movq 0xa0(%rsp), %rax
movq %rax, 0x80(%rsp)
movapd 0x90(%rsp), %xmm0
movapd %xmm0, 0x70(%rsp)
pushq $0x1
popq %rax
shll %cl, %eax
orl %eax, (%rbp,%rdx,4)
movq %rsi, %r15
jmp 0xfa5e
movq 0x18(%rsp), %rcx
movq %r15, (%rcx,%rax,8)
imulq $0x18, %rax, %rax
movq 0x80(%rsp), %rcx
movq %rcx, 0x10(%r12,%rax)
movapd 0x70(%rsp), %xmm0
movupd %xmm0, (%r12,%rax)
movq 0x28(%rsp), %r12
movq 0x48(%rsp), %r8
movq 0x38(%rsp), %r9
incq %r9
jmp 0xf9fa
cmpl 0x60(%rsp), %edi
jbe 0xfba5
movq 0x50(%rsp), %rbx
leaq (,%rbx,8), %rsi
movq 0x18(%rsp), %rdi
callq 0x2340
movq %rax, 0x18(%rsp)
movq %rax, 0x18(%r12)
movq 0x20(%r12), %rdi
imulq $0x18, %rbx, %rsi
callq 0x2340
movq %rax, 0x20(%r12)
movq 0x10(%rsp), %rbx
movq 0x10(%r12), %rdi
callq 0x2050
movq %r14, 0x10(%r12)
movq 0x60(%rsp), %rsi
movl %esi, (%r12)
movq 0x58(%rsp), %rax
movl %eax, 0x8(%r12)
movq 0x40(%rsp), %rcx
movl %ecx, 0xc(%r12)
movl %ecx, 0x50(%rsp)
movl %eax, 0x40(%rsp)
leal -0x1(%rsi), %r15d
movq %rsi, %rbp
movq 0x30(%rsp), %rdi
callq 0x10254
movl %eax, %r8d
movl %eax, %esi
andl %r15d, %esi
movl %esi, %eax
shrl $0x4, %eax
movl (%r14,%rax,4), %eax
leal (%rsi,%rsi), %ecx
shrl %cl, %eax
testb $0x2, %al
movq %rbp, 0x20(%rsp)
je 0xfc18
movl %esi, %ebp
pushq $-0x1
popq %rdi
jmp 0xfce0
movl %r15d, %edx
movl %r8d, %eax
shrl $0x3, %eax
shll $0x3, %r8d
xorl %eax, %r8d
orl $0x1, %r8d
andl %r15d, %r8d
movl %esi, %ebx
pushq $-0x1
popq %rdi
movq %rsi, 0x38(%rsp)
movl %r15d, 0x48(%rsp)
movl %r8d, 0x60(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%r14,%rax,4), %r15d
leal (%rbx,%rbx), %r12d
andl $0x1e, %r12d
movl %r15d, %eax
movl %r12d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0xfcb7
testb $0x1, %al
jne 0xfc8e
movl %ebx, %eax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
movq 0x30(%rsp), %rsi
callq 0x2230
movl 0x60(%rsp), %r8d
movl 0x48(%rsp), %edx
movq 0x38(%rsp), %rsi
pushq $-0x1
popq %rdi
testl %eax, %eax
je 0xfcb7
btl %r12d, %r15d
cmovbl %ebx, %ebp
addl %r8d, %ebx
andl %edx, %ebx
cmpl %esi, %ebx
jne 0xfc43
movb $0x1, %al
movq 0x20(%rsp), %rdx
movl %edx, %ecx
cmpl %edx, %ebp
movq 0x28(%rsp), %r12
movq 0x10(%rsp), %rbx
je 0xfcd2
jmp 0xfce0
movl %r12d, %ecx
shrl %cl, %r15d
testb $0x2, %r15b
sete %al
movl %ebx, %esi
movl %ebp, %ecx
movq 0x28(%rsp), %r12
movq 0x10(%rsp), %rbx
cmpl 0x20(%rsp), %ecx
cmovel %esi, %ecx
testb %al, %al
cmovnel %esi, %ecx
movl %ecx, %ebp
movl %ebp, %eax
shrl $0x4, %eax
movl (%r14,%rax,4), %edx
leal (,%rbp,2), %ecx
andl $0x1e, %ecx
movl %edx, %esi
shrl %cl, %esi
movl %ebp, %r9d
testb $0x2, %sil
jne 0xfd34
testb $0x1, %sil
je 0xfd70
pushq $0x3
popq %rsi
shll %cl, %esi
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %r8
movq %r8, (%rcx,%r9,8)
notl %esi
andl %esi, %edx
movl %edx, (%r14,%rax,4)
movl 0x4(%r12), %eax
incl %eax
movq %rax, 0x58(%rsp)
movl %eax, 0x4(%r12)
jmp 0xfd70
movq 0x18(%rsp), %rsi
movq 0x30(%rsp), %r8
movq %r8, (%rsi,%r9,8)
pushq $0x3
popq %rsi
shll %cl, %esi
notl %esi
andl %esi, %edx
movl %edx, (%r14,%rax,4)
movl 0x4(%r12), %eax
movl 0x8(%r12), %ecx
incl %eax
movq %rax, 0x58(%rsp)
movl %eax, 0x4(%r12)
incl %ecx
movl %ecx, 0x40(%rsp)
movl %ecx, 0x8(%r12)
movq 0x20(%r12), %rbp
movq %r9, 0x38(%rsp)
imulq $0x18, %r9, %rax
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbp,%rax)
andq $0x0, 0x10(%rbp,%rax)
cmpl $0xa, 0xc(%rsp)
movl %edi, %edx
movl %edi, %r15d
je 0xfeea
movq %rbx, %rdi
movq 0x68(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0xfff6
pushq $-0x1
popq %r8
movl %r8d, %r15d
movl %r8d, %edx
testl %eax, %eax
jle 0xfe4b
callq 0x2470
pushq $-0x1
popq %r8
movq %rax, %r12
movq (%rax), %rax
movq 0x68(%rsp), %rcx
movq 0x10(%rcx), %rdi
movsbq (%rdi), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
movl %r8d, %r15d
movl %r8d, %edx
je 0xfe4b
callq 0x23f0
movl %eax, %r15d
cmpl $0xa, 0xc(%rsp)
jne 0xfdff
pushq $-0x1
popq %rdx
jmp 0xfe52
movq %rbx, %rdi
movq 0x68(%rsp), %rbx
movq %rbx, %rsi
leaq 0xc(%rsp), %rdx
callq 0xfff6
testl %eax, %eax
jle 0xfe2b
movq (%r12), %rax
movq 0x10(%rbx), %rdi
movsbq (%rdi), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0xfe34
pushq $-0x1
popq %r8
movl %r8d, %edx
jmp 0xfe46
callq 0x23f0
movl %eax, %edx
cmpl %r15d, %eax
pushq $-0x1
popq %r8
cmovll %r8d, %edx
movq 0x10(%rsp), %rbx
cmpl $0xa, 0xc(%rsp)
jne 0xfe5c
movq 0x28(%rsp), %r12
jmp 0xfeea
movl %edx, 0x48(%rsp)
movq %rbp, 0x30(%rsp)
movl 0x8(%rbx), %ebp
movl (%rbx), %ecx
movl 0x4(%rbx), %edx
testb $0x3, %bpl
je 0xfe7c
cmpl %edx, %ecx
jl 0xfe7c
movl %r8d, %esi
jmp 0xfec7
movq 0x18(%rbx), %r12
cmpl %edx, %ecx
jge 0xfe88
movl %edx, %eax
jmp 0xfebb
movq 0x10(%rbx), %rdi
movl %ebp, %ebx
sarl $0x2, %ebx
movq %r12, %rsi
movl %ebx, %edx
callq 0x2240
cmpl %ebx, %eax
jge 0xfea4
andl $-0x4, %ebp
incl %ebp
pushq $-0x1
popq %r8
xorl %ecx, %ecx
movl $0x0, %edx
movl %r8d, %esi
testl %eax, %eax
movq 0x10(%rsp), %rbx
je 0xfec7
movslq %ecx, %rdx
incl %ecx
movzbl (%r12,%rdx), %esi
movl %eax, %edx
movl %esi, 0xc(%rsp)
testl %esi, %esi
jle 0xfed4
cmpl $0xa, %esi
jne 0xfe6d
movl %ebp, 0x8(%rbx)
movl %ecx, (%rbx)
movl %edx, 0x4(%rbx)
movq 0x28(%rsp), %r12
movq 0x30(%rsp), %rbp
movl 0x48(%rsp), %edx
testl %edx, %edx
sets %al
testl %r15d, %r15d
setg %cl
andb %al, %cl
movzbl %cl, %eax
testb %al, %al
cmovnel %r15d, %edx
subl %eax, %r15d
js 0xf897
cmpl %r15d, %edx
jle 0xf897
imulq $0x18, 0x38(%rsp), %rbx
addq %rbp, %rbx
movl (%rbx), %ecx
cmpl 0x4(%rbx), %ecx
jne 0xff56
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
pushq $0x4
popq %rcx
cmovel %ecx, %eax
movl %eax, 0x4(%rbx)
movq 0x8(%rbx), %rdi
shll $0x3, %eax
movslq %eax, %rsi
movq %rbp, %r12
movl %edx, %ebp
callq 0x2340
movl %ebp, %edx
movq %r12, %rbp
movq 0x28(%rsp), %r12
movq %rax, 0x8(%rbx)
movl (%rbx), %ecx
jmp 0xff5a
movq 0x8(%rbx), %rax
shlq $0x20, %r15
movl %edx, %edx
orq %r15, %rdx
leal 0x1(%rcx), %esi
movl %esi, (%rbx)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rsp), %rbx
jmp 0xf897
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0xff94
movq 0x18(%r14), %rdi
callq 0x2050
movq %r14, %rdi
callq 0x2050
movq 0x88(%rsp), %rdi
callq 0x2040
movq 0x10(%rbx), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2050
movq %r12, %rdi
callq 0xf5c2
jmp 0xffbf
xorl %r12d, %r12d
movq %r12, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10fad(%rip), %rax     # 0x20f88
movq (%rax), %rdi
callq 0x22a0
leaq 0x920e(%rip), %rsi      # 0x191f8
movl %eax, %edi
callq 0x2140
jmp 0xf80a