user: What is the c source code of the assembly code below?

```asm
<socket_recv>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,0x8(%rsp)
  mov    %edx,0xc(%rsp)
  mov    $0x0,%ebp
  test   %rsi,%rsi
  jne    L2
L11:
  mov    %ebp,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L2:
  mov    %rsi,%r12
  mov    $0x401,%edi
  call   <malloc@plt>
  mov    %rax,(%r12)
  mov    $0x0,%r13d
  lea    D32(%rip),%r15
  jmp    L59
L48:
  mov    %r14d,%r13d
L59:
  movslq %ebp,%rsi
  add    (%r12),%rsi
  mov    0xc(%rsp),%ecx
  mov    $0x400,%edx
  mov    0x8(%rsp),%edi
  call   <recv@plt>
  mov    %eax,%ebx
  lea    0x1(%r13),%r14d
  mov    %eax,%edx
  mov    %r13d,%esi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    %ebx,%ebp
  mov    %ebp,%edx
  mov    %ebx,%esi
  lea    D42(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    (%r12),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %eax,%esi
  mov    %r13,%rdx
  lea    D34(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmp    $0x3ff,%ebx
  jle    L15
  test   %ebp,%ebp
  jle    L48
  lea    0x401(%rbp),%esi
  mov    (%r12),%rdi
  call   <realloc@plt>
  mov    %rax,(%r12)
  jmp    L48
L15:
  lea    0x1(%rbp),%edi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %ebp,%edx
  mov    (%r12),%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  movslq %ebp,%rax
  movb   $0x0,(%rbx,%rax,1)
  mov    %ebp,%esi
  lea    D7(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %eax,%esi
  mov    %rbx,%rdx
  lea    D20(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L11
```

tool_calls: name: unpack_data
arguments: label: D32
data_type: string
name: unpack_data
arguments: label: D42
data_type: string
name: unpack_data
arguments: label: D34
data_type: string
name: unpack_data
arguments: label: D7
data_type: string
name: unpack_data
arguments: label: D20
data_type: string

tool: D32: socket_recv iteration #%d, nread = %zd


tool: D42: Read %ld bytes from socket.
Total bytes read so far: %ld.


tool: D34: socket_recv buffer (%lu): %s




tool: D7: End of socket_recv iteration, total_read_size = %ld


tool: D20: socket_recv string output result (%lu): %s




assistant: ```c
ssize_t socket_recv(int sockfd, char **buffer, int flag) {
  if (!buffer) {
    return 0;
  }
  ssize_t total_read_size = 0;
  ssize_t nread = 0;
  ssize_t buffer_default_size = 1024 * sizeof(char);
  *buffer = (char *)malloc(buffer_default_size + sizeof(char));
  int iteration = 0;
  while (nread >= 0) {
    if (total_read_size > 0) {
      *buffer = (char *)realloc(*buffer, total_read_size + buffer_default_size + sizeof(char));
    }
    nread = recv(sockfd, *buffer + total_read_size, 1024, flag);
    if (1)
      printf("socket_recv iteration #%d, nread = %zd\n", iteration++, nread);
    total_read_size += nread;
    if (1)
      printf("Read %ld bytes from socket.\nTotal bytes read so far: %ld.\n", nread, total_read_size);
    if (1)
      printf("socket_recv buffer (%lu): %s\n\n\n", strlen(*buffer), *buffer);
    if (nread < 1024) {
      break;
    }
  }
  char *str_result = (char *)malloc(total_read_size + sizeof(char));
  strncpy(str_result, *buffer, total_read_size);
  str_result[total_read_size] = '\0';
  if (1)
    printf("End of socket_recv iteration, total_read_size = %ld\n", total_read_size);
  if (1)
    printf("socket_recv string output result (%lu): %s\n\n\n", strlen(str_result), str_result);
  return total_read_size;
}
```