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

```asm
<eb_recv_data>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x110,%rsp
  mov    %rdi,-0x108(%rbp)
  mov    %rsi,-0x110(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x70(%rbp),%rax
  mov    $0x64,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x0,-0xf4(%rbp)
  movl   $0x0,-0xec(%rbp)
  movl   $0x63,-0xe8(%rbp)
L104:
  lea    -0xe0(%rbp),%rax
  mov    $0x64,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x64,-0xf8(%rbp)
  lea    -0xf8(%rbp),%rdx
  lea    -0xe0(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <eb_serial_recv@plt>
  mov    %eax,-0xe4(%rbp)
  cmpl   $0x0,-0xe4(%rbp)
  jns    L67
  mov    $0xffffffff,%eax
  jmp    L175
L67:
  mov    -0xf8(%rbp),%eax
  test   %eax,%eax
  jle    L81
  mov    -0x110(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jle    L58
  mov    -0xf8(%rbp),%edx
  lea    -0xe0(%rbp),%rcx
  lea    -0x70(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0xf8(%rbp),%eax
  mov    %eax,-0xf4(%rbp)
  lea    -0xe0(%rbp),%rax
  mov    $0x64,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x110(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x108(%rbp),%rcx
  lea    -0xe0(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x110(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0xf8(%rbp)
  mov    -0x110(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0xf8(%rbp),%eax
  lea    -0xe0(%rbp),%rdx
  cltq
  lea    (%rdx,%rax,1),%rcx
  mov    -0xf4(%rbp),%edx
  lea    -0x70(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0xf8(%rbp),%edx
  mov    -0xf4(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0xf8(%rbp)
  lea    -0x70(%rbp),%rax
  mov    $0x64,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x0,-0xf4(%rbp)
L58:
  movl   $0x0,-0xf0(%rbp)
  jmp    L11
L27:
  mov    -0xf0(%rbp),%eax
  cltq
  movzbl -0xe0(%rbp,%rax,1),%edx
  mov    -0xf4(%rbp),%eax
  cltq
  mov    %dl,-0x70(%rbp,%rax,1)
  addl   $0x1,-0xf4(%rbp)
  movzbl -0x70(%rbp),%eax
  cmp    $0xaa,%al
  jne    L143
  movl   $0xfffffffe,-0xe8(%rbp)
  jmp    L81
L143:
  cmpl   $0x1,-0xf4(%rbp)
  jle    L174
  mov    -0xf4(%rbp),%eax
  sub    $0x1,%eax
  cltq
  movzbl -0x70(%rbp,%rax,1),%eax
  cmp    $0xa9,%al
  jne    L169
  addl   $0x1,-0xec(%rbp)
L169:
  movzbl -0x70(%rbp),%eax
  movzbl %al,%eax
  lea    0x2(%rax),%edx
  mov    -0xec(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0xf4(%rbp)
  jne    L174
  movl   $0x0,-0xe8(%rbp)
  jmp    L81
L174:
  mov    -0xf4(%rbp),%eax
  cltq
  movzbl -0x70(%rbp,%rax,1),%eax
  cmp    $0xaa,%al
  je     L165
  movzbl -0x70(%rbp),%eax
  cmp    $0x10,%al
  jbe    L2
L165:
  movl   $0xfffffffd,-0xe8(%rbp)
  jmp    L81
L2:
  addl   $0x1,-0xf0(%rbp)
L11:
  mov    -0xf8(%rbp),%eax
  cmp    %eax,-0xf0(%rbp)
  jl     L27
L81:
  cmpl   $0x63,-0xe8(%rbp)
  je     L104
  mov    -0x110(%rbp),%rax
  mov    -0xf4(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x108(%rbp),%rax
  mov    $0x8,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x0,-0xf0(%rbp)
  jmp    L63
L151:
  mov    -0xf0(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x108(%rbp),%rax
  add    %rax,%rdx
  mov    -0xf0(%rbp),%eax
  cltq
  movzbl -0x70(%rbp,%rax,1),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0xf0(%rbp)
L63:
  mov    -0xf0(%rbp),%eax
  cmp    -0xf4(%rbp),%eax
  jl     L151
  mov    -0xe8(%rbp),%eax
L175:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L181
  call   <__stack_chk_fail@plt>
L181:
  leave
  ret
```

assistant: ```c
int eb_recv_data(unsigned char *buf, int *buflen) {
  unsigned char tmp[100], msg[100];
  int tmplen, msglen, ret, i, esc, found;
  memset(msg, '\0', sizeof(msg));
  msglen = 0;
  esc = 0;
  found = 99;
  do {
    memset(tmp, '\0', sizeof(tmp));
    tmplen = sizeof(tmp);
    ret = eb_serial_recv(tmp, &tmplen);
    if (ret < 0)
      return -1;
    if (tmplen > 0) {
      if (*buflen > 0) {
        memcpy(msg, tmp, tmplen);
        msglen = tmplen;
        memset(tmp, '\0', sizeof(tmp));
        memcpy(tmp, buf, *buflen);
        tmplen = *buflen;
        *buflen = 0;
        memcpy(&tmp[tmplen], msg, msglen);
        tmplen += msglen;
        memset(msg, '\0', sizeof(msg));
        msglen = 0;
      }
      i = 0;
      while (i < tmplen) {
        msg[msglen] = tmp[i];
        msglen++;
        if (msg[0] == 0xAA) {
          found = -2;
          break;
        }
        if (msglen > 1) {
          if (msg[msglen - 1] == 0xA9)
            esc++;
          if (msglen == (2 + msg[0] + esc)) {
            found = 0;
            break;
          }
        }
        if (msg[msglen] == 0xAA || msg[0] > 16) {
          found = -3;
          break;
        }
        i++;
      }
    }
  } while (found == 99);
  *buflen = msglen;
  memset(buf, '\0', sizeof(buf));
  for (i = 0; i < msglen; i++)
    buf[i] = msg[i];
  return found;
}
```