// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %r8, %r13
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x1690d(%rip), %rcx     # 0x2e5c4
pushq $0x1
popq %rdx
movq %r8, %rdi
xorl %esi, %esi
callq 0x43f0
testl %eax, %eax
je 0x17dad
movl (%rbx), %ebp
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x17eca
pushq $0x40
popq %rdi
callq 0x4320
movq %rax, %rcx
addq $0x30, %rcx
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movb $0x0, 0x30(%rax)
movq %rax, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x5914
movq %rax, %rbp
leaq 0x168a7(%rip), %rsi     # 0x2e5c4
leaq 0x70(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x58d8
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rdx
movq %rbp, %rsi
callq 0x18be4
leaq 0x90(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x188fc
leaq 0x90(%rsp), %rdi
callq 0x4170
leaq 0x70(%rsp), %rdi
callq 0x4170
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x5, %rax
cmpq $0x2, %rax
je 0x17dcd
cmpq $0x1, %rax
jne 0x17eca
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x5914
movq (%r15), %rdi
addq $0x20, %rdi
movq %rax, %rsi
callq 0x41a0
jmp 0x17eca
movq 0x3cd23c(%rip), %rdi    # 0x3e4ff0
leaq 0x16574(%rip), %rsi     # 0x2e32f
callq 0x4300
movq %rax, %rdi
callq 0x4180
jmp 0x17eca
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x5914
leaq 0x90(%rsp), %rdi
pushq $0x18
popq %rdx
movq %rax, %rsi
callq 0x44b0
leaq 0x90(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x41f0
leaq 0x90(%rsp), %rdi
callq 0x4260
movsd 0x28(%rsp), %xmm0
movq (%r15), %rax
movsd %xmm0, (%rax)
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x5914
leaq 0x90(%rsp), %rdi
pushq $0x18
popq %rdx
movq %rax, %rsi
callq 0x44b0
leaq 0x90(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x4550
leaq 0x90(%rsp), %rdi
callq 0x4260
movl 0xc(%rsp), %eax
movq (%r15), %rbp
movl %eax, 0x8(%rbp)
incl (%rbx)
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x4430
addq $0x10, %rbp
leaq 0x50(%rsp), %r8
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x17c82
leaq 0x50(%rsp), %rdi
callq 0x4170
movq (%r15), %r15
incl (%rbx)
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x4430
addq $0x18, %r15
leaq 0x30(%rsp), %r8
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x17c82
leaq 0x30(%rsp), %rdi
callq 0x4170
leaq 0x10(%rsp), %rdi
callq 0x59a0
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
jmp 0x17f2c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x17f2c
jmp 0x17efc
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x4260
jmp 0x17f3a
jmp 0x17f37
jmp 0x17f37
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x4170
jmp 0x17f27
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4170
jmp 0x17f3a
jmp 0x17f37
jmp 0x17f37
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x59a0
movq %rbx, %rdi
callq 0x4560