// File: /workspace/github_c_makefile_star2_O0/lh3[P]miniprot/ntseq.c
// Function: mp_ntseq_spsc_get
int64_t mp_ntseq_spsc_get(const mp_ntdb_t *db, int32_t cid, int64_t st0, int64_t en0, int32_t rev, uint8_t *sc)
{
	int64_t st, en;
	const mp_spsc_t *s;
	if (cid >= db->n_ctg || cid < 0 || db->spsc == 0) return -1;
	if (en0 < 0 || en0 > db->ctg[cid].len) en0 = db->ctg[cid].len;
	if (!rev) st = st0, en = en0;
	else st = db->ctg[cid].len - en0, en = db->ctg[cid].len - st0;
	memset(sc, 0xff, en - st);
	s = &db->spsc[cid << 1 | (!!rev)];
	if (s->n > 0) {
		int32_t j, l, r;
		l = mp_ntseq_find_intv(s->n, s->a, st);
		r = mp_ntseq_find_intv(s->n, s->a, en);
		for (j = l + 1; j <= r; ++j) {
			int64_t x = (s->a[j]>>8) - st;
			uint8_t score = s->a[j] & 0xff;
			assert(x <= en - st);
			if (x == en - st) continue;
			if (sc[x] == 0xff || sc[x] < score) sc[x] = score;
		}
	}
	return en - st;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1689b
cmpl $0x0, -0x14(%rbp)
jl 0x1689b
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x168a8
movq $-0x1, -0x8(%rbp)
jmp 0x16aa6
cmpq $0x0, -0x28(%rbp)
jl 0x168cc
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x14(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jle 0x168e7
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x168ff
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x1693d
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
subq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
subq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rdx
subq -0x40(%rbp), %rdx
movl $0xff, %esi
callq 0x2190
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x14(%rbp), %ecx
shll %ecx
cmpl $0x0, -0x2c(%rbp)
setne %dl
xorb $-0x1, %dl
xorb $-0x1, %dl
andb $0x1, %dl
movzbl %dl, %edx
orl %edx, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x0, (%rax)
jbe 0x16a9a
movq -0x50(%rbp), %rax
movl (%rax), %edi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x40(%rbp), %rdx
callq 0x16ab0
movl %eax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movl (%rax), %edi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x48(%rbp), %rdx
callq 0x16ab0
movl %eax, -0x5c(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x16a98
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x8, %rax
subq -0x40(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rax
andq $0xff, %rax
movb %al, -0x69(%rbp)
movq -0x68(%rbp), %rax
movq -0x48(%rbp), %rcx
subq -0x40(%rbp), %rcx
cmpq %rcx, %rax
jg 0x16a21
jmp 0x16a40
leaq 0xafc6(%rip), %rdi      # 0x219ee
leaq 0xafcc(%rip), %rsi      # 0x219fb
movl $0x93, %edx
leaq 0xafc8(%rip), %rcx      # 0x21a03
callq 0x2180
movq -0x68(%rbp), %rax
movq -0x48(%rbp), %rcx
subq -0x40(%rbp), %rcx
cmpq %rcx, %rax
jne 0x16a53
jmp 0x16a8a
movq -0x38(%rbp), %rax
movq -0x68(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x16a7a
movq -0x38(%rbp), %rax
movq -0x68(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movzbl -0x69(%rbp), %ecx
cmpl %ecx, %eax
jge 0x16a88
movb -0x69(%rbp), %dl
movq -0x38(%rbp), %rax
movq -0x68(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x16a8a
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x169cd
jmp 0x16a9a
movq -0x48(%rbp), %rax
subq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq