// File: /workspace/github_c_makefile_star2_O1/lh3[P]miniprot/ntseq.c
// Function: mp_ntseq_read
mp_ntdb_t *mp_ntseq_read(const char *fn)
{
	gzFile fp;
	kseq_t *ks;
	mp_ntdb_t *d = 0;
	int64_t off = 0;

	fp = gzopen(fn, "r");
	if (fp == 0) return 0;
	ks = kseq_init(fp);

	d = Kcalloc(0, mp_ntdb_t, 1);
	while (kseq_read(ks) >= 0) {
		int64_t i, ltmp;
		mp_ctg_t *c;

		// update mp_ntdb_t::ctg
		if (d->n_ctg == d->m_ctg) {
			d->m_ctg += (d->m_ctg>>1) + 16;
			d->ctg = Krealloc(0, mp_ctg_t, d->ctg, d->m_ctg);
		}
		c = &d->ctg[d->n_ctg++];
		c->name = mp_strdup(ks->name.s);
		c->off = off;
		c->len = ks->seq.l;

		// update mp_ntdb_t::seq
		ltmp = (d->l_seq + ks->seq.l + 1) >> 1 << 1;
		if (ltmp > d->m_seq) {
			int64_t oldm = d->m_seq;
			d->m_seq = ltmp;
			kroundup64(d->m_seq);
			d->seq = Krealloc(0, uint8_t, d->seq, d->m_seq >> 1);
			memset(&d->seq[oldm>>1], 0, (d->m_seq - oldm) >> 1);
		}
		for (i = 0; i < ks->seq.l; ++i, ++off) {
			uint8_t b = ns_tab_nt4[(uint8_t)ks->seq.s[i]];
			d->seq[off >> 1] |= b << (off&1) * 4;
		}
		d->l_seq += ks->seq.l;
	}

	kseq_destroy(ks);
	gzclose(fp);
	mp_ntseq_merge_name(d);
	if (mp_verbose >= 3)
		fprintf(stderr, "[M::%s@%.3f*%.2f] read %ld bases in %d contigs\n", __func__, mp_realtime(), mp_percent_cpu(), (long)d->l_seq, d->n_ctg);
	return d;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x638f(%rip), %rsi      # 0x123e0
callq 0x2260
testq %rax, %rax
je 0xc2b0
movq %rax, (%rsp)
movq %rax, %rdi
callq 0xbc55
movq %rax, %r15
movl $0x1, %esi
movl $0x48, %edx
xorl %edi, %edi
callq 0x7f34
movq %rax, %rbx
movq %r15, %rdi
callq 0xbcef
testq %rax, %rax
js 0xc1da
xorl %r12d, %r12d
leaq 0xc363(%rip), %r13      # 0x18400
movl 0x4(%rbx), %eax
cmpl %eax, (%rbx)
jne 0xc0c9
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x10, %eax
movl %eax, 0x4(%rbx)
movq 0x28(%rbx), %rsi
cltq
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdx
xorl %edi, %edi
callq 0x81a4
movq %rax, 0x28(%rbx)
movq 0x28(%rbx), %rbp
movslq (%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%rbx)
leaq (%rax,%rax,2), %r14
movq 0x10(%r15), %rdi
callq 0x495b
movq %rax, 0x10(%rbp,%r14,8)
movq %r12, (%rbp,%r14,8)
movq 0x30(%r15), %rax
movq %rax, 0x8(%rbp,%r14,8)
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %rbp
addq %rcx, %rax
incq %rax
andq $-0x2, %rax
cmpq %rbp, %rax
jle 0xc17d
decq %rax
movq %rax, %rcx
sarq %rcx
orq %rax, %rcx
movq %rcx, %rax
sarq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
sarq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
sarq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
sarq $0x10, %rcx
orq %rax, %rcx
movq %rcx, %rdx
sarq $0x20, %rdx
orq %rcx, %rdx
incq %rdx
movq %rdx, 0x18(%rbx)
movq 0x20(%rbx), %rsi
sarq %rdx
xorl %edi, %edi
callq 0x81a4
movq %rax, 0x20(%rbx)
movq %rbp, %rdi
sarq %rdi
addq %rax, %rdi
movq 0x18(%rbx), %rdx
subq %rbp, %rdx
sarq %rdx
xorl %esi, %esi
callq 0x2160
movq 0x30(%r15), %rcx
testq %rcx, %rcx
je 0xc1c5
leal (,%r12,4), %eax
xorl %edx, %edx
leaq (%r12,%rdx), %rsi
movq 0x40(%r15), %rcx
movzbl (%rcx,%rdx), %ecx
movb (%r13,%rcx), %dil
movl %eax, %ecx
andb $0x4, %cl
shlb %cl, %dil
movq 0x20(%rbx), %rcx
sarq %rsi
orb %dil, (%rcx,%rsi)
incq %rdx
movq 0x30(%r15), %rcx
addb $0x4, %al
cmpq %rcx, %rdx
jb 0xc190
addq %rdx, %r12
addq %rcx, 0x10(%rbx)
movq %r15, %rdi
callq 0xbcef
testq %rax, %rax
jns 0xc09d
movq %r15, %rdi
callq 0xbcaf
movq (%rsp), %rdi
callq 0x2040
movl $0x0, 0x8(%rbx)
movslq (%rbx), %rax
testq %rax, %rax
jle 0xc229
movq 0x28(%rbx), %r14
shlq $0x3, %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x10(%r14,%r12), %rdi
callq 0x2100
addl %eax, %r13d
incl %r13d
movl %r13d, 0x8(%rbx)
addq $0x18, %r12
cmpq %r12, %r15
jne 0xc20c
movslq 0x8(%rbx), %rsi
xorl %edi, %edi
callq 0x80a1
movq %rax, 0x30(%rbx)
cmpl $0x0, (%rbx)
jle 0xc29a
movq %rax, %r14
movl $0x10, %r12d
xorl %r13d, %r13d
movq 0x28(%rbx), %rax
movq (%rax,%r12), %r15
movq %r15, %rdi
callq 0x2100
leaq 0x1(%rax), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x21e0
movq 0x28(%rbx), %rax
movq (%rax,%r12), %rdi
callq 0x2050
movq 0x28(%rbx), %rax
movq %r14, (%rax,%r12)
movq %r14, %rdi
callq 0x2100
addq %rax, %r14
incq %r14
incq %r13
movslq (%rbx), %rax
addq $0x18, %r12
cmpq %rax, %r13
jl 0xc249
leaq 0xc13f(%rip), %rax      # 0x183e0
cmpl $0x3, (%rax)
jl 0xc2b2
movq %rbx, %rdi
callq 0x2c98
jmp 0xc2b2
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq