// File: jstaursky[P]hutch/src/Sleigh/slghsymbol.cc
// Function: DecisionNode::split(DecisionProperties&)
void DecisionNode::split(DecisionProperties &props)

{
  if (list.size() <= 1) {
    bitsize = 0;		// Only one pattern, terminal node by default
    return;
  }

  chooseOptimalField();
  if (bitsize == 0) {
    orderPatterns(props);
    return;
  }
  if ((parent != (DecisionNode *)0) && (list.size() >= parent->num))
    throw LowlevelError("Child has as many Patterns as parent");

  int4 numChildren = 1 << bitsize;

  for(int4 i=0;i<numChildren;++i) {
    DecisionNode *nd = new DecisionNode( this );
    children.push_back( nd );
  }
  for(int4 i=0;i<list.size();++i) {
    vector<uint4> vals;		// Bins this pattern belongs in
				// If the pattern does not care about some
				// bits in the field we are splitting on, that
				// pattern will get put into multiple bins
    consistentValues(vals,list[i].first);
    for(int4 j=0;j<vals.size();++j)
      children[vals[j]]->addConstructorPair(list[i].first,list[i].second);
    delete list[i].first;	// We no longer need original pattern
  }
  list.clear();

  for(int4 i=0;i<numChildren;++i)
    children[i]->split(props);
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movq 0xd0(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0xd5590
cmpq $0x1, %rax
ja 0x14a800
movq 0x50(%rsp), %rax
movl $0x0, 0x3c(%rax)
jmp 0x14aba6
movq 0x50(%rsp), %rdi
callq 0xd9320
movq 0x50(%rsp), %rax
cmpl $0x0, 0x3c(%rax)
jne 0x14a82c
movq 0x50(%rsp), %rdi
movq 0xc8(%rsp), %rsi
callq 0xdd6a0
jmp 0x14aba6
movq 0x50(%rsp), %rax
cmpq $0x0, 0x40(%rax)
je 0x14a938
movq 0x50(%rsp), %rdi
callq 0xd5590
movq 0x50(%rsp), %rcx
movq 0x40(%rcx), %rcx
movslq 0x30(%rcx), %rcx
cmpq %rcx, %rax
jb 0x14a938
movb $0x1, 0x93(%rsp)
movl $0x20, %edi
callq 0xd2b40
movq %rax, 0x40(%rsp)
leaq 0xa7(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xe0c80
movq 0x48(%rsp), %rdx
leaq 0x3ecf7(%rip), %rsi     # 0x189588
leaq 0xa8(%rsp), %rdi
callq 0xe00a0
jmp 0x14a8a0
movq 0x40(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xd1ae0
jmp 0x14a8b4
movq 0x40(%rsp), %rdi
movb $0x0, 0x93(%rsp)
movq 0x7d5c8(%rip), %rsi     # 0x1c7e90
movq 0x7d301(%rip), %rdx     # 0x1c7bd0
callq 0xe01f0
jmp 0x14abbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
jmp 0x14a910
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xd4550
leaq 0xa7(%rsp), %rdi
callq 0xd8ec0
testb $0x1, 0x93(%rsp)
jne 0x14a929
jmp 0x14a933
movq 0x40(%rsp), %rdi
callq 0xd5400
jmp 0x14abae
movq 0x50(%rsp), %rax
movl 0x3c(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, 0x8c(%rsp)
movl $0x0, 0x88(%rsp)
movl 0x88(%rsp), %eax
cmpl 0x8c(%rsp), %eax
jge 0x14a9e8
movl $0x48, %edi
callq 0xd8380
movq 0x50(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x38(%rsp)
callq 0xda360
jmp 0x14a98a
movq 0x50(%rsp), %rdi
movq 0x38(%rsp), %rax
movq %rax, 0x80(%rsp)
addq $0x18, %rdi
leaq 0x80(%rsp), %rsi
callq 0xcea70
movl 0x88(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
jmp 0x14a959
movq 0x38(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
movl $0x48, %esi
callq 0xd8620
jmp 0x14abae
movl $0x0, 0x7c(%rsp)
movq 0x50(%rsp), %rdi
movslq 0x7c(%rsp), %rax
movq %rax, 0x30(%rsp)
callq 0xd5590
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0x14ab57
leaq 0x60(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xcf460
movq 0x50(%rsp), %rdi
movslq 0x7c(%rsp), %rsi
callq 0xd9cd0
movq 0x50(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq (%rax), %rdx
callq 0xdb960
jmp 0x14aa47
movl $0x0, 0x5c(%rsp)
movslq 0x5c(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x60(%rsp), %rdi
callq 0xcec30
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x14ab17
movq 0x50(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x8(%rsp)
movslq 0x5c(%rsp), %rsi
leaq 0x60(%rsp), %rdi
callq 0xdd2d0
movq 0x8(%rsp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0xd08d0
movq 0x50(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movslq 0x7c(%rsp), %rsi
callq 0xd9cd0
movq 0x50(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movslq 0x7c(%rsp), %rsi
callq 0xd9cd0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x8(%rax), %rdx
callq 0xcfb50
jmp 0x14aae2
jmp 0x14aae4
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x14aa4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x60(%rsp), %rdi
callq 0xe3070
jmp 0x14abae
movq 0x50(%rsp), %rdi
movslq 0x7c(%rsp), %rsi
callq 0xd9cd0
movq (%rax), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x14ab3d
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x60(%rsp), %rdi
callq 0xe3070
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x14a9f0
movq 0x50(%rsp), %rdi
callq 0xdc3b0
movl $0x0, 0x58(%rsp)
movl 0x58(%rsp), %eax
cmpl 0x8c(%rsp), %eax
jge 0x14aba6
movq 0x50(%rsp), %rdi
addq $0x18, %rdi
movslq 0x58(%rsp), %rsi
callq 0xd08d0
movq (%rax), %rdi
movq 0xc8(%rsp), %rsi
callq 0xd5ec0
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x14ab69
addq $0xd8, %rsp
retq
movq 0x98(%rsp), %rdi
callq 0xe0be0
nopl (%rax,%rax)