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

```asm
<sg_err_category_new>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    %edx,-0x1c(%rbp)
  mov    %ecx,-0x20(%rbp)
  mov    %r8,-0x28(%rbp)
  mov    %r9d,-0x2c(%rbp)
  andl   $0x7e,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jne    L135
  cmpl   $0x0,-0x1c(%rbp)
  jne    L135
  cmpl   $0x0,-0x20(%rbp)
  jne    L135
  mov    $0x0,%eax
  jmp    L280
L135:
  cmpl   $0x2,-0x14(%rbp)
  je     L188
  cmpl   $0x22,-0x14(%rbp)
  je     L188
  mov    -0x20(%rbp),%eax
  and    $0xf,%eax
  cmp    $0x8,%eax
  jne    L265
L188:
  cmpq   $0x0,-0x28(%rbp)
  je     L297
  cmpl   $0x2,-0x2c(%rbp)
  jle    L297
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0x2,%eax
  test   %eax,%eax
  je     L178
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xf,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x28(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  mov    %al,-0x5(%rbp)
  jmp    L63
L178:
  mov    -0x28(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xf,%eax
  mov    %eax,-0x4(%rbp)
  cmpl   $0xc,-0x2c(%rbp)
  jle    L253
  mov    -0x28(%rbp),%rax
  add    $0xc,%rax
  movzbl (%rax),%eax
  jmp    L288
L253:
  mov    $0x0,%eax
L288:
  mov    %al,-0x5(%rbp)
L63:
  mov    D16(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x4(%rbp)
  jne    L215
  mov    $0x4,%eax
  jmp    L280
L215:
  mov    D10(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x4(%rbp)
  jne    L9
  cmpb   $0x28,-0x5(%rbp)
  jne    L225
  mov    $0x1,%eax
  jmp    L280
L225:
  cmpb   $0x29,-0x5(%rbp)
  jne    L297
  mov    $0x2,%eax
  jmp    L280
L9:
  mov    D15(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x4(%rbp)
  jne    L297
  mov    $0x5,%eax
  jmp    L280
L297:
  mov    $0x62,%eax
  jmp    L280
L265:
  cmpl   $0x0,-0x1c(%rbp)
  je     L104
  cmpl   $0x1,-0x1c(%rbp)
  je     L247
  cmpl   $0x2,-0x1c(%rbp)
  je     L247
  cmpl   $0x3,-0x1c(%rbp)
  jne    L104
L247:
  mov    $0x3,%eax
  jmp    L280
L104:
  cmpl   $0x0,-0x20(%rbp)
  je     L36
  cmpl   $0x6,-0x20(%rbp)
  jne    L36
  mov    $0x3,%eax
  jmp    L280
L36:
  mov    $0x63,%eax
L280:
  pop    %rbp
  ret
```

assistant: ```c
int sg_err_category_new(int scsi_status, int msg_status, int host_status, int driver_status, const unsigned char *sense_buffer, int sb_len) {
  scsi_status &= 0x7e;
  if (!scsi_status && !host_status && !driver_status) {
    return 0;
  }
  if ((scsi_status == 0x2) || (scsi_status == 0x22) || ((driver_status & 0xf) == 0x08)) {
    if (sense_buffer && (sb_len > 2)) {
      int sense_key;
      unsigned char asc;
      if (sense_buffer[0] & 0x2) {
        sense_key = sense_buffer[1] & 0xf;
        asc = sense_buffer[2];
      } else {
        sense_key = sense_buffer[2] & 0xf;
        asc = (sb_len > 12) ? sense_buffer[12] : 0;
      }
      if (sense_key == RECOVERED_ERROR) {
        return 4;
      } else if (sense_key == UNIT_ATTENTION) {
        if (0x28 == asc) {
          return 1;
        }
        if (0x29 == asc) {
          return 2;
        }
      } else if (sense_key == ILLEGAL_REQUEST) {
        return 5;
      }
    }
    return 98;
  }
  if (host_status) {
    if ((host_status == 0x01) || (host_status == 0x02) || (host_status == 0x03)) {
      return 3;
    }
  }
  if (driver_status) {
    if (driver_status == 0x06) {
      return 3;
    }
  }
  return 99;
}
```