user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<replaceNWord>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %ecx,-0x5c(%rbp)
  movl   $0x0,-0x30(%rbp)
  movl   $0x0,-0x2c(%rbp)
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x24(%rbp)
  movl   $0x0,-0x20(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movq   $0x0,-0x8(%rbp)
  movl   $0x0,-0x18(%rbp)
  movl   $0x0,-0x14(%rbp)
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0xc(%rbp)
  movb   $0x0,-0x31(%rbp)
  cmpq   $0x0,-0x48(%rbp)
  je     L162
  cmpq   $0x0,-0x50(%rbp)
  je     L162
  cmpq   $0x0,-0x58(%rbp)
  je     L162
  cmpl   $0x0,-0x5c(%rbp)
  jne    L7
L162:
  mov    $0x0,%eax
  jmp    L105
L7:
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x18(%rbp)
  mov    -0x50(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <countWordInBuff@plt>
  mov    %eax,-0x30(%rbp)
  cmpl   $0x0,-0x5c(%rbp)
  jle    L126
  mov    -0x5c(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jg     L126
  mov    -0x5c(%rbp),%eax
  mov    %eax,-0x30(%rbp)
L126:
  cmpl   $0x0,-0x30(%rbp)
  jne    L11
  mov    $0x0,%eax
  jmp    L105
L11:
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0xc(%rbp),%eax
  sub    -0x14(%rbp),%eax
  imul   -0x30(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    $0x0,%r8d
  mov    %rax,%rcx
  lea    D17(%rip),%rax
  mov    %rax,%rdx
  lea    D10(%rip),%rax
  mov    %rax,%rsi
  mov    $0x86,%edi
  call   <printOpt@plt>
  cmpq   $0x0,-0x8(%rbp)
  jne    L139
  mov    $0x0,%eax
  jmp    L105
L139:
  movl   $0x0,-0x28(%rbp)
  jmp    L246
L240:
  mov    -0x1c(%rbp),%eax
  cmp    -0x5c(%rbp),%eax
  jl     L150
  cmpl   $0x0,-0x5c(%rbp)
  jns    L144
L150:
  mov    $0x1,%eax
  jmp    L108
L144:
  mov    $0x0,%eax
L108:
  mov    %al,-0x31(%rbp)
  mov    -0x28(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x24(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L107
  mov    -0x24(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L107
  cmpb   $0x0,-0x31(%rbp)
  je     L107
  cmpl   $0x0,-0x24(%rbp)
  jne    L21
  cmpl   $0x1,-0x14(%rbp)
  jle    L21
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  jmp    L225
L21:
  mov    -0x24(%rbp),%eax
  add    $0x1,%eax
  cmp    %eax,-0x14(%rbp)
  jne    L225
  movl   $0x0,-0x24(%rbp)
  jmp    L258
L169:
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  movzbl (%rcx),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x24(%rbp)
L258:
  mov    -0x24(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jl     L169
  addl   $0x1,-0x1c(%rbp)
L225:
  addl   $0x1,-0x24(%rbp)
  jmp    L219
L107:
  mov    -0x24(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L232
  cmpl   $0x0,-0x24(%rbp)
  jle    L232
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  movl   $0x0,-0x24(%rbp)
  mov    -0x28(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  movzbl (%rcx),%eax
  mov    %al,(%rdx)
  jmp    L219
L232:
  mov    -0x28(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  movzbl (%rcx),%eax
  mov    %al,(%rdx)
  movl   $0x0,-0x24(%rbp)
L219:
  addl   $0x1,-0x28(%rbp)
L246:
  mov    -0x28(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L240
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
L105:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D17
type: string
name: unpack_data
arguments: data_label: D10
type: string

tool: D17: replaceWord.c

tool: D10: replaceNWord

assistant: ```c
char *replaceNWord(const char *buffer, const char *old, const char *nw, int count) {
  int numOldWord = 0;
  int firstPos = 0;
  int index = 0, index2 = 0, index3 = 0;
  int numRep = 0;
  char *newBuff = NULL;
  int sizeOldBuff = 0;
  int sizeOldWord = 0;
  int sizeNewBuff = 0;
  int sizeNewWord = 0;
  char fact1 = 0;
  if (buffer == NULL || old == NULL || nw == NULL || count == 0) {
    return NULL;
  } else {
  }
  sizeOldWord = strlen(old);
  sizeNewWord = strlen(nw);
  sizeOldBuff = strlen(buffer);
  numOldWord = countWordInBuff(buffer, old);
  if (count > 0 && count <= numOldWord) {
    numOldWord = count;
  } else {
  }
  if (numOldWord == 0) {
    return 0;
  } else {
  }
  sizeNewBuff = 1 + sizeOldBuff + (sizeNewWord - sizeOldWord) * numOldWord;
  newBuff = (char *)malloc(sizeof(char) * sizeNewBuff);
  printOpt(135 - 1, "replaceNWord", "replaceWord.c", (void *)newBuff, 0);
  if (newBuff == NULL) {
    return NULL;
  } else {
  }
  for (index = 0; index < sizeOldBuff; index++) {
    fact1 = (numRep < count) || count < 0;
    if (buffer[index] == old[index2] && index2 < sizeOldWord && fact1) {
      if (index2 == 0 && sizeOldWord > 1) {
        firstPos = index;
      } else if (index2 + 1 == sizeOldWord) {
        for (index2 = 0; index2 < sizeNewWord; index2++) {
          newBuff[index3++] = nw[index2];
        }
        numRep++;
      } else {
      }
      index2++;
    } else if (index2 < sizeOldWord && index2 > 0) {
      index = firstPos;
      index2 = 0;
      newBuff[index3++] = buffer[index];
    } else {
      newBuff[index3++] = buffer[index];
      index2 = 0;
    }
  }
  newBuff[index3] = '\0';
  return newBuff;
}
```