// File: /workspace/github_c_makefile_star2_O3/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 $0x78, %rsp
movaps %xmm0, 0x60(%rsp)
movl %edx, %r14d
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
testq %rsi, %rsi
je 0xa09a
cmpb $0x2d, (%rsi)
jne 0xa086
cmpb $0x0, 0x1(%rsi)
je 0xa09a
leaq 0x232a3(%rip), %rax     # 0x2d330
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2350
jmp 0xa0a8
leaq 0x2328f(%rip), %rsi     # 0x2d330
xorl %edi, %edi
callq 0x20f0
movq %rax, %r15
testq %rax, %rax
je 0xa418
cmpq $0x0, 0x58(%rbx)
jne 0xa0c3
movq %rbx, %rdi
callq 0x6dec
cmpl $0x3f, %r14d
movl $0x3f, %eax
cmovll %r14d, %eax
movl %eax, 0x8(%rsp)
movl 0x10(%rbx), %esi
addl %esi, %esi
movl $0x10, %edx
xorl %edi, %edi
callq 0x124ec
movq %rbx, 0x10(%rsp)
movq %rax, 0x40(%rbx)
movq %r15, 0x38(%rsp)
movq %r15, %rdi
callq 0x12908
leaq 0x40(%rsp), %rdx
leaq 0x2c(%rsp), %rcx
movq %rax, 0x30(%rsp)
movq %rax, %rdi
movl $0x2, %esi
xorl %r8d, %r8d
callq 0x12961
movl $0x0, %ecx
movq %rcx, 0x18(%rsp)
testl %eax, %eax
js 0xa389
movss 0x22abc(%rip), %xmm0    # 0x2cbf0
movaps 0x60(%rsp), %xmm2
movaps %xmm2, %xmm1
cmpltps %xmm0, %xmm1
xorps %xmm0, %xmm0
cmpltps %xmm2, %xmm0
andps %xmm1, %xmm0
movss %xmm0, 0x4(%rsp)
movl 0x8(%rsp), %eax
negl %eax
movl %eax, 0x28(%rsp)
leaq 0x22fcf(%rip), %rbp     # 0x2d130
movq $0x0, 0x18(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x1(%rdi), %r13
movq $-0x1, %rdx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r12d, %r12d
xorl %r14d, %r14d
movl $0x0, 0xc(%rsp)
movzbl -0x1(%r13), %r15d
cmpl $0x9, %r15d
je 0xa19d
testl %r15d, %r15d
jne 0xa1fb
movb $0x0, -0x1(%r13)
cmpl $0x4, %r14d
ja 0xa1f0
movl %r14d, %eax
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq %rdi, %r12
jmp 0xa1f0
xorl %eax, %eax
cmpb $0x2b, (%rdi)
sete %al
leal -0x1(,%rax,2), %eax
movl %eax, 0xc(%rsp)
jmp 0xa1f0
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 0xa1f0
callq 0x2360
movq %rax, %rdx
testb %r15b, %r15b
je 0xa200
incl %r14d
movq %r13, %rdi
incq %r13
jmp 0xa18d
cmpl $0x4, %r14d
jl 0xa365
movq %rdx, 0x20(%rsp)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movss 0x22f27(%rip), %xmm0    # 0x2d144
movsd 0x22e9b(%rip), %xmm1    # 0x2d0c0
testb $0x1, 0x4(%rsp)
movq %r12, %rsi
jne 0xa26c
jmp 0xa27f
movq %rdx, 0x20(%rsp)
callq 0x23c0
movl %eax, %r13d
testb $0x1, 0x4(%rsp)
je 0xa25f
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
testl %r13d, %r13d
movq %r12, %rsi
jle 0xa264
movsd 0x20dc3(%rip), %xmm1    # 0x2b020
jmp 0xa26c
movq %r12, %rsi
jmp 0xa27f
movsd 0x22e54(%rip), %xmm1    # 0x2d0c0
mulss 0x60(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r13d
movl 0x8(%rsp), %eax
cmpl %eax, %r13d
cmovgel %eax, %r13d
movl 0x28(%rsp), %eax
cmpl %eax, %r13d
cmovlel %eax, %r13d
movq 0x10(%rsp), %rdi
callq 0x70b7
testl %eax, %eax
js 0xa365
testl %ebx, %ebx
js 0xa365
movl 0xc(%rsp), %edx
testl %edx, %edx
je 0xa365
movq 0x20(%rsp), %rsi
testq %rsi, %rsi
js 0xa365
movl %eax, %r15d
movq 0x10(%rsp), %rax
movq 0x40(%rax), %rcx
xorl %eax, %eax
testl %edx, %edx
setle %al
leal (%rax,%r15,2), %eax
movslq %eax, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r14
movl (%rcx,%rdx), %eax
cmpl 0x4(%rcx,%rdx), %eax
jb 0xa31b
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 0x12755
movq 0x20(%rsp), %rsi
movq %rax, 0x8(%r14)
testq %rsi, %rsi
je 0xa365
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movl %r15d, %ecx
leaq (%rcx,%rcx,2), %rcx
movl 0x10(%rax,%rcx,8), %eax
cmpq %rax, %rsi
jae 0xa365
shlq $0x8, %rsi
leal 0x80(,%r13,2), %eax
cltq
movl %ebx, %ecx
orq %rsi, %rcx
orq %rax, %rcx
movq 0x8(%r14), %rax
movl (%r14), %edx
leal 0x1(%rdx), %esi
movl %esi, (%r14)
movq %rcx, (%rax,%rdx,8)
incq 0x18(%rsp)
movq 0x30(%rsp), %rdi
movl $0x2, %esi
leaq 0x40(%rsp), %rdx
leaq 0x2c(%rsp), %rcx
xorl %r8d, %r8d
callq 0x12961
testl %eax, %eax
jns 0xa16a
movq 0x30(%rsp), %rdi
callq 0x12945
movq 0x38(%rsp), %rdi
callq 0x2030
movq 0x10(%rsp), %r15
movl 0x10(%r15), %eax
testl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
je 0xa3e2
movl $0x8, %ebx
xorl %r14d, %r14d
movq 0x40(%r15), %rcx
movl -0x8(%rcx,%rbx), %edx
testq %rdx, %rdx
je 0xa3d3
movq (%rcx,%rbx), %rdi
leaq (%rdi,%rdx,8), %rsi
callq 0x5c97
movl 0x10(%r15), %eax
incq %r14
leal (%rax,%rax), %ecx
addq $0x10, %rbx
cmpq %rcx, %r14
jb 0xa3b5
leaq 0x2c317(%rip), %rax     # 0x36700
xorl %ebx, %ebx
cmpl $0x3, (%rax)
jl 0xa41d
movq 0x2bc01(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0x23127(%rip), %rsi     # 0x2d528
leaq 0x23140(%rip), %rdx     # 0x2d548
xorl %ebx, %ebx
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x2260
jmp 0xa41d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq