user: Please show me the C implementation that matches the assembly code listed below:

```asm
<__libc_readv>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x38(%rbp)
  movl   $0x0,-0x28(%rbp)
  movq   $0x0,-0x18(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L11
L26:
  mov    D5(%rip),%rax
  mov    (%rax),%rax
  sub    -0x18(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x4,%rax
  mov    %rax,%rcx
  mov    -0x40(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jae    L62
  mov    D12(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <__set_errno@plt>
  mov    $0xffffffff,%eax
  jmp    L101
L62:
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x4,%rax
  mov    %rax,%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  add    %rax,-0x18(%rbp)
  addl   $0x1,-0x2c(%rbp)
L11:
  mov    -0x2c(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jl     L26
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <__libc_use_alloca@plt>
  test   %rax,%rax
  je     L106
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <__alloca@plt>
  mov    %rax,-0x20(%rbp)
  jmp    L14
L106:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L27
  mov    $0xffffffff,%eax
  jmp    L101
L27:
  movl   $0x1,-0x28(%rbp)
L14:
  mov    -0x18(%rbp),%rdx
  mov    -0x20(%rbp),%rcx
  mov    -0x34(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <__read@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jg     L64
  mov    $0xffffffff,%eax
  jmp    L101
L64:
  mov    -0x24(%rbp),%eax
  cltq
  mov    %rax,-0x18(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L117
L49:
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x4,%rax
  mov    %rax,%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x18(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <MIN@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x4,%rax
  mov    %rax,%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    0x8(%rax),%rax
  mov    %rax,%rcx
  mov    -0x8(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x8(%rbp),%rax
  add    %rax,-0x20(%rbp)
  mov    -0x8(%rbp),%rax
  sub    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L111
  addl   $0x1,-0x2c(%rbp)
L117:
  mov    -0x2c(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jl     L49
  jmp    L89
L111:
  nop
L89:
  cmpl   $0x0,-0x28(%rbp)
  je     L137
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L137:
  mov    -0x24(%rbp),%eax
L101:
  leave
  ret
```

assistant: ```c
ssize_t __libc_readv(int fd, const struct iovec *vector, int count) {
  char *buffer;
  char *buffer_start;
  size_t bytes;
  ssize_t bytes_read;
  int i;
  bool use_malloc = false;
  bytes = 0;
  for (i = 0; i < count; ++i) {
    if (SSIZE_MAX - bytes < vector[i].iov_len) {
      __set_errno(EINVAL);
      return -1;
    }
    bytes += vector[i].iov_len;
  }
  if (__libc_use_alloca(bytes))
    buffer = (char *)__alloca(bytes);
  else {
    buffer = (char *)malloc(bytes);
    if (buffer == NULL)
      return -1;
    use_malloc = true;
  }
  bytes_read = __read(fd, buffer, bytes);
  if (bytes_read <= 0)
    return -1;
  bytes = bytes_read;
  buffer_start = buffer;
  for (i = 0; i < count; ++i) {
    size_t copy = MIN(vector[i].iov_len, bytes);
    (void)memcpy((void *)vector[i].iov_base, (void *)buffer, copy);
    buffer += copy;
    bytes -= copy;
    if (bytes == 0)
      break;
  }
  if (use_malloc)
    free(buffer_start);
  return bytes_read;
}
```