// File: /workspace/github_c_makefile_star2_O3/ToniWestbrook[P]paladin/bwa.c
// Function: bseq_read
bseq1_t *bseq_read(int chunk_size, int *n_, void *ks1_, void *ks2_)
{
	kseq_t *ks = (kseq_t*)ks1_, *ks2 = (kseq_t*)ks2_;
	int size = 0, m, n;
	bseq1_t *seqs;
	m = n = 0; seqs = 0;
	while (kseq_read(ks) >= 0) {
		if (ks2 && kseq_read(ks2) < 0) { // the 2nd file has fewer reads
			fprintf(stderr, "[W::%s] the 2nd file has fewer sequences.\n", __func__);
			break;
		}
		if (n >= m) {
			m = m? m<<1 : 256;
			seqs = realloc(seqs, m * sizeof(bseq1_t));
		}
		trim_readno(&ks->name);
		kseq2bseq1(ks, &seqs[n]);
		seqs[n].id = n;
		size += seqs[n++].l_seq;
		if (ks2) {
			trim_readno(&ks2->name);
			kseq2bseq1(ks2, &seqs[n]);
			seqs[n].id = n;
			size += seqs[n++].l_seq;
		}
		if (size >= chunk_size && (n&1) == 0) break;
	}
	if (size == 0) { // test if the 2nd file is finished
		if (ks2 && kseq_read(ks2) >= 0)
			fprintf(stderr, "[W::%s] the 1st file has fewer sequences.\n", __func__);
	}
	*n_ = n;
	return seqs;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x38(%rsp)
movl %edi, 0x2c(%rsp)
xorl %r13d, %r13d
xorl %r14d, %r14d
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, 0x30(%rsp)
movq %r12, %rdi
callq 0xd8a7
testl %eax, %eax
js 0x11eb5
testq %r15, %r15
je 0x11c10
movq %r15, %rdi
callq 0xd8a7
testl %eax, %eax
js 0x11eb0
cmpl %r14d, 0x10(%rsp)
movq %r13, 0x18(%rsp)
jl 0x11c5b
leal (%r14,%r14), %ebx
testl %r14d, %r14d
movl $0x100, %eax            # imm = 0x100
cmovel %eax, %ebx
movslq %ebx, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
movq 0x8(%rsp), %rdi
leaq 0x1692b(%rip), %rdx     # 0x2856d
movl $0x37, %ecx
leaq 0x16915(%rip), %r8      # 0x28563
callq 0x2324c
movq %rax, 0x8(%rsp)
movl %ebx, %r14d
movq (%r12), %rbx
movq 0x10(%r12), %rbp
cmpq $0x3, %rbx
movq %r14, 0x40(%rsp)
jb 0x11c9d
cmpb $0x2f, -0x2(%rbp,%rbx)
jne 0x11c9d
callq 0x3320
movq (%rax), %rax
movsbq -0x1(%rbp,%rbx), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x11c9d
addq $-0x2, %rbx
movq %rbx, (%r12)
movb $0x0, (%rbp,%rbx)
movq 0x10(%r12), %rbp
movslq 0x10(%rsp), %rax
leaq (%rax,%rax,2), %r15
shlq $0x4, %r15
movq %rbp, %rdi
leaq 0x168b9(%rip), %rbx     # 0x2856d
movq %rbx, %rsi
movl $0x23, %edx
leaq 0x16b0e(%rip), %r14     # 0x287d1
movq %r14, %rcx
callq 0x23285
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx,%r15)
cmpq $0x0, 0x18(%r12)
je 0x11cf4
movq 0x28(%r12), %rdi
movq %rbx, %rsi
movl $0x24, %edx
movq %r14, %rcx
callq 0x23285
jmp 0x11cf6
xorl %eax, %eax
movq 0x18(%rsp), %r13
addq 0x8(%rsp), %r15
movq %rax, 0x10(%r15)
movq 0x40(%r12), %rdi
movq %rbx, %rsi
movl $0x25, %edx
movq %r14, %rcx
callq 0x23285
movq %rax, 0x18(%r15)
cmpq $0x0, 0x48(%r12)
je 0x11d43
movq 0x58(%r12), %rdi
movq %rbx, %rsi
movl $0x26, %edx
movq %r14, %rcx
callq 0x23285
movq %rax, %rcx
movq 0x18(%r15), %rax
jmp 0x11d45
xorl %ecx, %ecx
movq %rcx, 0x20(%r15)
movq %rax, %rdi
callq 0x3100
movq 0x10(%rsp), %rcx
leal 0x1(%rcx), %ebx
addl %eax, %r13d
movl %eax, (%r15)
movl %ecx, 0x4(%r15)
movq 0x20(%rsp), %r15
testq %r15, %r15
je 0x11e89
movq %r13, 0x18(%rsp)
movq %r15, %rax
movq (%r15), %r15
movq 0x10(%rax), %rbp
cmpq $0x3, %r15
jb 0x11db9
cmpb $0x2f, -0x2(%rbp,%r15)
jne 0x11db9
callq 0x3320
movq (%rax), %rax
movsbq -0x1(%rbp,%r15), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x11db9
addq $-0x2, %r15
movq 0x20(%rsp), %rax
movq %r15, (%rax)
movb $0x0, (%rbp,%r15)
movq 0x10(%rax), %rbp
movslq %ebx, %rax
leaq (%rax,%rax,2), %r15
shlq $0x4, %r15
movq %rbp, %rdi
leaq 0x1679f(%rip), %rbp     # 0x2856d
movq %rbp, %rsi
movl $0x23, %edx
leaq 0x169f4(%rip), %r12     # 0x287d1
movq %r12, %rcx
callq 0x23285
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx,%r15)
movq 0x20(%rsp), %r14
cmpq $0x0, 0x18(%r14)
je 0x11e11
movq 0x28(%r14), %rdi
movq %rbp, %rsi
movl $0x24, %edx
movq %r12, %rcx
callq 0x23285
jmp 0x11e13
xorl %eax, %eax
movq 0x18(%rsp), %r13
addq 0x8(%rsp), %r15
movq %rax, 0x10(%r15)
movq 0x40(%r14), %rdi
movq %rbp, %rsi
movl $0x25, %edx
movq %r12, %rcx
callq 0x23285
movq %rax, 0x18(%r15)
cmpq $0x0, 0x48(%r14)
je 0x11e5d
movq 0x58(%r14), %rdi
movq %rbp, %rsi
movl $0x26, %edx
movq %r12, %rcx
callq 0x23285
movq %rax, %rcx
movq 0x18(%r15), %rax
jmp 0x11e5f
xorl %ecx, %ecx
movq 0x30(%rsp), %r12
movq %rcx, 0x20(%r15)
movq %rax, %rdi
callq 0x3100
movl %eax, (%r15)
movl %ebx, 0x4(%r15)
movq 0x10(%rsp), %rcx
addl $0x2, %ecx
addl %eax, %r13d
movl %ecx, %ebx
movq 0x20(%rsp), %r15
cmpl 0x2c(%rsp), %r13d
setge %al
testb $0x1, %bl
sete %cl
andb %al, %cl
movl %ebx, %eax
movq %rax, 0x10(%rsp)
cmpb $0x1, %cl
movq 0x40(%rsp), %r14
jne 0x11beb
jmp 0x11ebc
callq 0x4324
movq 0x10(%rsp), %rax
movl %eax, %ebx
testq %r15, %r15
je 0x11ed2
testl %r13d, %r13d
jne 0x11ed2
movq %r15, %rdi
callq 0xd8a7
testl %eax, %eax
jns 0x11eed
movq 0x38(%rsp), %rax
movl %ebx, (%rax)
movq 0x8(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4343
jmp 0x11ed2