// File: /workspace/github_c_makefile_star2_O2/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 0x68e3(%rip), %rsi      # 0x113e0
callq 0x2280
testq %rax, %rax
je 0xad6b
movq %rax, (%rsp)
movq %rax, %rdi
callq 0xa814
movq %rax, %r15
xorl %r13d, %r13d
pushq $0x1
popq %rsi
pushq $0x48
popq %rdx
xorl %edi, %edi
callq 0x72e4
movq %rax, %rbx
movq %r15, %rdi
callq 0xa880
testq %rax, %rax
js 0xac68
movl (%rbx), %eax
movq 0x28(%rbx), %r12
cmpl 0x4(%rbx), %eax
jne 0xab6e
movl %eax, %ecx
sarl %ecx
addl %ecx, %eax
addl $0x10, %eax
movl %eax, 0x4(%rbx)
cltq
imulq $0x18, %rax, %rdx
xorl %edi, %edi
movq %r12, %rsi
callq 0x7568
movq %rax, %r12
movq %rax, 0x28(%rbx)
movl (%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%rbx)
cltq
imulq $0x18, %rax, %rbp
movq 0x10(%r15), %rdi
callq 0x3cd8
movq %rax, 0x10(%r12,%rbp)
movq %r13, (%r12,%rbp)
movq 0x30(%r15), %r14
movq %r14, 0x8(%r12,%rbp)
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %r12
addq %r14, %rax
incq %rax
andq $-0x2, %rax
cmpq %r12, %rax
jle 0xac1c
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 0x7568
movq %rax, 0x20(%rbx)
movq %r12, %rdi
sarq %rdi
addq %rax, %rdi
movq 0x18(%rbx), %rdx
subq %r12, %rdx
sarq %rdx
xorl %esi, %esi
callq 0x2160
leal (,%r13,4), %eax
xorl %edx, %edx
leaq 0xd7e3(%rip), %r8       # 0x18410
leaq (%rdx,%r13), %rsi
cmpq %r14, %rdx
jae 0xac5c
movq 0x40(%r15), %rcx
movzbl (%rcx,%rdx), %ecx
movb (%r8,%rcx), %dil
movl %eax, %ecx
andb $0x4, %cl
shlb %cl, %dil
movq 0x20(%rbx), %rcx
sarq %rsi
orb %dil, (%rcx,%rsi)
incq %rdx
addb $0x4, %al
jmp 0xac2d
addq %r14, 0x10(%rbx)
movq %rsi, %r13
jmp 0xab2d
movq %r15, %rdi
callq 0xa840
movq (%rsp), %rdi
callq 0x2040
andl $0x0, 0x8(%rbx)
movl (%rbx), %eax
xorl %r14d, %r14d
testl %eax, %eax
cmovlel %r14d, %eax
imulq $0x18, %rax, %r15
xorl %r12d, %r12d
cmpq %r14, %r15
je 0xacb2
movq 0x28(%rbx), %rax
movq 0x10(%rax,%r14), %rdi
callq 0x2100
addl %eax, %r12d
incl %r12d
movl %r12d, 0x8(%rbx)
addq $0x18, %r14
jmp 0xac8f
movslq %r12d, %rsi
xorl %r12d, %r12d
xorl %edi, %edi
callq 0x7460
movq %rax, %r14
movq %rax, 0x30(%rbx)
pushq $0x10
popq %r13
movslq (%rbx), %rax
cmpq %rax, %r12
jge 0xad1d
movq 0x28(%rbx), %rax
movq (%rax,%r13), %r15
movq %r15, %rdi
callq 0x2100
leaq 0x1(%rax), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x21f0
movq 0x28(%rbx), %rax
movq (%rax,%r13), %rdi
callq 0x2050
movq 0x28(%rbx), %rax
movq %r14, (%rax,%r13)
movq %r14, %rdi
callq 0x2100
addq %rax, %r14
incq %r14
incq %r12
addq $0x18, %r13
jmp 0xacca
leaq 0xd6cc(%rip), %rax      # 0x183f0
cmpl $0x3, (%rax)
jl 0xad6d
movq 0xd2c0(%rip), %rax      # 0x17ff0
movq (%rax), %r14
callq 0x3801
movsd %xmm0, (%rsp)
callq 0x3852
movaps %xmm0, %xmm1
movq 0x10(%rbx), %rcx
movl (%rbx), %r8d
leaq 0x8061(%rip), %rsi      # 0x12db4
leaq 0x808a(%rip), %rdx      # 0x12de4
movq %r14, %rdi
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x21e0
jmp 0xad6d
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq