// File: atfrank[P]PCASA/lib/DTree.cpp
// Function: DTree::genDTree(DTreeNode*&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, unsigned int&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void DTree::genDTree(DTreeNode *&node, std::vector<std::string> &t, unsigned int &inx, std::string delim){
  //Pre-order string expected
  //Example: 0.0:0 1.0:1 2.0:2 3.0:3 A B 4.0:4 C D 5.0:5 E F 6.0:6 7.0:7 8.0:8 G H 9.0:9 I J 10.0:10 K L 
  //Value:Index or Class

  std::vector<std::string> s;
  unsigned int i;
  double d;

  if (delim.compare(0,1," " ) == 0){
    std::cerr << "Error: Delimiter cannot be whitespace!" << std::endl;
    return;
  }

  if (inx < t.size()){
    node=new DTreeNode;
    node->left=NULL;
    node->right=NULL;

    Misc::splitStr(Misc::trim(t.at(inx)), delim, s, false);
    if (s.size() == 1){
      //std::cerr << t.at(inx) << std::endl;
      node->leaf=s.at(0);
      return;
    }
    else if (s.size() == 2){
      //std::cerr << t.at(inx) << std::endl;
      std::stringstream(s.at(0)) >> d;
      node->key_value=d;
      std::stringstream(s.at(1)) >> i;
      node->inx=i; //Base zero
      this->genDTree(node->left, t, ++inx, delim);
      this->genDTree(node->right, t, ++inx, delim);
    }
    else{
      //I shouldn't be here
    }
  }
  else{
    //Do nothing
  }
}

// Assembly:
subq $0x498, %rsp            # imm = 0x498
movq %r8, 0x90(%rsp)
movq %rdi, 0x490(%rsp)
movq %rsi, 0x488(%rsp)
movq %rdx, 0x480(%rsp)
movq %rcx, 0x478(%rsp)
movq %r8, 0x470(%rsp)
movq 0x490(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x458(%rsp), %rdi
callq 0x77e0
movq 0x90(%rsp), %rdi
leaq 0x41035(%rip), %rcx     # 0x7c598
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x55a0
movl %eax, 0x9c(%rsp)
jmp 0x3b57a
movl 0x9c(%rsp), %eax
cmpl $0x0, %eax
jne 0x3b5e2
movq 0x3ffa63(%rip), %rdi    # 0x43aff0
leaq 0x40d49(%rip), %rsi     # 0x7c2dd
callq 0x53f0
movq %rax, 0x80(%rsp)
jmp 0x3b5a3
movq 0x80(%rsp), %rdi
movq 0x3ff9f6(%rip), %rsi    # 0x43afa8
callq 0x5460
jmp 0x3b5b9
movl $0x1, 0x438(%rsp)
jmp 0x3ba91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x440(%rsp)
movl %eax, 0x43c(%rsp)
jmp 0x3baa6
movq 0x478(%rsp), %rax
movl (%rax), %eax
movq %rax, 0x78(%rsp)
movq 0x480(%rsp), %rdi
callq 0x78e0
movq %rax, %rcx
movq 0x78(%rsp), %rax
cmpq %rcx, %rax
jae 0x3ba84
movl $0x40, %edi
callq 0x5410
movq %rax, 0x70(%rsp)
jmp 0x3b620
movq 0x70(%rsp), %rdi
callq 0x3c730
movq 0x70(%rsp), %rcx
movq 0x488(%rsp), %rax
movq %rcx, (%rax)
movq 0x488(%rsp), %rax
movq (%rax), %rax
movq $0x0, 0x10(%rax)
movq 0x488(%rsp), %rax
movq (%rax), %rax
movq $0x0, 0x18(%rax)
movq 0x480(%rsp), %rdi
movq 0x478(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
callq 0x79c0
movq %rax, 0x68(%rsp)
jmp 0x3b680
leaq 0x3f7(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x5730
movq 0x60(%rsp), %rdx
leaq 0x40efa(%rip), %rsi     # 0x7c598
leaq 0x3f8(%rsp), %rdi
callq 0x7900
jmp 0x3b6ad
movq 0x68(%rsp), %rsi
leaq 0x418(%rsp), %rdi
leaq 0x3f8(%rsp), %rdx
callq 0x3dee0
jmp 0x3b6c9
movq 0x90(%rsp), %rsi
leaq 0x418(%rsp), %rdi
leaq 0x458(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3d840
jmp 0x3b6ea
leaq 0x418(%rsp), %rdi
callq 0x5250
leaq 0x3f8(%rsp), %rdi
callq 0x5250
leaq 0x3f7(%rsp), %rdi
callq 0x5480
leaq 0x458(%rsp), %rdi
callq 0x78e0
cmpq $0x1, %rax
jne 0x3b7d7
xorl %eax, %eax
movl %eax, %esi
leaq 0x458(%rsp), %rdi
callq 0x79c0
movq %rax, 0x58(%rsp)
jmp 0x3b740
movq 0x58(%rsp), %rsi
movq 0x488(%rsp), %rax
movq (%rax), %rdi
addq $0x20, %rdi
callq 0x5060
jmp 0x3b75b
movl $0x1, 0x438(%rsp)
jmp 0x3ba91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x440(%rsp)
movl %eax, 0x43c(%rsp)
jmp 0x3b7c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x440(%rsp)
movl %eax, 0x43c(%rsp)
jmp 0x3b7b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x440(%rsp)
movl %eax, 0x43c(%rsp)
leaq 0x418(%rsp), %rdi
callq 0x5250
leaq 0x3f8(%rsp), %rdi
callq 0x5250
leaq 0x3f7(%rsp), %rdi
callq 0x5480
jmp 0x3baa6
leaq 0x458(%rsp), %rdi
callq 0x78e0
cmpq $0x2, %rax
jne 0x3ba7e
xorl %eax, %eax
movl %eax, %esi
leaq 0x458(%rsp), %rdi
callq 0x79c0
movq %rax, 0x50(%rsp)
jmp 0x3b806
movl $0x10, %edi
movl $0x8, %esi
callq 0x7850
movl %eax, 0x4c(%rsp)
jmp 0x3b81b
movl 0x4c(%rsp), %edx
movq 0x50(%rsp), %rsi
leaq 0x268(%rsp), %rdi
callq 0x5670
jmp 0x3b833
leaq 0x268(%rsp), %rdi
leaq 0x448(%rsp), %rsi
callq 0x3c750
jmp 0x3b84a
leaq 0x268(%rsp), %rdi
callq 0x52e0
movsd 0x448(%rsp), %xmm0
movq 0x488(%rsp), %rax
movq (%rax), %rax
movsd %xmm0, (%rax)
leaq 0x458(%rsp), %rdi
movl $0x1, %esi
callq 0x79c0
movq %rax, 0x40(%rsp)
jmp 0x3b888
movl $0x10, %edi
movl $0x8, %esi
callq 0x7850
movl %eax, 0x3c(%rsp)
jmp 0x3b89d
movl 0x3c(%rsp), %edx
movq 0x40(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x5670
jmp 0x3b8b5
leaq 0xe0(%rsp), %rdi
leaq 0x454(%rsp), %rsi
callq 0x3c780
jmp 0x3b8cc
leaq 0xe0(%rsp), %rdi
callq 0x52e0
movq 0x90(%rsp), %rsi
movl 0x454(%rsp), %ecx
movq 0x488(%rsp), %rax
movq (%rax), %rax
movl %ecx, 0x8(%rax)
movq 0x488(%rsp), %rax
movq (%rax), %rax
addq $0x10, %rax
movq %rax, 0x20(%rsp)
movq 0x480(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x478(%rsp), %rax
movq %rax, 0x30(%rsp)
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
leaq 0xc0(%rsp), %rdi
callq 0x51b0
jmp 0x3b939
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rsi
movq 0x88(%rsp), %rdi
leaq 0xc0(%rsp), %r8
callq 0x3b500
jmp 0x3b95f
leaq 0xc0(%rsp), %rdi
callq 0x5250
movq 0x90(%rsp), %rsi
movq 0x488(%rsp), %rax
movq (%rax), %rax
addq $0x18, %rax
movq %rax, 0x8(%rsp)
movq 0x480(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x478(%rsp), %rax
movq %rax, 0x18(%rsp)
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
leaq 0xa0(%rsp), %rdi
callq 0x51b0
jmp 0x3b9b7
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq 0x88(%rsp), %rdi
leaq 0xa0(%rsp), %r8
callq 0x3b500
jmp 0x3b9dd
leaq 0xa0(%rsp), %rdi
callq 0x5250
jmp 0x3ba80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x440(%rsp)
movl %eax, 0x43c(%rsp)
leaq 0x268(%rsp), %rdi
callq 0x52e0
jmp 0x3baa6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x440(%rsp)
movl %eax, 0x43c(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x52e0
jmp 0x3baa6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x440(%rsp)
movl %eax, 0x43c(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x5250
jmp 0x3baa6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x440(%rsp)
movl %eax, 0x43c(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x5250
jmp 0x3baa6
jmp 0x3ba80
jmp 0x3ba82
jmp 0x3ba86
jmp 0x3ba86
movl $0x0, 0x438(%rsp)
leaq 0x458(%rsp), %rdi
callq 0x7ab0
addq $0x498, %rsp            # imm = 0x498
retq
leaq 0x458(%rsp), %rdi
callq 0x7ab0
movq 0x440(%rsp), %rdi
callq 0x5720