// File: /workspace/github_c_makefile_star2_O3/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 0x1a1c
movq %rsi, %r15
movq %rdi, %rbx
movl 0x8(%rdi), %esi
cmpl $0x40, %esi
jae 0x1ad5
movq %rdx, %r14
leaq 0x18(%rbx), %rdi
leaq 0xc(%rsp), %r8
movq %r15, %rdx
movl %r14d, %ecx
callq 0x133a
testl %eax, %eax
je 0x1a12
jns 0x1a1c
movq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1986
testq %rax, %rax
je 0x1a1c
cmpq $0x0, 0x10(%rax)
jne 0x1a1e
cmpl $0x0, 0xc(%rax)
jne 0x1a1e
movq %rbx, %rcx
cmpq %rax, (%rbx)
je 0x1ac2
leaq 0x18b0(%rip), %rdi      # 0x32aa
leaq 0x1603(%rip), %rsi      # 0x3004
leaq 0x1846(%rip), %rcx      # 0x324e
movl $0x150, %edx            # imm = 0x150
callq 0x1090
movslq 0xc(%rsp), %rax
cmpl %eax, 0x8(%rbx)
jbe 0x1a2b
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
subq %rax, %r14
jbe 0x1a8c
movq 0x10(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1986
testq %rax, %rax
je 0x1a1c
cmpq $0x0, 0x10(%rax)
jne 0x1a6a
cmpl $0x0, 0xc(%rax)
jne 0x1a6a
cmpq %rax, 0x10(%rbx)
jne 0x1b13
movq (%rax), %rcx
movq %rcx, 0x10(%rbx)
movq %rax, %rdi
callq 0x1030
cmpq %rbx, 0x3677(%rip)      # 0x50e8
jne 0x1a1e
cmpq $0x0, 0x10(%rbx)
jne 0x1a1e
cmpl $0x0, 0xc(%rbx)
jne 0x1a1e
leaq 0x3661(%rip), %rcx      # 0x50e8
movq %rbx, %rax
jmp 0x1ac2
jne 0x1af4
cmpl $0x0, 0xc(%rbx)
je 0x1a1c
movl $0x0, 0xc(%rbx)
cmpq %rbx, 0x3646(%rip)      # 0x50e8
jne 0x1a1e
cmpq $0x0, 0x10(%rbx)
jne 0x1a1e
leaq 0x362e(%rip), %rcx      # 0x50e8
movq %rbx, %rax
movl $0x100100, %ebx         # imm = 0x100100
movq (%rax), %rdx
movq %rdx, (%rcx)
movq %rax, %rdi
callq 0x1030
jmp 0x1a1e
leaq 0x1613(%rip), %rdi      # 0x30ef
leaq 0x1521(%rip), %rsi      # 0x3004
leaq 0x1764(%rip), %rcx      # 0x324e
movl $0x113, %edx            # imm = 0x113
callq 0x1090
leaq 0x164a(%rip), %rdi      # 0x3145
leaq 0x1502(%rip), %rsi      # 0x3004
leaq 0x1745(%rip), %rcx      # 0x324e
movl $0x132, %edx            # imm = 0x132
callq 0x1090
leaq 0x1778(%rip), %rdi      # 0x3292
leaq 0x14e3(%rip), %rsi      # 0x3004
leaq 0x1726(%rip), %rcx      # 0x324e
movl $0x123, %edx            # imm = 0x123
callq 0x1090