user: Please show me the C implementation that matches the assembly code listed below:

```asm
<replace>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  push   %r13
  mov    %rcx,%r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  mov    %rdx,%rdi
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x68,%rsp
  call   <length@plt>
  mov    %r13,%rdi
  mov    %rax,%r12
  mov    %eax,0x20(%rsp)
  call   <length@plt>
  mov    %rbp,%rdi
  mov    %rax,%r14
  call   <length@plt>
  mov    %rax,%rdi
  mov    %rax,0x18(%rsp)
  movslq %r12d,%rax
  sub    %rax,%rdi
  mov    %rdi,0x8(%rsp)
  js     L387
  movslq %r14d,%r14
  lea    0x1(%r13),%rsi
  test   %rax,%rax
  mov    0x20(%rsp),%r12d
  mov    %rsi,0x30(%rsp)
  mov    %r14,%rsi
  lea    -0x1(%r14),%rdi
  setg   0x14(%rsp)
  and    $0xf,%esi
  sub    $0x1,%r12d
  xor    %ecx,%ecx
  mov    %rsi,0x50(%rsp)
  sub    $0x1,%rsi
  movzbl 0x14(%rsp),%r9d
  xor    %edx,%edx
  mov    %rsi,0x58(%rsp)
  movslq %r12d,%rsi
  mov    %rdi,0x38(%rsp)
  mov    %r14,%rdi
  movl   $0x0,0x14(%rsp)
  and    $0xfffffffffffffff0,%rdi
  mov    %rsi,0x28(%rsp)
  mov    %rdi,0x48(%rsp)
  mov    %rdi,0x40(%rsp)
  xor    %edi,%edi
L68:
  lea    0x0(%rbp,%rdx,1),%r8
  movzbl (%rbx),%esi
  cmp    %sil,(%r8)
  jne    L474
  xor    %esi,%esi
  test   %r9b,%r9b
  jne    L268
  jmp    L474
  nopl   (%rax)
L442:
  cmp    %rax,%rsi
  jge    L323
L268:
  add    $0x1,%rsi
  movzbl (%rbx,%rsi,1),%r11d
  cmp    %r11b,(%r8,%rsi,1)
  je     L442
L323:
  cmp    %rsi,%rax
  je     L167
L465:
  add    $0x1,%rdx
  cmp    0x8(%rsp),%rdx
  jle    L68
  movslq 0x14(%rsp),%r10
L415:
  mov    0x18(%rsp),%rax
  cmp    %rcx,%rax
  jl     L376
  sub    %rcx,%rax
  lea    (%r15,%rdi,1),%rsi
  mov    %rdi,%r9
  mov    %rcx,%r11
  mov    %rax,%r8
  lea    0x1(%rcx),%rax
  mov    %rsi,%rdx
  sub    %rcx,%r9
  lea    0x0(%rbp,%rax,1),%rbx
  sub    %rbx,%rdx
  cmp    $0xe,%rdx
  jbe    L597
  cmp    $0x6,%r8
  jbe    L597
  lea    0x1(%r8),%rdx
  cmp    $0xe,%r8
  jbe    L109
  mov    %rdx,%rbx
  lea    0x0(%rbp,%rcx,1),%r12
  xor    %eax,%eax
  and    $0xfffffffffffffff0,%rbx
  nopl   (%rax)
L67:
  movdqu (%r12,%rax,1),%xmm2
  movups %xmm2,(%rsi,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%rbx
  jne    L67
  mov    %rdx,%rax
  and    $0xfffffffffffffff0,%rax
  add    %rax,%rcx
  cmp    %rdx,%rax
  je     L376
  sub    %rax,%r8
  lea    0x1(%r8),%rdx
  cmp    $0x6,%r8
  jbe    L54
L614:
  lea    0x0(%rbp,%rax,1),%rsi
  add    %r15,%rax
  mov    (%rsi,%r11,1),%rsi
  mov    %rsi,(%rax,%rdi,1)
  mov    %rdx,%rax
  and    $0xfffffffffffffff8,%rax
  add    %rax,%rcx
  cmp    %rax,%rdx
  je     L376
L54:
  movzbl 0x0(%rbp,%rcx,1),%edx
  lea    (%r15,%rcx,1),%rax
  mov    0x18(%rsp),%rdi
  mov    %dl,(%rax,%r9,1)
  lea    0x1(%rcx),%rax
  cmp    %rax,%rdi
  jl     L376
  movzbl 0x1(%rbp,%rcx,1),%edx
  add    %r15,%rax
  mov    %dl,(%rax,%r9,1)
  lea    0x2(%rcx),%rax
  cmp    %rdi,%rax
  jg     L376
  movzbl 0x2(%rbp,%rcx,1),%edx
  add    %r15,%rax
  mov    %dl,(%rax,%r9,1)
  lea    0x3(%rcx),%rdx
  cmp    %rdx,%rdi
  jl     L376
  movzbl 0x3(%rbp,%rcx,1),%esi
  lea    (%r15,%r9,1),%rax
  lea    0x4(%rcx),%rdx
  mov    %sil,0x3(%rax,%rcx,1)
  cmp    %rdi,%rdx
  jg     L376
  movzbl 0x4(%rbp,%rcx,1),%esi
  lea    0x5(%rcx),%rdx
  mov    %sil,0x4(%rax,%rcx,1)
  cmp    %rdx,%rdi
  jl     L376
  movzbl 0x5(%rbp,%rcx,1),%esi
  mov    %sil,0x5(%rax,%rcx,1)
  lea    0x6(%rcx),%rax
  cmp    %rax,%rdi
  jl     L376
  movzbl 0x6(%rbp,%rcx,1),%edx
  add    %r15,%rax
  mov    %dl,(%rax,%r9,1)
L376:
  add    $0x68,%rsp
  mov    %r10,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L167:
  addl   $0x1,0x14(%rsp)
  cmp    %rcx,%rdx
  jle    L25
  lea    (%r15,%rdi,1),%r10
  mov    %rdi,%rsi
  lea    0x1(%rbp,%rcx,1),%r12
  mov    %rdx,%r8
  mov    %r10,%r11
  sub    %rcx,%rsi
  sub    %rcx,%r8
  sub    %r12,%r11
  mov    %rsi,0x20(%rsp)
  lea    -0x1(%r8),%rsi
  cmp    $0xe,%r11
  jbe    L272
  cmp    $0x6,%rsi
  jbe    L272
  cmp    $0xe,%rsi
  jbe    L408
  mov    %r8,%r11
  lea    0x0(%rbp,%rcx,1),%r12
  xor    %esi,%esi
  and    $0xfffffffffffffff0,%r11
  xchg   %ax,%ax
L570:
  movdqu (%r12,%rsi,1),%xmm0
  movups %xmm0,(%r10,%rsi,1)
  add    $0x10,%rsi
  cmp    %r11,%rsi
  jne    L570
  mov    %r8,%r10
  and    $0xfffffffffffffff0,%r10
  lea    (%r10,%rcx,1),%rsi
  cmp    %r10,%r8
  je     L25
  sub    %r10,%r8
  lea    -0x1(%r8),%r11
  cmp    $0x6,%r11
  jbe    L495
L40:
  lea    0x0(%rbp,%r10,1),%r11
  add    %r15,%r10
  mov    (%r11,%rcx,1),%r11
  mov    %r11,(%r10,%rdi,1)
  mov    %r8,%r10
  and    $0xfffffffffffffff8,%r10
  add    %r10,%rsi
  cmp    %r10,%r8
  je     L25
L495:
  mov    0x20(%rsp),%r8
  movzbl 0x0(%rbp,%rsi,1),%r10d
  add    %r15,%r8
  mov    %r10b,(%r8,%rsi,1)
  lea    0x1(%rsi),%r10
  cmp    %r10,%rdx
  jle    L25
  movzbl 0x1(%rbp,%rsi,1),%r11d
  lea    0x2(%rsi),%r10
  mov    %r11b,0x1(%rsi,%r8,1)
  cmp    %r10,%rdx
  jle    L25
  movzbl 0x2(%rbp,%rsi,1),%r11d
  lea    0x3(%rsi),%r10
  mov    %r11b,0x2(%rsi,%r8,1)
  cmp    %r10,%rdx
  jle    L25
  movzbl 0x3(%rbp,%rsi,1),%r11d
  lea    0x4(%rsi),%r10
  mov    %r11b,0x3(%rsi,%r8,1)
  cmp    %r10,%rdx
  jle    L25
  movzbl 0x4(%rbp,%rsi,1),%r11d
  lea    0x5(%rsi),%r10
  mov    %r11b,0x4(%rsi,%r8,1)
  cmp    %r10,%rdx
  jle    L25
  movzbl 0x5(%rbp,%rsi,1),%r11d
  lea    0x6(%rsi),%r10
  mov    %r11b,0x5(%rsi,%r8,1)
  cmp    %r10,%rdx
  jle    L25
  movzbl 0x6(%rbp,%rsi,1),%esi
  mov    %sil,(%r8,%r10,1)
L25:
  mov    %rdx,%r8
  sub    %rcx,%r8
  add    %rdi,%r8
  test   %r14,%r14
  jle    L90
  add    %rdx,%rdi
  sub    %rcx,%rdi
  lea    (%r15,%rdi,1),%rsi
  mov    %rsi,%rcx
  sub    0x30(%rsp),%rcx
  cmp    $0xe,%rcx
  jbe    L588
  mov    0x38(%rsp),%rcx
  cmp    $0x6,%rcx
  jbe    L588
  cmp    $0xe,%rcx
  jbe    L358
  mov    0x48(%rsp),%r10
  xor    %ecx,%ecx
  xchg   %ax,%ax
L244:
  movdqu 0x0(%r13,%rcx,1),%xmm1
  movups %xmm1,(%rsi,%rcx,1)
  add    $0x10,%rcx
  cmp    %rcx,%r10
  jne    L244
  mov    0x40(%rsp),%rcx
  cmp    %rcx,%r14
  je     L90
  cmpq   $0x6,0x58(%rsp)
  mov    0x50(%rsp),%r10
  jbe    L354
  mov    %rcx,%rsi
L581:
  mov    0x0(%r13,%rsi,1),%r11
  add    %r15,%rsi
  mov    %r11,(%rsi,%rdi,1)
  mov    %r10,%rsi
  and    $0xfffffffffffffff8,%rsi
  add    %rsi,%rcx
  cmp    %rsi,%r10
  je     L90
L354:
  movzbl 0x0(%r13,%rcx,1),%edi
  lea    (%r15,%r8,1),%rsi
  mov    %dil,(%rsi,%rcx,1)
  lea    0x1(%rcx),%rdi
  cmp    %rdi,%r14
  jle    L90
  movzbl 0x1(%r13,%rcx,1),%r10d
  lea    0x2(%rcx),%rdi
  mov    %r10b,0x1(%rcx,%rsi,1)
  cmp    %rdi,%r14
  jle    L90
  movzbl 0x2(%r13,%rcx,1),%r10d
  lea    0x3(%rcx),%rdi
  mov    %r10b,0x2(%rcx,%rsi,1)
  cmp    %rdi,%r14
  jle    L90
  movzbl 0x3(%r13,%rcx,1),%r10d
  lea    0x4(%rcx),%rdi
  mov    %r10b,0x3(%rcx,%rsi,1)
  cmp    %rdi,%r14
  jle    L90
  movzbl 0x4(%r13,%rcx,1),%r10d
  lea    0x5(%rcx),%rdi
  mov    %r10b,0x4(%rcx,%rsi,1)
  cmp    %rdi,%r14
  jle    L90
  movzbl 0x5(%r13,%rcx,1),%r10d
  lea    0x6(%rcx),%rdi
  mov    %r10b,0x5(%rcx,%rsi,1)
  cmp    %rdi,%r14
  jle    L90
  movzbl 0x6(%r13,%rcx,1),%ecx
  mov    %cl,(%rsi,%rdi,1)
L90:
  lea    (%rax,%rdx,1),%rcx
  lea    (%r8,%r14,1),%rdi
  add    0x28(%rsp),%rdx
  jmp    L465
  nopw   0x0(%rax,%rax,1)
L474:
  xor    %esi,%esi
  jmp    L323
L588:
  xor    %ecx,%ecx
  lea    (%r15,%r8,1),%rdi
  nopl   (%rax)
L164:
  movzbl 0x0(%r13,%rcx,1),%esi
  mov    %sil,(%rdi,%rcx,1)
  add    $0x1,%rcx
  cmp    %rcx,%r14
  jne    L164
  lea    (%rax,%rdx,1),%rcx
  lea    (%r8,%r14,1),%rdi
  add    0x28(%rsp),%rdx
  jmp    L465
L272:
  mov    0x20(%rsp),%r10
  mov    %rcx,%rsi
  lea    (%r15,%r10,1),%r8
  nopl   0x0(%rax)
L589:
  movzbl 0x0(%rbp,%rsi,1),%r10d
  mov    %r10b,(%r8,%rsi,1)
  add    $0x1,%rsi
  cmp    %rsi,%rdx
  jne    L589
  jmp    L25
L597:
  mov    0x18(%rsp),%rdi
  lea    (%r15,%r9,1),%rsi
  add    $0x1,%rdi
  jmp    L123
  nop
L482:
  add    $0x1,%rax
L123:
  movzbl 0x0(%rbp,%rcx,1),%edx
  mov    %dl,(%rsi,%rcx,1)
  mov    %rax,%rcx
  cmp    %rax,%rdi
  jne    L482
  jmp    L376
L387:
  xor    %r10d,%r10d
  xor    %edi,%edi
  xor    %ecx,%ecx
  jmp    L415
L408:
  mov    %rcx,%rsi
  xor    %r10d,%r10d
  jmp    L40
L358:
  mov    %r14,%r10
  xor    %esi,%esi
  xor    %ecx,%ecx
  jmp    L581
L109:
  xor    %eax,%eax
  jmp    L614
```

assistant: ```c
long replace(char *str, char *str2, char *s, char *t) {
  int ls, lt, c;
  long a, b, fl, f, e, m;
  ls = length(s);
  lt = length(t);
  fl = length(str);
  c = 0;
  f = 0;
  e = 0;
  for (a = 0; a <= fl - ls; a++) {
    b = 0;
    while (*(str + a + b) == *(s + b) && b < ls)
      b++;
    if (b == ls) {
      c++;
      for (m = f; m < a; m++)
        *(str2 + e + m - f) = *(str + m);
      e += a - f;
      for (m = 0; m < lt; m++)
        *(str2 + e + m) = *(t + m);
      e += lt;
      f = a + ls;
      a += ls - 1;
    }
  }
  for (m = f; m <= fl; m++)
    *(str2 + e + m - f) = *(str + m);
  return c;
}
```