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

```asm
<str_replace_first>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  movl   $0x0,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x8(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x10(%rbp)
L120:
  addl   $0x1,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L120
L27:
  addl   $0x1,-0x8(%rbp)
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L27
  mov    -0x8(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  je     L117
  lea    D1(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L30
L117:
  addl   $0x1,-0x10(%rbp)
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L117
  movl   $0x0,-0x18(%rbp)
  jmp    L54
L138:
  movl   $0x0,-0x14(%rbp)
  jmp    L132
L22:
  mov    -0x18(%rbp),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x14(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  je     L51
  movl   $0x0,-0x4(%rbp)
  jmp    L115
L51:
  movl   $0x1,-0x4(%rbp)
  addl   $0x1,-0x14(%rbp)
L132:
  mov    -0x14(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jl     L22
L115:
  cmpl   $0x0,-0x4(%rbp)
  je     L34
  movl   $0x0,-0x14(%rbp)
  jmp    L104
L66:
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    -0x18(%rbp),%ecx
  mov    -0x14(%rbp),%edx
  add    %ecx,%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x14(%rbp)
L104:
  mov    -0x14(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jl     L66
L34:
  addl   $0x1,-0x18(%rbp)
L54:
  mov    -0x18(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L138
  mov    -0x28(%rbp),%rax
  mov    %rax,%rsi
  lea    D17(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L30:
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D1
type_guessed: string
name: disassemble_data
arguments: tag: D17
type_guessed: string

tool: D1: Les chaines de recherche et de remplacement ne correspondent pas

tool: D17: %s

assistant: ```c
void str_replace_first(char *string, char *pattern, char *replacement) {
  int i, j, tailleS, tailleP, tailleR, trouve;
  tailleS = tailleP = tailleR = trouve = 0;
  do {
    tailleP++;
  } while (pattern[tailleP] != '\0');
  do {
    tailleR++;
  } while (replacement[tailleR] != '\0');
  if (tailleR != tailleP) {
    printf("Les chaines de recherche et de remplacement ne correspondent pas");
  } else {
    do {
      tailleS++;
    } while (string[tailleS] != '\0');
    for (i = 0; i < tailleS; i++) {
      for (j = 0; j < tailleP; j++) {
        if (string[i + j] != pattern[j]) {
          trouve = 0;
          break;
        } else {
          trouve = 1;
        }
      }
      if (trouve) {
        for (j = 0; j < tailleP; j++) {
          string[i + j] = replacement[j];
        }
      }
    }
    printf("%s", string);
  }
}
```