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

```asm
<set_serial>:
  endbr64
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%r12
  mov    %r12,%rsi
  call   <tcgetattr@plt>
  test   %rax,%rax
  jne    L91
  mov    D9(%rip),%rax
  mov    D148(%rip),%rdx
  movq   $0x0,0x20(%rsp)
  movq   $0x0,0x18(%rsp)
  mov    (%rax),%eax
  mov    %eax,0x28(%rsp)
  mov    D166(%rip),%rax
  mov    (%rax),%eax
  or     (%rdx),%eax
  mov    D115(%rip),%rdx
  or     (%rdx),%eax
  mov    %eax,0x10(%rsp)
  cmp    $0x1c200,%ebx
  je     L153
  cmp    $0xe100,%ebx
  je     L76
  cmp    $0x9600,%ebx
  je     L163
  cmp    $0x4b00,%ebx
  je     L48
  cmp    $0x2580,%ebx
  je     L93
  cmp    $0x12c0,%ebx
  je     L71
  cmp    $0x960,%ebx
  je     L203
  cmp    $0x4b0,%ebx
  je     L194
  cmp    $0x12c,%ebx
  jne    L91
  mov    D86(%rip),%rbx
  jmp    L148
  nopl   (%rax)
L153:
  mov    D15(%rip),%rbx
L148:
  mov    (%rbx),%esi
  mov    %r12,%rdi
  call   <cfsetospeed@plt>
  mov    (%rbx),%esi
  mov    %r12,%rdi
  call   <cfsetispeed@plt>
  mov    D144(%rip),%rax
  mov    %r12,%rdx
  mov    %ebp,%edi
  mov    (%rax),%esi
  call   <tcsetattr@plt>
  test   %rax,%rax
  jne    L91
  mov    D128(%rip),%rax
  lea    0xc(%rsp),%r12
  mov    %ebp,%edi
  mov    %r12,%rdx
  mov    (%rax),%esi
  call   <ioctl@plt>
  mov    D34(%rip),%rax
  mov    %r12,%rdx
  mov    %ebp,%edi
  mov    (%rax),%eax
  or     %eax,0xc(%rsp)
  mov    D37(%rip),%rax
  mov    (%rax),%esi
  call   <ioctl@plt>
  xor    %eax,%eax
L44:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L77
  add    $0x40,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  cs nopw 0x0(%rax,%rax,1)
L48:
  mov    D161(%rip),%rbx
  jmp    L148
  nopl   0x0(%rax)
L76:
  mov    D167(%rip),%rbx
  jmp    L148
  nopl   0x0(%rax)
L163:
  mov    D139(%rip),%rbx
  jmp    L148
  nopl   0x0(%rax)
L93:
  mov    D42(%rip),%rbx
  jmp    L148
  nopl   0x0(%rax)
L71:
  mov    D153(%rip),%rbx
  jmp    L148
  nopl   0x0(%rax)
L203:
  mov    D163(%rip),%rbx
  jmp    L148
  nopl   0x0(%rax)
L194:
  mov    D99(%rip),%rbx
  jmp    L148
  nopl   0x0(%rax)
L91:
  mov    $0xffffffff,%eax
  jmp    L44
L77:
  call   <__stack_chk_fail@plt>
```

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;
}
```