// File: /workspace/github_c_makefile_star2_O3/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 $0x88, %rsp
movq %rdi, %r14
movl $0x1, %edi
movl $0x28, %esi
callq 0x2220
movq %rax, %r13
cmpb $0x2d, (%r14)
jne 0x14349
cmpb $0x0, 0x1(%r14)
je 0x14c0a
leaq 0xaef8(%rip), %rsi      # 0x1f248
movq %r14, %rdi
callq 0x2370
testq %rax, %rax
je 0x14bf2
movl $0x1, %edi
movl $0x18, %esi
movq %rax, %rbx
callq 0x2220
movq %rax, %rbp
movl $0x1, %edi
movl $0x20, %esi
callq 0x2220
movq %rbx, 0x68(%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)
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x14c2c
testl %eax, %eax
js 0x14bbc
xorl %r12d, %r12d
xorl %edi, %edi
movq %r13, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
movq %rbx, 0x48(%rsp)
movq %r12, 0x10(%rsp)
movq 0x10(%rbp), %rsi
movl $0x0, %r12d
testl %edi, %edi
movq %rdi, 0x18(%rsp)
je 0x144b2
movsbl (%rsi), %r15d
testl %r15d, %r15d
je 0x1441d
movb 0x1(%rsi), %al
testb %al, %al
je 0x14420
leaq 0x2(%rsi), %rcx
movl %r15d, %edx
shll $0x5, %edx
subl %r15d, %edx
movsbl %al, %r15d
addl %edx, %r15d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x14402
jmp 0x14420
xorl %r15d, %r15d
leal -0x1(%rdi), %r14d
movl %r15d, %edi
andl %r14d, %edi
movl %r15d, %eax
shrl $0x3, %eax
shll $0x3, %r15d
xorl %eax, %r15d
orl $0x1, %r15d
andl %r14d, %r15d
movq 0x10(%r13), %r8
movl %edi, %r12d
movl %edi, 0x20(%rsp)
movq %r8, 0x8(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %ebx
leal (%r12,%r12), %ebp
andl $0x1e, %ebp
movl %ebx, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x144a2
testb $0x1, %al
jne 0x14495
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rsi, %r13
callq 0x2230
movq 0x8(%rsp), %r8
movl 0x20(%rsp), %edi
movq %r13, %rsi
testl %eax, %eax
je 0x144a2
addl %r15d, %r12d
andl %r14d, %r12d
cmpl %edi, %r12d
jne 0x1444e
jmp 0x144b7
movl %ebp, %ecx
shrl %cl, %ebx
testb $0x3, %bl
movq 0x18(%rsp), %rdi
cmovnel %edi, %r12d
cmpl %edi, %r12d
jne 0x144e6
movq %rsi, %rdi
callq 0x2420
movq %rax, %rsi
movq 0x30(%rsp), %r13
movl 0x8(%r13), %eax
cmpl 0xc(%r13), %eax
jae 0x14502
movl %eax, %r9d
movq 0x18(%rsp), %rax
movl %eax, %r14d
movq 0x10(%rsp), %r12
jmp 0x147d7
movl %r12d, %r15d
movq 0x30(%rsp), %r13
movq 0x28(%rsp), %rbp
movq 0x48(%rsp), %rbx
movq 0x10(%rsp), %r12
jmp 0x149bc
movl 0x4(%r13), %r8d
leal (%r8,%r8), %ecx
movq 0x18(%rsp), %r14
cmpl %r14d, %ecx
movl $0x0, %ecx
sbbl %ecx, %ecx
orl $0x1, %ecx
addl %r14d, %ecx
decl %ecx
movl %ecx, %edx
shrl %edx
orl %ecx, %edx
movl %edx, %ecx
shrl $0x2, %ecx
orl %edx, %ecx
movl %ecx, %edx
shrl $0x4, %edx
orl %ecx, %edx
movl %edx, %edi
shrl $0x8, %edi
orl %edx, %edi
movl %edi, %ecx
shrl $0x10, %ecx
orl %edi, %ecx
incl %ecx
cmpl $0x5, %ecx
movl $0x4, %ebx
cmovael %ecx, %ebx
cvtsi2sd %rbx, %xmm0
mulsd 0xa8db(%rip), %xmm0     # 0x1ee38
addsd 0xa8db(%rip), %xmm0     # 0x1ee40
cvttsd2si %xmm0, %rdx
movq %r8, 0x40(%rsp)
cmpl %edx, %r8d
movq 0x10(%rsp), %r12
jae 0x147d4
movq %rdx, 0x8(%rsp)
movq %rsi, 0x20(%rsp)
movl %ebx, %r15d
shrl $0x2, %r15d
andl $-0x4, %r15d
cmpl $0x10, %ecx
movl $0x4, %eax
cmovbl %eax, %r15d
movq %r15, %rdi
callq 0x22e0
movq %rax, %rbp
movq %rax, %rdi
movl $0xaa, %esi
movq %r15, %rdx
callq 0x21e0
cmpl %ebx, %r14d
jae 0x145f1
movq 0x18(%r13), %rdi
movl %ebx, %r15d
shlq $0x3, %r15
movq %r15, %rsi
callq 0x2330
movq %rax, 0x18(%r13)
leaq (%r15,%r15,2), %rsi
movq %r12, %rdi
callq 0x2330
movq %rax, %r12
movq %rax, 0x20(%r13)
testl %r14d, %r14d
je 0x147a7
movq %rbx, 0x38(%rsp)
leal -0x1(%rbx), %eax
movq 0x10(%r13), %rdx
xorl %esi, %esi
movl %esi, %r9d
shrl $0x4, %r9d
movl (%rdx,%r9,4), %r10d
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl %r10d, %edi
shrl %cl, %edi
testb $0x3, %dil
jne 0x14767
movq 0x18(%r13), %rdi
movq (%rdi,%rsi,8), %r8
leaq (%rsi,%rsi,2), %r11
movq 0x10(%r12,%r11,8), %rbx
movq %rbx, 0x60(%rsp)
movupd (%r12,%r11,8), %xmm0
movapd %xmm0, 0x50(%rsp)
btsl %ecx, %r10d
movl %r10d, (%rdx,%r9,4)
movsbl (%r8), %r10d
testl %r10d, %r10d
je 0x1467b
movb 0x1(%r8), %cl
testb %cl, %cl
je 0x1467e
leaq 0x2(%r8), %r9
movl %r10d, %r11d
shll $0x5, %r11d
subl %r10d, %r11d
movsbl %cl, %r10d
addl %r11d, %r10d
movb (%r9), %cl
incq %r9
testb %cl, %cl
jne 0x1465e
jmp 0x1467e
xorl %r10d, %r10d
movl %r10d, %ecx
shrl $0x3, %ecx
leal (,%r10,8), %r11d
xorl %ecx, %r11d
orl $0x1, %r11d
andl %eax, %r11d
movl %r10d, %ebx
andl %eax, %ebx
movl %ebx, %r9d
leal (%rbx,%rbx), %ecx
andl $0x1e, %ecx
movl $0x2, %r14d
shll %cl, %r14d
shrl $0x4, %r9d
movl (%rbp,%r9,4), %r15d
leal (%rbx,%r11), %r10d
testl %r15d, %r14d
je 0x14696
notl %r14d
andl %r14d, %r15d
movl %r15d, (%rbp,%r9,4)
movl %ebx, %r10d
movq 0x18(%rsp), %r14
cmpl %r14d, %ebx
jae 0x14749
movl (%rdx,%r9,4), %r11d
shrl %cl, %r11d
testb $0x3, %r11b
jne 0x14749
movq (%rdi,%r10,8), %r11
movq %r8, (%rdi,%r10,8)
leaq (%r10,%r10,2), %r8
movq 0x10(%r12,%r8,8), %r10
movq %r10, 0x80(%rsp)
movups (%r12,%r8,8), %xmm0
movaps %xmm0, 0x70(%rsp)
movq 0x60(%rsp), %r10
movq %r10, 0x10(%r12,%r8,8)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%r12,%r8,8)
movq 0x80(%rsp), %r8
movq %r8, 0x60(%rsp)
movapd 0x70(%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
movl $0x1, %r8d
shll %cl, %r8d
orl %r8d, (%rdx,%r9,4)
movq %r11, %r8
jmp 0x14649
movq %r8, (%rdi,%r10,8)
leaq (%r10,%r10,2), %rcx
movq 0x60(%rsp), %rdi
movq %rdi, 0x10(%r12,%rcx,8)
movapd 0x50(%rsp), %xmm0
movupd %xmm0, (%r12,%rcx,8)
incq %rsi
cmpl %esi, %r14d
jne 0x145ff
movq 0x38(%rsp), %rbx
cmpl %ebx, %r14d
jbe 0x147a7
movq 0x18(%r13), %rdi
movl %ebx, %r15d
shlq $0x3, %r15
movq %r15, %rsi
callq 0x2330
movq %rax, 0x18(%r13)
leaq (%r15,%r15,2), %rsi
movq %r12, %rdi
callq 0x2330
movq %rax, %r12
movq %rax, 0x20(%r13)
movq 0x10(%r13), %rdi
callq 0x2050
movq %rbp, 0x10(%r13)
movl %ebx, (%r13)
movq 0x40(%rsp), %r9
movl %r9d, 0x8(%r13)
movq 0x8(%rsp), %rax
movl %eax, 0xc(%r13)
movq 0x20(%rsp), %rsi
movq %rbx, %r14
jmp 0x147d7
movl %eax, %r9d
movsbl (%rsi), %r15d
testl %r15d, %r15d
movq 0x28(%rsp), %rbp
je 0x1480e
movb 0x1(%rsi), %al
testb %al, %al
je 0x14811
movq %rsi, %rcx
addq $0x2, %rcx
movl %r15d, %edx
shll $0x5, %edx
subl %r15d, %edx
movsbl %al, %r15d
addl %edx, %r15d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x147f3
jmp 0x14811
xorl %r15d, %r15d
movq %r12, 0x10(%rsp)
leal -0x1(%r14), %edi
movl %r15d, %edx
andl %edi, %edx
movq 0x10(%r13), %r10
movl %edx, %eax
shrl $0x4, %eax
movl (%r10,%rax,4), %eax
leal (%rdx,%rdx), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x1483d
movl %edx, %r12d
jmp 0x14923
movq %r9, 0x40(%rsp)
movl %r15d, %eax
shrl $0x3, %eax
shll $0x3, %r15d
xorl %eax, %r15d
orl $0x1, %r15d
andl %edi, %r15d
movq %r14, 0x38(%rsp)
movl %r14d, %r12d
movl %edx, %r14d
movq %rsi, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movl %edi, 0x8(%rsp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%r10,%rax,4), %r13d
leal (%r14,%r14), %ebp
andl $0x1e, %ebp
movl %r13d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x148ef
testb $0x1, %al
jne 0x148bc
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r10, %rbx
callq 0x2230
movl 0x8(%rsp), %edi
movq 0x18(%rsp), %rdx
movq %rbx, %r10
movq 0x20(%rsp), %rsi
testl %eax, %eax
je 0x148ef
btl %ebp, %r13d
cmovbl %r14d, %r12d
addl %r15d, %r14d
andl %edi, %r14d
cmpl %edx, %r14d
jne 0x1486f
movb $0x1, %al
movq 0x38(%rsp), %r14
movl %r14d, %ecx
cmpl %r14d, %r12d
movq 0x30(%rsp), %r13
movq 0x28(%rsp), %rbp
movq 0x40(%rsp), %r9
je 0x14915
jmp 0x14923
movl %ebp, %ecx
shrl %cl, %r13d
testb $0x2, %r13b
sete %al
movl %r14d, %edx
movl %r12d, %ecx
movq 0x30(%rsp), %r13
movq 0x28(%rsp), %rbp
movq 0x40(%rsp), %r9
movq 0x38(%rsp), %r14
cmpl %r14d, %ecx
cmovel %edx, %ecx
testb %al, %al
cmovnel %edx, %ecx
movl %ecx, %r12d
movl %r12d, %eax
shrl $0x4, %eax
movl (%r10,%rax,4), %edx
leal (%r12,%r12), %ecx
andl $0x1e, %ecx
movl %edx, %edi
shrl %cl, %edi
testb $0x2, %dil
jne 0x1494e
testb $0x1, %dil
movq 0x48(%rsp), %rbx
jne 0x1497a
movl %r12d, %r15d
jmp 0x14998
movq 0x18(%r13), %r8
movl $0x3, %edi
shll %cl, %edi
movl %r12d, %r15d
movq %rsi, (%r8,%r15,8)
notl %edi
andl %edi, %edx
movl %edx, (%r10,%rax,4)
incl 0x4(%r13)
incl %r9d
movl %r9d, 0x8(%r13)
movq 0x48(%rsp), %rbx
jmp 0x14998
movq 0x18(%r13), %r8
movl $0x3, %edi
shll %cl, %edi
movl %r12d, %r15d
movq %rsi, (%r8,%r15,8)
notl %edi
andl %edi, %edx
movl %edx, (%r10,%rax,4)
incl 0x4(%r13)
leaq (%r15,%r15,2), %rax
xorpd %xmm0, %xmm0
movq 0x10(%rsp), %r12
movupd %xmm0, (%r12,%rax,8)
movq $0x0, 0x10(%r12,%rax,8)
movl %r14d, %eax
movq %rax, 0x18(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $0xa, 0x4(%rsp)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
je 0x14b20
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x4(%rsp), %rdx
callq 0x14c2c
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %eax, %eax
movq %r15, 0x8(%rsp)
jle 0x14a63
callq 0x2460
movq %rax, %r15
movq (%rax), %rax
movq 0x10(%rbp), %rdi
movsbq (%rdi), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
je 0x14a68
callq 0x23e0
movl %eax, %r14d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $0xa, 0x4(%rsp)
je 0x14a6f
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x4(%rsp), %rdx
callq 0x14c2c
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testl %eax, %eax
jle 0x14a68
movq (%r15), %rax
movq 0x10(%rbp), %rdi
movsbq (%rdi), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x14a68
callq 0x23e0
movl %eax, %edx
cmpl %r14d, %eax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovll %eax, %edx
jmp 0x14a68
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $0xa, 0x4(%rsp)
jne 0x14a79
movq 0x8(%rsp), %r15
jmp 0x14b20
movl %edx, 0x10(%rsp)
movl 0x8(%rbx), %ebp
movl (%rbx), %ecx
movl 0x4(%rbx), %eax
movq %r14, 0x20(%rsp)
testb $0x3, %bpl
je 0x14a94
cmpl %eax, %ecx
jge 0x14afe
movq 0x18(%rbx), %r15
cmpl %eax, %ecx
jl 0x14add
movq %r13, %r14
movq %r12, %r13
movq 0x10(%rbx), %rdi
movl %ebp, %r12d
sarl $0x2, %r12d
movq %r15, %rsi
movl %r12d, %edx
callq 0x2240
cmpl %r12d, %eax
jge 0x14ac2
andl $-0x4, %ebp
incl %ebp
movq %r13, %r12
xorl %edx, %edx
movl $0x0, %esi
movl $0x0, %ecx
testl %eax, %eax
movq %r14, %r13
movq 0x20(%rsp), %r14
je 0x14b02
movslq %ecx, %rdx
incl %ecx
movzbl (%r15,%rdx), %edx
movl %edx, 0x4(%rsp)
cmpl $0xa, %edx
je 0x14af4
testl %edx, %edx
jne 0x14a8a
movl %ebp, 0x8(%rbx)
movl %ecx, (%rbx)
movl %eax, 0x4(%rbx)
jmp 0x14b12
movl %eax, %edx
movl %ecx, %esi
movl %ebp, 0x8(%rbx)
movl %esi, (%rbx)
movl %edx, 0x4(%rbx)
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movq 0x28(%rsp), %rbp
movq 0x8(%rsp), %r15
movl 0x10(%rsp), %edx
testl %edx, %edx
sets %al
testl %r14d, %r14d
setg %cl
andb %al, %cl
movzbl %cl, %eax
testb %al, %al
cmovnel %r14d, %edx
subl %eax, %r14d
js 0x14b9a
cmpl %r14d, %edx
jle 0x14b9a
leaq (%r15,%r15,2), %rax
leaq (%r12,%rax,8), %rbx
movl (%rbx), %ecx
cmpl 0x4(%rbx), %ecx
jne 0x14b7c
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
movl $0x4, %ecx
cmovel %ecx, %eax
movl %eax, 0x4(%rbx)
movq 0x8(%rbx), %rdi
shll $0x3, %eax
movslq %eax, %rsi
movl %edx, %r15d
callq 0x2330
movl %r15d, %edx
movq %rax, 0x8(%rbx)
movl (%rbx), %ecx
jmp 0x14b80
movq 0x8(%rbx), %rax
shlq $0x20, %r14
movl %edx, %edx
orq %r14, %rdx
leal 0x1(%rcx), %esi
movl %esi, (%rbx)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x4(%rsp), %rdx
callq 0x14c2c
testl %eax, %eax
movq 0x18(%rsp), %rdi
jns 0x143d2
testq %rbx, %rbx
je 0x14bcd
movq 0x18(%rbx), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2050
movq 0x68(%rsp), %rdi
callq 0x2040
movq 0x10(%rbp), %rdi
callq 0x2050
movq %rbp, %rdi
callq 0x2050
movq %r13, %rdi
callq 0x140b8
jmp 0x14bf5
xorl %r13d, %r13d
movq %r13, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x11377(%rip), %rax     # 0x25f88
movq (%rax), %rdi
callq 0x22a0
leaq 0xa628(%rip), %rsi      # 0x1f248
movl %eax, %edi
callq 0x2140
jmp 0x14358