user: 请从给定的汇编指令推导出C源代码：

```asm
<escribir_bit>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x430,%rsp
  mov    %edi,-0x424(%rbp)
  mov    %esi,%eax
  mov    %al,-0x428(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x424(%rbp),%eax
  mov    %eax,%edi
  call   <tamMB@plt>
  mov    %eax,-0x41c(%rbp)
  lea    -0x410(%rbp),%rdx
  mov    -0x41c(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <bread@plt>
  test   %rax,%rax
  jns    L69
  movsbl -0x428(%rbp),%edx
  mov    -0x41c(%rbp),%ecx
  mov    -0x424(%rbp),%eax
  mov    %eax,%esi
  lea    D12(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L78
L69:
  mov    -0x424(%rbp),%eax
  mov    %eax,%edi
  call   <pbit@plt>
  mov    %eax,-0x418(%rbp)
  mov    -0x424(%rbp),%eax
  mov    %eax,%edi
  call   <pbyte@plt>
  mov    %eax,-0x414(%rbp)
  movb   $0x80,-0x41d(%rbp)
  cmpl   $0x0,-0x418(%rbp)
  jle    L0
  movzbl -0x41d(%rbp),%edx
  mov    -0x418(%rbp),%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  mov    %al,-0x41d(%rbp)
L0:
  cmpb   $0x1,-0x428(%rbp)
  jne    L7
  mov    -0x414(%rbp),%eax
  cltd
  shr    $0x16,%edx
  add    %edx,%eax
  and    $0x3ff,%eax
  sub    %edx,%eax
  mov    %eax,%ecx
  movslq %ecx,%rax
  movzbl -0x410(%rbp,%rax,1),%eax
  or     -0x41d(%rbp),%al
  mov    %eax,%edx
  movslq %ecx,%rax
  mov    %dl,-0x410(%rbp,%rax,1)
  jmp    L26
L7:
  cmpb   $0x0,-0x428(%rbp)
  jne    L26
  mov    -0x414(%rbp),%eax
  cltd
  shr    $0x16,%edx
  add    %edx,%eax
  and    $0x3ff,%eax
  sub    %edx,%eax
  mov    %eax,%edx
  movslq %edx,%rax
  movzbl -0x410(%rbp,%rax,1),%eax
  mov    %eax,%ecx
  movzbl -0x41d(%rbp),%eax
  not    %eax
  and    %ecx,%eax
  mov    %eax,%ecx
  movslq %edx,%rax
  mov    %cl,-0x410(%rbp,%rax,1)
L26:
  lea    -0x410(%rbp),%rdx
  mov    -0x41c(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <bwrite@plt>
  test   %rax,%rax
  jns    L59
  movsbl -0x428(%rbp),%edx
  mov    -0x41c(%rbp),%eax
  mov    %eax,%esi
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L78
L59:
  mov    $0x1,%eax
L78:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L74
  call   <__stack_chk_fail@plt>
L74:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D12
type: string
name: disassemble_data
arguments: data_label: D4
type: string

tool: D12: ERROR AL ESCRIBIR BIT (ficheros_basico.c -> escribir_bit(%d, %d)): Error de lectura en bread(%d, buffer)


tool: D4: ERROR AL ESCRIBIR BIT (escribir_bit): Bloque %d, valor %d


assistant: ```c
int escribir_bit(unsigned int nbit, char valor) {
  int num_bloq_mb = tamMB(nbit);
  unsigned char buffer[1024];
  if (bread(num_bloq_mb, buffer) < 0) {
    printf("ERROR AL ESCRIBIR BIT (ficheros_basico.c -> escribir_bit(%d, %d)): Error de lectura en bread(%d, buffer)\n", nbit, valor, num_bloq_mb);
    return (-1);
  } else if (0 == 1) {
    printf("DEBUG | (escribir_bit): Lectura del bloque %d completada correctamente\n", num_bloq_mb);
  }
  int pos_bit = pbit(nbit);
  int pos_byte = pbyte(nbit);
  unsigned char mascara = 128;
  if (pos_bit > 0) {
    mascara >>= pos_bit;
  }
  if (valor == 1) {
    buffer[pos_byte % 1024] |= mascara;
  } else if (valor == 0) {
    buffer[pos_byte % 1024] &= ~mascara;
  }
  if (bwrite(num_bloq_mb, buffer) < 0) {
    printf("ERROR AL ESCRIBIR BIT (escribir_bit): Bloque %d, valor %d\n", num_bloq_mb, valor);
    return (-1);
  } else if (0 == 1) {
    printf("DEBUG | (ficheros_basico.c -> escribir_bit(%d, %d)): Bit escrito correctamente.\n", nbit, valor);
  }
  return (1);
}
```