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

```asm
<set_serial>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x44(%rbp)
  mov    %esi,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x30(%rbp),%rdx
  mov    -0x44(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <tcgetattr@plt>
  test   %rax,%rax
  je     L118
  mov    $0xffffffff,%eax
  jmp    L169
L118:
  mov    D126(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x18(%rbp)
  movq   $0x0,-0x20(%rbp)
  mov    D22(%rip),%rax
  mov    (%rax),%edx
  mov    D168(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%edx
  mov    D46(%rip),%rax
  mov    (%rax),%eax
  or     %edx,%eax
  mov    %eax,-0x30(%rbp)
  movq   $0x0,-0x28(%rbp)
  cmpl   $0x1c200,-0x48(%rbp)
  jne    L144
  mov    D197(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    D197(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  jmp    L9
L144:
  cmpl   $0xe100,-0x48(%rbp)
  jne    L161
  mov    D132(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    D132(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  jmp    L9
L161:
  cmpl   $0x9600,-0x48(%rbp)
  jne    L19
  mov    D10(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    D10(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  jmp    L9
L19:
  cmpl   $0x4b00,-0x48(%rbp)
  jne    L63
  mov    D134(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    D134(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  jmp    L9
L63:
  cmpl   $0x2580,-0x48(%rbp)
  jne    L149
  mov    D143(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    D143(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  jmp    L9
L149:
  cmpl   $0x12c0,-0x48(%rbp)
  jne    L28
  mov    D237(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    D237(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  jmp    L9
L28:
  cmpl   $0x960,-0x48(%rbp)
  jne    L113
  mov    D231(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    D231(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  jmp    L9
L113:
  cmpl   $0x4b0,-0x48(%rbp)
  jne    L58
  mov    D185(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    D185(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  jmp    L9
L58:
  cmpl   $0x12c,-0x48(%rbp)
  jne    L170
  mov    D83(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetospeed@plt>
  mov    D83(%rip),%rax
  mov    (%rax),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cfsetispeed@plt>
  jmp    L9
L170:
  mov    $0xffffffff,%eax
  jmp    L169
L9:
  mov    D202(%rip),%rax
  mov    (%rax),%ecx
  lea    -0x30(%rbp),%rdx
  mov    -0x44(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <tcsetattr@plt>
  test   %rax,%rax
  je     L153
  mov    $0xffffffff,%eax
  jmp    L169
L153:
  mov    D147(%rip),%rax
  mov    (%rax),%ecx
  lea    -0x34(%rbp),%rdx
  mov    -0x44(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <ioctl@plt>
  mov    -0x34(%rbp),%edx
  mov    D224(%rip),%rax
  mov    (%rax),%eax
  or     %edx,%eax
  mov    %eax,-0x34(%rbp)
  mov    D81(%rip),%rax
  mov    (%rax),%ecx
  lea    -0x34(%rbp),%rdx
  mov    -0x44(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <ioctl@plt>
  mov    $0x0,%eax
L169:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L114
  call   <__stack_chk_fail@plt>
L114:
  leave
  ret
```

assistant: ```c
int set_serial(int fd, int baud) {
  struct termios tios;
  if (tcgetattr(fd, &tios))
    return -1;
  tios.c_iflag = IGNPAR;
  tios.c_oflag = 0;
  tios.c_cflag = (CS8 | CREAD | CLOCAL);
  tios.c_lflag = 0;
  if (baud == 115200) {
    cfsetospeed(&tios, B115200);
    cfsetispeed(&tios, B115200);
  } else if (baud == 57600) {
    cfsetospeed(&tios, B57600);
    cfsetispeed(&tios, B57600);
  } else if (baud == 38400) {
    cfsetospeed(&tios, B38400);
    cfsetispeed(&tios, B38400);
  } else if (baud == 19200) {
    cfsetospeed(&tios, B19200);
    cfsetispeed(&tios, B19200);
  } else if (baud == 9600) {
    cfsetospeed(&tios, B9600);
    cfsetispeed(&tios, B9600);
  } else if (baud == 4800) {
    cfsetospeed(&tios, B4800);
    cfsetispeed(&tios, B4800);
  } else if (baud == 2400) {
    cfsetospeed(&tios, B2400);
    cfsetispeed(&tios, B2400);
  } else if (baud == 1200) {
    cfsetospeed(&tios, B1200);
    cfsetispeed(&tios, B1200);
  } else if (baud == 300) {
    cfsetospeed(&tios, B300);
    cfsetispeed(&tios, B300);
  } else
    return -1;
  if (tcsetattr(fd, TCSANOW, &tios))
    return -1;
  struct serial_struct ss;
  ioctl(fd, TIOCGSERIAL, &ss);
  ss.flags |= ASYNC_LOW_LATENCY;
  ioctl(fd, TIOCSSERIAL, &ss);
  return 0;
}
```