// File: jstaursky[P]hutch/src/Sleigh/slghsymbol.cc
// Function: DecisionNode::getScore(int, int, bool)
double DecisionNode::getScore(int4 low,int4 size,bool context)

{
  int4 numBins = 1 << size;		// size is between 1 and 8
  int4 i;
  uintm val,mask;
  uintm m = ((uintm)1)<<size;
  m = m-1;

  int4 total = 0;
  vector<int4> count(numBins,0);

  for(i=0;i<list.size();++i) {
    mask = list[i].first->getMask(low,size,context);
    if ((mask&m)!=m) continue;	// Skip if field not fully specified
    val = list[i].first->getValue(low,size,context);
    total += 1;
    count[val] += 1;
  }
  if (total <= 0) return -1.0;
  double sc = 0.0;
  for(i=0;i<numBins;++i) {
    if (count[i] <= 0) continue;
    if (count[i] >= list.size()) return -1.0;
    double p = ((double)count[i])/total;
    sc -= p * log(p);
  }
  return ( sc / log(2.0) );
}

// Assembly:
subq $0xb8, %rsp
movb %cl, %al
movq %rdi, 0xa8(%rsp)
movl %esi, 0xa4(%rsp)
movl %edx, 0xa0(%rsp)
andb $0x1, %al
movb %al, 0x9f(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x28(%rsp)
movb 0xa0(%rsp), %cl
movl $0x1, %eax
movl %eax, %edx
shll %cl, %edx
movl %edx, %ecx
movl %ecx, 0x98(%rsp)
movb 0xa0(%rsp), %cl
shll %cl, %eax
movl %eax, 0x88(%rsp)
movl 0x88(%rsp), %eax
decl %eax
movl %eax, 0x88(%rsp)
movl $0x0, 0x84(%rsp)
movslq 0x98(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x64(%rsp)
leaq 0x63(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xd28c0
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rcx
leaq 0x68(%rsp), %rdi
leaq 0x64(%rsp), %rdx
callq 0xe1f00
jmp 0x14b2a8
leaq 0x63(%rsp), %rdi
callq 0xcf270
movl $0x0, 0x94(%rsp)
movq 0x28(%rsp), %rdi
movslq 0x94(%rsp), %rax
movq %rax, 0x20(%rsp)
callq 0xd5590
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x14b404
movq 0x28(%rsp), %rdi
movslq 0x94(%rsp), %rsi
callq 0xd9cd0
movq (%rax), %rdi
movl 0xa4(%rsp), %esi
movl 0xa0(%rsp), %edx
movzbl 0x9f(%rsp), %ecx
andl $0x1, %ecx
callq 0xe1bf0
movl %eax, 0x1c(%rsp)
jmp 0x14b31e
movl 0x1c(%rsp), %eax
movl %eax, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
andl 0x88(%rsp), %eax
cmpl 0x88(%rsp), %eax
je 0x14b37f
jmp 0x14b3ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
leaq 0x63(%rsp), %rdi
callq 0xcf270
jmp 0x14b599
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
leaq 0x68(%rsp), %rdi
callq 0xd5e90
jmp 0x14b599
movq 0x28(%rsp), %rdi
movslq 0x94(%rsp), %rsi
callq 0xd9cd0
movq (%rax), %rdi
movl 0xa4(%rsp), %esi
movl 0xa0(%rsp), %edx
movzbl 0x9f(%rsp), %ecx
andl $0x1, %ecx
callq 0xda0f0
movl %eax, 0x18(%rsp)
jmp 0x14b3b8
movl 0x18(%rsp), %eax
movl %eax, 0x90(%rsp)
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
movl 0x90(%rsp), %eax
movl %eax, %esi
leaq 0x68(%rsp), %rdi
callq 0xd2680
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x14b2bd
cmpl $0x0, 0x84(%rsp)
jg 0x14b42c
movsd 0x3bd4a(%rip), %xmm0    # 0x187160
movsd %xmm0, 0xb0(%rsp)
movl $0x1, 0x50(%rsp)
jmp 0x14b57e
xorps %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
movl $0x0, 0x94(%rsp)
movl 0x94(%rsp), %eax
cmpl 0x98(%rsp), %eax
jge 0x14b549
movslq 0x94(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0xd2680
cmpl $0x0, (%rax)
jg 0x14b470
jmp 0x14b533
movslq 0x94(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0xd2680
movq 0x28(%rsp), %rdi
movslq (%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xd5590
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jb 0x14b4bf
movsd 0x3bcb7(%rip), %xmm0    # 0x187160
movsd %xmm0, 0xb0(%rsp)
movl $0x1, 0x50(%rsp)
jmp 0x14b57e
movslq 0x94(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0xd2680
cvtsi2sdl (%rax), %xmm0
cvtsi2sdl 0x84(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x40(%rsp), %xmm0
callq 0xd6430
movaps %xmm0, %xmm2
movsd 0x8(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x14b440
movsd 0x48(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x3d9a4(%rip), %xmm0    # 0x188f00
callq 0xd6430
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
movl $0x1, 0x50(%rsp)
leaq 0x68(%rsp), %rdi
callq 0xd5e90
movsd 0xb0(%rsp), %xmm0
addq $0xb8, %rsp
retq
movq 0x58(%rsp), %rdi
callq 0xe0be0
nopw %cs:(%rax,%rax)