// File: /workspace/github_c_makefile_star2_O2/stevenmherring[P]DNS/sequential-trie.c
// Function: delete
struct trie_node *
        _delete (struct trie_node *node, const char *string,
          size_t strlen) {
            int keylen, cmp;

            // First things first, check if we are NULL
            if (node == NULL) return NULL;

            assert(node->strlen < 64);

            // See if this key is a substring of the string passed in
            cmp = compare_keys (node->key, node->strlen, string, strlen, &keylen);
            if (cmp == 0) {
              // Yes, either quit, or recur on the children

              // If this key is longer than our search string, the key isn't here
              if (node->strlen > keylen) {
                return NULL;
              } else if (strlen > keylen) {
                struct trie_node *found =  _delete(node->children, string, strlen - keylen);
                if (found) {
                  /* If the node doesn't have children, delete it.
                  * Otherwise, keep it around to find the kids */
                  if (found->children == NULL && found->ip4_address == 0) {
                    assert(node->children == found);
                    node->children = found->next;
                    free(found);
                  }

                  /* Delete the root node if we empty the tree */
                  if (node == root && node->children == NULL && node->ip4_address == 0) {
                    root = node->next;
                    free(node);
                  }

                  return node; /* Recursively delete needless interior nodes */
                } else
                return NULL;
              } else {
                assert (strlen == keylen);

                /* We found it! Clear the ip4 address and return. */
                if (node->ip4_address) {
                  node->ip4_address = 0;

                  /* Delete the root node if we empty the tree */
                  if (node == root && node->children == NULL && node->ip4_address == 0) {
                    root = node->next;
                    free(node);
                    return (struct trie_node *) 0x100100; /* XXX: Don't use this pointer for anything except
                    * comparison with NULL, since the memory is freed.
                    * Return a "poison" pointer that will probably
                    * segfault if used.
                    */
                  }
                  return node;
                } else {
                  /* Just an interior node with no value */
                  return NULL;
                }
              }

            } else if (cmp < 0) {
              // No, look right (the node's key is "less" than  the search key)
              struct trie_node *found = _delete(node->next, string, strlen);
              if (found) {
                /* If the node doesn't have children, delete it.
                * Otherwise, keep it around to find the kids */
                if (found->children == NULL && found->ip4_address == 0) {
                  assert(node->next == found);
                  node->next = found->next;
                  free(found);
                }

                return node; /* Recursively delete needless interior nodes */
              }
              return NULL;
            } else {
              // Quit early
              return NULL;
            }

          }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0x19d9
movq %rsi, %r15
movq %rdi, %rbx
movl 0x8(%rdi), %esi
cmpl $0x40, %esi
jae 0x1a8f
movq %rdx, %r14
leaq 0x18(%rbx), %rdi
leaq 0xc(%rsp), %r8
movq %r15, %rdx
movl %r14d, %ecx
callq 0x1330
testl %eax, %eax
je 0x19cf
jns 0x19d9
movq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1943
testq %rax, %rax
je 0x19d9
cmpq $0x0, 0x10(%rax)
jne 0x19db
cmpl $0x0, 0xc(%rax)
jne 0x19db
movq %rbx, %rcx
cmpq %rax, (%rbx)
je 0x1a7c
leaq 0x18f3(%rip), %rdi      # 0x32aa
leaq 0x1646(%rip), %rsi      # 0x3004
leaq 0x1889(%rip), %rcx      # 0x324e
movl $0x150, %edx            # imm = 0x150
callq 0x1090
movslq 0xc(%rsp), %rax
cmpl %eax, 0x8(%rbx)
jbe 0x19e8
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
subq %rax, %r14
jbe 0x1a49
movq 0x10(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1943
testq %rax, %rax
je 0x19d9
cmpq $0x0, 0x10(%rax)
jne 0x1a27
cmpl $0x0, 0xc(%rax)
jne 0x1a27
cmpq %rax, 0x10(%rbx)
jne 0x1acd
movq (%rax), %rcx
movq %rcx, 0x10(%rbx)
movq %rax, %rdi
callq 0x1030
cmpq %rbx, 0x46ba(%rip)      # 0x60e8
jne 0x19db
cmpq $0x0, 0x10(%rbx)
jne 0x19db
cmpl $0x0, 0xc(%rbx)
jne 0x19db
leaq 0x46a4(%rip), %rcx      # 0x60e8
movq %rbx, %rax
jmp 0x1a7c
jne 0x1aae
cmpl $0x0, 0xc(%rbx)
je 0x19d9
andl $0x0, 0xc(%rbx)
cmpq %rbx, 0x468c(%rip)      # 0x60e8
jne 0x19db
cmpq $0x0, 0x10(%rbx)
jne 0x19db
leaq 0x4674(%rip), %rcx      # 0x60e8
movq %rbx, %rax
movl $0x100100, %ebx         # imm = 0x100100
movq (%rax), %rdx
movq %rdx, (%rcx)
movq %rax, %rdi
callq 0x1030
jmp 0x19db
leaq 0x1659(%rip), %rdi      # 0x30ef
leaq 0x1567(%rip), %rsi      # 0x3004
leaq 0x17aa(%rip), %rcx      # 0x324e
movl $0x113, %edx            # imm = 0x113
callq 0x1090
leaq 0x1690(%rip), %rdi      # 0x3145
leaq 0x1548(%rip), %rsi      # 0x3004
leaq 0x178b(%rip), %rcx      # 0x324e
movl $0x132, %edx            # imm = 0x132
callq 0x1090
leaq 0x17be(%rip), %rdi      # 0x3292
leaq 0x1529(%rip), %rsi      # 0x3004
leaq 0x176c(%rip), %rcx      # 0x324e
movl $0x123, %edx            # imm = 0x123
callq 0x1090