// File: /workspace/github_cpp_makefile_star2_O3/Ahhgust[P]STRaitRazor/trie.cpp
// Function: Trie::addWord(char const*, unsigned int, unsigned int, unsigned char)
void
Trie::addWord(const char *w, unsigned wordLen, unsigned id, unsigned char type) {
  
  unsigned i;
  char c;
  TrieNode *parent, *child;
  parent = root;

  //  cout << w << "\t" << mem - root << "\t";

  // traverse the tree, allocing as needed
  for (i=0; i < wordLen && *w; ++i, ++w) {
    c = *w;
    if (c == 'A') {
      if (parent->a == NULL) {
	parent->a = ++mem;
      }
      child = parent->a;
    } else if (c == 'C') {
      if (parent->c == NULL) {
	parent->c = ++mem;
      }
      child = parent->c;
    } else if (c == 'G') {
      if (parent->g == NULL) {
	parent->g = ++mem;
      }
      child = parent->g;
    } else {
      if (parent->t == NULL) {
	parent->t = ++mem;
      }
      child = parent->t;
    }
    
    parent = child;
  }

  if (parent->id == NULL) {
    parent->id = new vector<unsigned>;
    parent->type = new vector<unsigned char>;
    parent->id->push_back(id);
    parent->type->push_back(type);
  } else {
    // ensure that each type/id pair is only added once    
    for (i=0; i < parent->id->size(); ++i) {
      if (parent->id->at(i) == id &&
          parent->type->at(i) == type)
        return;
    }

    parent->id->push_back(id);
    parent->type->push_back(type);    


  }


  
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %ecx, %ebx
movl %ecx, 0xc(%rsp)
movb %r8b, 0xb(%rsp)
movq (%rdi), %r9
testl %edx, %edx
je 0x9bdc
movq 0x8(%rdi), %rax
movl %edx, %ecx
xorl %edx, %edx
movzbl (%rsi,%rdx), %r10d
cmpl $0x42, %r10d
jle 0x9b91
cmpl $0x43, %r10d
je 0x9ba1
cmpl $0x47, %r10d
jne 0x9bb5
movq 0x10(%r9), %r14
testq %r14, %r14
jne 0x9bd0
addq $0x10, %r9
jmp 0x9bc2
cmpl $0x41, %r10d
jne 0x9bb0
movq (%r9), %r14
testq %r14, %r14
jne 0x9bd0
jmp 0x9bc2
movq 0x8(%r9), %r14
testq %r14, %r14
jne 0x9bd0
addq $0x8, %r9
jmp 0x9bc2
testl %r10d, %r10d
je 0x9bdc
movq 0x18(%r9), %r14
testq %r14, %r14
jne 0x9bd0
addq $0x18, %r9
addq $0x30, %rax
movq %rax, 0x8(%rdi)
movq %rax, (%r9)
movq %rax, %r14
incq %rdx
movq %r14, %r9
cmpl %edx, %ecx
jne 0x9b6b
jmp 0x9bdf
movq %r9, %r14
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x9c46
movq (%rdi), %rcx
movq 0x8(%rdi), %rsi
movq %rsi, %r9
subq %rcx, %r9
je 0x9c34
sarq $0x2, %r9
movl $0x1, %r10d
xorl %eax, %eax
cmpl %ebx, (%rcx,%rax,4)
jne 0x9c29
movq 0x28(%r14), %rdx
movq (%rdx), %r11
movq 0x8(%rdx), %rdx
subq %r11, %rdx
cmpq %rax, %rdx
jbe 0x9cf9
cmpb %r8b, (%r11,%rax)
je 0x9cef
movl %r10d, %eax
incl %r10d
cmpq %rax, %r9
ja 0x9c03
cmpq 0x10(%rdi), %rsi
je 0x9c93
movl %ebx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x9c9d
movl $0x18, %edi
callq 0x32c0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
xorl %r15d, %r15d
movq %r15, 0x10(%rax)
movq %rax, 0x20(%r14)
movl $0x18, %edi
callq 0x32c0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r15, 0x10(%rax)
movq %rax, 0x28(%r14)
movq 0x20(%r14), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x9cbe
movl %ebx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x9ccc
leaq 0xc(%rsp), %rdx
callq 0x8520
movq 0x28(%r14), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x9cb7
movb 0xb(%rsp), %al
movb %al, (%rsi)
incq 0x8(%rdi)
jmp 0x9cef
leaq 0xb(%rsp), %rdx
jmp 0x9cea
leaq 0xc(%rsp), %rdx
callq 0x8520
movq 0x28(%r14), %rax
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x9ce2
movb 0xb(%rsp), %cl
movb %cl, (%rsi)
incq 0x8(%rax)
jmp 0x9cef
leaq 0xb(%rsp), %rdx
movq %rax, %rdi
callq 0xac66
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x230f(%rip), %rdi      # 0xc00f
movq %rax, %rsi
xorl %eax, %eax
callq 0x33d0