user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<substitute>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x460,%rsp
  mov    %rdi,-0x448(%rbp)
  mov    %rsi,-0x450(%rbp)
  mov    %rdx,-0x458(%rbp)
  mov    %rcx,-0x460(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x434(%rbp)
  mov    -0x458(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x420(%rbp)
  mov    -0x450(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x418(%rbp)
  mov    -0x458(%rbp),%rdx
  lea    -0x410(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    -0x410(%rbp),%rax
  mov    %rax,%rdi
  call   <make_upper_case@plt>
  mov    -0x458(%rbp),%rdx
  lea    -0x210(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    -0x210(%rbp),%rax
  mov    %rax,%rdi
  call   <make_lower_case@plt>
  mov    -0x448(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x23,%al
  jne    L5
  mov    -0x448(%rbp),%rax
  mov    %rax,-0x430(%rbp)
  jmp    L77
L125:
  mov    -0x430(%rbp),%rax
  lea    D6(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <matches@plt>
  test   %rax,%rax
  je     L30
  movl   $0x2,-0x434(%rbp)
L30:
  addq   $0x1,-0x430(%rbp)
L77:
  mov    -0x430(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L125
L5:
  mov    -0x448(%rbp),%rax
  mov    %rax,-0x430(%rbp)
  mov    -0x460(%rbp),%rax
  mov    %rax,-0x428(%rbp)
  jmp    L73
L6:
  mov    -0x450(%rbp),%rdx
  mov    -0x430(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <matches@plt>
  test   %rax,%rax
  je     L111
  cmpl   $0x2,-0x434(%rbp)
  jne    L23
  mov    -0x420(%rbp),%rdx
  mov    -0x458(%rbp),%rcx
  mov    -0x428(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  subl   $0x1,-0x434(%rbp)
  jmp    L93
L23:
  cmpl   $0x1,-0x434(%rbp)
  jne    L81
  mov    -0x420(%rbp),%rdx
  lea    -0x210(%rbp),%rcx
  mov    -0x428(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  subl   $0x1,-0x434(%rbp)
  jmp    L93
L81:
  mov    -0x420(%rbp),%rdx
  mov    -0x458(%rbp),%rcx
  mov    -0x428(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
L93:
  mov    -0x420(%rbp),%rax
  add    %rax,-0x428(%rbp)
  mov    -0x418(%rbp),%rax
  add    %rax,-0x430(%rbp)
  jmp    L73
L111:
  mov    -0x430(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x428(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x430(%rbp)
  addq   $0x1,-0x428(%rbp)
L73:
  mov    -0x430(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L6
  mov    -0x428(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x460(%rbp),%rdx
  mov    -0x448(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L116
  call   <__stack_chk_fail@plt>
L116:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D6
type: string

tool: D6: define

assistant: ```c
void substitute(char *str, char *match, char *replace, char *result) {
  char *p, *q;
  char allup[512], alllo[512];
  size_t n, m;
  int nmatch = 0;
  n = strlen(replace);
  m = strlen(match);
  strcpy(allup, replace);
  make_upper_case(allup);
  strcpy(alllo, replace);
  make_lower_case(alllo);
  if (str[0] == '#') {
    for (p = str; *p; p++) {
      if (matches(p, "define"))
        nmatch = 2;
    }
  }
  for (p = str, q = result; *p;) {
    if (matches(p, match)) {
      if (nmatch == 2) {
        strncpy(q, replace, n);
        nmatch--;
      } else if (nmatch == 1) {
        strncpy(q, alllo, n);
        nmatch--;
      } else {
        strncpy(q, replace, n);
      }
      q += n;
      p += m;
    } else {
      *q = *p;
      p++;
      q++;
    }
  }
  *q = '\0';
  strcpy(str, result);
}
```