user: Please show me the C implementation that matches the assembly code listed below:

```asm
<Serial_Openport>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x30,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  cmp    $0x12c0,%esi
  je     L60
  jg     L407
  cmp    $0xc8,%esi
  je     L395
  jle    L179
  cmp    $0x4b0,%esi
  je     L263
  jle    L559
  cmp    $0x708,%esi
  je     L431
  cmp    $0x960,%esi
  jne    L419
  mov    D156(%rip),%rax
  mov    (%rax),%r12d
  nopl   0x0(%rax)
L472:
  mov    D41(%rip),%rax
  mov    (%rax),%esi
  mov    D297(%rip),%rax
  or     (%rax),%esi
  call   <open@plt>
  mov    %eax,%r13d
  test   %eax,%eax
  js     L21
  mov    D144(%rip),%rax
  xor    %edx,%edx
  mov    %r13d,%edi
  mov    %rsp,%r14
  mov    (%rax),%esi
  call   <fcntl@plt>
  xor    %esi,%esi
  mov    $0x28,%edx
  mov    %r14,%rdi
  call   <memset@plt>
  mov    D196(%rip),%rdx
  pxor   %xmm0,%xmm0
  mov    %r13d,%edi
  mov    D235(%rip),%rax
  movaps %xmm0,0x10(%rsp)
  mov    (%rax),%eax
  or     (%rdx),%eax
  mov    D150(%rip),%rdx
  or     (%rdx),%eax
  mov    D152(%rip),%rdx
  or     %r12d,%eax
  mov    %eax,(%rsp)
  mov    D126(%rip),%rax
  mov    (%rdx),%rdx
  mov    (%rax),%eax
  mov    %eax,0x20(%rsp)
  mov    0x8(%rsp),%rax
  mov    %ebp,(%rax,%rdx,4)
  mov    D142(%rip),%rdx
  mov    (%rdx),%rdx
  mov    %ebx,(%rax,%rdx,4)
  mov    D324(%rip),%rax
  mov    %r14,%rdx
  mov    (%rax),%esi
  call   <tcsetattr@plt>
  cmp    $0xffffffff,%eax
  je     L312
L14:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L527
  add    $0x30,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L559:
  cmp    $0x12c,%esi
  je     L386
  cmp    $0x258,%esi
  jne    L419
  mov    D301(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nopl   (%rax)
L179:
  cmp    $0x6e,%esi
  je     L514
  jle    L314
  cmp    $0x86,%esi
  je     L206
  cmp    $0x96,%esi
  jne    L419
  mov    D55(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nopw   0x0(%rax,%rax,1)
L407:
  cmp    $0x70800,%esi
  je     L497
  jle    L330
  cmp    $0xe1000,%esi
  je     L48
  jle    L69
  cmp    $0xf4240,%esi
  jne    L419
  mov    D222(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nopl   0x0(%rax,%rax,1)
L314:
  cmp    $0x32,%esi
  je     L197
  cmp    $0x4b,%esi
  jne    L419
  mov    D180(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nopl   0x0(%rax)
L69:
  cmp    $0x7a120,%esi
  je     L155
  cmp    $0x8ca00,%esi
  jne    L419
  mov    D191(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nopl   0x0(%rax,%rax,1)
L330:
  cmp    $0x9600,%esi
  je     L283
  jle    L296
  cmp    $0xe100,%esi
  je     L482
  cmp    $0x38400,%esi
  jne    L419
  mov    D182(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nopl   0x0(%rax)
L296:
  cmp    $0x2580,%esi
  je     L77
  cmp    $0x4b00,%esi
  jne    L419
  mov    D113(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nopl   0x0(%rax,%rax,1)
L419:
  mov    D9(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L386:
  mov    D251(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L431:
  mov    D276(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L263:
  mov    D269(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L395:
  mov    D138(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L60:
  mov    D38(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L77:
  mov    D289(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L482:
  mov    D4(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L283:
  mov    D95(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L155:
  mov    D216(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L197:
  mov    D172(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L48:
  mov    D274(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L497:
  mov    D27(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L206:
  mov    D190(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L514:
  mov    D260(%rip),%rax
  mov    (%rax),%r12d
  jmp    L472
  nop
L21:
  mov    $0xffffffff,%r13d
  jmp    L14
L312:
  mov    %r13d,%edi
  mov    $0xffffffff,%r13d
  call   <close@plt>
  jmp    L14
L527:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int Serial_Openport(const char *port, int baudrate, int rec_chars, int block_time) {
  struct termios options;
  int baudr;
  int port_id;
  switch (baudrate) {
  case 50:
    baudr = B50;
    break;
  case 75:
    baudr = B75;
    break;
  case 110:
    baudr = B110;
    break;
  case 134:
    baudr = B134;
    break;
  case 150:
    baudr = B150;
    break;
  case 200:
    baudr = B200;
    break;
  case 300:
    baudr = B300;
    break;
  case 600:
    baudr = B600;
    break;
  case 1200:
    baudr = B1200;
    break;
  case 1800:
    baudr = B1800;
    break;
  case 2400:
    baudr = B2400;
    break;
  case 4800:
    baudr = B4800;
    break;
  case 9600:
    baudr = B9600;
    break;
  case 19200:
    baudr = B19200;
    break;
  case 38400:
    baudr = B38400;
    break;
  case 57600:
    baudr = B57600;
    break;
  case 115200:
    baudr = B115200;
    break;
  case 230400:
    baudr = B230400;
    break;
  case 460800:
    baudr = B460800;
    break;
  case 500000:
    baudr = B500000;
    break;
  case 576000:
    baudr = B576000;
    break;
  case 921600:
    baudr = B921600;
    break;
  case 1000000:
    baudr = B1000000;
    break;
  default:
    baudr = B115200;
    break;
  }
  port_id = open(port, O_RDWR | O_NOCTTY);
  if (port_id < 0)
    return (-1);
  fcntl(port_id, F_SETFL, 0);
  memset(&options, 0, sizeof(options));
  options.c_cflag = baudr | CS8 | CLOCAL | CREAD;
  options.c_iflag = IGNPAR;
  options.c_oflag = 0;
  options.c_lflag = 0;
  options.c_cc[VMIN] = rec_chars;
  options.c_cc[VTIME] = block_time;
  if (tcsetattr(port_id, TCSANOW, &options) == -1) {
    close(port_id);
    return (-1);
  }
  return port_id;
}
```