// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, 0x20(%rsp)
movl %edi, 0x1c(%rsp)
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %ebx, %ebx
movq $0x0, 0x8(%rsp)
movq %rcx, 0x28(%rsp)
movq %r12, %rdi
callq 0xd61e
testl %eax, %eax
js 0x11b76
testq %r14, %r14
je 0x118ff
movq %r14, %rdi
callq 0xd61e
testl %eax, %eax
js 0x11b71
cmpl %ebp, %ebx
jge 0x1190a
movq %rbp, 0x10(%rsp)
jmp 0x1194d
movq %rbp, %rax
addl %ebp, %ebp
testl %eax, %eax
movl $0x100, %eax            # imm = 0x100
cmovel %eax, %ebp
movslq %ebp, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
movq 0x8(%rsp), %rdi
leaq 0x16ba5(%rip), %rdx     # 0x284d5
movl $0x37, %ecx
leaq 0x16b8f(%rip), %r8      # 0x284cb
callq 0x22d64
movq %rax, 0x8(%rsp)
movl %ebp, %eax
movq %rax, 0x10(%rsp)
movq (%r12), %r13
cmpq $0x3, %r13
jb 0x11987
movq 0x10(%r12), %rbp
cmpb $0x2f, -0x2(%rbp,%r13)
jne 0x11987
callq 0x3320
movq (%rax), %rax
movsbq -0x1(%rbp,%r13), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x11987
addq $-0x2, %r13
movq %r13, (%r12)
movb $0x0, (%rbp,%r13)
movslq %ebx, %rax
leaq (%rax,%rax,2), %rbp
shlq $0x4, %rbp
movq 0x10(%r12), %rdi
leaq 0x16b37(%rip), %r13     # 0x284d5
movq %r13, %rsi
movl $0x23, %edx
leaq 0x16d90(%rip), %r14     # 0x2873d
movq %r14, %rcx
callq 0x22d9d
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx,%rbp)
cmpq $0x0, 0x18(%r12)
je 0x119de
movq 0x28(%r12), %rdi
movq %r13, %rsi
movl $0x24, %edx
movq %r14, %rcx
callq 0x22d9d
jmp 0x119e0
xorl %eax, %eax
addq 0x8(%rsp), %rbp
movq %rax, 0x10(%rbp)
movq 0x40(%r12), %rdi
movq %r13, %rsi
movl $0x25, %edx
movq %r14, %rcx
callq 0x22d9d
movq %rax, 0x18(%rbp)
cmpq $0x0, 0x48(%r12)
je 0x11a21
movq 0x58(%r12), %rdi
movq %r13, %rsi
movl $0x26, %edx
movq %r14, %rcx
callq 0x22d9d
jmp 0x11a23
xorl %eax, %eax
movq %rax, 0x20(%rbp)
movq 0x18(%rbp), %rdi
callq 0x3100
leal 0x1(%rbx), %r13d
addl %eax, %r15d
movl %eax, (%rbp)
movl %ebx, 0x4(%rbp)
movq 0x28(%rsp), %r14
testq %r14, %r14
je 0x11b4d
movq %r15, 0x30(%rsp)
movq (%r14), %rbp
cmpq $0x3, %rbp
jb 0x11a86
movq 0x10(%r14), %r15
cmpb $0x2f, -0x2(%r15,%rbp)
jne 0x11a86
callq 0x3320
movq (%rax), %rax
movsbq -0x1(%r15,%rbp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x11a86
addq $-0x2, %rbp
movq %rbp, (%r14)
movb $0x0, (%r15,%rbp)
movslq %r13d, %rax
leaq (%rax,%rax,2), %rbp
shlq $0x4, %rbp
movq 0x10(%r14), %rdi
leaq 0x16a39(%rip), %rsi     # 0x284d5
movl $0x23, %edx
movq %r14, %r15
leaq 0x16c92(%rip), %r14     # 0x2873d
movq %r14, %rcx
callq 0x22d9d
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx,%rbp)
cmpq $0x0, 0x18(%r15)
je 0x11ade
movq 0x28(%r15), %rdi
leaq 0x16a06(%rip), %rsi     # 0x284d5
movl $0x24, %edx
movq %r14, %rcx
callq 0x22d9d
jmp 0x11ae0
xorl %eax, %eax
addq 0x8(%rsp), %rbp
movq %rax, 0x10(%rbp)
movq 0x40(%r15), %rdi
leaq 0x169e1(%rip), %rsi     # 0x284d5
movl $0x25, %edx
movq %r14, %rcx
callq 0x22d9d
movq %rax, 0x18(%rbp)
cmpq $0x0, 0x48(%r15)
je 0x11b26
movq 0x58(%r15), %rdi
leaq 0x169be(%rip), %rsi     # 0x284d5
movl $0x26, %edx
movq %r14, %rcx
callq 0x22d9d
jmp 0x11b28
xorl %eax, %eax
movq %r15, %r14
movq %rax, 0x20(%rbp)
movq 0x18(%rbp), %rdi
callq 0x3100
movl %eax, (%rbp)
movl %r13d, 0x4(%rbp)
addl $0x2, %ebx
movq 0x30(%rsp), %r15
addl %eax, %r15d
movl %ebx, %r13d
movq 0x10(%rsp), %rbp
cmpl 0x1c(%rsp), %r15d
setge %al
testb $0x1, %r13b
sete %cl
andb %al, %cl
movl %r13d, %ebx
cmpb $0x1, %cl
jne 0x118da
jmp 0x11b79
callq 0x432c
movl %ebx, %r13d
testq %r14, %r14
je 0x11b8f
testl %r15d, %r15d
jne 0x11b8f
movq %r14, %rdi
callq 0xd61e
testl %eax, %eax
jns 0x11bab
movq 0x20(%rsp), %rax
movl %r13d, (%rax)
movq 0x8(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x434b
jmp 0x11b8f