user: 请将以下的汇编代码转换成C语言代码：

```asm
<tty_getw_irq>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x4c(%rbp)
  movl   $0x0,-0x48(%rbp)
  movl   $0x0,-0x44(%rbp)
  movl   $0x0,-0x40(%rbp)
  movl   $0x0,-0x3c(%rbp)
  jmp    L195
L28:
  lea    -0x4d(%rbp),%rax
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    $0x1,%edx
  mov    %eax,%esi
  mov    $0xa,%edi
  call   <sys_call@plt>
  mov    %eax,-0x34(%rbp)
  cmpl   $0x1,-0x34(%rbp)
  jne    L28
  movzbl -0x4d(%rbp),%eax
  cmp    $0x2f,%al
  jbe    L146
  movzbl -0x4d(%rbp),%eax
  cmp    $0x39,%al
  ja     L146
  movzbl -0x4d(%rbp),%edx
  mov    -0x3c(%rbp),%eax
  mov    %dl,-0x30(%rbp,%rax,1)
  addl   $0x1,-0x3c(%rbp)
  movzbl -0x4d(%rbp),%eax
  movzbl %al,%eax
  mov    %eax,%edi
  call   <tty_putc@plt>
  jmp    L177
L146:
  movzbl -0x4d(%rbp),%eax
  cmp    $0xa,%al
  je     L174
  movzbl -0x4d(%rbp),%eax
  cmp    $0xd,%al
  jne    L1
L174:
  movl   $0x1,-0x44(%rbp)
  jmp    L177
L1:
  movzbl -0x4d(%rbp),%eax
  cmp    $0x7f,%al
  jne    L177
  cmpl   $0x0,-0x3c(%rbp)
  je     L177
  subl   $0x1,-0x3c(%rbp)
  mov    $0x8,%edi
  call   <tty_putc@plt>
  mov    $0x20,%edi
  call   <tty_putc@plt>
  mov    $0x8,%edi
  call   <tty_putc@plt>
L177:
  cmpl   $0x20,-0x3c(%rbp)
  jne    L195
  movl   $0x0,-0x38(%rbp)
  jmp    L36
L182:
  mov    $0x8,%edi
  call   <tty_putc@plt>
  mov    $0x20,%edi
  call   <tty_putc@plt>
  mov    $0x8,%edi
  call   <tty_putc@plt>
  addl   $0x1,-0x38(%rbp)
L36:
  mov    -0x38(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jb     L182
  mov    $0x30,%edi
  call   <tty_putc@plt>
  mov    -0x58(%rbp),%rax
  movl   $0x0,(%rax)
  mov    $0x0,%eax
  jmp    L223
L195:
  cmpl   $0x0,-0x44(%rbp)
  je     L28
  movl   $0x0,-0x38(%rbp)
  jmp    L138
L134:
  mov    -0x48(%rbp),%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  movzbl -0x30(%rbp,%rax,1),%eax
  movzbl %al,%eax
  add    %edx,%eax
  sub    $0x30,%eax
  mov    %eax,-0x48(%rbp)
  mov    -0x48(%rbp),%eax
  cmp    -0x4c(%rbp),%eax
  jae    L7
  movl   $0x1,-0x40(%rbp)
L7:
  mov    -0x48(%rbp),%eax
  mov    %eax,-0x4c(%rbp)
  addl   $0x1,-0x38(%rbp)
L138:
  mov    -0x38(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jb     L134
  cmpl   $0x0,-0x40(%rbp)
  jne    L103
  mov    -0x58(%rbp),%rax
  mov    -0x48(%rbp),%edx
  mov    %edx,(%rax)
  jmp    L148
L103:
  movl   $0x0,-0x38(%rbp)
  jmp    L171
L181:
  mov    $0x8,%edi
  call   <tty_putc@plt>
  mov    $0x20,%edi
  call   <tty_putc@plt>
  mov    $0x8,%edi
  call   <tty_putc@plt>
  addl   $0x1,-0x38(%rbp)
L171:
  mov    -0x38(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jb     L181
  mov    $0x30,%edi
  call   <tty_putc@plt>
  mov    -0x58(%rbp),%rax
  movl   $0x0,(%rax)
L148:
  mov    $0x0,%eax
L223:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L70
  call   <__stack_chk_fail@plt>
L70:
  leave
  ret
```

assistant: ```c
unsigned int tty_getw_irq(unsigned int *val) {
  unsigned char buf[32];
  unsigned char byte;
  unsigned int save = 0;
  unsigned int dec = 0;
  unsigned int done = 0;
  unsigned int overflow = 0;
  unsigned int max = 0;
  unsigned int i;
  unsigned int ret;
  while (done == 0) {
    do {
      ret = sys_call(0x0A, (unsigned int)(&byte), 1, 0, 0);
    } while (ret != 1);
    if ((byte > 0x2F) && (byte < 0x3A)) {
      buf[max] = byte;
      max++;
      tty_putc(byte);
    } else if ((byte == 0x0A) || (byte == 0x0D)) {
      done = 1;
    } else if (byte == 0x7F) {
      if (max > 0) {
        max--;
        tty_putc(0x08);
        tty_putc(0x20);
        tty_putc(0x08);
      }
    }
    if (max == 32) {
      for (i = 0; i < max; i++) {
        tty_putc(0x08);
        tty_putc(0x20);
        tty_putc(0x08);
      }
      tty_putc(0x30);
      *val = 0;
      return 0;
    }
  }
  for (i = 0; i < max; i++) {
    dec = dec * 10 + (buf[i] - 0x30);
    if (dec < save)
      overflow = 1;
    save = dec;
  }
  if (overflow == 0) {
    *val = dec;
  } else {
    for (i = 0; i < max; i++) {
      tty_putc(0x08);
      tty_putc(0x20);
      tty_putc(0x08);
    }
    tty_putc(0x30);
    *val = 0;
  }
  return 0;
}
```