// File: /workspace/github_c_makefile_star2_O2/DReichLab[P]adna/trim.c
// Function: bseq_read
bseq1_t *bseq_read(kseq_t *ks, int chunk_size, int *n_)
{
	int size = 0, m, n;
	bseq1_t *seqs;
	m = n = 0; seqs = 0;
	while (kseq_read(ks) >= 0) {
		bseq1_t *s;
		if (n >= m) {
			m = m? m<<1 : 256;
			seqs = realloc(seqs, m * sizeof(bseq1_t));
		}
		s = &seqs[n];
		s->name = strdup(ks->name.s);
		s->seq = strdup(ks->seq.s);
		s->qual = ks->qual.l? strdup(ks->qual.s) : 0;
		s->bc = 0;
		s->l_seq = ks->seq.l;
		s->dbl_bind = 0;
		s->type = AD_UNKNOWN;
		size += seqs[n++].l_seq;
		if (size >= chunk_size && (n&1) == 0) break;
	}
	*n_ = n;
	return seqs;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, 0x10(%rsp)
movl %esi, 0x24(%rsp)
movq %rdi, %r15
leaq 0x30(%rdi), %r12
leaq 0x20(%rdi), %r13
leaq 0x10(%rdi), %rax
movq %rax, 0x30(%rsp)
movq $0x0, 0x18(%rsp)
leaq 0x4(%rsp), %rbp
pushq $0x2
popq %rbx
movq $0x0, 0x28(%rsp)
movq $0x0, 0x8(%rsp)
xorl %esi, %esi
movl %esi, 0x20(%rsp)
movq 0x48(%r15), %r14
cmpl $0x0, 0x40(%r15)
jne 0x330d
movq %r14, %rdi
callq 0x4ba5
cmpl $-0x1, %eax
je 0x3554
cmpl $0x40, %eax
je 0x3305
cmpl $0x3e, %eax
jne 0x32ea
movl %eax, 0x4(%rsp)
movl %eax, 0x40(%r15)
andl $0x0, 0x30(%r15)
andl $0x0, 0x20(%r15)
andl $0x0, 0x10(%r15)
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x37d6
testl %eax, %eax
js 0x3554
cmpl $0xa, 0x4(%rsp)
je 0x334c
movq %r14, %rdi
movl %ebx, %esi
movq 0x30(%rsp), %rdx
xorl %ecx, %ecx
callq 0x37d6
cmpq $0x0, 0x28(%r15)
pushq $0x1
popq %rbp
jne 0x336c
movl $0x100, 0x24(%r15)      # imm = 0x100
movl $0x100, %edi            # imm = 0x100
callq 0x21b0
movq %rax, 0x28(%r15)
movq %r14, %rdi
callq 0x4ba5
movl %eax, 0x4(%rsp)
cmpl $0xa, %eax
je 0x336c
cmpl $-0x1, %eax
je 0x33bb
cmpl $0x2b, %eax
je 0x33bb
cmpl $0x3e, %eax
je 0x33b7
cmpl $0x40, %eax
je 0x33b7
movq 0x28(%r15), %rcx
movl 0x20(%r15), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x20(%r15)
movb %al, (%rcx,%rdx)
movq %r14, %rdi
movl %ebx, %esi
movq %r13, %rdx
xorl %ecx, %ecx
movl %ebp, %r8d
callq 0x4c18
jmp 0x336c
movl %eax, 0x40(%r15)
movl 0x20(%r15), %ecx
leal 0x1(%rcx), %edx
movq 0x28(%r15), %rax
cmpl 0x24(%r15), %edx
jb 0x3404
movl %edx, %ecx
shrl %ecx
orl %edx, %ecx
movl %ecx, %edx
shrl $0x2, %edx
orl %ecx, %edx
movl %edx, %ecx
shrl $0x4, %ecx
orl %edx, %ecx
movl %ecx, %edx
shrl $0x8, %edx
orl %ecx, %edx
movl %edx, %esi
shrl $0x10, %esi
orl %edx, %esi
incl %esi
movl %esi, 0x24(%r15)
movq %rax, %rdi
callq 0x21d0
movq %rax, 0x28(%r15)
movl 0x20(%r15), %ecx
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
cmpl $0x2b, 0x4(%rsp)
jne 0x3476
movl 0x24(%r15), %esi
cmpl %esi, 0x34(%r15)
jae 0x342c
movl %esi, 0x34(%r15)
movq 0x38(%r15), %rdi
callq 0x21d0
movq %rax, 0x38(%r15)
movq %r14, %rdi
callq 0x4ba5
movl %eax, 0x4(%rsp)
cmpl $-0x1, %eax
je 0x3554
cmpl $0xa, %eax
jne 0x342c
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movl %ebp, %r8d
callq 0x4c18
movl (%r13), %ecx
movl (%r12), %edx
testl %eax, %eax
js 0x3468
cmpl %ecx, %edx
jb 0x3446
andl $0x0, 0x40(%r15)
cmpl %edx, %ecx
je 0x347a
jmp 0x3554
movl (%r13), %ecx
testl %ecx, %ecx
js 0x3554
movq 0x28(%rsp), %rcx
movslq %ecx, %rax
cmpq %rax, 0x18(%rsp)
jge 0x3498
movq 0x8(%rsp), %rbp
jmp 0x34c3
leal (%rcx,%rcx), %r14d
testl %ecx, %ecx
movl $0x100, %eax            # imm = 0x100
cmovel %eax, %r14d
movslq %r14d, %rax
imulq $0x30, %rax, %rsi
movq 0x8(%rsp), %rdi
callq 0x21d0
movq %rax, %rbp
movl %r14d, %eax
movq %rax, 0x28(%rsp)
imulq $0x30, 0x18(%rsp), %r14
movq 0x8(%r15), %rdi
callq 0x2260
movq %rax, 0x8(%rbp,%r14)
movq 0x28(%r15), %rdi
callq 0x2260
movq %rbp, 0x8(%rsp)
movq %rax, 0x10(%rbp,%r14)
cmpl $0x0, 0x30(%r15)
je 0x34fc
movq 0x38(%r15), %rdi
callq 0x2260
jmp 0x34fe
xorl %eax, %eax
leaq 0x4(%rsp), %rbp
movl 0x20(%rsp), %esi
addq 0x8(%rsp), %r14
movq %rax, 0x18(%r14)
andq $0x0, 0x20(%r14)
movl (%r13), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ecx
movl %ecx, (%r14)
andl $0x0, 0x4(%r14)
movq 0x18(%rsp), %rdx
movq %rdx, %rax
incq %rax
addl %ecx, %esi
cmpl 0x24(%rsp), %esi
setl %cl
testb $0x1, %dl
sete %dl
orb %cl, %dl
movq %rax, 0x18(%rsp)
jne 0x32db
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %rcx
movl %ecx, (%rdx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq