user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<HA_ExtractTemplateAndLines>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%rbp
  mov    %rsi,0x18(%rsp)
  mov    %rdx,0x20(%rsp)
  mov    %rcx,0x28(%rsp)
  mov    $0x0,%r13d
  lea    D12(%rip),%rbx
  jmp    L91
L1:
  add    $0x1,%r13d
  lea    0x3(%rax),%rdi
L91:
  mov    %rbx,%rsi
  call   <strstr@plt>
  test   %rax,%rax
  jne    L1
  lea    -0x1(%r13),%eax
  mov    %eax,0x4(%rsp)
  movslq %eax,%rdi
  shl    $0x3,%rdi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  lea    D12(%rip),%rsi
  mov    %rbp,%rdi
  call   <strstr@plt>
  mov    %rax,%rbx
  mov    %rax,0x10(%rsp)
  test   %rax,%rax
  je     L53
  mov    %rax,%r12
  sub    %rbp,%r12
  add    $0x1,%r12
  mov    %r12,%rdi
  call   <malloc@plt>
  mov    %rax,%r15
  mov    %rax,0x10(%rsp)
  mov    %r12,%rdx
  mov    %rbp,%rsi
  mov    %rax,%rdi
  call   <my_strlcpy@plt>
  mov    %r15,%rdx
  lea    D14(%rip),%rsi
  mov    $0x4,%edi
  mov    $0x0,%eax
  call   <diagnostics@plt>
L53:
  add    $0x3,%rbx
  jmp    L19
L47:
  add    $0x1,%rbx
L19:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L47
  cmpl   $0x0,0x4(%rsp)
  jle    L6
  mov    0x8(%rsp),%r14
  sub    $0x1,%r13d
  mov    $0x0,%r12d
  jmp    L49
L96:
  add    $0x1,%rbx
L82:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L96
  add    $0x1,%r12d
  add    $0x8,%r14
  cmp    %r13d,%r12d
  je     L6
L49:
  lea    D12(%rip),%rsi
  mov    %rbx,%rdi
  call   <strstr@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L50
  mov    %rax,%r15
  sub    %rbx,%r15
  add    $0x1,%r15
  mov    %r15,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,(%r14)
  mov    %r15,%rdx
  mov    %rbx,%rsi
  call   <my_strlcpy@plt>
  mov    (%r14),%rcx
  mov    %r12d,%edx
  lea    D6(%rip),%rsi
  mov    $0x4,%edi
  mov    $0x0,%eax
  call   <diagnostics@plt>
L50:
  lea    0x3(%rbp),%rbx
  jmp    L82
L6:
  mov    0x28(%rsp),%rax
  mov    0x4(%rsp),%ecx
  mov    %ecx,(%rax)
  mov    0x20(%rsp),%rax
  mov    0x8(%rsp),%rcx
  mov    %rcx,(%rax)
  mov    0x18(%rsp),%rax
  mov    0x10(%rsp),%rcx
  mov    %rcx,(%rax)
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: tag: D12
type_infered: string
name: parse_data
arguments: tag: D14
type_infered: string
name: parse_data
arguments: tag: D6
type_infered: string

tool: D12: \cr

tool: D14: HA_template = '%s'

tool: D6: line[%2d] = '%s'

assistant: ```c
void HA_ExtractTemplateAndLines(const char *s, char **thetemplate, char ***thelines, int *nl) {
  char *p, *ss, *HA_template = NULL;
  char **lines;
  int nlines, i;
  ss = (char *)s;
  nlines = 0;
  while ((p = strstr(ss, "\\cr"))) {
    nlines++;
    ss = p + 3;
  }
  nlines--;
  lines = (char **)malloc(nlines * sizeof(char *));
  p = strstr(s, "\\cr");
  if (p) {
    size_t n = p - s + 1;
    HA_template = (char *)malloc(n * sizeof(char));
    my_strlcpy(HA_template, s, n);
    diagnostics(4, "HA_template = '%s'", HA_template);
  }
  ss = p + 3;
  while (isspace(*ss))
    ss++;
  for (i = 0; i < nlines; i++) {
    p = strstr(ss, "\\cr");
    if (p) {
      size_t n = p - ss + 1;
      lines[i] = (char *)malloc(n * sizeof(char));
      my_strlcpy(lines[i], ss, n);
      diagnostics(4, "line[%2d] = '%s'", i, lines[i]);
    }
    ss = p + 3;
    while (isspace(*ss))
      ss++;
  }
  *nl = nlines;
  *thelines = lines;
  *thetemplate = HA_template;
}
```