// File: /workspace/github_c_makefile_star2_O1/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, 0x8(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r13
movl (%r8), %eax
cmpl %eax, 0x8(%rsi)
jne 0x10c57
addl %eax, %eax
movl %eax, (%r8)
movq 0x10(%rbx), %rdi
cltq
shlq $0x3, %rax
leaq (%rax,%rax,4), %rsi
leaq 0x1760e(%rip), %rdx     # 0x28250
leaq 0x17697(%rip), %r8      # 0x282e0
movl $0x114, %ecx            # imm = 0x114
callq 0x22d64
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rax
movslq 0x8(%rbx), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %r14
movq 0x10(%r13), %rdi
leaq 0x175de(%rip), %rsi     # 0x28250
leaq 0x17667(%rip), %rcx     # 0x282e0
movl $0x117, %edx            # imm = 0x117
callq 0x22d9d
movq %rax, 0x18(%r14)
cmpq $0x0, 0x18(%r13)
je 0x10c94
movq 0x28(%r13), %rdi
jmp 0x10c9b
leaq 0x1764a(%rip), %rdi     # 0x282e5
leaq 0x175ae(%rip), %rsi     # 0x28250
leaq 0x17637(%rip), %rcx     # 0x282e0
movl $0x118, %edx            # imm = 0x118
callq 0x22d9d
movq %rax, 0x20(%r14)
movl $0x0, 0x10(%r14)
movl 0x30(%r13), %eax
movl %eax, 0x8(%r14)
cmpl $0x0, 0x8(%rbx)
je 0x10cd7
movslq -0x20(%r14), %rax
addq -0x28(%r14), %rax
jmp 0x10cd9
xorl %eax, %eax
movq %rax, (%r14)
movl $0x0, 0xc(%r14)
cmpq $0x0, 0x30(%r13)
je 0x10e78
movq %r14, 0x18(%rsp)
leaq 0x18(%rbx), %rax
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
movl $0x0, 0x4(%rsp)
movq 0x40(%r13), %rax
movsbq (%rax,%r14), %rax
leaq 0x1ff28(%rip), %rcx     # 0x30c40
movb (%rax,%rcx), %bpl
cmpb $0x16, %bpl
jb 0x10dcb
cmpl %eax, 0x4(%rsp)
jne 0x10d40
movq 0x60(%rsp), %rax
movq (%rax), %rcx
movl 0x8(%rcx), %eax
addq $0x8, %rcx
jmp 0x10dc7
movq 0x8(%rsp), %rax
movl (%rax), %eax
movq 0x10(%rsp), %rcx
cmpl %eax, (%rcx)
jne 0x10d80
addl %eax, %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
movq 0x20(%rbx), %rdi
movslq %eax, %rsi
shlq $0x4, %rsi
leaq 0x174e5(%rip), %rdx     # 0x28250
movl $0x12b, %ecx            # imm = 0x12B
leaq 0x17569(%rip), %r8      # 0x282e0
callq 0x22d64
movq %rax, 0x20(%rbx)
movq 0x20(%rbx), %rcx
movslq 0x18(%rbx), %rax
movq %rax, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rsi
movq 0x60(%rsp), %rdi
movq %rsi, (%rdi)
movl $0x1, 0x8(%rcx,%rdx)
movq 0x18(%rsp), %rdi
movq (%rdi), %rsi
addq %r14, %rsi
movq %rsi, (%rcx,%rdx)
movq 0x40(%r13), %rsi
movb (%rsi,%r14), %sil
movb %sil, 0xc(%rcx,%rdx)
incl 0xc(%rdi)
movq 0x10(%rsp), %rcx
incl %eax
movl %eax, (%rcx)
movq %r13, %r15
movq 0x40(%r13), %rax
movsbl (%rax,%r14), %eax
movl %eax, 0x4(%rsp)
movq 0x20(%rsp), %rax
movq (%rax), %rsi
cmpq %rsi, (%rbx)
jne 0x10e26
addq %rsi, %rsi
movq %rsi, (%rax)
movq %r12, %rdi
leaq 0x17458(%rip), %rdx     # 0x28250
movl $0x13d, %ecx            # imm = 0x13D
leaq 0x174dc(%rip), %r8      # 0x282e0
movq %rax, %r12
callq 0x22d64
movq (%rbx), %rcx
movq %rax, %r13
leaq (%rax,%rcx), %rdi
movq (%r12), %rdx
subq %rcx, %rdx
xorl %esi, %esi
callq 0x3140
jmp 0x10e29
movq %r12, %r13
cmpb $0x16, %bpl
jb 0x10e5a
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 %r13, %r12
movb %bpl, (%r13,%rax)
incq (%rbx)
incq %r14
movq %r15, %r13
cmpq %r14, 0x30(%r15)
ja 0x10d08
incl 0x8(%rbx)
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq