// File: /workspace/github_cpp_makefile_star2_O1/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 $0x228, %rsp            # imm = 0x228
movq %r8, %r12
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x1cbec(%rip), %rcx     # 0x3d6a0
movl $0x1, %edx
movq %r8, %rdi
xorl %esi, %esi
callq 0x43c0
testl %eax, %eax
je 0x20be1
movl (%rbx), %ebp
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x20c27
movl $0x40, %edi
callq 0x42d0
movq %rax, %rcx
addq $0x30, %rcx
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movb $0x0, 0x30(%rax)
movq %rax, (%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq (%r14), %r15
movq 0x8(%r14), %rdx
subq %r15, %rdx
sarq $0x5, %rdx
cmpq %rbp, %rdx
jbe 0x20dca
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1cb6c(%rip), %rsi     # 0x3d6a0
leaq 0x1cb66(%rip), %rdx     # 0x3d6a1
leaq 0x38(%rsp), %rdi
callq 0x6516
shlq $0x5, %rbp
addq %rbp, %r15
leaq 0xa0(%rsp), %rdi
leaq 0x38(%rsp), %rdx
movq %r15, %rsi
callq 0x21f22
leaq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x21b34
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20b99
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42e0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x20bb5
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42e0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq $0x2, %rax
je 0x20c43
cmpq $0x1, %rax
jne 0x20c27
movq (%r13), %rdi
addq $0x20, %rdi
callq 0x4180
jmp 0x20c27
movq 0x3d0408(%rip), %rbx    # 0x3f0ff0
leaq 0x1c760(%rip), %rsi     # 0x3d34f
movl $0x26, %edx
movq %rbx, %rdi
callq 0x4340
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x42a0
movsbl %al, %esi
movq 0x3d03d6(%rip), %rdi    # 0x3f0ff0
callq 0x4040
movq %rax, %rdi
callq 0x41f0
leaq 0x10(%rsp), %rdi
callq 0x6420
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa0(%rsp), %rdi
movl $0x18, %edx
callq 0x4490
leaq 0xa0(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x41d0
movq 0x3d033a(%rip), %rsi    # 0x3f0fa8
leaq 0xa0(%rsp), %rdi
callq 0x4240
leaq 0x120(%rsp), %rdi
callq 0x4110
movsd 0x58(%rsp), %xmm0
movq (%r13), %rax
movsd %xmm0, (%rax)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq $0x1, %rdx
jbe 0x20ddb
addq $0x20, %rsi
leaq 0xa0(%rsp), %rdi
movl $0x18, %edx
callq 0x4490
leaq 0xa0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x4540
movq 0x3d02c8(%rip), %rsi    # 0x3f0fa8
leaq 0xa0(%rsp), %rdi
callq 0x4240
leaq 0x120(%rsp), %rdi
callq 0x4110
movl 0xc(%rsp), %eax
movq (%r13), %r15
movl %eax, 0x8(%r15)
incl (%rbx)
leaq 0x90(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x6486
addq $0x10, %r15
leaq 0x80(%rsp), %r8
movq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x20a7a
movq 0x80(%rsp), %rdi
cmpq %rbp, %rdi
je 0x20d69
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42e0
movq (%r13), %r15
incl (%rbx)
leaq 0x70(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0x6486
addq $0x18, %r15
leaq 0x60(%rsp), %r8
movq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x20a7a
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x20c27
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42e0
jmp 0x20c27
leaq 0x1b558(%rip), %rdi     # 0x3c329
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4440
leaq 0x1b547(%rip), %rdi     # 0x3c329
movl $0x1, %esi
xorl %eax, %eax
callq 0x4440
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x20ea1
movq 0x70(%rsp), %rsi
jmp 0x20e90
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %rbp, %rdi
je 0x20ea1
movq 0x90(%rsp), %rsi
jmp 0x20e90
jmp 0x20e29
movq %rax, %rbx
movq 0x3d0175(%rip), %rsi    # 0x3f0fa8
leaq 0xa0(%rsp), %rdi
callq 0x4240
leaq 0x120(%rsp), %rdi
callq 0x4110
jmp 0x20ea1
jmp 0x20e9e
jmp 0x20e9e
movq %rax, %rbx
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20e7c
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42e0
jmp 0x20e7c
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x20ea1
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42e0
jmp 0x20ea1
jmp 0x20e9e
jmp 0x20e9e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x6420
movq %rbx, %rdi
callq 0x4550
nop