// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq %r9, 0x20(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r12
movl 0x8(%rsi), %eax
cmpl (%r8), %eax
jne 0xf40d
addl %eax, %eax
movl %eax, (%r8)
movq 0x10(%r15), %rdi
cltq
imulq $0x28, %rax, %rsi
leaq 0x13e91(%rip), %rdx     # 0x23280
leaq 0x13f1a(%rip), %r8      # 0x23310
movl $0x114, %ecx            # imm = 0x114
callq 0x1e0b4
movq %rax, %rbp
movq %rax, 0x10(%r15)
movl 0x8(%r15), %eax
jmp 0xf411
movq 0x10(%r15), %rbp
cltq
imulq $0x28, %rax, %rbx
leaq (%rbx,%rbp), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%r12), %rdi
leaq 0x13e54(%rip), %rsi     # 0x23280
leaq 0x13edd(%rip), %rcx     # 0x23310
movl $0x117, %edx            # imm = 0x117
callq 0x1e123
movq %rax, 0x18(%rbp,%rbx)
cmpq $0x0, 0x18(%r12)
je 0xf451
movq 0x28(%r12), %rdi
jmp 0xf458
leaq 0x13ebd(%rip), %rdi     # 0x23315
leaq 0x13e21(%rip), %rsi     # 0x23280
leaq 0x13eaa(%rip), %rcx     # 0x23310
movl $0x118, %edx            # imm = 0x118
callq 0x1e123
movq 0x8(%rsp), %rdx
movq %rax, 0x20(%rdx)
andl $0x0, 0x10(%rdx)
movq 0x30(%r12), %rax
movl %eax, 0x8(%rdx)
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0x8(%r15)
je 0xf49f
movslq -0x20(%rdx), %rcx
addq -0x28(%rdx), %rcx
jmp 0xf4a1
xorl %ecx, %ecx
movq %rcx, (%rdx)
andl $0x0, 0xc(%rdx)
leaq 0x18(%r15), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x1d788(%rip), %r14     # 0x2cc40
xorl %ebx, %ebx
movq %r15, 0x28(%rsp)
cmpq %rbx, %rax
jbe 0xf613
movq 0x40(%r12), %rdx
movsbq (%rdx,%rbx), %rax
movb (%rax,%r14), %bpl
cmpb $0x16, %bpl
jb 0xf57e
cmpl %eax, 0x10(%rsp)
jne 0xf4fa
movq 0x70(%rsp), %rax
movq (%rax), %rax
movl 0x8(%rax), %ecx
addq $0x8, %rax
jmp 0xf57a
movl 0x18(%r15), %ecx
movq 0x20(%r15), %rax
movq 0x20(%rsp), %rdx
cmpl (%rdx), %ecx
jne 0xf539
addl %ecx, %ecx
movl %ecx, (%rdx)
movslq %ecx, %rsi
shlq $0x4, %rsi
movq %rax, %rdi
leaq 0x13d60(%rip), %rdx     # 0x23280
movl $0x12b, %ecx            # imm = 0x12B
leaq 0x13de4(%rip), %r8      # 0x23310
callq 0x1e0b4
movq %rax, 0x20(%r15)
movl 0x18(%r15), %ecx
movslq %ecx, %rsi
shlq $0x4, %rsi
leaq (%rax,%rsi), %rdx
movq 0x70(%rsp), %rdi
movq %rdx, (%rdi)
movl $0x1, 0x8(%rax,%rsi)
movq 0x8(%rsp), %r8
movq (%r8), %rdx
addq %rbx, %rdx
movq %rdx, (%rax,%rsi)
movq 0x40(%r12), %rdx
movb (%rdx,%rbx), %dil
movb %dil, 0xc(%rax,%rsi)
incl 0xc(%r8)
movq 0x18(%rsp), %rax
incl %ecx
movl %ecx, (%rax)
movsbl (%rdx,%rbx), %eax
movq %rax, 0x10(%rsp)
movq (%r15), %rsi
movq 0x30(%rsp), %rax
cmpq (%rax), %rsi
jne 0xf5e0
addq %rsi, %rsi
movq %rsi, (%rax)
movq %r13, %rdi
leaq 0x13cdc(%rip), %rdx     # 0x23280
movl $0x13d, %ecx            # imm = 0x13D
leaq 0x13d60(%rip), %r8      # 0x23310
movq %r15, %r13
movq %r14, %r15
movq %r12, %r14
movq %rax, %r12
callq 0x1e0b4
movq (%r13), %rcx
movq %rax, %r13
leaq (%rax,%rcx), %rdi
movq (%r12), %rdx
movq %r14, %r12
movq %r15, %r14
subq %rcx, %rdx
xorl %esi, %esi
callq 0x3140
cmpb $0x16, %bpl
jb 0xf5f6
callq 0x3200
cqto
pushq $0x16
popq %rcx
idivq %rcx
movq %rdx, %rbp
movq 0x28(%rsp), %r15
movq (%r15), %rax
movb %bpl, (%r13,%rax)
incq (%r15)
incq %rbx
movq 0x30(%r12), %rax
jmp 0xf4bf
incl 0x8(%r15)
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq