// File: /workspace/github_c_makefile_star2_O2/lh3[P]minimap2/index.c
// Function: mm_idx_spsc_read2
int32_t mm_idx_spsc_read2(mm_idx_t *idx, const char *fn, int32_t max_sc, float scale)
{
	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 (idx->h == 0) mm_idx_index_name(idx);
	if (max_sc > 63) max_sc = 63;
	idx->spsc = Kcalloc(0, mm_idx_spsc_t, idx->n_seq * 2);
	ks = ks_init(fp);
	while (ks_getuntil(ks, KS_SEP_LINE, &str, &dret) >= 0) {
		mm_idx_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 (scale > 0.0f && scale < 1.0f)
			score = score > 0.0f? (int)(score * scale + .499) : (int)(score * scale - .499);
		if (score > max_sc) score = max_sc;
		if (score < -max_sc) score = -max_sc;
		cid = mm_idx_name2id(idx, name);
		if (cid < 0 || type < 0 || strand == 0 || pos < 0) continue; // FIXME: give a warning!
		s = &idx->spsc[cid << 1 | (strand > 0? 0 : 1)];
		Kgrow(0, uint64_t, s->a, s->n, s->m);
		if (pos > 0 && pos < idx->seq[cid].len) { // ignore scores at the ends
			s->a[s->n++] = (uint64_t)pos << 8 | (score + KSW_SPSC_OFFSET) << 1 | type;
			++n_read;
		}
	}
	ks_destroy(ks);
	gzclose(fp);
	for (j = 0; j < idx->n_seq * 2; ++j) {
		mm_idx_spsc_t *s = &idx->spsc[j];
		if (s->n > 0)
			radix_sort_64(s->a, s->a + s->n);
	}
	if (mm_verbose >= 3)
		fprintf(stderr, "[M::%s] read %ld splice scores\n", __func__, (long)n_read);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movaps %xmm0, 0x40(%rsp)
movl %edx, %ebp
movq %rdi, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
testq %rsi, %rsi
je 0x8f09
cmpb $0x2d, (%rsi)
jne 0x8ef5
cmpb $0x0, 0x1(%rsi)
je 0x8f09
leaq 0x1f434(%rip), %rax     # 0x28330
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2350
jmp 0x8f17
leaq 0x1f420(%rip), %rsi     # 0x28330
xorl %edi, %edi
callq 0x20f0
movq %rax, %r14
testq %rax, %rax
je 0x922f
movq 0x8(%rsp), %rbx
cmpq $0x0, 0x58(%rbx)
jne 0x8f37
movq %rbx, %rdi
callq 0x5daa
cmpl $0x3f, %ebp
pushq $0x3f
popq %r15
cmovll %ebp, %r15d
movl 0x10(%rbx), %esi
addl %esi, %esi
pushq $0x10
popq %rdx
xorl %edi, %edi
callq 0x10980
movq %rax, 0x40(%rbx)
movq %r14, 0x28(%rsp)
movq %r14, %rdi
callq 0x10df8
movq %rax, 0x20(%rsp)
movss 0x1ec81(%rip), %xmm0    # 0x27bf0
movaps 0x40(%rsp), %xmm2
movaps %xmm2, %xmm1
cmpltps %xmm0, %xmm1
xorps %xmm0, %xmm0
cmpltps %xmm2, %xmm0
andps %xmm1, %xmm0
movss %xmm0, 0x4(%rsp)
movl %r15d, 0x14(%rsp)
negl %r15d
movl %r15d, 0x10(%rsp)
leaq 0x1f191(%rip), %r12     # 0x28130
movq $0x0, 0x18(%rsp)
movq %rbx, %rbp
movq 0x20(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x3c(%rsp), %rdx
callq 0x7927
testl %eax, %eax
js 0x91b2
movq 0x60(%rsp), %rdi
leaq 0x1(%rdi), %r13
xorl %r14d, %r14d
xorl %r15d, %r15d
pushq $-0x1
popq %rbx
movl $0x0, (%rsp)
pushq $-0x1
popq %rdx
movzbl -0x1(%r13), %ebp
cmpl $0x9, %ebp
je 0x8ff1
testl %ebp, %ebp
jne 0x904d
movb $0x0, -0x1(%r13)
cmpl $0x4, %r15d
ja 0x9042
movl %r15d, %eax
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq %rdi, %r14
jmp 0x9042
xorl %eax, %eax
cmpb $0x2b, (%rdi)
sete %al
leal -0x1(,%rax,2), %eax
movl %eax, (%rsp)
jmp 0x9042
movb (%rdi), %al
xorl %ecx, %ecx
cmpb $0x41, %al
sete %cl
cmpb $0x44, %al
leal -0x1(%rcx,%rcx), %ebx
movl $0x0, %eax
cmovel %eax, %ebx
jmp 0x9042
callq 0x2360
movq %rax, %rdx
testb %bpl, %bpl
je 0x9052
incl %r15d
movq %r13, %rdi
incq %r13
jmp 0x8fe3
cmpl $0x4, %r15d
movq 0x8(%rsp), %rbp
jl 0x8fab
movq %rdx, %r13
movss 0x1f0d8(%rip), %xmm0    # 0x28144
movsd 0x1f04c(%rip), %xmm1    # 0x280c0
pushq $-0x1
popq %rax
testb $0x1, 0x4(%rsp)
jne 0x90b5
jmp 0x90c7
movq %rdx, %r13
callq 0x23c0
testb $0x1, 0x4(%rsp)
je 0x90a6
cvtsi2ss %eax, %xmm0
testl %eax, %eax
movq 0x8(%rsp), %rbp
jle 0x90ad
movsd 0x1cf74(%rip), %xmm1    # 0x26018
jmp 0x90b5
movq 0x8(%rsp), %rbp
jmp 0x90c7
movsd 0x1f00b(%rip), %xmm1    # 0x280c0
mulss 0x40(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movq %rax, 0x30(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x6048
testl %eax, %eax
js 0x8fab
testl %ebx, %ebx
js 0x8fab
cmpl $0x0, (%rsp)
je 0x8fab
movq %r13, %rsi
testq %r13, %r13
js 0x8fab
movl %eax, %r14d
movq 0x40(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, (%rsp)
setle %al
leal (%rax,%r14,2), %eax
movslq %eax, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r15
movl (%rcx,%rdx), %eax
cmpl 0x4(%rcx,%rdx), %eax
jb 0x914a
leal 0x1(%rax), %ecx
shrl %ecx
leal (%rax,%rcx), %edx
addl $0x11, %edx
movl %edx, 0x4(%r15)
movq 0x8(%r15), %rsi
shlq $0x3, %rdx
xorl %edi, %edi
callq 0x10c04
movq %r13, %rsi
movq %rax, 0x8(%r15)
testq %rsi, %rsi
je 0x8fab
movq 0x20(%rbp), %rax
movl %r14d, %ecx
imulq $0x18, %rcx, %rcx
movl 0x10(%rax,%rcx), %eax
cmpq %rax, %rsi
jae 0x8fab
movl 0x14(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl 0x10(%rsp), %eax
cmpl %eax, %ecx
cmovlel %eax, %ecx
shlq $0x8, %rsi
leal 0x80(,%rcx,2), %eax
cltq
movl %ebx, %ecx
orq %rsi, %rcx
orq %rax, %rcx
movq 0x8(%r15), %rax
movl (%r15), %edx
leal 0x1(%rdx), %esi
movl %esi, (%r15)
movq %rcx, (%rax,%rdx,8)
incq 0x18(%rsp)
jmp 0x8fab
movq 0x20(%rsp), %rdi
callq 0x10e31
movq 0x28(%rsp), %rdi
callq 0x2030
pushq $0x8
popq %rbx
xorl %r14d, %r14d
movl 0x10(%rbp), %eax
addl %eax, %eax
cmpq %rax, %r14
jae 0x91f9
movq 0x40(%rbp), %rax
movl -0x8(%rax,%rbx), %ecx
testq %rcx, %rcx
je 0x91f0
movq (%rax,%rbx), %rdi
leaq (%rdi,%rcx,8), %rsi
callq 0x49de
incq %r14
addq $0x10, %rbx
jmp 0x91cc
leaq 0x29500(%rip), %rax     # 0x32700
xorl %ebx, %ebx
cmpl $0x3, (%rax)
jl 0x9232
movq 0x28dea(%rip), %rax     # 0x31ff8
movq (%rax), %rdi
leaq 0x1f310(%rip), %rsi     # 0x28528
leaq 0x1f329(%rip), %rdx     # 0x28548
xorl %ebx, %ebx
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x2260
jmp 0x9232
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq