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

```asm
<block_write>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  call   <unlock_block_for_writes@plt>
  mov    %ebp,%edi
  mov    $0xe8,%esi
  call   <flash_write@plt>
  mov    %ebp,%edi
  call   <flash_read@plt>
  test   $0x80,%al
  je     L92
L103:
  mov    $0x1f,%esi
  mov    %ebp,%edi
  xor    %ebx,%ebx
  call   <flash_write@plt>
  nopl   0x0(%rax,%rax,1)
L79:
  mov    (%r12,%rbx,4),%esi
  lea    0x0(%rbp,%rbx,1),%edi
  add    $0x1,%rbx
  call   <flash_write@plt>
  cmp    $0x20,%rbx
  jne    L79
  mov    %ebp,%edi
  mov    $0xd0,%esi
  call   <flash_write@plt>
  mov    %ebp,%edi
  call   <flash_read@plt>
  test   $0x80,%al
  jne    L77
  mov    $0xfff,%ebx
  jmp    L0
  nopl   (%rax)
L150:
  sub    $0x1,%ebx
  je     L135
L0:
  mov    %ebp,%edi
  call   <flash_read@plt>
  test   $0x80,%al
  je     L150
L77:
  mov    %ebp,%edi
  call   <flash_read_status@plt>
  mov    %eax,%r12d
  test   $0x8,%al
  jne    L136
L118:
  test   $0x30,%r12b
  jne    L56
L61:
  test   $0x2,%r12b
  jne    L34
L48:
  test   $0x20,%r12b
  jne    L35
L54:
  mov    %ebp,%edi
  call   <lock_block_to_prevent_writes@plt>
  pop    %rbx
  mov    %ebp,%edi
  pop    %rbp
  pop    %r12
  jmp    1100 <flash_read_mode@plt>
L92:
  lea    D13(%rip),%rdi
  xor    %eax,%eax
  call   <warnx@plt>
  jmp    L103
L35:
  lea    0x0(%rbp,%rbp,1),%esi
  mov    %r12d,%edx
  lea    D7(%rip),%rdi
  xor    %eax,%eax
  call   <warnx@plt>
  jmp    L54
L34:
  mov    %r12d,%esi
  lea    D36(%rip),%rdi
  xor    %eax,%eax
  call   <warnx@plt>
  jmp    L48
L56:
  mov    %r12d,%esi
  lea    D15(%rip),%rdi
  xor    %eax,%eax
  call   <warnx@plt>
  jmp    L61
L136:
  mov    %eax,%esi
  lea    D6(%rip),%rdi
  xor    %eax,%eax
  call   <warnx@plt>
  jmp    L118
L135:
  mov    $0xfff,%esi
  lea    D45(%rip),%rdi
  xor    %eax,%eax
  call   <warnx@plt>
  jmp    L77
```

tool_calls: name: retrieve_data
arguments: data_tag: D13
type_infered: string
name: retrieve_data
arguments: data_tag: D7
type_infered: string
name: retrieve_data
arguments: data_tag: D36
type_infered: string
name: retrieve_data
arguments: data_tag: D15
type_infered: string
name: retrieve_data
arguments: data_tag: D6
type_infered: string
name: retrieve_data
arguments: data_tag: D45
type_infered: string

tool: D13: block_write to flash failed - block write not supported by device?

tool: D7: Block-write failed at offset 0x%08x, status=0x%02x


tool: D36: Block locked during block-write process, aborted, status=0x%02x


tool: D15: Command sequence error during block-write, aborted, status=0x%02x


tool: D6: Vpp voltage droop error during block-write, aborted, status=0x%02x


tool: D45: ERROR on block-write - flash is busy even after 0x%x checks


assistant: ```c
void block_write(int addr16b, int *data) {
  int j, f, status;
  unlock_block_for_writes(addr16b);
  flash_write(addr16b, 0xe8);
  if ((flash_read(addr16b) & 0x80) == 0)
    warnx("block_write to flash failed - block write not supported by device?");
  flash_write(addr16b, 0x1f);
  for (j = 0; j < 0x20; j++)
    flash_write(addr16b + j, data[j]);
  flash_write(addr16b, 0xd0);
  status = flash_read(addr16b);
  for (j = 0; ((status & 0x80) == 0) && (j < 0xfff); j++)
    status = flash_read(addr16b);
  if ((status & 0x80) == 0)
    warnx("ERROR on block-write - flash is busy even after 0x%x checks\n", j);
  status = flash_read_status(addr16b);
  if ((status & (1 << 3)) != 0)
    warnx("Vpp voltage droop error during block-write, aborted, status=0x%02x\n", status);
  if ((status & (3 << 4)) != 0)
    warnx("Command sequence error during block-write, aborted, status=0x%02x\n", status);
  if ((status & (1 << 1)) != 0)
    warnx("Block locked during block-write process, aborted, status=0x%02x\n", status);
  if ((status & (1 << 5)) != 0)
    warnx("Block-write failed at offset 0x%08x, status=0x%02x\n", addr16b << 1, status);
  lock_block_to_prevent_writes(addr16b);
  flash_read_mode(addr16b);
}
```