// File: atfrank[P]PCASA/lib/DTree.cpp
// Function: DTree::genDTree(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>>>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void DTree::genDTree(std::vector<std::string> &t, std::string delim){
  //Public version of the genDTree function
  //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

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

  inx=0;

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

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

// Assembly:
subq $0x478, %rsp            # imm = 0x478
movq %rdx, 0x78(%rsp)
movq %rdi, 0x470(%rsp)
movq %rsi, 0x468(%rsp)
movq %rdx, 0x460(%rsp)
movq 0x470(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x440(%rsp), %rdi
callq 0x77e0
movq 0x78(%rsp), %rdi
movl $0x0, 0x45c(%rsp)
leaq 0x40593(%rip), %rcx     # 0x7c598
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x55a0
movl %eax, 0x84(%rsp)
jmp 0x3c01c
movl 0x84(%rsp), %eax
cmpl $0x0, %eax
jne 0x3c07e
movq 0x3fefc1(%rip), %rdi    # 0x43aff0
leaq 0x402a7(%rip), %rsi     # 0x7c2dd
callq 0x53f0
movq %rax, 0x68(%rsp)
jmp 0x3c042
movq 0x68(%rsp), %rdi
movq 0x3fef5a(%rip), %rsi    # 0x43afa8
callq 0x5460
jmp 0x3c055
movl $0x1, 0x420(%rsp)
jmp 0x3c4ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x428(%rsp)
movl %eax, 0x424(%rsp)
jmp 0x3c504
movl 0x45c(%rsp), %eax
movq %rax, 0x60(%rsp)
movq 0x468(%rsp), %rdi
callq 0x78e0
movq %rax, %rcx
movq 0x60(%rsp), %rax
cmpq %rcx, %rax
jae 0x3c4e2
movl $0x40, %edi
callq 0x5410
movq %rax, 0x58(%rsp)
jmp 0x3c0b9
movq 0x58(%rsp), %rdi
callq 0x3c730
movq 0x58(%rsp), %rcx
movq 0x70(%rsp), %rax
movq %rcx, (%rax)
movq (%rax), %rcx
movq $0x0, 0x10(%rcx)
movq (%rax), %rax
movq $0x0, 0x18(%rax)
movq 0x468(%rsp), %rdi
movl 0x45c(%rsp), %eax
movl %eax, %esi
callq 0x79c0
movq %rax, 0x50(%rsp)
jmp 0x3c103
leaq 0x3df(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x5730
movq 0x48(%rsp), %rdx
leaq 0x40477(%rip), %rsi     # 0x7c598
leaq 0x3e0(%rsp), %rdi
callq 0x7900
jmp 0x3c130
movq 0x50(%rsp), %rsi
leaq 0x400(%rsp), %rdi
leaq 0x3e0(%rsp), %rdx
callq 0x3dee0
jmp 0x3c14c
movq 0x78(%rsp), %rsi
leaq 0x400(%rsp), %rdi
leaq 0x440(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3d840
jmp 0x3c16a
leaq 0x400(%rsp), %rdi
callq 0x5250
leaq 0x3e0(%rsp), %rdi
callq 0x5250
leaq 0x3df(%rsp), %rdi
callq 0x5480
leaq 0x440(%rsp), %rdi
callq 0x78e0
cmpq $0x1, %rax
jne 0x3c254
xorl %eax, %eax
movl %eax, %esi
leaq 0x440(%rsp), %rdi
callq 0x79c0
movq %rax, 0x40(%rsp)
jmp 0x3c1c0
movq 0x40(%rsp), %rsi
movq 0x70(%rsp), %rax
movq (%rax), %rdi
addq $0x20, %rdi
callq 0x5060
jmp 0x3c1d8
movl $0x1, 0x420(%rsp)
jmp 0x3c4ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x428(%rsp)
movl %eax, 0x424(%rsp)
jmp 0x3c242
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x428(%rsp)
movl %eax, 0x424(%rsp)
jmp 0x3c235
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x428(%rsp)
movl %eax, 0x424(%rsp)
leaq 0x400(%rsp), %rdi
callq 0x5250
leaq 0x3e0(%rsp), %rdi
callq 0x5250
leaq 0x3df(%rsp), %rdi
callq 0x5480
jmp 0x3c504
leaq 0x440(%rsp), %rdi
callq 0x78e0
cmpq $0x2, %rax
jne 0x3c4dc
xorl %eax, %eax
movl %eax, %esi
leaq 0x440(%rsp), %rdi
callq 0x79c0
movq %rax, 0x38(%rsp)
jmp 0x3c283
movl $0x10, %edi
movl $0x8, %esi
callq 0x7850
movl %eax, 0x34(%rsp)
jmp 0x3c298
movl 0x34(%rsp), %edx
movq 0x38(%rsp), %rsi
leaq 0x250(%rsp), %rdi
callq 0x5670
jmp 0x3c2b0
leaq 0x250(%rsp), %rdi
leaq 0x430(%rsp), %rsi
callq 0x3c750
jmp 0x3c2c7
leaq 0x250(%rsp), %rdi
callq 0x52e0
movq 0x70(%rsp), %rax
movsd 0x430(%rsp), %xmm0
movq (%rax), %rax
movsd %xmm0, (%rax)
leaq 0x440(%rsp), %rdi
movl $0x1, %esi
callq 0x79c0
movq %rax, 0x28(%rsp)
jmp 0x3c302
movl $0x10, %edi
movl $0x8, %esi
callq 0x7850
movl %eax, 0x24(%rsp)
jmp 0x3c317
movl 0x24(%rsp), %edx
movq 0x28(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x5670
jmp 0x3c32f
leaq 0xc8(%rsp), %rdi
leaq 0x43c(%rsp), %rsi
callq 0x3c780
jmp 0x3c346
leaq 0xc8(%rsp), %rdi
callq 0x52e0
movq 0x70(%rsp), %rax
movq 0x78(%rsp), %rsi
movl 0x43c(%rsp), %edx
movq (%rax), %rcx
movl %edx, 0x8(%rcx)
movq (%rax), %rax
addq $0x10, %rax
movq %rax, 0x10(%rsp)
movq 0x468(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x45c(%rsp), %eax
incl %eax
movl %eax, 0x45c(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x51b0
jmp 0x3c3a2
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rsi
movq 0x70(%rsp), %rdi
leaq 0x45c(%rsp), %rcx
leaq 0xa8(%rsp), %r8
callq 0x3b500
jmp 0x3c3c8
leaq 0xa8(%rsp), %rdi
callq 0x5250
movq 0x70(%rsp), %rax
movq 0x78(%rsp), %rsi
movq (%rax), %rax
addq $0x18, %rax
movq %rax, (%rsp)
movq 0x468(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x45c(%rsp), %eax
incl %eax
movl %eax, 0x45c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x51b0
jmp 0x3c416
movq 0x8(%rsp), %rdx
movq (%rsp), %rsi
movq 0x70(%rsp), %rdi
leaq 0x45c(%rsp), %rcx
leaq 0x88(%rsp), %r8
callq 0x3b500
jmp 0x3c43b
leaq 0x88(%rsp), %rdi
callq 0x5250
jmp 0x3c4de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x428(%rsp)
movl %eax, 0x424(%rsp)
leaq 0x250(%rsp), %rdi
callq 0x52e0
jmp 0x3c504
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x428(%rsp)
movl %eax, 0x424(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x52e0
jmp 0x3c504
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x428(%rsp)
movl %eax, 0x424(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x5250
jmp 0x3c504
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x428(%rsp)
movl %eax, 0x424(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x5250
jmp 0x3c504
jmp 0x3c4de
jmp 0x3c4e0
jmp 0x3c4e4
jmp 0x3c4e4
movl $0x0, 0x420(%rsp)
leaq 0x440(%rsp), %rdi
callq 0x7ab0
addq $0x478, %rsp            # imm = 0x478
retq
leaq 0x440(%rsp), %rdi
callq 0x7ab0
movq 0x428(%rsp), %rdi
callq 0x5720
nop