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

```asm
<tsc40_init>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movb   $0x55,-0xa(%rbp)
  lea    -0xa(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  cmp    $0x1,%eax
  je     L22
  mov    $0xffffffff,%eax
  jmp    L185
L22:
  mov    $0x3a98,%edi
  call   <usleep@plt>
  movb   $0x15,-0xa(%rbp)
  lea    -0xa(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  cmp    $0x1,%eax
  je     L171
  mov    $0xffffffff,%eax
  jmp    L185
L171:
  lea    -0x11(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x64,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <readchar@plt>
  test   %rax,%rax
  je     L31
  mov    $0xffffffff,%eax
  jmp    L185
L31:
  movzbl -0x11(%rbp),%eax
  not    %eax
  shr    $0x7,%al
  movzbl %al,%eax
  mov    %eax,-0x10(%rbp)
  lea    -0x11(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x64,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <readchar@plt>
  test   %rax,%rax
  je     L214
  mov    $0xffffffff,%eax
  jmp    L185
L214:
  movb   $0x5,-0xa(%rbp)
  movb   $0x45,-0x9(%rbp)
  lea    -0xa(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x2,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  cmp    $0x2,%eax
  je     L208
  mov    $0xffffffff,%eax
  jmp    L185
L208:
  lea    -0x11(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x64,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <readchar@plt>
  test   %rax,%rax
  je     L20
  mov    $0xffffffff,%eax
  jmp    L185
L20:
  movzbl -0x11(%rbp),%eax
  cmp    $0x15,%al
  jne    L149
  cmpl   $0x1,-0x10(%rbp)
  jne    L149
  lea    -0x11(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x64,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <readchar@plt>
  test   %rax,%rax
  je     L13
  mov    $0xffffffff,%eax
  jmp    L185
L13:
  movzbl -0x11(%rbp),%eax
  movzbl %al,%eax
  cmp    $0x8,%eax
  seta   %dl
  test   %dl,%dl
  jne    L112
  mov    $0x114,%edx
  mov    %eax,%ecx
  shr    %cl,%rdx
  mov    %rdx,%rax
  and    $0x1,%eax
  test   %rax,%rax
  setne  %al
  test   %al,%al
  je     L112
  mov    $0xffffffff,%eax
  jmp    L185
L112:
  nop
L149:
  movb   $0x1,-0xa(%rbp)
  lea    -0xa(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  cmp    $0x1,%eax
  je     L204
  mov    $0xffffffff,%eax
  jmp    L185
L204:
  mov    $0x0,%eax
L185:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L119
  call   <__stack_chk_fail@plt>
L119:
  leave
  ret
```

assistant: ```c
int tsc40_init(int fd, unsigned long *id, unsigned long *extra) {
  unsigned char cmd[2], data;
  unsigned int eeprom;
  cmd[0] = 0x55;
  if (write(fd, cmd, 1) != 1)
    return -1;
  usleep(15 * 1000);
  cmd[0] = 0x15;
  if (write(fd, cmd, 1) != 1)
    return -1;
  if (readchar(fd, &data, 100))
    return -1;
  eeprom = !((data & 0x80) >> 7);
  if (readchar(fd, &data, 100))
    return -1;
  cmd[0] = 0x05;
  cmd[1] = 0x45;
  if (write(fd, cmd, 2) != 2)
    return -1;
  if (readchar(fd, &data, 100))
    return -1;
  if ((data == 0x15) && (eeprom == 1)) {
    if (readchar(fd, &data, 100))
      return -1;
    switch (data) {
    case 0x02:
    case 0x04:
    case 0x08:
      return -1;
      break;
    default:
      break;
    }
  }
  cmd[0] = 0x01;
  if (write(fd, cmd, 1) != 1)
    return -1;
  return 0;
}
```