user: Translate the below assembly code into C programming language:

```asm
<gui_completion_build_list_template>:
  endbr64
  push   %r15
  push   %r14
  lea    D7(%rip),%r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %rdi,%r12
  mov    %rsi,%rdi
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  call   <strdup@plt>
  mov    %rax,%r15
  jmp    L108
  nopl   0x0(%rax)
L72:
  test   $0xdf,%al
  je     L118
L54:
  movslq %ebp,%rdx
  add    $0x1,%ebp
  mov    %al,(%r15,%rdx,1)
L87:
  test   $0xdf,%al
  je     L209
L164:
  add    $0x1,%rbx
L108:
  movzbl (%rbx),%eax
  cmp    $0x25,%al
  je     L38
  jle    L72
  cmp    $0x7c,%al
  jne    L54
  test   %ebp,%ebp
  je     L164
  jmp    L131
  nopl   0x0(%rax)
L38:
  movzbl 0x1(%rbx),%eax
  lea    0x1(%rbx),%rdx
  test   %al,%al
  jne    L82
L209:
  add    $0x18,%rsp
  mov    %r15,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10b0 <free@plt>
  nopw   0x0(%rax,%rax,1)
L118:
  test   %ebp,%ebp
  je     L209
L131:
  movslq %ebp,%rbp
  mov    %r14,%rcx
  xor    %edx,%edx
  mov    %r15,%rsi
  mov    %r12,%rdi
  movb   $0x0,(%r15,%rbp,1)
  xor    %ebp,%ebp
  call   <gui_completion_list_add@plt>
  movzbl (%rbx),%eax
  jmp    L87
  nopl   0x0(%rax,%rax,1)
L82:
  cmp    $0x28,%al
  je     L157
  cmp    $0x2d,%al
  jne    L109
  mov    %r12,%rdi
  call   <gui_completion_stop@plt>
  jmp    L209
  nopw   0x0(%rax,%rax,1)
L109:
  mov    %rdx,%rbx
  jmp    L87
  nopl   0x0(%rax,%rax,1)
L157:
  lea    0x2(%rbx),%rdi
  mov    $0x29,%esi
  mov    %rdi,0x8(%rsp)
  call   <strchr@plt>
  mov    0x8(%rsp),%rdi
  test   %rax,%rax
  mov    %rax,%rcx
  je     L199
  cmp    %rax,%rdi
  jb     L23
L183:
  movzbl 0x1(%rcx),%eax
  lea    0x1(%rcx),%rbx
  jmp    L87
  nopw   0x0(%rax,%rax,1)
L199:
  movzbl 0x2(%rbx),%eax
  mov    %rdi,%rbx
  jmp    L87
  nopl   0x0(%rax)
L23:
  mov    %eax,%esi
  mov    %rax,0x8(%rsp)
  sub    %edi,%esi
  call   <string_strndup@plt>
  mov    0x8(%rsp),%rcx
  test   %rax,%rax
  mov    %rax,%rbx
  je     L183
  mov    %r13,%rdx
  mov    %rax,%rsi
  mov    %r12,%rdi
  call   <gui_completion_custom@plt>
  mov    %rbx,%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rcx
  jmp    L183
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D7
type: string

tool: D7: 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);
}
```