// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/index.c
// Function: mm_idx_bed_read_core
static mm_idx_intv_t *mm_idx_bed_read_core(const mm_idx_t *mi, const char *fn, int read_junc, int min_sc)
{
	gzFile fp;
	kstream_t *ks;
	kstring_t str = {0,0,0};
	mm_idx_intv_t *I;

	fp = fn && strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
	if (fp == 0) return 0;
	I = CALLOC(mm_idx_intv_t, mi->n_seq);
	ks = ks_init(fp);
	while (ks_getuntil(ks, KS_SEP_LINE, &str, 0) >= 0) {
		mm_idx_intv_t *r;
		mm_idx_intv1_t t = {-1,-1,-1,-1,0};
		char *p, *q, *bl, *bs;
		int32_t i, id = -1, n_blk = 0;
		for (p = q = str.s, i = 0;; ++p) {
			if (*p == 0 || *p == '\t') {
				int32_t c = *p;
				*p = 0;
				if (i == 0) { // chr
					id = mm_idx_name2id(mi, q);
					if (id < 0) break; // unknown name; TODO: throw a warning
				} else if (i == 1) { // start
					t.st = atol(q); // TODO: watch out integer overflow!
					if (t.st < 0) break;
				} else if (i == 2) { // end
					t.en = atol(q);
					if (t.en < 0) break;
				} else if (i == 4) { // BED score
					t.score = *q >= '0' && *q <= '9'? atol(q) : -1;
				} else if (i == 5) { // strand
					t.strand = *q == '+'? 1 : *q == '-'? -1 : 0;
				} else if (i == 9) {
					if (!isdigit(*q)) break;
					n_blk = atol(q);
				} else if (i == 10) {
					bl = q;
				} else if (i == 11) {
					bs = q;
					break;
				}
				if (c == 0) break;
				++i, q = p + 1;
			}
		}
		if (id < 0 || t.st < 0 || t.st >= t.en) continue; // contig ID not found, or other problems
		if (min_sc > 0 && t.score < min_sc) continue;
		r = &I[id];
		if (i >= 11 && read_junc) { // BED12
			int32_t st, sz, en;
			st = strtol(bs, &bs, 10); ++bs;
			sz = strtol(bl, &bl, 10); ++bl;
			en = t.st + st + sz;
			for (i = 1; i < n_blk; ++i) {
				mm_idx_intv1_t s = t;
				if (r->n == r->m) {
					r->m = r->m? r->m + (r->m>>1) : 16;
					r->a = (mm_idx_intv1_t*)realloc(r->a, sizeof(*r->a) * r->m);
				}
				st = strtol(bs, &bs, 10); ++bs;
				sz = strtol(bl, &bl, 10); ++bl;
				s.st = en, s.en = t.st + st;
				en = t.st + st + sz;
				if (s.en > s.st) r->a[r->n++] = s;
			}
		} else {
			if (r->n == r->m) {
				r->m = r->m? r->m + (r->m>>1) : 16;
				r->a = (mm_idx_intv1_t*)realloc(r->a, sizeof(*r->a) * r->m);
			}
			r->a[r->n++] = t;
		}
	}
	free(str.s);
	ks_destroy(ks);
	gzclose(fp);
	return I;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x21b0
cmpq $0x0, -0x18(%rbp)
je 0xe77e
movq -0x18(%rbp), %rdi
leaq 0x48c37(%rip), %rsi     # 0x57392
callq 0x2230
cmpl $0x0, %eax
je 0xe77e
movq -0x18(%rbp), %rdi
leaq 0x48147(%rip), %rsi     # 0x568b7
callq 0x2340
movq %rax, -0xc0(%rbp)
jmp 0xe7a2
movq 0x4f853(%rip), %rax     # 0x5dfd8
movq (%rax), %rdi
callq 0x22a0
movl %eax, %edi
leaq 0x48121(%rip), %rsi     # 0x568b7
callq 0x20f0
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xe7c1
movq $0x0, -0x8(%rbp)
jmp 0xed6d
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edi
movl $0x10, %esi
callq 0x2220
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
callq 0x1b040
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl $0x2, %esi
leaq -0x48(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0xb330
cmpl $0x0, %eax
jl 0xed4a
movq 0x48515(%rip), %rax     # 0x56d20
movq %rax, -0x68(%rbp)
movq 0x48512(%rip), %rax     # 0x56d28
movq %rax, -0x60(%rbp)
movl $0xffffffff, -0x90(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x94(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x78(%rbp)
movq %rax, -0x70(%rbp)
movl $0x0, -0x8c(%rbp)
movq -0x70(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xe860
movq -0x70(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
jne 0xea44
movq -0x70(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x98(%rbp)
movq -0x70(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x0, -0x8c(%rbp)
jne 0xe8a3
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x88f0
movl %eax, -0x90(%rbp)
cmpl $0x0, -0x90(%rbp)
jge 0xe89e
jmp 0xea57
jmp 0xea1e
cmpl $0x1, -0x8c(%rbp)
jne 0xe8c8
movq -0x78(%rbp), %rdi
callq 0x2350
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x68(%rbp)
jge 0xe8c3
jmp 0xea57
jmp 0xea1c
cmpl $0x2, -0x8c(%rbp)
jne 0xe8ed
movq -0x78(%rbp), %rdi
callq 0x2350
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jge 0xe8e8
jmp 0xea57
jmp 0xea1a
cmpl $0x4, -0x8c(%rbp)
jne 0xe951
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jl 0xe920
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
jg 0xe920
movq -0x78(%rbp), %rdi
callq 0x2350
movq %rax, -0xc8(%rbp)
jmp 0xe930
movq $-0x1, %rax
movq %rax, -0xc8(%rbp)
jmp 0xe930
movq -0xc8(%rbp), %rax
movl %eax, %ecx
movl -0x5c(%rbp), %eax
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
andl $0xc0000000, %eax       # imm = 0xC0000000
orl %ecx, %eax
movl %eax, -0x5c(%rbp)
jmp 0xea18
cmpl $0x5, -0x8c(%rbp)
jne 0xe9a8
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
jne 0xe973
movl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0xe98d
movq -0x78(%rbp), %rax
movsbl (%rax), %edx
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x2d, %edx
cmovel %ecx, %eax
movl %eax, -0xcc(%rbp)
movl -0xcc(%rbp), %ecx
movl -0x5c(%rbp), %eax
andl $0x3, %ecx
shll $0x1e, %ecx
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
orl %ecx, %eax
movl %eax, -0x5c(%rbp)
jmp 0xea16
cmpl $0x9, -0x8c(%rbp)
jne 0xe9e7
callq 0x2450
movq (%rax), %rax
movq -0x78(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0xe9d6
jmp 0xea57
movq -0x78(%rbp), %rdi
callq 0x2350
movl %eax, -0x94(%rbp)
jmp 0xea14
cmpl $0xa, -0x8c(%rbp)
jne 0xe9fa
movq -0x78(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0xea12
cmpl $0xb, -0x8c(%rbp)
jne 0xea10
movq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0xea57
jmp 0xea12
jmp 0xea14
jmp 0xea16
jmp 0xea18
jmp 0xea1a
jmp 0xea1c
jmp 0xea1e
cmpl $0x0, -0x98(%rbp)
jne 0xea29
jmp 0xea57
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0xea46
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0xe844
cmpl $0x0, -0x90(%rbp)
jl 0xea6e
cmpl $0x0, -0x68(%rbp)
jl 0xea6e
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jl 0xea73
jmp 0xe7e5
cmpl $0x0, -0x20(%rbp)
jle 0xea8c
movl -0x5c(%rbp), %eax
shll $0x2, %eax
sarl $0x2, %eax
cmpl -0x20(%rbp), %eax
jge 0xea8c
jmp 0xe7e5
movq -0x50(%rbp), %rax
movslq -0x90(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
cmpl $0xb, -0x8c(%rbp)
jl 0xeca6
cmpl $0x0, -0x1c(%rbp)
je 0xeca6
movq -0x88(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movl $0xa, %edx
callq 0x2280
movl %eax, -0x9c(%rbp)
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0xa, %edx
callq 0x2280
movl %eax, -0xa0(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
movl -0x68(%rbp), %eax
addl -0x9c(%rbp), %eax
addl -0xa0(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl $0x1, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0xeca1
movq -0x68(%rbp), %rax
movq %rax, -0xb4(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xac(%rbp)
movq -0x58(%rbp), %rax
movl (%rax), %eax
movq -0x58(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0xebc5
movq -0x58(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0xeb87
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x58(%rbp), %rcx
movl 0x4(%rcx), %ecx
sarl %ecx
addl %ecx, %eax
movl %eax, -0xd0(%rbp)
jmp 0xeb94
movl $0x10, %eax
movl %eax, -0xd0(%rbp)
jmp 0xeb94
movl -0xd0(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x58(%rbp), %rax
movslq 0x4(%rax), %rsi
shlq $0x4, %rsi
callq 0x2310
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x88(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movl $0xa, %edx
callq 0x2280
movl %eax, -0x9c(%rbp)
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0xa, %edx
callq 0x2280
movl %eax, -0xa0(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0x68(%rbp), %eax
addl -0x9c(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0x68(%rbp), %eax
addl -0x9c(%rbp), %eax
addl -0xa0(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xb0(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jle 0xec8b
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x58(%rbp), %rdx
movl (%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, (%rdx)
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0xb4(%rbp), %rcx
movq %rcx, (%rax)
movq -0xac(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0xec8d
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0xeb2c
jmp 0xed45
movq -0x58(%rbp), %rax
movl (%rax), %eax
movq -0x58(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0xed17
movq -0x58(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0xecd9
movq -0x58(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x58(%rbp), %rcx
movl 0x4(%rcx), %ecx
sarl %ecx
addl %ecx, %eax
movl %eax, -0xd4(%rbp)
jmp 0xece6
movl $0x10, %eax
movl %eax, -0xd4(%rbp)
jmp 0xece6
movl -0xd4(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x58(%rbp), %rax
movslq 0x4(%rax), %rsi
shlq $0x4, %rsi
callq 0x2310
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x58(%rbp), %rdx
movl (%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, (%rdx)
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x68(%rbp), %rcx
movq %rcx, (%rax)
movq -0x60(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0xe7e5
movq -0x38(%rbp), %rdi
callq 0x2040
movq -0x30(%rbp), %rdi
callq 0x1b0a0
movq -0x28(%rbp), %rdi
callq 0x2030
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)