user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<serialOpen>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %edx,-0x40(%rbp)
  mov    %ecx,%eax
  mov    %r8d,-0x48(%rbp)
  mov    %al,-0x44(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0xffffffff,-0x24(%rbp)
  mov    D305(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  mov    D347(%rip),%rax
  mov    (%rax),%edx
  mov    D217(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%edx
  mov    D143(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <open@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jle    L411
  mov    D243(%rip),%rax
  mov    (%rax),%ecx
  mov    -0x24(%rbp),%eax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <fcntl@plt>
  lea    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <tcgetattr@plt>
  lea    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <cfmakeraw@plt>
  mov    -0x20(%rbp),%rdx
  mov    D213(%rip),%rax
  mov    (%rax),%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%rdx
  mov    D237(%rip),%rax
  mov    (%rax),%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  movl   $0x14,(%rax)
  cmpl   $0x1c200,-0x3c(%rbp)
  je     L17
  cmpl   $0x1c200,-0x3c(%rbp)
  ja     L364
  cmpl   $0xe100,-0x3c(%rbp)
  je     L166
  cmpl   $0xe100,-0x3c(%rbp)
  ja     L364
  cmpl   $0x9600,-0x3c(%rbp)
  je     L45
  cmpl   $0x9600,-0x3c(%rbp)
  ja     L364
  cmpl   $0x4b00,-0x3c(%rbp)
  je     L348
  cmpl   $0x4b00,-0x3c(%rbp)
  ja     L364
  cmpl   $0x2580,-0x3c(%rbp)
  je     L80
  cmpl   $0x2580,-0x3c(%rbp)
  ja     L364
  cmpl   $0x12c0,-0x3c(%rbp)
  je     L44
  cmpl   $0x12c0,-0x3c(%rbp)
  ja     L364
  cmpl   $0x4b0,-0x3c(%rbp)
  je     L172
  cmpl   $0x708,-0x3c(%rbp)
  je     L405
  jmp    L364
L172:
  mov    D212(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L148
L405:
  mov    D329(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L148
L44:
  mov    D284(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L148
L80:
  mov    D304(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L148
L348:
  mov    D305(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L148
L45:
  mov    D227(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L148
L166:
  mov    D100(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L148
L17:
  mov    D266(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L148
L364:
  mov    D305(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x28(%rbp)
  nop
L148:
  mov    -0x28(%rbp),%edx
  lea    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  mov    -0x28(%rbp),%edx
  lea    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    -0x18(%rbp),%edx
  mov    D12(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%edx
  mov    D56(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x14(%rbp),%edx
  mov    D328(%rip),%rax
  mov    (%rax),%ecx
  mov    D176(%rip),%rax
  mov    (%rax),%eax
  or     %ecx,%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x18(%rbp),%edx
  mov    D197(%rip),%rax
  mov    (%rax),%ecx
  mov    D162(%rip),%rax
  mov    (%rax),%eax
  or     %ecx,%eax
  or     %edx,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0xc(%rbp),%edx
  mov    D50(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0xc(%rbp)
  cmpl   $0x7,-0x40(%rbp)
  je     L340
  cmpl   $0x7,-0x40(%rbp)
  ja     L156
  cmpl   $0x5,-0x40(%rbp)
  je     L99
  cmpl   $0x6,-0x40(%rbp)
  je     L283
  jmp    L156
L99:
  mov    -0x18(%rbp),%edx
  mov    D361(%rip),%rax
  mov    (%rax),%eax
  or     %edx,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L308
L283:
  mov    -0x18(%rbp),%edx
  mov    D252(%rip),%rax
  mov    (%rax),%eax
  or     %edx,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L308
L340:
  mov    -0x18(%rbp),%edx
  mov    D71(%rip),%rax
  mov    (%rax),%eax
  or     %edx,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L308
L156:
  mov    -0x18(%rbp),%edx
  mov    D80(%rip),%rax
  mov    (%rax),%eax
  or     %edx,%eax
  mov    %eax,-0x18(%rbp)
  nop
L308:
  mov    -0x18(%rbp),%edx
  mov    D251(%rip),%rax
  mov    (%rax),%eax
  or     %edx,%eax
  mov    %eax,-0x18(%rbp)
  movsbl -0x44(%rbp),%eax
  cmp    $0x6f,%eax
  je     L106
  cmp    $0x6f,%eax
  jg     L304
  cmp    $0x65,%eax
  je     L127
  cmp    $0x65,%eax
  jg     L304
  cmp    $0x45,%eax
  je     L127
  cmp    $0x4f,%eax
  je     L106
  jmp    L304
L127:
  mov    -0x18(%rbp),%edx
  mov    D210(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L313
L106:
  mov    -0x18(%rbp),%edx
  mov    D210(%rip),%rax
  mov    (%rax),%eax
  and    %edx,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L313
L304:
  mov    -0x18(%rbp),%edx
  mov    D251(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0x18(%rbp)
  nop
L313:
  cmpl   $0x2,-0x48(%rbp)
  jne    L189
  mov    -0x18(%rbp),%edx
  mov    D326(%rip),%rax
  mov    (%rax),%eax
  and    %edx,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L426
L189:
  mov    -0x18(%rbp),%edx
  mov    D326(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0x18(%rbp)
L426:
  mov    -0x10(%rbp),%edx
  mov    D306(%rip),%rax
  mov    (%rax),%ecx
  mov    D61(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%ecx
  mov    D324(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%ecx
  mov    D297(%rip),%rax
  mov    (%rax),%eax
  or     %ecx,%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0x10(%rbp)
  mov    D164(%rip),%rax
  mov    (%rax),%ecx
  lea    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <tcsetattr@plt>
L411:
  mov    -0x24(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L203
  call   <__stack_chk_fail@plt>
L203:
  leave
  ret
```

assistant: ```c
int serialOpen(const char *device, unsigned int baudrate, unsigned int bits, char parity, unsigned int stop) {
  int fd = -1;
  struct termios optnew;
  speed_t speed = B19200;
  fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
  if (fd > 0) {
    fcntl(fd, F_SETFL, 0);
    tcgetattr(fd, &optnew);
    cfmakeraw(&optnew);
    optnew.c_cc[VMIN] = 0;
    optnew.c_cc[VTIME] = 2 * 10;
    switch (baudrate) {
    case 1200:
      speed = B1200;
      break;
    case 1800:
      speed = B1800;
      break;
    case 4800:
      speed = B4800;
      break;
    case 9600:
      speed = B9600;
      break;
    case 19200:
      speed = B19200;
      break;
    case 38400:
      speed = B38400;
      break;
    case 57600:
      speed = B57600;
      break;
    case 115200:
      speed = B115200;
      break;
    default:
      speed = B19200;
      break;
    }
    cfsetispeed(&optnew, speed);
    cfsetospeed(&optnew, speed);
    optnew.c_cflag &= ~CSIZE;
    optnew.c_cflag &= ~CRTSCTS;
    optnew.c_iflag &= ~(ICRNL | IXON);
    optnew.c_cflag |= CLOCAL | CREAD;
    optnew.c_oflag &= ~OPOST;
    switch (bits) {
    case 5:
      optnew.c_cflag |= CS5;
      break;
    case 6:
      optnew.c_cflag |= CS6;
      break;
    case 7:
      optnew.c_cflag |= CS7;
      break;
    default:
      optnew.c_cflag |= CS8;
      break;
    }
    optnew.c_cflag |= PARENB;
    switch (parity) {
    case 'e':
    case 'E':
      optnew.c_cflag &= ~PARODD;
      break;
    case 'o':
    case 'O':
      optnew.c_cflag &= PARODD;
      break;
    default:
      optnew.c_cflag &= ~PARENB;
      break;
    }
    if (stop == 2)
      optnew.c_cflag &= CSTOPB;
    else
      optnew.c_cflag &= ~CSTOPB;
    optnew.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
    tcsetattr(fd, TCSANOW, &optnew);
  }
  return fd;
}
```