user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<realtek_mst_i2c_spi_send_command>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %r8,0x8(%rsp)
  cmp    $0x3,%edx
  ja     L143
  lea    -0x1(%rsi),%r15d
  cmp    $0x3,%r15d
  ja     L143
  mov    %esi,%r13d
  mov    %edx,%r14d
  mov    %rcx,%r12
  call   <get_fd_from_context@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  js     L143
  lea    0x0(,%r15,8),%eax
  lea    (%r14,%r14,1),%edx
  or     %eax,%edx
  movzbl (%r12),%eax
  cmp    $0x20,%al
  je     L64
  ja     L192
  cmp    $0x1,%al
  je     L142
  cmp    $0x6,%al
  jne    L24
  xor    %r12d,%r12d
L89:
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L135:
  cmp    $0x52,%al
  je     L64
  cmp    $0x60,%al
  jne    L24
L64:
  movl   $0x1,(%rsp)
L93:
  or     $0xa0,%dl
  mov    %edx,0x4(%rsp)
L114:
  mov    0x4(%rsp),%edx
  mov    $0x60,%esi
  mov    %ebp,%edi
  call   <realtek_mst_i2c_spi_write_register@plt>
  movzbl (%r12),%edx
  mov    $0x61,%esi
  mov    %ebp,%edi
  mov    %eax,%ebx
  call   <realtek_mst_i2c_spi_write_register@plt>
  or     %eax,%ebx
  test   %r15d,%r15d
  je     L66
  lea    -0x2(%r13),%eax
  lea    0x1(%r12),%r15
  lea    0x2(%r12,%rax,1),%r13
  mov    $0x64,%r12d
  sub    %r15d,%r12d
  nopl   0x0(%rax,%rax,1)
L38:
  movzbl (%r15),%edx
  lea    (%r12,%r15,1),%esi
  mov    %ebp,%edi
  add    $0x1,%r15
  call   <realtek_mst_i2c_spi_write_register@plt>
  or     %eax,%ebx
  cmp    %r13,%r15
  jne    L38
L66:
  movzbl 0x4(%rsp),%edx
  mov    $0x60,%esi
  mov    %ebp,%edi
  or     $0x1,%edx
  movzbl %dl,%edx
  call   <realtek_mst_i2c_spi_write_register@plt>
  or     %ebx,%eax
  mov    %eax,%r12d
  jne    L89
  mov    (%rsp),%r8d
  xor    %ecx,%ecx
  mov    $0x1,%edx
  mov    $0x60,%esi
  mov    %ebp,%edi
  call   <realtek_mst_i2c_spi_wait_command_done@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L89
  test   %r14d,%r14d
  je     L89
  mov    0x8(%rsp),%rbx
  lea    -0x1(%r14),%eax
  mov    $0x67,%r14d
  lea    0x1(%rbx,%rax,1),%r13
  sub    %ebx,%r14d
  cs nopw 0x0(%rax,%rax,1)
L160:
  lea    (%r14,%rbx,1),%esi
  mov    %rbx,%rdx
  mov    %ebp,%edi
  add    $0x1,%rbx
  call   <realtek_mst_i2c_spi_read_register@plt>
  or     %eax,%r12d
  cmp    %rbx,%r13
  jne    L160
  jmp    L89
  nop
L192:
  cmp    $0xc7,%al
  je     L210
  jbe    L135
  add    $0x29,%eax
  cmp    $0x1,%al
  jbe    L64
L24:
  or     $0x40,%edx
  movl   $0x1,(%rsp)
  mov    %edx,0x4(%rsp)
  jmp    L114
  nopl   0x0(%rax,%rax,1)
L210:
  movl   $0x14,(%rsp)
  jmp    L93
  nopl   0x0(%rax)
L142:
  or     $0x60,%edx
  movl   $0x1,(%rsp)
  mov    %edx,0x4(%rsp)
  jmp    L114
L143:
  mov    $0xffffffff,%r12d
  jmp    L89
```

assistant: ```c
int realtek_mst_i2c_spi_send_command(const struct flashrom_flashctx *flash, unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr) {
  unsigned i;
  int max_timeout_mul = 1;
  int ret = 0;
  if (writecnt > 4 || readcnt > 3 || writecnt == 0) {
    return -1;
  }
  int fd = get_fd_from_context(flash);
  if (fd < 0)
    return -1;
  writecnt--;
  uint8_t ctrl_reg_val = (writecnt << 3) | (readcnt << 1);
  switch (writearr[0]) {
  case 0x06:
    return 0;
  case 0x01:
    ctrl_reg_val |= (1 << 5);
    ctrl_reg_val |= (2 << 5);
    break;
  case 0xc7:
    max_timeout_mul *= 20;
  case 0x60:
  case 0x52:
  case 0xd8:
  case 0xd7:
  case 0x20:
    ctrl_reg_val |= (1 << 5);
    ctrl_reg_val |= (4 << 5);
    break;
  default:
    ctrl_reg_val |= (2 << 5);
  }
  ret |= realtek_mst_i2c_spi_write_register(fd, 0x60, ctrl_reg_val);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0x61, writearr[0]);
  for (i = 0; i < writecnt; ++i)
    ret |= realtek_mst_i2c_spi_write_register(fd, 0x64 + i, writearr[i + 1]);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0x60, ctrl_reg_val | 0x1);
  if (ret)
    return ret;
  ret = realtek_mst_i2c_spi_wait_command_done(fd, 0x60, 0x01, 0, max_timeout_mul);
  if (ret)
    return ret;
  for (i = 0; i < readcnt; ++i)
    ret |= realtek_mst_i2c_spi_read_register(fd, 0x67 + i, &readarr[i]);
  return ret;
}
```