// File: /workspace/github_c_makefile_star2_O3/lh3[P]minimap2/bseq.c
// Function: mm_bseq_read3
mm_bseq1_t *mm_bseq_read3(mm_bseq_file_t *fp, int64_t chunk_size, int with_qual, int with_comment, int frag_mode, int *n_)
{
	int64_t size = 0;
	int ret;
	kvec_t(mm_bseq1_t) a = {0,0,0};
	kseq_t *ks = fp->ks;
	*n_ = 0;
	if (fp->s.seq) {
		kv_resize(mm_bseq1_t, 0, a, 256);
		kv_push(mm_bseq1_t, 0, a, fp->s);
		size = fp->s.l_seq;
		memset(&fp->s, 0, sizeof(mm_bseq1_t));
	}
	while ((ret = kseq_read(ks)) >= 0) {
		mm_bseq1_t *s;
		assert(ks->seq.l <= INT32_MAX);
		if (a.m == 0) kv_resize(mm_bseq1_t, 0, a, 256);
		kv_pushp(mm_bseq1_t, 0, a, &s);
		kseq2bseq(ks, s, with_qual, with_comment);
		size += s->l_seq;
		if (size >= chunk_size) {
			if (frag_mode && a.a[a.n-1].l_seq < CHECK_PAIR_THRES) {
				while ((ret = kseq_read(ks)) >= 0) {
					kseq2bseq(ks, &fp->s, with_qual, with_comment);
					if (mm_qname_same(fp->s.name, a.a[a.n-1].name)) {
						kv_push(mm_bseq1_t, 0, a, fp->s);
						memset(&fp->s, 0, sizeof(mm_bseq1_t));
					} else break;
				}
			}
			break;
		}
	}
	if (ret < -1) {
		if (a.n) fprintf(stderr, "[WARNING]\033[1;31m failed to parse the FASTA/FASTQ record next to '%s'. Continue anyway.\033[0m\n", a.a[a.n-1].name);
		else fprintf(stderr, "[WARNING]\033[1;31m failed to parse the first FASTA/FASTQ record. Continue anyway.\033[0m\n");
	}
	*n_ = a.n;
	return a.a;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, 0x34(%rsp)
movl %ecx, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
movq %rsi, 0x48(%rsp)
movq 0x8(%rdi), %rcx
movq %r9, 0x10(%rsp)
movl $0x0, (%r9)
leaq 0x10(%rdi), %rbx
movq %rdi, 0x40(%rsp)
cmpq $0x0, 0x20(%rdi)
movq %rcx, 0x18(%rsp)
movq %rbx, 0x38(%rsp)
je 0x1311b
movl $0x2800, %edx           # imm = 0x2800
xorl %edi, %edi
xorl %esi, %esi
callq 0x12755
movq 0x18(%rsp), %rcx
movq %rax, %r14
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0x10(%rax)
movq 0x20(%rbx), %rax
movq %rax, 0x20(%r14)
movups %xmm0, (%r14)
movslq (%rbx), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movq $0x0, 0x20(%rbx)
movl $0x100, %eax            # imm = 0x100
movq %rax, 0x20(%rsp)
movl $0x1, %ebp
jmp 0x1312c
xorl %ebp, %ebp
movq $0x0, 0x20(%rsp)
xorl %r14d, %r14d
xorl %r13d, %r13d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leal (,%rbp,8), %eax
leaq (%rax,%rax,4), %rax
movq %rax, 0x8(%rsp)
leal (,%rbp,2), %r12d
movl %ebp, %eax
shll $0x4, %eax
leaq (%rax,%rax,4), %rbx
leaq -0x7fffffff(%rdx), %rax
movq %rax, 0x50(%rsp)
movq %rbp, %r15
movq %r14, %rbp
movq %rcx, %rdi
movq %rcx, %r14
callq 0x12ca6
testl %eax, %eax
js 0x1338c
movq 0x50(%rsp), %rax
cmpq %rax, 0x30(%r14)
jae 0x133e8
movq %r14, %rdi
movq 0x20(%rsp), %rax
testq %rax, %rax
movq %rbp, %r14
jne 0x131b2
movl $0x2800, %edx           # imm = 0x2800
xorl %edi, %edi
movq %r14, %rsi
callq 0x12755
movq 0x18(%rsp), %rdi
movq %rax, %r14
movl $0x100, %eax            # imm = 0x100
movq %r15, %rbp
cmpq %rax, %r15
jne 0x131d6
xorl %edi, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x12755
movq 0x18(%rsp), %rdi
movq %rax, %r14
movq %r12, 0x20(%rsp)
jmp 0x131db
movq %rax, 0x20(%rsp)
incq %rbp
movq 0x8(%rsp), %r15
leaq (%r14,%r15), %rsi
movl 0x2c(%rsp), %edx
movl 0x30(%rsp), %ecx
callq 0x13407
movq 0x18(%rsp), %rcx
movslq (%r14,%r15), %rax
addq %rax, %r13
addq $0x28, %r15
movq %r15, 0x8(%rsp)
addq $0x2, %r12
addq $0x50, %rbx
cmpq 0x48(%rsp), %r13
jl 0x1315e
cmpl $0x0, 0x34(%rsp)
je 0x13397
cmpl $0xf423f, %eax          # imm = 0xF423F
jg 0x13397
movq %rcx, %rdi
callq 0x12ca6
testl %eax, %eax
js 0x13392
movq 0x18(%rsp), %rbx
movq 0x38(%rsp), %r15
movq 0x8(%rsp), %r12
movq %rbx, %rdi
movq %r15, %rsi
movl 0x2c(%rsp), %edx
movl 0x30(%rsp), %ecx
callq 0x13407
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rbx
movq %r12, %r13
movq -0x20(%r14,%r12), %rax
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x2130
cmpl $0x3, %eax
jl 0x132a6
movl %eax, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
addl %edx, %ecx
movb (%rbx,%rcx), %cl
addb $-0x30, %cl
cmpb $0x9, %cl
ja 0x132a6
leal -0x2(%rax), %r12d
cmpb $0x2f, (%rbx,%r12)
je 0x132a9
movl %eax, %r12d
movq 0x8(%rsp), %rdi
callq 0x2130
cmpl $0x3, %eax
jl 0x132df
movl %eax, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
addl %edx, %ecx
movq 0x8(%rsp), %rdx
movb (%rdx,%rcx), %cl
addb $-0x30, %cl
cmpb $0x9, %cl
ja 0x132df
leal -0x2(%rax), %ecx
movq 0x8(%rsp), %rdx
cmpb $0x2f, (%rdx,%rcx)
je 0x132e1
movl %eax, %ecx
cmpl %ecx, %r12d
jne 0x13397
movslq %r12d, %rdx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x2080
testl %eax, %eax
jne 0x13397
movq 0x20(%rsp), %rax
cmpq %rax, %rbp
jne 0x1333a
leaq (%rax,%rax), %rbx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,4), %rdx
xorl %edi, %edi
movq %r14, %rsi
callq 0x12755
movq %rax, %r14
movq %rbx, 0x20(%rsp)
movq 0x18(%rsp), %rbx
movq %r13, %r12
incq %rbp
movq 0x20(%r15), %rax
movq %rax, 0x20(%r14,%r13)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm1, 0x10(%r14,%r13)
movups %xmm0, (%r14,%r13)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movups %xmm0, 0x10(%r15)
movq $0x0, 0x20(%r15)
movq %rbx, %rdi
callq 0x12ca6
addq $0x28, %r12
testl %eax, %eax
jns 0x13251
jmp 0x13392
movq %rbp, %r14
movq %r15, %rbp
cmpl $-0x1, %eax
jne 0x133b0
movq 0x10(%rsp), %rax
movl %ebp, (%rax)
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x22c41(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
testq %rbp, %rbp
jne 0x133c8
callq 0x3213
xorl %ebp, %ebp
jmp 0x13397
leaq (,%rbp,4), %rax
addq %rbp, %rax
movq -0x20(%r14,%rax,8), %rdx
leaq 0x1ae17(%rip), %rsi     # 0x2e1f6
xorl %eax, %eax
callq 0x2260
jmp 0x13397
leaq 0x1ad9e(%rip), %rdi     # 0x2e18d
leaq 0x1adae(%rip), %rsi     # 0x2e1a4
leaq 0x1adae(%rip), %rcx     # 0x2e1ab
movl $0x5f, %edx
callq 0x21a0