// File: /workspace/github_c_makefile_star2_O1/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 0x19f0
movq %rsi, %r15
movq %rdi, %rbx
movl 0x8(%rdi), %esi
cmpl $0x40, %esi
jae 0x1aa9
movq %rdx, %r14
leaq 0x18(%rbx), %rdi
leaq 0xc(%rsp), %r8
movq %r15, %rdx
movl %r14d, %ecx
callq 0x133c
testl %eax, %eax
je 0x19e6
jns 0x19f0
movq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x195a
testq %rax, %rax
je 0x19f0
cmpq $0x0, 0x10(%rax)
jne 0x19f2
cmpl $0x0, 0xc(%rax)
jne 0x19f2
movq %rbx, %rcx
cmpq %rax, (%rbx)
je 0x1a96
leaq 0x18dc(%rip), %rdi      # 0x32aa
leaq 0x162f(%rip), %rsi      # 0x3004
leaq 0x1872(%rip), %rcx      # 0x324e
movl $0x150, %edx            # imm = 0x150
callq 0x1090
movslq 0xc(%rsp), %rax
cmpl %eax, 0x8(%rbx)
jbe 0x19ff
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
subq %rax, %r14
jbe 0x1a60
movq 0x10(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x195a
testq %rax, %rax
je 0x19f0
cmpq $0x0, 0x10(%rax)
jne 0x1a3e
cmpl $0x0, 0xc(%rax)
jne 0x1a3e
cmpq %rax, 0x10(%rbx)
jne 0x1ae7
movq (%rax), %rcx
movq %rcx, 0x10(%rbx)
movq %rax, %rdi
callq 0x1030
cmpq %rbx, 0x36a3(%rip)      # 0x50e8
jne 0x19f2
cmpq $0x0, 0x10(%rbx)
jne 0x19f2
cmpl $0x0, 0xc(%rbx)
jne 0x19f2
leaq 0x368d(%rip), %rcx      # 0x50e8
movq %rbx, %rax
jmp 0x1a96
jne 0x1ac8
cmpl $0x0, 0xc(%rbx)
je 0x19f0
movl $0x0, 0xc(%rbx)
cmpq %rbx, 0x3672(%rip)      # 0x50e8
jne 0x19f2
cmpq $0x0, 0x10(%rbx)
jne 0x19f2
leaq 0x365a(%rip), %rcx      # 0x50e8
movq %rbx, %rax
movl $0x100100, %ebx         # imm = 0x100100
movq (%rax), %rdx
movq %rdx, (%rcx)
movq %rax, %rdi
callq 0x1030
jmp 0x19f2
leaq 0x163f(%rip), %rdi      # 0x30ef
leaq 0x154d(%rip), %rsi      # 0x3004
leaq 0x1790(%rip), %rcx      # 0x324e
movl $0x113, %edx            # imm = 0x113
callq 0x1090
leaq 0x1676(%rip), %rdi      # 0x3145
leaq 0x152e(%rip), %rsi      # 0x3004
leaq 0x1771(%rip), %rcx      # 0x324e
movl $0x132, %edx            # imm = 0x132
callq 0x1090
leaq 0x17a4(%rip), %rdi      # 0x3292
leaq 0x150f(%rip), %rsi      # 0x3004
leaq 0x1752(%rip), %rcx      # 0x324e
movl $0x123, %edx            # imm = 0x123
callq 0x1090