// File: /workspace/github_c_makefile_star2_O1/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 $0x88, %rsp
movapd %xmm0, 0x70(%rsp)
movl %edx, %ebp
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
testq %rsi, %rsi
je 0xa12a
movq %rsi, %r14
leaq 0x2267d(%rip), %rsi     # 0x2c78a
movq %r14, %rdi
callq 0x2240
testl %eax, %eax
je 0xa12a
leaq 0x221ec(%rip), %rsi     # 0x2c30c
movq %r14, %rdi
callq 0x2350
jmp 0xa138
leaq 0x221db(%rip), %rsi     # 0x2c30c
xorl %edi, %edi
callq 0x20f0
movq %rax, %r14
testq %rax, %rax
je 0xa4bb
cmpq $0x0, 0x58(%rbx)
jne 0xa153
movq %rbx, %rdi
callq 0x6e63
cmpl $0x3f, %ebp
movl $0x3f, %eax
cmovll %ebp, %eax
movl %eax, 0x4(%rsp)
movl 0x10(%rbx), %esi
addl %esi, %esi
movl $0x10, %edx
xorl %edi, %edi
callq 0x1257c
movq %rbx, 0x8(%rsp)
movq %rax, 0x40(%rbx)
movq %r14, 0x48(%rsp)
movq %r14, %rdi
callq 0x129a4
leaq 0x50(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
movq %rax, 0x40(%rsp)
movq %rax, %rdi
movl $0x2, %esi
xorl %r8d, %r8d
callq 0x12a05
movl $0x0, %ecx
movq %rcx, 0x10(%rsp)
testl %eax, %eax
js 0xa42e
movss 0x21a0e(%rip), %xmm0    # 0x2bbd0
movaps 0x70(%rsp), %xmm2
movaps %xmm2, %xmm1
cmpltps %xmm0, %xmm1
xorps %xmm0, %xmm0
cmpltps %xmm2, %xmm0
andps %xmm1, %xmm0
movss %xmm0, 0x38(%rsp)
movl 0x4(%rsp), %eax
negl %eax
movl %eax, 0x34(%rsp)
leaq 0x21f21(%rip), %rbx     # 0x2c110
movq $0x0, 0x10(%rsp)
movq 0x60(%rsp), %rbp
leaq 0x1(%rbp), %r13
movq $-0x1, 0x28(%rsp)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq $0x0, 0x18(%rsp)
xorl %r15d, %r15d
movl $0x0, (%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x20(%rsp)
movzbl -0x1(%r13), %r14d
cmpl $0x9, %r14d
je 0xa241
testl %r14d, %r14d
jne 0xa2c7
movb $0x0, -0x1(%r13)
cmpl $0x4, %r15d
ja 0xa2b2
movl %r15d, %eax
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
movq %rbp, 0x18(%rsp)
jmp 0xa2b2
movq %rbp, %rdi
callq 0x23c0
movq %rax, 0x20(%rsp)
movl $0x4, %r15d
jmp 0xa2c1
xorl %eax, %eax
cmpb $0x2b, (%rbp)
sete %al
leal -0x1(,%rax,2), %eax
movl %eax, (%rsp)
jmp 0xa2b2
movb (%rbp), %al
xorl %ecx, %ecx
cmpb $0x41, %al
sete %cl
cmpb $0x44, %al
leal -0x1(%rcx,%rcx), %r12d
movl $0x0, %eax
cmovel %eax, %r12d
jmp 0xa2b2
movq %rbp, %rdi
callq 0x2360
movq %rax, 0x28(%rsp)
testb %r14b, %r14b
je 0xa2c1
incl %r15d
movb $0x1, %al
movq %r13, %rbp
jmp 0xa2c3
xorl %eax, %eax
testb %al, %al
je 0xa2cf
incq %r13
jmp 0xa22d
cmpl $0x4, %r15d
jge 0xa2fe
movq 0x40(%rsp), %rdi
movl $0x2, %esi
leaq 0x50(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
xorl %r8d, %r8d
callq 0x12a05
testl %eax, %eax
jns 0xa1f8
jmp 0xa42e
testb $0x1, 0x38(%rsp)
je 0xa339
xorl %eax, %eax
movq 0x20(%rsp), %rcx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
testl %ecx, %ecx
setg %al
mulss 0x70(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x21da7(%rip), %rcx     # 0x2c0d0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %ebp
movq 0x28(%rsp), %r15
jmp 0xa343
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %rbp
movq 0x18(%rsp), %rsi
movl 0x4(%rsp), %eax
cmpl %eax, %ebp
cmovgel %eax, %ebp
movl 0x34(%rsp), %eax
cmpl %eax, %ebp
cmovlel %eax, %ebp
movq 0x8(%rsp), %rdi
callq 0x7108
testl %eax, %eax
js 0xa2d5
testl %r12d, %r12d
js 0xa2d5
cmpl $0x0, (%rsp)
je 0xa2d5
testq %r15, %r15
js 0xa2d5
movl %eax, %r13d
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rcx
xorl %eax, %eax
cmpl $0x0, (%rsp)
setle %al
leal (%rax,%r13,2), %eax
movslq %eax, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r14
movl (%rcx,%rdx), %eax
cmpl 0x4(%rcx,%rdx), %eax
jb 0xa3d7
leal 0x1(%rax), %ecx
shrl %ecx
leal (%rax,%rcx), %edx
addl $0x11, %edx
movl %edx, 0x4(%r14)
movq 0x8(%r14), %rsi
shlq $0x3, %rdx
xorl %edi, %edi
callq 0x127ec
movq %rax, 0x8(%r14)
testq %r15, %r15
jle 0xa2d5
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %r13d, %ecx
leaq (%rcx,%rcx,2), %rcx
movl 0x10(%rax,%rcx,8), %eax
cmpq %rax, %r15
jge 0xa2d5
shlq $0x8, %r15
leal 0x80(,%rbp,2), %eax
cltq
movl %r12d, %ecx
orq %r15, %rcx
orq %rax, %rcx
movq 0x8(%r14), %rax
movl (%r14), %edx
leal 0x1(%rdx), %esi
movl %esi, (%r14)
movq %rcx, (%rax,%rdx,8)
incq 0x10(%rsp)
jmp 0xa2d5
movq 0x40(%rsp), %rdi
callq 0x129e9
movq 0x48(%rsp), %rdi
callq 0x2030
movq 0x8(%rsp), %r15
testl $0x7fffffff, 0x10(%r15) # imm = 0x7FFFFFFF
je 0xa485
movl $0x8, %ebx
xorl %r14d, %r14d
movq 0x40(%r15), %rax
movl -0x8(%rax,%rbx), %ecx
testq %rcx, %rcx
je 0xa473
movq (%rax,%rbx), %rdi
leaq (%rdi,%rcx,8), %rsi
callq 0x5d2f
incq %r14
movl 0x10(%r15), %eax
addl %eax, %eax
addq $0x10, %rbx
cmpq %rax, %r14
jb 0xa459
leaq 0x2b274(%rip), %rax     # 0x35700
xorl %ebx, %ebx
cmpl $0x3, (%rax)
jl 0xa4c0
movq 0x2ab5e(%rip), %rax     # 0x34ff8
movq (%rax), %rdi
leaq 0x22060(%rip), %rsi     # 0x2c504
leaq 0x22079(%rip), %rdx     # 0x2c524
xorl %ebx, %ebx
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x2260
jmp 0xa4c0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq