// File: /workspace/github_cpp_makefile_star2_O1/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), %r14
testl %edx, %edx
je 0x9c98
movq 0x8(%rdi), %rax
addq $0x8, %rdi
movl %edx, %ecx
movzbl -0x1(%rsi,%rcx), %edx
cmpl $0x47, %edx
je 0x9c6b
cmpl $0x43, %edx
je 0x9c5e
cmpl $0x41, %edx
jne 0x9c78
leaq 0x18(%r14), %rdx
cmpq $0x0, 0x18(%r14)
jne 0x9c90
jmp 0x9c86
leaq 0x10(%r14), %rdx
cmpq $0x0, 0x10(%r14)
jne 0x9c90
jmp 0x9c86
leaq 0x8(%r14), %rdx
cmpq $0x0, 0x8(%r14)
jne 0x9c90
jmp 0x9c86
cmpq $0x0, (%r14)
movq %r14, %rdx
je 0x9c86
movq %r14, %rdx
jmp 0x9c90
addq $0x30, %rax
movq %rax, (%rdi)
movq %rax, (%rdx)
movq (%rdx), %r14
decq %rcx
jne 0x9c3d
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x9cef
movq (%rdi), %rcx
movq 0x8(%rdi), %rsi
movq %rsi, %r9
subq %rcx, %r9
je 0x9d2a
sarq $0x2, %r9
movl $0x1, %r10d
xorl %eax, %eax
cmpl %ebx, (%rcx,%rax,4)
jne 0x9ce2
movq 0x28(%r14), %rdx
movq (%rdx), %r11
movq 0x8(%rdx), %rdx
subq %r11, %rdx
cmpq %rax, %rdx
jbe 0x9d74
cmpb %r8b, (%r11,%rax)
je 0x9d6a
movl %r10d, %eax
incl %r10d
cmpq %rax, %r9
ja 0x9cbc
jmp 0x9d2a
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 0x9d3c
movl %ebx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x9d46
leaq 0xc(%rsp), %rdx
callq 0x840a
movq 0x28(%r14), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x9d60
movb 0xb(%rsp), %al
movb %al, (%rsi)
incq 0x8(%rdi)
jmp 0x9d6a
leaq 0xb(%rsp), %rdx
callq 0xab34
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x2274(%rip), %rdi      # 0xbfef
movq %rax, %rsi
xorl %eax, %eax
callq 0x33d0
nop