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

```asm
<cfg_ack_check>:
  endbr64
  push   %r15
  mov    $0x1,%r15d
  push   %r14
  lea    D20(%rip),%r14
  push   %r13
  lea    0x1(%rdi),%r13d
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  sub    $0xfe8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xfd8(%rsp)
  xor    %eax,%eax
  movl   $0x3,0x20(%rsp)
  lea    0x1c(%rsp),%rbx
  lea    0x20(%rsp),%r12
  movq   $0x0,0x28(%rsp)
  cs nopw 0x0(%rax,%rax,1)
L111:
  mov    %rbx,%rdi
  call   <FD_ZERO@plt>
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <FD_SET@plt>
  xor    %ecx,%ecx
  xor    %edx,%edx
  mov    %r12,%r8
  mov    %rbx,%rsi
  mov    %r13d,%edi
  call   <select@plt>
  cmp    $0xffffffff,%eax
  je     L42
  test   %eax,%eax
  je     L119
  lea    0x30(%rsp),%r15
  mov    $0xfa0,%edx
  mov    %ebp,%edi
  mov    %r15,%rsi
  call   <read@plt>
  mov    %rax,%rcx
  xor    %eax,%eax
  test   %rcx,%rcx
  jne    L147
  jmp    L32
  nopl   0x0(%rax)
L1:
  cmp    %rax,%rcx
  je     L32
L147:
  mov    (%r15,%rax,4),%edx
  mov    %rax,%rsi
  add    $0x1,%rax
  cmp    $0xb5,%edx
  jne    L1
  cmpl   $0x62,(%r15,%rax,4)
  jne    L1
  mov    %r14,%rdi
  mov    %rsi,0x8(%rsp)
  mov    %rcx,(%rsp)
  call   <printf@plt>
  mov    (%rsp),%rcx
  mov    0x8(%rsp),%rsi
  cmp    %rcx,%rsi
  jne    L96
L32:
  mov    $0x3,%r15d
  jmp    L111
L42:
  lea    D18(%rip),%rdi
  call   <perror@plt>
L100:
  mov    0xfd8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L63
  add    $0xfe8,%rsp
  mov    %r15d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L119:
  lea    D35(%rip),%rdi
  mov    $0x3,%r15d
  call   <printf@plt>
  jmp    L100
L96:
  cmpl   $0x5,0x38(%rsp,%rsi,4)
  jne    L68
  mov    0x3c(%rsp,%rsi,4),%eax
  test   %eax,%eax
  je     L75
L68:
  lea    D45(%rip),%rdi
  mov    $0x1,%r15d
  call   <printf@plt>
  jmp    L100
L75:
  lea    D14(%rip),%rdi
  mov    $0x2,%r15d
  call   <printf@plt>
  jmp    L100
L63:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D20
data_type: string
name: parse_data
arguments: data_tag: D18
data_type: string
name: parse_data
arguments: data_tag: D35
data_type: string
name: parse_data
arguments: data_tag: D45
data_type: string
name: parse_data
arguments: data_tag: D14
data_type: string

tool: D20: Found header B5 62


tool: D18: select

tool: D35: No ACK/NAK received.


tool: D45: Received ACK, succeeded.


tool: D14: Received NAK, failed.


assistant: ```c
u_int8_t cfg_ack_check(int fd) {
  int rev;
  fd_set rfds;
  struct timeval tv;
  tv.tv_sec = 3;
  tv.tv_usec = 0;
  u_int16_t len = 0, i;
  u_int8_t rval = 1, buf[1000];
  while (1) {
    FD_ZERO(&rfds);
    FD_SET(fd, &rfds);
    rev = select(fd + 1, &rfds, NULL, NULL, &tv);
    if (rev == -1) {
      perror("select");
      break;
    } else if (rev) {
      len = read(fd, buf, sizeof(buf));
      for (i = 0; i < len; i++) {
        if (buf[i] == 0xB5 && buf[i + 1] == 0x62) {
          printf("Found header B5 62\n");
          break;
        }
      }
      if (i == len) {
        rval = 3;
      } else {
        if (buf[i + 2] == 0x05 && buf[i + 3] == 0x00) {
          printf("Received NAK, failed.\n");
          rval = 2;
          break;
        } else {
          printf("Received ACK, succeeded.\n");
          rval = 1;
          break;
        }
      }
    } else {
      printf("No ACK/NAK received.\n");
      rval = 3;
      break;
    }
  }
  return rval;
}
```