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

```asm
<escape_spaces>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L128
  mov    $0x0,%eax
  jmp    L98
L128:
  movq   $0x0,-0x18(%rbp)
  movq   $0x0,-0x10(%rbp)
  jmp    L132
L58:
  mov    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  jne    L84
  addq   $0x3,-0x18(%rbp)
  jmp    L21
L84:
  addq   $0x1,-0x18(%rbp)
L21:
  addq   $0x1,-0x10(%rbp)
L132:
  mov    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L58
  cmpq   $0x0,-0x18(%rbp)
  je     L69
  mov    -0x18(%rbp),%rax
  cmp    -0x10(%rbp),%rax
  jne    L78
L69:
  mov    -0x28(%rbp),%rax
  jmp    L98
L78:
  mov    -0x28(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x8(%rbp)
  subq   $0x1,-0x10(%rbp)
  jmp    L63
L104:
  mov    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  jne    L131
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rax
  movb   $0x30,(%rax)
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rax
  movb   $0x32,(%rax)
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rax
  movb   $0x25,(%rax)
  jmp    L29
L131:
  mov    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x28(%rbp),%rdx
  add    %rax,%rdx
  movzbl (%rcx),%eax
  mov    %al,(%rdx)
L29:
  subq   $0x1,-0x10(%rbp)
L63:
  cmpq   $0x0,-0x10(%rbp)
  jne    L104
  mov    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  jne    L7
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rax
  movb   $0x30,(%rax)
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rax
  movb   $0x32,(%rax)
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rax
  movb   $0x25,(%rax)
  jmp    L142
L7:
  mov    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x28(%rbp),%rdx
  add    %rax,%rdx
  movzbl (%rcx),%eax
  mov    %al,(%rdx)
L142:
  mov    -0x28(%rbp),%rax
L98:
  pop    %rbp
  ret
```

assistant: ```c
char *escape_spaces(char *str) {
  if (str == NULL) {
    return NULL;
  }
  size_t new_len = 0;
  size_t i;
  for (i = 0; str[i] != '\0'; i++) {
    if (str[i] == ' ') {
      new_len += 3;
    } else {
      new_len++;
    }
  }
  if (new_len == 0 || new_len == i) {
    return str;
  }
  str[new_len] = '\0';
  size_t j = new_len - 1;
  for (i--; i > 0; i--) {
    if (str[i] == ' ') {
      str[j--] = '0';
      str[j--] = '2';
      str[j--] = '%';
    } else {
      str[j--] = str[i];
    }
  }
  if (str[i] == ' ') {
    str[j--] = '0';
    str[j--] = '2';
    str[j--] = '%';
  } else {
    str[j--] = str[i];
  }
  return str;
}
```