user: Converte this assembly snippet into its equivalent C code:

```asm
<man2string>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x24(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x20(%rbp)
  movq   $0x0,-0x10(%rbp)
  movq   $0x0,-0x8(%rbp)
  movq   $0x0,-0x18(%rbp)
  mov    $0x14,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L83
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  movl   $0x1,-0x28(%rbp)
  jmp    L17
L83:
  movl   $0x12,-0x24(%rbp)
  movl   $0x0,-0x1c(%rbp)
  jmp    L93
L43:
  mov    -0x24(%rbp),%eax
  mov    %eax,%esi
  mov    $0x2,%edi
  call   <pow@plt>
  and    -0x40(%rbp),%rax
  test   %rax,%rax
  je     L71
  mov    $0x2e,%ecx
  jmp    L82
L71:
  mov    $0x30,%ecx
L82:
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %cl,(%rax)
  subl   $0x1,-0x24(%rbp)
L93:
  mov    -0x24(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jge    L43
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    $0x31,%eax
  sub    %edx,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%edi
  call   <floor@plt>
  mov    %rax,-0x10(%rbp)
  movl   $0x0,-0x20(%rbp)
  mov    -0x10(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L21
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  movl   $0x1,-0x28(%rbp)
  jmp    L17
L21:
  movl   $0x0,-0x24(%rbp)
  mov    -0x10(%rbp),%rax
  mov    %eax,-0x1c(%rbp)
  jmp    L1
L95:
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x2e,(%rax)
  addl   $0x1,-0x24(%rbp)
L1:
  mov    -0x24(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L95
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x8(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x18(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
L17:
  cmpq   $0x0,-0x8(%rbp)
  je     L107
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L107:
  cmpq   $0x0,-0x18(%rbp)
  je     L105
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L105:
  mov    -0x28(%rbp),%eax
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D6
type_guessed: string

tool: D6: Memory error


assistant: ```c
int man2string(char *line, long man) {
  int rc = 0, i = 0, l = 0, counter = 0;
  size_t length = 0;
  char *output = NULL, *pad = NULL;
  output = malloc(sizeof(char) * 20);
  if (!output) {
    printf("Memory error\n");
    rc = 1;
    goto cleanup;
  }
  for (i = 19 - 1, l = 0; i >= l; i--) {
    output[counter++] = (man & (long)pow(2, i)) ? '.' : '0';
  }
  output[counter] = '\0';
  length = floor((49 - strlen(output)) / 2);
  counter = 0;
  pad = malloc(sizeof(char) * length + 1);
  if (!pad) {
    printf("Memory error\n");
    rc = 1;
    goto cleanup;
  }
  for (i = 0, l = length; i < l; i++) {
    pad[counter++] = '.';
  }
  pad[counter] = '\0';
  strcpy(line, pad);
  strcat(line, output);
  strcat(line, pad);
cleanup:
  if (output) {
    free(output);
  }
  if (pad) {
    free(pad);
  }
  return rc;
}
```