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

```asm
<realtek_mst_i2c_spi_write_256>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %ecx,-0x38(%rbp)
  movl   $0x0,-0x14(%rbp)
  mov    -0x34(%rbp),%eax
  movzbl %al,%eax
  test   %eax,%eax
  je     L77
  mov    -0x38(%rbp),%ecx
  mov    -0x34(%rbp),%edx
  mov    -0x30(%rbp),%rsi
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <default_spi_write_256@plt>
  jmp    L160
L77:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <get_fd_from_context@plt>
  mov    %eax,-0x10(%rbp)
  cmpl   $0x0,-0x10(%rbp)
  jns    L125
  mov    $0xffffffff,%eax
  jmp    L160
L125:
  mov    -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <realtek_mst_i2c_spi_disable_protection@plt>
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  je     L60
  mov    -0x14(%rbp),%eax
  jmp    L160
L60:
  mov    -0x10(%rbp),%eax
  mov    $0x2,%edx
  mov    $0x6d,%esi
  mov    %eax,%edi
  call   <realtek_mst_i2c_spi_write_register@plt>
  or     %eax,-0x14(%rbp)
  mov    -0x10(%rbp),%eax
  mov    $0xff,%edx
  mov    $0x71,%esi
  mov    %eax,%edi
  call   <realtek_mst_i2c_spi_write_register@plt>
  or     %eax,-0x14(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L109
L158:
  mov    -0x38(%rbp),%eax
  sub    -0x18(%rbp),%eax
  mov    $0x100,%esi
  mov    %eax,%edi
  call   <min@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0x38(%rbp),%eax
  sub    -0x18(%rbp),%eax
  cmp    $0xff,%eax
  ja     L156
  mov    -0xc(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x10(%rbp),%eax
  mov    $0x71,%esi
  mov    %eax,%edi
  call   <realtek_mst_i2c_spi_write_register@plt>
  or     %eax,-0x14(%rbp)
L156:
  mov    -0x34(%rbp),%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  shr    $0x10,%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x34(%rbp),%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  shr    $0x8,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x8(%rbp),%esi
  mov    -0x10(%rbp),%eax
  mov    $0x0,%ecx
  mov    %eax,%edi
  call   <realtek_mst_i2c_spi_map_page@plt>
  or     %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jne    L123
  mov    -0x10(%rbp),%eax
  mov    $0x1,%r8d
  mov    $0x10,%ecx
  mov    $0x10,%edx
  mov    $0x6f,%esi
  mov    %eax,%edi
  call   <realtek_mst_i2c_spi_wait_command_done@plt>
  or     %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jne    L126
  mov    -0x18(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0xc(%rbp),%edx
  mov    -0x10(%rbp),%eax
  mov    %edx,%ecx
  mov    %rsi,%rdx
  mov    $0x70,%esi
  mov    %eax,%edi
  call   <realtek_mst_i2c_spi_write_page@plt>
  or     %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jne    L24
  mov    -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <realtek_mst_i2c_execute_write@plt>
  or     %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jne    L50
  addl   $0x100,-0x18(%rbp)
L109:
  mov    -0x18(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jb     L158
  jmp    L100
L123:
  nop
  jmp    L100
L126:
  nop
  jmp    L100
L24:
  nop
  jmp    L100
L50:
  nop
L100:
  mov    -0x14(%rbp),%eax
L160:
  leave
  ret
```

assistant: ```c
int realtek_mst_i2c_spi_write_256(struct flashrom_flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) {
  unsigned i;
  int ret = 0;
  if (start & 0xff)
    return default_spi_write_256(flash, buf, start, len);
  int fd = get_fd_from_context(flash);
  if (fd < 0)
    return -1;
  ret = realtek_mst_i2c_spi_disable_protection(fd);
  if (ret)
    return ret;
  ret |= realtek_mst_i2c_spi_write_register(fd, 0x6D, 0x02);
  ret |= realtek_mst_i2c_spi_write_register(fd, 0x71, (256 - 1));
  for (i = 0; i < len; i += 256) {
    uint16_t page_len = min(len - i, 256);
    if (len - i < 256)
      ret |= realtek_mst_i2c_spi_write_register(fd, 0x71, page_len - 1);
    uint8_t block_idx = (start + i) >> 16;
    uint8_t page_idx = (start + i) >> 8;
    ret |= realtek_mst_i2c_spi_map_page(fd, block_idx, page_idx, 0);
    if (ret)
      break;
    ret |= realtek_mst_i2c_spi_wait_command_done(fd, 0x6F, 0x10, 0x10, 1);
    if (ret)
      break;
    ret |= realtek_mst_i2c_spi_write_page(fd, 0x70, buf + i, page_len);
    if (ret)
      break;
    ret |= realtek_mst_i2c_execute_write(fd);
    if (ret)
      break;
  }
  return ret;
}
```