user: 请将以下的汇编代码转换成C语言代码:

```asm
<strsub>:
  endbr64
  push   %r15
  mov    $0xff,%ecx
  mov    %rdi,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x818,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x808(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rbp
  test   %rsi,%rsi
  mov    %rbp,%rdi
  rep stos %rax,%es:(%rdi)
  sete   %al
  test   %rdx,%rdx
  sete   %dl
  or     %dl,%al
  jne    L23
  test   %r15,%r15
  je     L23
  mov    %rsi,%r12
  mov    %r15,%rdi
  call   <strlen@plt>
  mov    %r12,%rdi
  mov    %eax,0xc(%rsp)
  mov    %eax,%ebx
  call   <strlen@plt>
  mov    %r14,%rdi
  mov    %eax,0x8(%rsp)
  mov    %eax,%r13d
  call   <strlen@plt>
  mov    %eax,0x4(%rsp)
  cmp    %r13d,%ebx
  jl     L23
  mov    %r15,%rdi
  xor    %ebx,%ebx
  jmp    L14
  nopw   0x0(%rax,%rax,1)
L158:
  mov    %r12,%rdi
  call   <strlen@plt>
  cltq
  lea    0x0(%r13,%rax,1),%rdi
L14:
  mov    %r12,%rsi
  mov    %ebx,(%rsp)
  call   <strstr@plt>
  mov    %rax,0x0(%rbp,%rbx,8)
  mov    %rax,%r13
  add    $0x1,%rbx
  test   %rax,%rax
  jne    L158
  mov    (%rsp),%eax
  test   %eax,%eax
  je     L23
  mov    0x4(%rsp),%edi
  sub    0x8(%rsp),%edi
  imul   %eax,%edi
  add    0xc(%rsp),%edi
  call   <malloc@plt>
  mov    %rax,%r10
  test   %rax,%rax
  je     L23
  mov    (%rsp),%eax
  movslq 0x8(%rsp),%r8
  mov    %r10,%rdx
  mov    0x4(%rsp),%esi
  sub    $0x1,%eax
  lea    0x18(%rsp,%rax,8),%rbx
  nopl   (%rax)
L39:
  mov    0x0(%rbp),%r11
  xor    %eax,%eax
  mov    %r11,%rdi
  sub    %r15,%rdi
  cmp    %r15,%r11
  jbe    L0
  nopl   (%rax)
L55:
  movzbl (%r15,%rax,1),%ecx
  mov    %cl,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rdi,%rax
  jne    L55
  add    %rax,%rdx
L122:
  mov    0x4(%rsp),%eax
  test   %eax,%eax
  je     L94
  xor    %eax,%eax
  cs nopw 0x0(%rax,%rax,1)
L80:
  movzbl (%r14,%rax,1),%ecx
  mov    %cl,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L80
  add    %rsi,%rdx
L94:
  add    $0x8,%rbp
  lea    (%r11,%r8,1),%r15
  cmp    %rbx,%rbp
  jne    L39
  jmp    L148
  nopl   0x0(%rax,%rax,1)
L23:
  xor    %r10d,%r10d
L5:
  mov    0x808(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L134
  add    $0x818,%rsp
  mov    %r10,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L145:
  mov    %al,(%rdx)
  add    $0x1,%rdx
  add    $0x1,%r15
L148:
  movzbl (%r15),%eax
  test   %al,%al
  jne    L145
  movb   $0x0,(%rdx)
  jmp    L5
  nop
L0:
  mov    %r15,%r11
  jmp    L122
L134:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *strsub(char *str, char *old, char *new) {
  int tl, ol, nl, sl, i = 0, j;
  char *gs[255] = {
      NULL,
  };
  char *sp = str;
  char *tn;
  char *tnp;
  if (str == NULL || old == NULL || new == NULL)
    return NULL;
  sl = strlen(str);
  ol = strlen(old);
  nl = strlen(new);
  if (sl < ol)
    return NULL;
  while (gs[i] = strstr(sp, old))
    sp = gs[i++] + strlen(old);
  if (i == 0)
    return NULL;
  tl = sl + i * (nl - ol);
  tn = (char *)malloc(tl);
  if (tn == NULL)
    return NULL;
  sp = str;
  tnp = tn;
  j = 0;
  while (j < i) {
    int tmp = nl;
    char *np = new;
    while (sp < gs[j])
      *tnp++ = *sp++;
    while (tmp--)
      *tnp++ = *np++;
    sp = sp + ol;
    j++;
  }
  while (*sp != '\0')
    *tnp++ = *sp++;
  *tnp = '\0';
  return tn;
}
```