// File: /workspace/github_c_makefile_star2_O3/zpole[P]IICV/vl/aib.c
// Function: vl_aib_process
VL_EXPORT
void vl_aib_process(VlAIB *aib)
{
    vl_uint i, besti, bestj, newnode, nodei, nodej;
    double I, H;
    double minbeta;

    /* Calculate initial value of cost function */
    vl_aib_calculate_information (aib, &I, &H) ;
    aib->costs[0] = I;

    /* Initially which = all */

    /* For each merge */
    for(i = 0 ; i < aib->nvalues - 1 ; i++) {

      /* update entries in aib-> which */
      vl_aib_update_beta(aib);

      /* find best pair of nodes to merge */
      vl_aib_min_beta (aib, &besti, &bestj, &minbeta);

      if(minbeta == BETA_MAX)
        /* only null-probability entries remain */
        break;

      /* Add the parent pointers for the new node */
      newnode = aib->nvalues + i ;
      nodei = aib->nodes[besti];
      nodej = aib->nodes[bestj];

      aib->parents [nodei] = newnode ;
      aib->parents [nodej] = newnode ;
      aib->parents [newnode] = 0 ;

      /* Merge the nodes which produced the minimum beta */
      vl_aib_merge_nodes (aib, besti, bestj, newnode) ;
      vl_aib_calculate_information (aib, &I, &H) ;

      aib->costs[i+1] = I;

      if (aib->verbosity > 0) {
        VL_PRINTF ("aib: (%5d,%5d)=%5d dE: %10.3g I: %6.4g H: %6.4g updt: %5d\n",
                   nodei,
                   nodej,
                   newnode,
                   minbeta,
                   I,
                   H,
                   aib->nwhich) ;
      }
    }

    /* fill ignored entries with NaNs */
    for(; i < aib->nvalues - 1 ; i++)
        aib->costs[i+1] = VL_NAN_D ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x10(%rsp), %r14
leaq 0x8(%rsp), %rdx
movq %r14, %rsi
callq 0xa0fd
movsd (%r14), %xmm0
movq 0x58(%rbx), %rax
movsd %xmm0, (%rax)
cmpl $0x1, 0x48(%rbx)
je 0xa775
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
movq %rbx, %rdi
callq 0x9eec
movq 0x10(%rbx), %rax
movsd (%rax), %xmm1
movq 0x18(%rbx), %rcx
movl (%rcx), %edx
movl 0x8(%rbx), %edi
xorl %esi, %esi
testq %rdi, %rdi
je 0xa601
xorl %r8d, %r8d
movsd (%rax,%r8,8), %xmm0
ucomisd %xmm0, %xmm1
jbe 0xa5f9
movl (%rcx,%r8,4), %edx
movl %r8d, %esi
movapd %xmm0, %xmm1
incq %r8
cmpq %r8, %rdi
jne 0xa5e2
ucomisd 0x27a2f(%rip), %xmm1    # 0x32038
movl 0x48(%rbx), %r13d
jne 0xa615
jnp 0xa6be
movsd %xmm1, 0x20(%rsp)
addl %r14d, %r13d
movl %esi, %eax
movq (%rbx), %rcx
movq 0x50(%rbx), %rdi
movl (%rcx,%rax,4), %ebp
movl %edx, %eax
movl (%rcx,%rax,4), %r12d
movl %r13d, (%rdi,%rbp,4)
movl %r13d, (%rdi,%r12,4)
movl $0x0, (%rdi,%r13,4)
movq %rbx, %rdi
movl %r13d, %ecx
callq 0x9da9
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0xa0fd
movsd 0x10(%rsp), %xmm0
movq 0x58(%rbx), %rax
movsd %xmm0, 0x8(%rax,%r14,8)
cmpl $0x0, 0x60(%rbx)
je 0xa6aa
movsd %xmm0, 0x18(%rsp)
callq 0x9180
movq %rax, %r9
movq 0x8(%rsp), %xmm2
movl 0x28(%rbx), %r8d
leaq 0x279af(%rip), %rdi     # 0x32040
movl %ebp, %esi
movl %r12d, %edx
movl %r13d, %ecx
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movb $0x3, %al
callq *%r9
incq %r14
movl 0x48(%rbx), %r13d
leal -0x1(%r13), %eax
cmpq %rax, %r14
jb 0xa5bf
decl %r13d
cmpl %r13d, %r14d
jae 0xa775
movq 0x58(%rbx), %rcx
movl %r14d, %edx
movl %r13d, %esi
subq %rdx, %rsi
leaq 0x1(%rsi), %rax
andq $-0x2, %rax
decq %rsi
movq %rsi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq (%rcx,%rdx,8), %rcx
addq $0x10, %rcx
xorl %edx, %edx
movdqa 0x27902(%rip), %xmm1    # 0x32000
movdqa 0x2790a(%rip), %xmm2    # 0x32010
pxor %xmm2, %xmm0
movabsq $0x7ff8000000000000, %rsi # imm = 0x7FF8000000000000
pcmpeqd %xmm3, %xmm3
movq %rdx, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm1, %xmm4
pxor %xmm2, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm0, %xmm5
pcmpeqd %xmm0, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %edi
notl %edi
testb $0x1, %dil
je 0xa759
movq %rsi, -0x8(%rcx,%rdx,8)
pxor %xmm3, %xmm4
pextrw $0x4, %xmm4, %edi
testb $0x1, %dil
je 0xa76c
movq %rsi, (%rcx,%rdx,8)
addq $0x2, %rdx
cmpq %rdx, %rax
jne 0xa718
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq