// File: /workspace/github_cpp_makefile_star2_O3/Ahhgust[P]STRaitRazor/trie.cpp
// Function: Trie::addWordRC(char const*, unsigned int, unsigned int, unsigned char)
void
Trie::addWordRC(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=wordLen; i > 0; --i) {
    c = w[i-1];

    if (c == 'A') {
      if (parent->t == NULL) {
        parent->t = ++mem;
      }
      child = parent->t;

    } else if (c == 'C') {
      if (parent->g == NULL) {
        parent->g = ++mem;
      }
      child = parent->g;
    } else if (c == 'G') {
      if (parent->c == NULL) {
        parent->c = ++mem;
      }
      child = parent->c;
    } else {
      if (parent->a == NULL) {
        parent->a = ++mem;
      }
      child = parent->a;
    }
    
    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 0x9d8c
movq 0x8(%rdi), %rax
movl %edx, %ecx
movzbl -0x1(%rsi,%rcx), %edx
cmpl $0x47, %edx
je 0x9d5d
cmpl $0x43, %edx
je 0x9d4e
cmpl $0x41, %edx
jne 0x9d6c
movq 0x18(%r9), %r14
testq %r14, %r14
jne 0x9d82
addq $0x18, %r9
jmp 0x9d74
movq 0x10(%r9), %r14
testq %r14, %r14
jne 0x9d82
addq $0x10, %r9
jmp 0x9d74
movq 0x8(%r9), %r14
testq %r14, %r14
jne 0x9d82
addq $0x8, %r9
jmp 0x9d74
movq (%r9), %r14
testq %r14, %r14
jne 0x9d82
addq $0x30, %rax
movq %rax, 0x8(%rdi)
movq %rax, (%r9)
movq %rax, %r14
movq %r14, %r9
decq %rcx
jne 0x9d2b
jmp 0x9d8f
movq %r9, %r14
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x9df6
movq (%rdi), %rcx
movq 0x8(%rdi), %rsi
movq %rsi, %r9
subq %rcx, %r9
je 0x9de4
sarq $0x2, %r9
movl $0x1, %r10d
xorl %eax, %eax
cmpl %ebx, (%rcx,%rax,4)
jne 0x9dd9
movq 0x28(%r14), %rdx
movq (%rdx), %r11
movq 0x8(%rdx), %rdx
subq %r11, %rdx
cmpq %rax, %rdx
jbe 0x9ea9
cmpb %r8b, (%r11,%rax)
je 0x9e9f
movl %r10d, %eax
incl %r10d
cmpq %rax, %r9
ja 0x9db3
cmpq 0x10(%rdi), %rsi
je 0x9e43
movl %ebx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x9e4d
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 0x9e6e
movl %ebx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x9e7c
leaq 0xc(%rsp), %rdx
callq 0x8520
movq 0x28(%r14), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x9e67
movb 0xb(%rsp), %al
movb %al, (%rsi)
incq 0x8(%rdi)
jmp 0x9e9f
leaq 0xb(%rsp), %rdx
jmp 0x9e9a
leaq 0xc(%rsp), %rdx
callq 0x8520
movq 0x28(%r14), %rax
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x9e92
movb 0xb(%rsp), %cl
movb %cl, (%rsi)
incq 0x8(%rax)
jmp 0x9e9f
leaq 0xb(%rsp), %rdx
movq %rax, %rdi
callq 0xac66
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x215f(%rip), %rdi      # 0xc00f
movq %rax, %rsi
xorl %eax, %eax
callq 0x33d0