user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<gui_completion_build_list_template>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  mov    %rax,-0x18(%rbp)
  movl   $0x0,-0x24(%rbp)
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  jmp    L77
L207:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    $0x7c,%eax
  je     L264
  cmp    $0x7c,%eax
  jg     L30
  cmp    $0x25,%eax
  je     L16
  cmp    $0x25,%eax
  jg     L30
  test   %eax,%eax
  je     L264
  cmp    $0x20,%eax
  jne    L30
L264:
  cmpl   $0x0,-0x24(%rbp)
  jle    L112
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rsi
  mov    -0x38(%rbp),%rax
  lea    D9(%rip),%rdx
  mov    %rdx,%rcx
  mov    $0x0,%edx
  mov    %rax,%rdi
  call   <gui_completion_list_add@plt>
L112:
  movl   $0x0,-0x24(%rbp)
  jmp    L63
L16:
  addq   $0x1,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L195
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L195
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    $0x2d,%eax
  je     L237
  cmp    $0x2d,%eax
  jg     L195
  cmp    $0x28,%eax
  je     L222
  cmp    $0x2a,%eax
  je     L162
  jmp    L195
L237:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <gui_completion_stop@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  jmp    L125
L222:
  addq   $0x1,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  mov    $0x29,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  je     L195
  mov    -0x10(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  jbe    L157
  mov    -0x10(%rbp),%rax
  sub    -0x20(%rbp),%rax
  mov    %eax,%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <string_strndup@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L157
  mov    -0x48(%rbp),%rdx
  mov    -0x8(%rbp),%rcx
  mov    -0x38(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <gui_completion_custom@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L157:
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x20(%rbp)
  jmp    L195
L162:
  nop
  jmp    L195
L30:
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24(%rbp)
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  jmp    L63
L195:
  nop
L63:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L107
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  jne    L266
L107:
  movq   $0x0,-0x20(%rbp)
  jmp    L77
L266:
  addq   $0x1,-0x20(%rbp)
L77:
  cmpq   $0x0,-0x20(%rbp)
  jne    L207
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L125:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D9
type_guessed: string

tool: D9: sort

assistant: ```c
void gui_completion_build_list_template(struct t_gui_completion *completion, const char *template, struct t_dogechat_plugin *plugin) {
  char *word, *custom_completion;
  const char *pos, *pos_end;
  int word_offset;
  word = strdup(template);
  word_offset = 0;
  pos = template;
  while (pos) {
    switch (pos[0]) {
    case '\0':
    case ' ':
    case '|':
      if (word_offset > 0) {
        word[word_offset] = '\0';
        gui_completion_list_add(completion, word, 0, "sort");
      }
      word_offset = 0;
      break;
    case '%':
      pos++;
      if (pos && pos[0]) {
        switch (pos[0]) {
        case '-':
          gui_completion_stop(completion);
          free(word);
          return;
          break;
        case '*':
          break;
        case '(':
          pos++;
          pos_end = strchr(pos, ')');
          if (pos_end) {
            if (pos_end > pos) {
              custom_completion = string_strndup(pos, pos_end - pos);
              if (custom_completion) {
                gui_completion_custom(completion, custom_completion, plugin);
                free(custom_completion);
              }
            }
            pos = pos_end + 1;
          }
        }
      }
      break;
    default:
      word[word_offset++] = pos[0];
    }
    if (!pos[0] || (pos[0] == ' '))
      pos = NULL;
    else
      pos++;
  }
  free(word);
}
```