// File: /workspace/github_c_makefile_star2_O3/ToniWestbrook[P]paladin/bntseq.c
// Function: add1
uint8_t *add1(const kseq_t *seq, bntseq_t *bns, uint8_t *pac, int64_t *m_pac, int *m_seqs, int *m_holes, bntamb1_t **q) {
	bntann1_t *p;
	int i, lasts;
	if (bns->n_seqs == *m_seqs) {
		*m_seqs <<= 1;
		bns->anns = (bntann1_t*)realloc(bns->anns, *m_seqs * sizeof(bntann1_t));
	}
	p = bns->anns + bns->n_seqs;
	p->name = strdup((char*)seq->name.s);
	p->anno = seq->comment.l > 0? strdup((char*)seq->comment.s) : strdup("(null)");
	p->gi = 0; p->len = seq->seq.l;
	p->offset = (bns->n_seqs == 0)? 0 : (p-1)->offset + (p-1)->len;
	p->n_ambs = 0;

	// Iterate through each AA in the sequence
	for (i = lasts = 0; i < seq->seq.l; ++i) {
		// Hash encoded value
		int c = (int) aa_encode_hash[(int)(seq->seq.s[i])];

		// Process unknowns
		if (c >= VALUE_DEFINED) {
			// Contiguous unknowns
			if (lasts == seq->seq.s[i]) {
				++(*q)->len;
			}
			else {
				if (bns->n_holes == *m_holes) {
					(*m_holes) <<= 1;
					bns->ambs = (bntamb1_t*)realloc(bns->ambs, (*m_holes) * sizeof(bntamb1_t));
				}

				*q = bns->ambs + bns->n_holes;
				(*q)->len = 1;
				(*q)->offset = p->offset + i;
				(*q)->amb = seq->seq.s[i];
				++p->n_ambs;
				++bns->n_holes;
			}
		}

		// Store value to check for contiguous runs
		lasts = seq->seq.s[i];

		// Expand buffer if necessary
		if (bns->l_pac == *m_pac) { // double the pac size
			*m_pac <<= 1;
			pac = realloc(pac, *m_pac);
			memset(pac + bns->l_pac, 0, (*m_pac - bns->l_pac));
		}

		// Pack and set value
		if (c >= VALUE_DEFINED) c = lrand48() % VALUE_DEFINED;
		pac[bns->l_pac] = c;

		++bns->l_pac;
	}

	++bns->n_seqs;
	return pac;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r15
movq %rcx, 0x20(%rsp)
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r13
movl 0x8(%rsi), %ecx
cmpl (%r8), %ecx
jne 0x10f30
addl %ecx, %ecx
movl %ecx, (%r8)
movq 0x10(%rbx), %rdi
movslq %ecx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rsi
leaq 0x173d2(%rip), %rdx     # 0x282e8
leaq 0x1745b(%rip), %r8      # 0x28378
movl $0x114, %ecx            # imm = 0x114
callq 0x2324c
movq %rax, 0x10(%rbx)
movl 0x8(%rbx), %ecx
jmp 0x10f34
movq 0x10(%rbx), %rax
movslq %ecx, %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %r12
movq 0x10(%r13), %rdi
leaq 0x1739e(%rip), %rsi     # 0x282e8
leaq 0x17427(%rip), %rcx     # 0x28378
movl $0x117, %edx            # imm = 0x117
callq 0x23285
movq %rax, 0x18(%r12)
cmpq $0x0, 0x18(%r13)
je 0x10f6d
movq 0x28(%r13), %rdi
jmp 0x10f74
leaq 0x17409(%rip), %rdi     # 0x2837d
leaq 0x1736d(%rip), %rsi     # 0x282e8
leaq 0x173f6(%rip), %rcx     # 0x28378
movl $0x118, %edx            # imm = 0x118
callq 0x23285
movq %rax, 0x20(%r12)
movl $0x0, 0x10(%r12)
movq 0x30(%r13), %rcx
movl %ecx, 0x8(%r12)
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0x10fb6
movslq -0x20(%r12), %rdx
addq -0x28(%r12), %rdx
jmp 0x10fb8
xorl %edx, %edx
movq %rdx, (%r12)
movl $0x0, 0xc(%r12)
testq %rcx, %rcx
je 0x1114d
movq %r12, 0x10(%rsp)
movq %r15, 0x18(%rsp)
leaq 0x18(%rbx), %rax
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
movl $0x0, 0x4(%rsp)
movq 0x40(%r13), %rdx
movsbq (%rdx,%r15), %rax
leaq 0x1fc44(%rip), %rcx     # 0x30c40
movb (%rax,%rcx), %bpl
cmpb $0x16, %bpl
jb 0x110a2
cmpl %eax, 0x4(%rsp)
jne 0x11021
movq 0x60(%rsp), %rax
movq (%rax), %rax
movl 0x8(%rax), %ecx
addq $0x8, %rax
jmp 0x1109e
movl 0x18(%rbx), %ecx
movq 0x20(%rbx), %rax
movq 0x18(%rsp), %rdx
cmpl (%rdx), %ecx
jne 0x1105e
addl %ecx, %ecx
movl %ecx, (%rdx)
movslq %ecx, %rsi
shlq $0x4, %rsi
movq %rax, %rdi
leaq 0x172a2(%rip), %rdx     # 0x282e8
movl $0x12b, %ecx            # imm = 0x12B
leaq 0x17326(%rip), %r8      # 0x28378
callq 0x2324c
movq %rax, 0x20(%rbx)
movl 0x18(%rbx), %ecx
movslq %ecx, %rsi
shlq $0x4, %rsi
leaq (%rax,%rsi), %rdx
movq 0x60(%rsp), %rdi
movq %rdx, (%rdi)
movl $0x1, 0x8(%rax,%rsi)
movq 0x10(%rsp), %r8
movq (%r8), %rdx
addq %r15, %rdx
movq %rdx, (%rax,%rsi)
movq 0x40(%r13), %rdx
movb (%rdx,%r15), %dil
movb %dil, 0xc(%rax,%rsi)
incl 0xc(%r8)
movq 0x8(%rsp), %rax
incl %ecx
movl %ecx, (%rax)
movsbl (%rdx,%r15), %eax
movl %eax, 0x4(%rsp)
movq (%rbx), %rsi
movq 0x20(%rsp), %rax
cmpq (%rax), %rsi
jne 0x110fc
addq %rsi, %rsi
movq %rsi, (%rax)
movq %r14, %rdi
leaq 0x17220(%rip), %rdx     # 0x282e8
movl $0x13d, %ecx            # imm = 0x13D
leaq 0x172a4(%rip), %r8      # 0x28378
movq %r13, %r14
movq %rax, %r13
callq 0x2324c
movq (%rbx), %rcx
movq %rax, %r12
leaq (%rax,%rcx), %rdi
movq (%r13), %rdx
movq %r14, %r13
subq %rcx, %rdx
xorl %esi, %esi
callq 0x3140
jmp 0x110ff
movq %r14, %r12
cmpb $0x16, %bpl
jb 0x11130
callq 0x3200
movq %rax, %rbp
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
shrl $0x2, %edx
addl %eax, %edx
leal (%rdx,%rdx,4), %eax
leal (%rdx,%rax,4), %eax
addl %edx, %eax
subl %eax, %ebp
movq (%rbx), %rax
movq %r12, %r14
movb %bpl, (%r12,%rax)
incq (%rbx)
incq %r15
cmpq %r15, 0x30(%r13)
ja 0x10fec
movl 0x8(%rbx), %eax
incl %eax
movl %eax, 0x8(%rbx)
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq