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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x270,%rsp
  mov    %edi,-0x264(%rbp)
  mov    %rsi,-0x270(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x250(%rbp)
  movq   $0x0,-0x248(%rbp)
  movq   $0x0,-0x240(%rbp)
  movq   $0x0,-0x238(%rbp)
  movq   $0x0,-0x230(%rbp)
  movq   $0x0,-0x228(%rbp)
  movq   $0x0,-0x220(%rbp)
  movq   $0x0,-0x218(%rbp)
  movq   $0x0,-0x210(%rbp)
  movq   $0x0,-0x208(%rbp)
  lea    -0x200(%rbp),%rdx
  mov    $0x0,%eax
  mov    $0x3e,%ecx
  mov    %rdx,%rdi
  rep stos %rax,%es:(%rdi)
  mov    $0x0,%eax
  call   <setMux@plt>
  cmpl   $0x2,-0x264(%rbp)
  je     L16
  mov    -0x270(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D10(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
L16:
  mov    -0x270(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <open_port@plt>
  mov    %eax,-0x254(%rbp)
  cmpl   $0xffffffff,-0x254(%rbp)
  jne    L20
  mov    -0x270(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
L20:
  mov    -0x254(%rbp),%eax
  mov    %eax,%edi
  call   <OW_detectKey@plt>
  test   %rax,%rax
  je     L17
  mov    -0x254(%rbp),%eax
  mov    $0x33,%esi
  mov    %eax,%edi
  call   <OW_WriteByte@plt>
  lea    -0x210(%rbp),%rcx
  mov    -0x254(%rbp),%eax
  mov    $0x8,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <OW_ReadBytes@plt>
  cmp    $0x8,%eax
  jne    L17
  movzbl -0x210(%rbp),%eax
  cmp    $0x1,%al
  jne    L17
  lea    -0x210(%rbp),%rax
  mov    $0x7,%esi
  mov    %rax,%rdi
  call   <OW_CRC@plt>
  movzbl -0x209(%rbp),%edx
  cmp    %dl,%al
  jne    L17
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movzbl -0x20f(%rbp),%eax
  movzbl %al,%esi
  movzbl -0x20e(%rbp),%eax
  movzbl %al,%r8d
  movzbl -0x20d(%rbp),%eax
  movzbl %al,%edi
  movzbl -0x20c(%rbp),%eax
  movzbl %al,%ecx
  movzbl -0x20b(%rbp),%eax
  movzbl %al,%edx
  movzbl -0x20a(%rbp),%eax
  movzbl %al,%eax
  sub    $0x8,%rsp
  push   %rsi
  mov    %r8d,%r9d
  mov    %edi,%r8d
  mov    %eax,%esi
  lea    D17(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x10,%rsp
  mov    $0x1,%edi
  call   <sleep@plt>
L17:
  mov    $0x186a0,%edi
  call   <usleep@plt>
  jmp    L20
```

tool_calls: name: disassemble_data
arguments: tag: D10
type_guessed: string
name: disassemble_data
arguments: tag: D11
type_guessed: string
name: disassemble_data
arguments: tag: D9
type_guessed: string
name: disassemble_data
arguments: tag: D17
type_guessed: string

tool: D10: Usage: %s <path to serialPort>


tool: D11: Failed to open serial port at %s


tool: D9: Valid key detected with ID:

tool: D17: %02x%02x%02x%02x%02x%02x


assistant: ```c
int main(int argc, char *argv[]) {
  int fd;
  int i, bytesRead;
  unsigned char buf[64] = {
      0,
  };
  unsigned char inBuf[512] = {
      0,
  };
  unsigned char crc;
  setMux();
  if (argc != 2) {
    printf("Usage: %s <path to serialPort>\n", argv[0]);
    exit(-1);
  }
  fd = open_port(argv[1]);
  if (fd == -1) {
    printf("Failed to open serial port at %s\n", argv[1]);
    exit(-1);
  }
  while (1) {
    if (OW_detectKey(fd)) {
      OW_WriteByte(fd, 0x33);
      if (OW_ReadBytes(fd, inBuf, 8) == 8) {
        if (inBuf[0] == 0x01) {
          if (OW_CRC(inBuf, 7) == inBuf[7]) {
            printf("Valid key detected with ID:");
            printf("%02x%02x%02x%02x%02x%02x\n", inBuf[6], inBuf[5], inBuf[4], inBuf[3], inBuf[2], inBuf[1]);
            sleep(1);
          }
        }
      }
    }
    usleep(1000 * 100);
  }
  close(fd);
}
```