// File: /workspace/github_c_makefile_star2_O2/lh3[P]fermi-lite/bfc.c
// Function: buf_update
static void buf_update(bfc_ec1buf_t *e, const echeap1_t *prev, bfc_penalty_t pen, int cnt)
{
	ecstack1_t *q;
	echeap1_t *r;
	const bfc_opt_t *o = e->opt;
	int b = pen.b;
	// update stack
	kv_pushp(ecstack1_t, e->stack, &q);
	q->parent = prev->k;
	q->i = prev->i;
	q->b = b;
	q->pen = pen;
	q->cnt = cnt > 0? cnt&0xff : 0;
	q->tot_pen = prev->tot_pen + weighted_penalty(o, pen);
	// update heap
	kv_pushp(echeap1_t, e->heap, &r);
	r->i = prev->i + 1;
	r->k = e->stack.n - 1;
	r->x = prev->x;
	if (pen.ec_high) {
		memcpy(r->ecpos_high + 1, prev->ecpos_high, (BFC_EC_HIST_HIGH - 1) * 4);
		r->ecpos_high[0] = prev->i;
	} else memcpy(r->ecpos_high, prev->ecpos_high, BFC_EC_HIST_HIGH * 4);
	if (pen.ec) {
		memcpy(r->ecpos + 1, prev->ecpos, (BFC_EC_HIST - 1) * 4);
		r->ecpos[0] = prev->i;
	} else memcpy(r->ecpos, prev->ecpos, BFC_EC_HIST * 4);
	r->tot_pen = q->tot_pen;
	bfc_kmer_append(e->opt->k, r->x.x, b);
	ks_heapup_ec(e->heap.n, e->heap.a);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rsi
movq 0x28(%rdi), %r13
movl %ebp, %edi
shrb $0x4, %dil
pushq $0x2
popq %rax
cmpq 0x30(%rbx), %r13
jne 0x631e
movq %rsi, %r12
leaq (,%r13,2), %rsi
testq %r13, %r13
cmoveq %rax, %rsi
movq %rsi, 0x30(%rbx)
movl %edi, %r15d
movq 0x38(%rbx), %rdi
shlq $0x4, %rsi
movl %ecx, %r13d
callq 0x21c0
movl %r13d, %ecx
movq %r12, %rsi
movl %r15d, %edi
movq %rax, %r15
movq %rax, 0x38(%rbx)
movq 0x28(%rbx), %r13
jmp 0x6322
movq 0x38(%rbx), %r15
leaq 0x1(%r13), %rax
movq %rax, 0x28(%rbx)
shlq $0x4, %r13
movq 0x4(%r14), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, (%r15,%r13)
movb %dil, 0xc(%r15,%r13)
movb %bpl, 0xd(%r15,%r13)
xorl %eax, %eax
testl %ecx, %ecx
movzbl %cl, %ecx
cmovlel %eax, %ecx
movw %cx, 0xe(%r15,%r13)
movl %ebp, %r8d
andb $0x1, %r8b
movzbl %r8b, %eax
imull 0x20(%rsi), %eax
movl %ebp, %r12d
shrb %r12b
andb $0x1, %r12b
movzbl %r12b, %ecx
imull 0x24(%rsi), %ecx
movl %ebp, %edx
shrb $0x2, %dl
andb $0x1, %dl
movzbl %dl, %edx
imull 0x28(%rsi), %edx
addl %ecx, %edx
shrb $0x3, %bpl
andb $0x1, %bpl
movzbl %bpl, %ecx
imull 0x2c(%rsi), %ecx
addl (%r14), %eax
addl %edx, %eax
addl %ecx, %eax
movl %eax, 0x8(%r15,%r13)
movq 0x10(%rbx), %rcx
cmpq 0x18(%rbx), %rcx
jne 0x63ea
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rax
movq %rax, 0x18(%rbx)
movb %dil, 0x7(%rsp)
movq 0x20(%rbx), %rdi
imulq $0x48, %rax, %rsi
movl %r8d, %ebp
callq 0x21c0
movl %ebp, %r8d
movb 0x7(%rsp), %dil
movq %rax, 0x20(%rbx)
movq 0x10(%rbx), %rcx
jmp 0x63ee
movq 0x20(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rbx)
imulq $0x48, %rcx, %rdx
leaq (%rax,%rdx), %rcx
movl 0x4(%r14), %esi
incl %esi
movl %esi, 0x4(%rax,%rdx)
movl 0x28(%rbx), %esi
decl %esi
movl %esi, 0x8(%rax,%rdx)
movups 0x28(%r14), %xmm0
movups 0x38(%r14), %xmm1
movups %xmm0, 0x28(%rax,%rdx)
movups %xmm1, 0x38(%rax,%rdx)
testb %r12b, %r12b
jne 0x6434
movq 0xc(%r14), %rsi
movq %rsi, 0xc(%rcx)
jmp 0x6442
movl 0xc(%r14), %esi
movl %esi, 0x10(%rcx)
movl 0x4(%r14), %esi
movl %esi, 0xc(%rcx)
addq %r13, %r15
leaq (%rax,%rdx), %rsi
addq $0x28, %rsi
testb %r8b, %r8b
jne 0x6467
leaq 0x14(%rcx), %rax
movl 0x24(%r14), %edx
movl %edx, 0x10(%rax)
movups 0x14(%r14), %xmm0
movups %xmm0, (%rax)
jmp 0x6477
movups 0x14(%r14), %xmm0
movups %xmm0, 0x18(%rcx)
movl 0x4(%r14), %eax
movl %eax, 0x14(%rcx)
movzbl %dil, %edx
movl 0x8(%r15), %eax
movl %eax, (%rcx)
movq (%rbx), %rax
movl 0x8(%rax), %edi
callq 0x4077
movq 0x10(%rbx), %rdi
movq 0x20(%rbx), %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x45cc