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

```asm
<substitute>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x438,%rsp
  mov    %rcx,0x10(%rsp)
  lea    0x20(%rsp),%r15
  mov    %rdi,0x8(%rsp)
  mov    %rdx,%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x428(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    %rbp,%rdi
  mov    %rax,%r12
  call   <strlen@plt>
  mov    %r13,%rsi
  mov    %r15,%rdi
  mov    %rax,(%rsp)
  call   <strcpy@plt>
  mov    %r15,%rdi
  call   <make_upper_case@plt>
  lea    0x220(%rsp),%rax
  mov    %r13,%rsi
  mov    %rax,%rbx
  mov    %rax,%rdi
  mov    %rax,0x18(%rsp)
  call   <strcpy@plt>
  mov    %rbx,%rdi
  call   <make_lower_case@plt>
  movzbl (%r14),%eax
  cmp    $0x23,%al
  je     L0
  xor    %ebx,%ebx
L118:
  mov    0x10(%rsp),%r14
  mov    0x8(%rsp),%r15
  test   %al,%al
  jne    L123
  jmp    L126
  nopl   0x0(%rax,%rax,1)
L18:
  mov    %r12,%rdx
  cmp    $0x2,%ebx
  je     L60
  cmp    $0x1,%ebx
  je     L21
  mov    %r13,%rsi
  mov    %r14,%rdi
  xor    %ebx,%ebx
  call   <strncpy@plt>
L100:
  add    (%rsp),%r15
  add    %r12,%r14
  cmpb   $0x0,(%r15)
  je     L126
L123:
  mov    %rbp,%rsi
  mov    %r15,%rdi
  call   <matches@plt>
  test   %rax,%rax
  jne    L18
  movzbl (%r15),%eax
  add    $0x1,%r15
  add    $0x1,%r14
  mov    %al,-0x1(%r14)
  cmpb   $0x0,(%r15)
  jne    L123
L126:
  mov    0x10(%rsp),%rsi
  mov    0x8(%rsp),%rdi
  movb   $0x0,(%r14)
  call   <strcpy@plt>
  mov    0x428(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  add    $0x438,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L21:
  mov    0x18(%rsp),%rsi
  mov    %r14,%rdi
  xor    %ebx,%ebx
  call   <strncpy@plt>
  jmp    L100
  nopl   0x0(%rax)
L60:
  mov    %r13,%rsi
  mov    %r14,%rdi
  mov    $0x1,%ebx
  call   <strncpy@plt>
  jmp    L100
  nopl   (%rax)
L0:
  mov    0x8(%rsp),%r14
  xor    %ebx,%ebx
  mov    $0x2,%r15d
  nopl   (%rax)
L15:
  mov    %r14,%rdi
  lea    D5(%rip),%rsi
  call   <matches@plt>
  test   %rax,%rax
  cmovne %r15d,%ebx
  add    $0x1,%r14
  cmpb   $0x0,(%r14)
  jne    L15
  mov    0x8(%rsp),%rax
  movzbl (%rax),%eax
  jmp    L118
L56:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D5
type_guessed: string

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