// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x17203
movq -0x28(%rbp), %rax
movl (%rax), %ecx
shll %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
movslq (%rax), %rax
imulq $0x28, %rax, %rsi
leaq 0x22f51(%rip), %rdx     # 0x3a138
movl $0x114, %ecx            # imm = 0x114
leaq 0x22fdd(%rip), %r8      # 0x3a1d0
callq 0x31d40
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x22f0b(%rip), %rsi     # 0x3a138
movl $0x117, %edx            # imm = 0x117
leaq 0x22f97(%rip), %rcx     # 0x3a1d0
callq 0x31df0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jbe 0x1727a
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
leaq 0x22ed5(%rip), %rsi     # 0x3a138
movl $0x118, %edx            # imm = 0x118
leaq 0x22f61(%rip), %rcx     # 0x3a1d0
callq 0x31df0
movq %rax, -0x50(%rbp)
jmp 0x1729d
leaq 0x22ee0(%rip), %rdi     # 0x3a161
leaq 0x22eb0(%rip), %rsi     # 0x3a138
movl $0x118, %edx            # imm = 0x118
leaq 0x22f3c(%rip), %rcx     # 0x3a1d0
callq 0x31df0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x172d7
xorl %eax, %eax
movq %rax, -0x58(%rbp)
jmp 0x172ee
movq -0x38(%rbp), %rax
movq -0x28(%rax), %rax
movq -0x38(%rbp), %rcx
movslq -0x20(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0xc(%rax)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movslq -0x3c(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jae 0x17503
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0x298f2(%rip), %rax     # 0x40c30
movzbl (%rax,%rcx), %eax
movl %eax, -0x44(%rbp)
cmpl $0x16, -0x44(%rbp)
jl 0x17443
movl -0x40(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x40(%rcx), %rcx
movslq -0x3c(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x1737b
movq 0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x17441
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x173ca
movq -0x30(%rbp), %rax
movl (%rax), %ecx
shll %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x30(%rbp), %rax
movslq (%rax), %rsi
shlq $0x4, %rsi
leaq 0x22d8a(%rip), %rdx     # 0x3a138
movl $0x12b, %ecx            # imm = 0x12B
leaq 0x22e16(%rip), %r8      # 0x3a1d0
callq 0x31d40
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0x18(%rax), %rax
shlq $0x4, %rax
addq %rax, %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rax
movl $0x1, 0x8(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movslq -0x3c(%rbp), %rax
addq %rax, %rcx
movq 0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x3c(%rbp), %rcx
movb (%rax,%rcx), %cl
movq 0x10(%rbp), %rax
movq (%rax), %rax
movb %cl, 0xc(%rax)
movq -0x38(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
jmp 0x17443
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x174ba
movq -0x20(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
leaq 0x22cb3(%rip), %rdx     # 0x3a138
movl $0x13d, %ecx            # imm = 0x13D
leaq 0x22d3f(%rip), %r8      # 0x3a1d0
callq 0x31d40
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
addq (%rax), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
subq (%rax), %rdx
xorl %esi, %esi
callq 0x3130
cmpl $0x16, -0x44(%rbp)
jl 0x174d4
callq 0x31f0
movl $0x16, %ecx
cqto
idivq %rcx
movl %edx, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x17312
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)