user: Demonstrate the C code that generates the assembly output below:

```asm
<smtp_recv_mail_data>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  mov    $0x200,%edi
  push   %rbx
  sub    $0x38,%rsp
  mov    %rsi,0x18(%rsp)
  mov    %rdx,0x10(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <malloc@plt>
  test   %rax,%rax
  je     L197
  mov    %rax,(%rsp)
  mov    %rax,%r15
  mov    $0x200,%ebx
  xor    %r14d,%r14d
  xor    %r13d,%r13d
  lea    0x27(%rsp),%r12
  jmp    L135
  nopw   0x0(%rax,%rax,1)
L36:
  cmp    $0x3,%r13d
  je     L195
  cmp    $0x2,%r13d
  je     L179
  cmp    $0x1,%r13d
  je     L116
  cmp    $0xd,%al
  mov    $0x1,%eax
  cmove  %eax,%r13d
L109:
  add    $0x1,%r14
  cmp    %r14,%rbx
  je     L31
L180:
  mov    %r9,%r15
L135:
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <buf_read@plt>
  cmp    $0x1,%eax
  jne    L102
  movzbl 0x27(%rsp),%eax
  lea    0x1(%r15),%r9
  mov    %al,(%r15)
  cmp    $0x4,%r13d
  jne    L36
  cmp    $0xa,%al
  je     L113
L35:
  xor    %r13d,%r13d
  cmp    $0xd,%al
  sete   %r13b
  add    $0x1,%r14
  cmp    %r14,%rbx
  jne    L180
L31:
  add    %rbx,%rbx
  mov    %rbx,%rdi
  call   <malloc@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L62
  mov    (%rsp),%rsi
  lea    (%rax,%r14,1),%r9
  mov    %r14,%rdx
  mov    %rax,%rdi
  mov    %r9,0x8(%rsp)
  call   <memcpy@plt>
  mov    (%rsp),%rdi
  call   <free@plt>
  mov    %r15,(%rsp)
  mov    0x8(%rsp),%r9
  jmp    L180
  nopw   0x0(%rax,%rax,1)
L195:
  xor    %ecx,%ecx
  cmp    $0xd,%al
  sete   %cl
  lea    0x0(,%rcx,4),%r13d
  jmp    L109
  nopl   0x0(%rax)
L179:
  mov    $0x3,%r13d
  cmp    $0x2e,%al
  jne    L35
  jmp    L109
  nopw   0x0(%rax,%rax,1)
L116:
  mov    $0x2,%r13d
  cmp    $0xa,%al
  jne    L35
  jmp    L109
  nopl   0x0(%rax,%rax,1)
L102:
  mov    0x18(%rsp),%rax
  mov    (%rsp),%rdi
  movq   $0x0,(%rax)
  mov    0x10(%rsp),%rax
  movq   $0x0,(%rax)
  call   <free@plt>
  mov    $0xffffffff,%eax
L6:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L196
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L113:
  mov    0x18(%rsp),%rdx
  mov    (%rsp),%rcx
  movb   $0x0,-0x2(%r15)
  lea    -0x2(%r14),%rax
  cmpq   $0x0,0x10(%rsp)
  mov    %rcx,(%rdx)
  je     L6
  mov    0x10(%rsp),%rdx
  mov    %rbx,(%rdx)
  jmp    L6
L62:
  mov    (%rsp),%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
  jmp    L6
L197:
  or     $0xffffffff,%eax
  jmp    L6
L196:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
ssize_t smtp_recv_mail_data(int sockfd, char **buf_ptr, size_t *buf_size) {
  int rc, state;
  size_t n, buflen;
  char c, *ptr, *buf, *temp_buf;
  if (NULL == (buf = malloc(512 * sizeof(char))))
    return -1;
  state = 0;
  ptr = buf;
  buflen = 512;
  n = 0;
  for (;;) {
    if ((rc = buf_read(sockfd, &c)) == 1) {
      *ptr++ = c;
      if (4 == state) {
        if (c == '\n') {
          n -= 2;
          *(ptr - 3) = '\0';
          break;
        } else if (c == '\r')
          state = 1;
        else
          state = 0;
      } else if (3 == state) {
        if (c == '\r')
          state = 4;
        else if (c == '\r')
          state = 1;
        else
          state = 0;
      } else if (2 == state) {
        if (c == '.')
          state = 3;
        else if (c == '\r')
          state = 1;
        else
          state = 0;
      } else if (1 == state) {
        if (c == '\n')
          state = 2;
        else if (c == '\r')
          state = 1;
        else
          state = 0;
      } else if (c == '\r')
        state = 1;
    } else {
      *buf_ptr = NULL;
      *buf_size = 0;
      free(buf);
      if (rc == 1)
        return 0;
      else
        return -1;
    }
    ++n;
    if (n == buflen) {
      buflen *= 2;
      temp_buf = buf;
      if (NULL == (buf = malloc(buflen * sizeof(char)))) {
        free(temp_buf);
        return -1;
      }
      ptr = buf + n;
      memcpy(buf, temp_buf, n);
      free(temp_buf);
      temp_buf = NULL;
    }
  }
  *buf_ptr = buf;
  if (NULL != buf_size)
    *buf_size = buflen;
  return n;
}
```