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

```asm
<eb_recv_data>:
  endbr64
  push   %r15
  mov    $0x64,%edx
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  xor    %r13d,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  xor    %esi,%esi
  sub    $0x108,%rsp
  mov    %rdi,0x8(%rsp)
  lea    0x20(%rsp),%r15
  lea    0x1c(%rsp),%rbp
  lea    0x90(%rsp),%r12
  mov    %r12,%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0xf8(%rsp)
  xor    %eax,%eax
  call   <memset@plt>
  nopw   0x0(%rax,%rax,1)
L109:
  xor    %esi,%esi
  mov    %r15,%rdi
  mov    $0x64,%edx
  call   <memset@plt>
  mov    %rbp,%rsi
  mov    %r15,%rdi
  movl   $0x64,0x1c(%rsp)
  call   <eb_serial_recv@plt>
  test   %eax,%eax
  js     L163
  mov    0x1c(%rsp),%r9d
  test   %r9d,%r9d
  jle    L109
  mov    (%rbx),%eax
  test   %eax,%eax
  jg     L56
L89:
  movslq %r14d,%rdi
  xor    %eax,%eax
  mov    %rdi,%rdx
  add    %r12,%rdi
  jmp    L92
  nopl   0x0(%rax,%rax,1)
L159:
  cmp    $0x1,%edx
  je     L61
  cmp    $0xa9,%sil
  sete   %sil
  movzbl %sil,%esi
  add    %esi,%r13d
  movzbl %cl,%esi
  lea    0x2(%r13,%rsi,1),%esi
  cmp    %edx,%esi
  je     L8
L61:
  cmpb   $0xaa,0x1(%rdi,%rax,1)
  je     L94
  cmp    $0x10,%cl
  ja     L94
  add    $0x1,%rax
  cmp    %eax,%r9d
  jle    L16
L92:
  movzbl (%r15,%rax,1),%esi
  mov    %edx,%r14d
  add    $0x1,%edx
  mov    %sil,(%rdi,%rax,1)
  movzbl 0x90(%rsp),%ecx
  cmp    $0xaa,%cl
  jne    L159
  mov    $0xfffffffe,%r15d
L150:
  mov    %edx,(%rbx)
  mov    0x8(%rsp),%rbx
  mov    $0x8,%edx
  xor    %esi,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
  movslq %r14d,%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  add    $0x1,%rdx
  call   <memcpy@plt>
L137:
  mov    0xf8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L167
  add    $0x108,%rsp
  mov    %r15d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L94:
  mov    $0xfffffffd,%r15d
  jmp    L150
  nopl   0x0(%rax,%rax,1)
L56:
  mov    %r9d,%edx
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <memcpy@plt>
  mov    $0x64,%edx
  xor    %esi,%esi
  mov    %r15,%rdi
  mov    0x1c(%rsp),%r14d
  call   <memset@plt>
  mov    (%rbx),%edx
  mov    0x8(%rsp),%rsi
  mov    %r15,%rdi
  call   <memcpy@plt>
  movslq (%rbx),%rax
  mov    %r14d,%edx
  mov    %r12,%rsi
  movl   $0x0,(%rbx)
  lea    (%r15,%rax,1),%rdi
  mov    %eax,0x1c(%rsp)
  call   <memcpy@plt>
  mov    $0x64,%edx
  xor    %esi,%esi
  mov    %r12,%rdi
  add    %r14d,0x1c(%rsp)
  call   <memset@plt>
  mov    0x1c(%rsp),%r9d
  test   %r9d,%r9d
  jle    L49
  xor    %r14d,%r14d
  jmp    L89
L49:
  xor    %edx,%edx
  nopl   (%rax)
L16:
  mov    %edx,%r14d
  jmp    L109
L163:
  mov    $0xffffffff,%r15d
  jmp    L137
  nopl   0x0(%rax,%rax,1)
L8:
  xor    %r15d,%r15d
  jmp    L150
L167:
  call   <__stack_chk_fail@plt>
```

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;
}
```