// File: /workspace/github_c_makefile_star2_O0/lh3[P]miniprot/ntseq.c
// Function: mp_ntseq_read_spsc
int32_t mp_ntseq_read_spsc(mp_ntdb_t *nt, const char *fn, int32_t max_sc)
{
	gzFile fp;
	kstring_t str = {0,0,0};
	kstream_t *ks;
	int32_t dret, j;
	int64_t n_read = 0;

	fp = fn && strcmp(fn, "-") != 0? gzopen(fn, "rb") : gzdopen(0, "rb");
	if (fp == 0) return -1;
	if (max_sc > 63) max_sc = 63;
	mp_ntseq_index_name(nt);
	nt->spsc = Kcalloc(0, mp_spsc_t, nt->n_ctg * 2);
	ks = ks_init(fp);
	while (ks_getuntil(ks, KS_SEP_LINE, &str, &dret) >= 0) {
		mp_spsc_t *s;
		char *p, *q, *name = 0;
		int32_t i, type = -1, strand = 0, cid = -1, score = -1;
		int64_t pos = -1;
		for (i = 0, p = q = str.s;; ++p) {
			if (*p == '\t' || *p == 0) {
				int c = *p;
				*p = 0;
				if (i == 0) {
					name = q;
				} else if (i == 1) {
					pos = atol(q);
				} else if (i == 2) {
					strand = *q == '+'? 1 : '-'? -1 : 0;
				} else if (i == 3) {
					type = *q == 'D'? 0 : *q == 'A'? 1 : -1;
				} else if (i == 4) {
					score = atoi(q);
					break;
				}
				if (c == 0) break;
				q = p + 1, ++i;
			}
		}
		if (i < 4) continue; // not enough fields
		if (score > max_sc) score = max_sc;
		if (score < -max_sc) score = -max_sc;
		cid = mp_ntseq_name2id(nt, name);
		if (cid < 0 || type < 0 || strand == 0 || pos < 0) continue; // FIXME: give a warning!
		s = &nt->spsc[cid << 1 | (strand > 0? 0 : 1)];
		Kgrow(0, uint64_t, s->a, s->n, s->m);
		if (strand < 0) pos = nt->ctg[cid].len - pos;
		if (pos > 0 && pos < nt->ctg[cid].len) { // ignore scores at the ends
			s->a[s->n++] = (uint64_t)pos << 8 | (score + NS_SPSC_OFFSET) << 1 | type;
			++n_read;
		}
	}
	ks_destroy(ks);
	gzclose(fp);
	for (j = 0; j < nt->n_ctg * 2; ++j) {
		mp_spsc_t *s = &nt->spsc[j];
		if (s->n > 0)
			radix_sort_mp64(s->a, s->a + s->n);
	}
	if (mp_verbose >= 3)
		fprintf(stderr, "[M::%s] read %ld splice scores\n", __func__, (long)n_read);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2190
movq $0x0, -0x58(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x17253
movq -0x18(%rbp), %rdi
leaq 0xa345(%rip), %rsi      # 0x21575
callq 0x21d0
cmpl $0x0, %eax
je 0x17253
movq -0x18(%rbp), %rdi
leaq 0xa29d(%rip), %rsi      # 0x214e2
callq 0x2290
movq %rax, -0xb0(%rbp)
jmp 0x17268
xorl %edi, %edi
leaq 0xa286(%rip), %rsi      # 0x214e2
callq 0x20e0
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x17286
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x176be
cmpl $0x3f, -0x1c(%rbp)
jle 0x17293
movl $0x3f, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x17000
movq -0x10(%rbp), %rax
movl (%rax), %eax
shll %eax
movslq %eax, %rsi
xorl %eax, %eax
movl %eax, %edi
movl $0x10, %edx
callq 0xab60
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rdi
callq 0x154d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movl $0x2, %esi
leaq -0x40(%rbp), %rdx
leaq -0x4c(%rbp), %rcx
callq 0x15fa0
cmpl $0x0, %eax
jl 0x17602
movq $0x0, -0x78(%rbp)
movl $0xffffffff, -0x80(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x84(%rbp)
movl $0xffffffff, -0x88(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x8c(%rbp) # imm = 0xFFFFFFFF
movq $-0x1, -0x98(%rbp)
movl $0x0, -0x7c(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x70(%rbp)
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
je 0x17353
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1743d
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x9c(%rbp)
movq -0x68(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x0, -0x7c(%rbp)
jne 0x1737a
movq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x1741d
cmpl $0x1, -0x7c(%rbp)
jne 0x17395
movq -0x70(%rbp), %rdi
callq 0x22a0
movq %rax, -0x98(%rbp)
jmp 0x1741b
cmpl $0x2, -0x7c(%rbp)
jne 0x173ba
movq -0x70(%rbp), %rax
movsbl (%rax), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpl $0x2b, %edx
cmovel %ecx, %eax
movl %eax, -0x84(%rbp)
jmp 0x17419
cmpl $0x3, -0x7c(%rbp)
jne 0x173fe
movq -0x70(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x44, %eax
jne 0x173d6
xorl %eax, %eax
movl %eax, -0xb4(%rbp)
jmp 0x173f3
movq -0x70(%rbp), %rax
movsbl (%rax), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpl $0x41, %edx
cmovel %ecx, %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0x17417
cmpl $0x4, -0x7c(%rbp)
jne 0x17415
movq -0x70(%rbp), %rdi
callq 0x22f0
movl %eax, -0x8c(%rbp)
jmp 0x17450
jmp 0x17417
jmp 0x17419
jmp 0x1741b
jmp 0x1741d
cmpl $0x0, -0x9c(%rbp)
jne 0x17428
jmp 0x17450
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x1743f
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x17337
cmpl $0x4, -0x7c(%rbp)
jge 0x1745b
jmp 0x172cd
movl -0x8c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x1746f
movl -0x1c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
xorl %ecx, %ecx
subl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x17489
xorl %eax, %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x17110
movl %eax, -0x88(%rbp)
cmpl $0x0, -0x88(%rbp)
jl 0x174be
cmpl $0x0, -0x80(%rbp)
jl 0x174be
cmpl $0x0, -0x84(%rbp)
je 0x174be
cmpq $0x0, -0x98(%rbp)
jge 0x174c3
jmp 0x172cd
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x88(%rbp), %ecx
shll %ecx
movl -0x84(%rbp), %edi
movl $0x1, %edx
xorl %esi, %esi
cmpl $0x0, %edi
cmovgl %esi, %edx
orl %edx, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl (%rax), %eax
movq -0x60(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jb 0x17554
movq -0x60(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x60(%rbp), %rax
movl 0x4(%rax), %ecx
shrl %ecx
addl $0x10, %ecx
movq -0x60(%rbp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x60(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %edx
shlq $0x3, %rdx
xorl %eax, %eax
movl %eax, %edi
callq 0xb100
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x17556
cmpl $0x0, -0x84(%rbp)
jge 0x17587
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x88(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
subq -0x98(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
jle 0x175fd
movq -0x98(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x88(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jge 0x175fd
movq -0x98(%rbp), %rdx
shlq $0x8, %rdx
movl -0x8c(%rbp), %eax
addl $0x40, %eax
shll %eax
cltq
orq %rax, %rdx
movslq -0x80(%rbp), %rax
orq %rax, %rdx
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x60(%rbp), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x172cd
movq -0x48(%rbp), %rdi
callq 0x15530
movq -0x28(%rbp), %rdi
callq 0x2030
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x17688
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
cmpl $0x0, (%rax)
jbe 0x1767b
movq -0xa8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0xa8(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0xa8(%rbp), %rax
movl (%rax), %eax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x46c0
jmp 0x1767d
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1761b
leaq 0xf049(%rip), %rax      # 0x266d8
cmpl $0x3, (%rax)
jl 0x176b7
movq 0xe95d(%rip), %rax      # 0x25ff8
movq (%rax), %rdi
movq -0x58(%rbp), %rcx
leaq 0xa3d6(%rip), %rsi      # 0x21a7f
leaq 0xa3ef(%rip), %rdx      # 0x21a9f
movb $0x0, %al
callq 0x21f0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)