// File: /workspace/github_c_makefile_star2_O0/neovim[P]libtermkey/driver-ti.c
// Function: insert_seq
static int insert_seq(TermKeyTI *ti, const char *seq, struct trie_node *node)
{
  int pos = 0;
  struct trie_node *p = ti->root;

  // Unsigned because we'll be using it as an array subscript
  unsigned char b;

  while((b = seq[pos])) {
    struct trie_node *next = lookup_next(p, b);
    if(!next)
      break;
    p = next;
    pos++;
  }

  while((b = seq[pos])) {
    struct trie_node *next;
    if(seq[pos+1])
      // Intermediate node
      next = new_node_arr(0, 0xff);
    else
      // Final key node
      next = node;

    if(!next)
      return 0;

    switch(p->type) {
    case TYPE_ARR:
      {
        struct trie_node_arr *nar = (struct trie_node_arr*)p;
        if(b < nar->min || b > nar->max) {
          fprintf(stderr, "ASSERT FAIL: Trie insert at 0x%02x is outside of extent bounds (0x%02x..0x%02x)\n",
              b, nar->min, nar->max);
          abort();
        }
        nar->arr[b - nar->min] = next;
        p = next;
        break;
      }
    case TYPE_KEY:
      fprintf(stderr, "ASSERT FAIL: Tried to insert child node in TYPE_KEY\n");
      abort();
    }

    pos++;
  }

  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x31(%rbp)
cmpb $0x0, %al
je 0x90b6
movq -0x30(%rbp), %rdi
movzbl -0x31(%rbp), %esi
callq 0x9350
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x90a3
jmp 0x90b6
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9077
jmp 0x90b8
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x31(%rbp)
cmpb $0x0, %al
je 0x91dc
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpb $0x0, (%rax,%rcx)
je 0x90f3
xorl %edi, %edi
movl $0xff, %esi
callq 0x8e50
movq %rax, -0x48(%rbp)
jmp 0x90fb
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x910e
movl $0x0, -0x4(%rbp)
jmp 0x91e3
movq -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x54(%rbp)
testl %eax, %eax
je 0x91b1
jmp 0x9121
movl -0x54(%rbp), %eax
subl $0x1, %eax
jne 0x91ce
jmp 0x912f
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movzbl -0x31(%rbp), %eax
movq -0x50(%rbp), %rcx
movzbl 0x4(%rcx), %ecx
cmpl %ecx, %eax
jl 0x9157
movzbl -0x31(%rbp), %eax
movq -0x50(%rbp), %rcx
movzbl 0x5(%rcx), %ecx
cmpl %ecx, %eax
jle 0x9189
movq 0x3e9a(%rip), %rax      # 0xcff8
movq (%rax), %rdi
movzbl -0x31(%rbp), %edx
movq -0x50(%rbp), %rax
movzbl 0x4(%rax), %ecx
movq -0x50(%rbp), %rax
movzbl 0x5(%rax), %r8d
leaq 0x1347(%rip), %rsi      # 0xa4c4
movb $0x0, %al
callq 0x3190
callq 0x3080
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rax
movzbl -0x31(%rbp), %ecx
movq -0x50(%rbp), %rsi
movzbl 0x4(%rsi), %esi
subl %esi, %ecx
movslq %ecx, %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x91ce
movq 0x3e40(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x1353(%rip), %rsi      # 0xa515
movb $0x0, %al
callq 0x3190
callq 0x3080
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x90b8
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)