// File: /workspace/github_c_makefile_star2_O1/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 0xa0ee
movsd (%r14), %xmm0
movq 0x58(%rbx), %rax
movsd %xmm0, (%rax)
xorl %r14d, %r14d
cmpl $0x1, 0x48(%rbx)
je 0xa6af
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
movq %rbx, %rdi
callq 0x9eea
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 0xa5f5
xorl %r8d, %r8d
movsd (%rax,%r8,8), %xmm0
ucomisd %xmm0, %xmm1
jbe 0xa5ed
movl (%rcx,%r8,4), %edx
movl %r8d, %esi
movapd %xmm0, %xmm1
incq %r8
cmpq %r8, %rdi
jne 0xa5d6
ucomisd 0x28a3b(%rip), %xmm1    # 0x33038
jne 0xa605
jnp 0xa6af
movsd %xmm1, 0x20(%rsp)
movl 0x48(%rbx), %r13d
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 0x9da7
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0xa0ee
movsd 0x10(%rsp), %xmm0
movq 0x58(%rbx), %rax
movsd %xmm0, 0x8(%rax,%r14,8)
cmpl $0x0, 0x60(%rbx)
je 0xa69e
movsd %xmm0, 0x18(%rsp)
callq 0x9180
movq %rax, %r9
movq 0x8(%rsp), %xmm2
movl 0x28(%rbx), %r8d
leaq 0x289bb(%rip), %rdi     # 0x33040
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), %eax
decl %eax
cmpq %rax, %r14
jb 0xa5b3
movl 0x48(%rbx), %eax
decl %eax
cmpl %eax, %r14d
jae 0xa767
movq 0x58(%rbx), %rcx
movl %r14d, %edx
movl %eax, %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 0x28910(%rip), %xmm1    # 0x33000
movdqa 0x28918(%rip), %xmm2    # 0x33010
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 0xa74b
movq %rsi, -0x8(%rcx,%rdx,8)
pxor %xmm3, %xmm4
pextrw $0x4, %xmm4, %edi
testb $0x1, %dil
je 0xa75e
movq %rsi, (%rcx,%rdx,8)
addq $0x2, %rdx
cmpq %rdx, %rax
jne 0xa70a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop