ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请将以下的汇编代码转换成C语言代码：

```asm
<get_version_line>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdx,(%rsp)
  mov    %rcx,0x8(%rsp)
  mov    %r8,0x10(%rsp)
  mov    %r9,0x18(%rsp)
  test   %rsi,%rsi
  je     L42
  mov    %rsi,%rbx
  mov    %rdi,%r13
  jmp    L25
  nopl   0x0(%rax)
L40:
  lea    0x4(%rax),%r14
  mov    %r13,%rdi
  mov    %r14,%rdx
  sub    %r13,%rdx
  sar    $0x2,%rdx
  mov    %edx,%esi
  mov    %rdx,%r15
  call   <is_version_line@plt>
  mov    %r15,%rsi
  test   %rax,%rax
  jne    L19
  mov    %r14,%r13
  sub    %r15,%rbx
  je     L65
L25:
  mov    %rbx,%rdx
  mov    $0xa,%esi
  mov    %r13,%rdi
  call   <memchr@plt>
  test   %rax,%rax
  jne    L40
L65:
  lea    (%r12,%rbp,4),%rax
  xor    %edx,%edx
  xor    %esi,%esi
  sub    %r13,%rax
  sar    $0x2,%rax
L1:
  mov    (%rsp),%rcx
  mov    %rdx,(%rcx)
  mov    0x8(%rsp),%rcx
  mov    %rsi,(%rcx)
  mov    0x10(%rsp),%rcx
  mov    %r13,(%rcx)
  mov    0x18(%rsp),%rcx
  mov    %rax,(%rcx)
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L19:
  lea    (%r12,%rbp,4),%rax
  mov    %r13,%rdx
  mov    %r14,%r13
  sub    %r14,%rax
  sar    $0x2,%rax
  jmp    L1
L42:
  mov    %rdi,%r13
  jmp    L65
```

assistant: ```c
int get_version_line(const uint8_t *in, size_t in_len, const uint8_t **ver, size_t *ver_len, const uint8_t **rest, size_t *rest_len) {
  const uint8_t *cur;
  size_t cur_len;
  cur = in;
  cur_len = in_len;
  while (cur_len > 0) {
    const uint8_t *end = memchr(cur, '\n', cur_len);
    if (end == NULL)
      break;
    end++;
    if (is_version_line(cur, end - cur)) {
      *ver = cur;
      *ver_len = end - cur;
      *rest = end;
      *rest_len = (in + in_len) - end;
      return 0;
    }
    cur_len -= end - cur;
    cur = end;
  }
  *ver = NULL;
  *ver_len = 0;
  *rest = cur;
  *rest_len = in + in_len - cur;
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<get_version_line>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdx,(%rsp)
  mov    %rcx,0x8(%rsp)
  mov    %r8,0x10(%rsp)
  mov    %r9,0x18(%rsp)
  test   %rsi,%rsi
  je     L10
  mov    %rsi,%rbx
  mov    %rdi,%r13
  jmp    L38
  nopl   0x0(%rax)
L32:
  lea    0x4(%rax),%r14
  mov    %r13,%rdi
  mov    %r14,%rdx
  sub    %r13,%rdx
  sar    $0x2,%rdx
  mov    %edx,%esi
  mov    %rdx,%r15
  call   <is_version_line@plt>
  mov    %r15,%rsi
  test   %rax,%rax
  jne    L16
  mov    %r14,%r13
  sub    %r15,%rbx
  je     L22
L38:
  mov    %rbx,%rdx
  mov    $0xa,%esi
  mov    %r13,%rdi
  call   <memchr@plt>
  test   %rax,%rax
  jne    L32
L22:
  lea    (%r12,%rbp,4),%rax
  xor    %edx,%edx
  xor    %esi,%esi
  sub    %r13,%rax
  sar    $0x2,%rax
L15:
  mov    (%rsp),%rcx
  mov    %rdx,(%rcx)
  mov    0x8(%rsp),%rcx
  mov    %rsi,(%rcx)
  mov    0x10(%rsp),%rcx
  mov    %r13,(%rcx)
  mov    0x18(%rsp),%rcx
  mov    %rax,(%rcx)
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L16:
  lea    (%r12,%rbp,4),%rax
  mov    %r13,%rdx
  mov    %r14,%r13
  sub    %r14,%rax
  sar    $0x2,%rax
  jmp    L15
L10:
  mov    %rdi,%r13
  jmp    L22
```

assistant: ```c
int get_version_line(const uint8_t *in, size_t in_len, const uint8_t **ver, size_t *ver_len, const uint8_t **rest, size_t *rest_len) {
  const uint8_t *cur;
  size_t cur_len;
  cur = in;
  cur_len = in_len;
  while (cur_len > 0) {
    const uint8_t *end = memchr(cur, '\n', cur_len);
    if (end == NULL)
      break;
    end++;
    if (is_version_line(cur, end - cur)) {
      *ver = cur;
      *ver_len = end - cur;
      *rest = end;
      *rest_len = (in + in_len) - end;
      return 0;
    }
    cur_len -= end - cur;
    cur = end;
  }
  *ver = NULL;
  *ver_len = 0;
  *rest = cur;
  *rest_len = in + in_len - cur;
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<strcompL>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  mov    %rdi,-0x10(%rbp)
  mov    %rsi,-0x18(%rbp)
  mov    %rdx,%rax
  mov    %rcx,%rdx
  mov    $0x0,%ebx
  jmp    L60
L48:
  addq   $0x1,-0x10(%rbp)
  addq   $0x1,-0x18(%rbp)
  add    $0x1,%rbx
L60:
  cmp    %rax,%rbx
  jge    L36
  cmp    %rdx,%rbx
  jge    L36
  mov    -0x10(%rbp),%rcx
  movzbl (%rcx),%esi
  mov    -0x18(%rbp),%rcx
  movzbl (%rcx),%ecx
  cmp    %cl,%sil
  je     L48
L36:
  cmp    %rbx,%rax
  jne    L90
  cmp    %rax,%rdx
  jne    L92
  mov    $0x0,%eax
  jmp    L10
L92:
  mov    $0xffffffff,%eax
  jmp    L10
L90:
  cmp    %rbx,%rdx
  jne    L97
  cmp    %rax,%rdx
  jne    L31
  mov    $0x0,%eax
  jmp    L10
L31:
  mov    $0x1,%eax
  jmp    L10
L97:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
L10:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int strcompL(const unsigned char *s1, const unsigned char *s2, register ulong ws1, register ulong ws2) {
  register ulong iters = 0;
  while (iters < ws1 && iters < ws2 && *s1 == *s2) {
    s1++;
    s2++;
    iters++;
  }
  if (ws1 == iters) {
    if (ws2 == ws1)
      return 0;
    else
      return -1;
  } else if (ws2 == iters) {
    if (ws2 == ws1)
      return 0;
    else
      return +1;
  } else {
    return (*s1 - *s2);
  }
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<strcompL>:
  endbr64
  cmp    %rcx,%rdx
  mov    %rcx,%rax
  cmovle %rdx,%rax
  mov    $0x0,%r8d
  test   %rax,%rax
  jle    L21
L43:
  movzbl (%rsi),%r9d
  cmp    %r9b,(%rdi)
  jne    L21
  add    $0x1,%rdi
  add    $0x1,%rsi
  add    $0x1,%r8
  cmp    %rax,%r8
  jne    L43
  mov    %rax,%r8
L21:
  cmp    %r8,%rdx
  je     L6
  mov    $0x1,%eax
  cmp    %r8,%rcx
  je     L8
  movzbl (%rdi),%eax
  movzbl (%rsi),%edx
  sub    %edx,%eax
L8:
  ret
L6:
  cmp    %rcx,%rdx
  setne  %al
  movzbl %al,%eax
  neg    %eax
  ret
```

assistant: ```c
int strcompL(const unsigned char *s1, const unsigned char *s2, register ulong ws1, register ulong ws2) {
  register ulong iters = 0;
  while (iters < ws1 && iters < ws2 && *s1 == *s2) {
    s1++;
    s2++;
    iters++;
  }
  if (ws1 == iters) {
    if (ws2 == ws1)
      return 0;
    else
      return -1;
  } else if (ws2 == iters) {
    if (ws2 == ws1)
      return 0;
    else
      return +1;
  } else {
    return (*s1 - *s2);
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<strcompL>:
  endbr64
  cmp    %rcx,%rdx
  mov    %rcx,%r8
  cmovle %rdx,%r8
  xor    %eax,%eax
  test   %r8,%r8
  jg     L26
  jmp    L16
  nopw   0x0(%rax,%rax,1)
L32:
  add    $0x1,%rax
  add    $0x1,%rdi
  add    $0x1,%rsi
  cmp    %r8,%rax
  je     L16
L26:
  movzbl (%rsi),%r9d
  cmp    %r9b,(%rdi)
  je     L32
L16:
  cmp    %rax,%rdx
  je     L8
  cmp    %rax,%rcx
  jne    L36
  xor    %eax,%eax
  cmp    %rcx,%rdx
  setne  %al
  ret
  nopl   (%rax)
L36:
  movzbl (%rdi),%eax
  movzbl (%rsi),%edx
  sub    %edx,%eax
  ret
  nopl   0x0(%rax)
L8:
  xor    %eax,%eax
  cmp    %rcx,%rdx
  setne  %al
  neg    %eax
  ret
```

assistant: ```c
int strcompL(const unsigned char *s1, const unsigned char *s2, register ulong ws1, register ulong ws2) {
  register ulong iters = 0;
  while (iters < ws1 && iters < ws2 && *s1 == *s2) {
    s1++;
    s2++;
    iters++;
  }
  if (ws1 == iters) {
    if (ws2 == ws1)
      return 0;
    else
      return -1;
  } else if (ws2 == iters) {
    if (ws2 == ws1)
      return 0;
    else
      return +1;
  } else {
    return (*s1 - *s2);
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<strcompL>:
  endbr64
  cmp    %rcx,%rdx
  mov    %rcx,%r8
  cmovle %rdx,%r8
  xor    %eax,%eax
  test   %r8,%r8
  jg     L3
  jmp    L19
  nopw   0x0(%rax,%rax,1)
L11:
  add    $0x1,%rax
  add    $0x1,%rdi
  add    $0x1,%rsi
  cmp    %r8,%rax
  je     L19
L3:
  movzbl (%rsi),%r9d
  cmp    %r9b,(%rdi)
  je     L11
L19:
  cmp    %rax,%rdx
  je     L2
  cmp    %rax,%rcx
  jne    L23
  xor    %eax,%eax
  cmp    %rcx,%rdx
  setne  %al
  ret
  nopl   (%rax)
L23:
  movzbl (%rdi),%eax
  movzbl (%rsi),%edx
  sub    %edx,%eax
  ret
  nopl   0x0(%rax)
L2:
  xor    %eax,%eax
  cmp    %rcx,%rdx
  setne  %al
  neg    %eax
  ret
```

assistant: ```c
int strcompL(const unsigned char *s1, const unsigned char *s2, register ulong ws1, register ulong ws2) {
  register ulong iters = 0;
  while (iters < ws1 && iters < ws2 && *s1 == *s2) {
    s1++;
    s2++;
    iters++;
  }
  if (ws1 == iters) {
    if (ws2 == ws1)
      return 0;
    else
      return -1;
  } else if (ws2 == iters) {
    if (ws2 == ws1)
      return 0;
    else
      return +1;
  } else {
    return (*s1 - *s2);
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<rop3_135_0_1>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,%ecx
  mov    %edx,%eax
  mov    %ecx,%edx
  mov    %dl,-0x1c(%rbp)
  mov    %al,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  and    -0x1c(%rbp),%al
  mov    %al,-0x2(%rbp)
  movzbl -0x20(%rbp),%eax
  xor    -0x2(%rbp),%al
  mov    %al,-0x1(%rbp)
  notb   -0x1(%rbp)
  movzbl -0x1(%rbp),%eax
  and    -0x1c(%rbp),%al
  mov    %eax,%ecx
  movzbl -0x20(%rbp),%eax
  not    %eax
  mov    %eax,%edx
  movzbl -0x1(%rbp),%eax
  and    %edx,%eax
  or     %eax,%ecx
  mov    %ecx,%edx
  movzbl -0x1c(%rbp),%eax
  not    %eax
  mov    %eax,%ecx
  movzbl -0x20(%rbp),%eax
  and    %eax,%ecx
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  and    %ecx,%eax
  or     %edx,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %dl,(%rax)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void rop3_135_0_1(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  stk2 = *D & S;
  stk1 = T ^ stk2;
  stk1 = ~stk1;
  *D = (stk1 & S) | (stk1 & (~T)) | (T & (~S) & *D);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<rop3_135_0_1>:
  endbr64
  mov    %rdi,%r8
  mov    %esi,%edi
  mov    %esi,%eax
  and    (%r8),%al
  mov    %eax,%ecx
  xor    %edx,%ecx
  not    %esi
  and    %edx,%esi
  and    (%r8),%sil
  or     %edx,%eax
  not    %eax
  or     %eax,%esi
  mov    %ecx,%eax
  not    %eax
  and    %edi,%eax
  or     %eax,%esi
  mov    %sil,(%r8)
  ret
```

assistant: ```c
void rop3_135_0_1(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  stk2 = *D & S;
  stk1 = T ^ stk2;
  stk1 = ~stk1;
  *D = (stk1 & S) | (stk1 & (~T)) | (T & (~S) & *D);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<rop3_135_0_1>:
  endbr64
  mov    %rdi,%r8
  mov    %esi,%edi
  movzbl (%r8),%eax
  and    %esi,%eax
  not    %esi
  mov    %eax,%ecx
  or     %edx,%eax
  and    %edx,%esi
  and    (%r8),%sil
  not    %eax
  xor    %edx,%ecx
  or     %eax,%esi
  mov    %ecx,%eax
  not    %eax
  and    %edi,%eax
  or     %eax,%esi
  mov    %sil,(%r8)
  ret
```

assistant: ```c
void rop3_135_0_1(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  stk2 = *D & S;
  stk1 = T ^ stk2;
  stk1 = ~stk1;
  *D = (stk1 & S) | (stk1 & (~T)) | (T & (~S) & *D);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<rop3_135_0_1>:
  endbr64
  mov    %rdi,%r8
  mov    %esi,%edi
  movzbl (%r8),%eax
  and    %esi,%eax
  not    %esi
  mov    %eax,%ecx
  or     %edx,%eax
  and    %edx,%esi
  and    (%r8),%sil
  not    %eax
  xor    %edx,%ecx
  or     %eax,%esi
  mov    %ecx,%eax
  not    %eax
  and    %edi,%eax
  or     %eax,%esi
  mov    %sil,(%r8)
  ret
```

assistant: ```c
void rop3_135_0_1(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  stk2 = *D & S;
  stk1 = T ^ stk2;
  stk1 = ~stk1;
  *D = (stk1 & S) | (stk1 & (~T)) | (T & (~S) & *D);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<checkfd>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x18,%rsp
  mov    %esi,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  mov    D53(%rip),%rax
  mov    (%rax),%edx
  movslq %edx,%rax
  add    $0xf,%rax
  mov    %rax,%rsi
  and    $0xfffffffffffffff0,%rsi
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rcx
  sub    %rax,%rcx
L5:
  cmp    %rcx,%rsp
  je     L49
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L5
L49:
  mov    %rsi,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L24
  orq    $0x0,-0x8(%rsp,%rax,1)
L24:
  mov    %rsp,%r12
  mov    (%rdi),%ebx
  mov    D24(%rip),%rax
  mov    (%rax),%eax
  mov    D20(%rip),%rcx
  or     (%rcx),%eax
  mov    D27(%rip),%rcx
  or     (%rcx),%eax
  test   %ebx,%eax
  jne    L75
  mov    D74(%rip),%rax
  and    (%rax),%ebx
  jne    L97
L29:
  mov    -0x28(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L86
  mov    %ebx,%eax
  lea    -0x18(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  ret
L97:
  mov    D23(%rip),%rax
  movq   $0x0,(%rax)
  mov    0x4(%rdi),%edi
  mov    %r12,%rsi
  call   <read@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  jle    L2
L37:
  mov    %ebx,%edx
  mov    %r12,%rsi
  mov    %r13d,%edi
  call   <write@plt>
  test   %eax,%eax
  jle    L115
  movslq %eax,%rdx
  add    %rdx,%r12
  sub    %eax,%ebx
  jne    L37
  jmp    L29
L2:
  mov    D23(%rip),%rdx
  mov    D36(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  setne  %bl
  movzbl %bl,%ebx
  neg    %ebx
  jmp    L29
L75:
  mov    $0xffffffff,%ebx
  jmp    L29
L115:
  mov    $0xffffffff,%ebx
  jmp    L29
L86:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int checkfd(struct pollfd *fdp, int outfd) {
  int nr, nw;
  char buf[BUFSIZ];
  if (fdp->revents & (POLLNVAL | POLLERR | POLLHUP))
    return -1;
  if ((fdp->revents & POLLIN) == 0)
    return 0;
  errno = 0;
  nr = read(fdp->fd, buf, sizeof buf);
  if (nr <= 0) {
    if (errno != EAGAIN)
      return -1;
    else
      return 0;
  } else {
    char *bc = buf;
    while (nr) {
      if ((nw = write(outfd, bc, nr)) <= 0)
        return -1;
      nr -= nw;
      bc += nw;
    }
    return 0;
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<checkfd>:
  endbr64
  push   %rbp
  mov    %rdi,%rdx
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    D48(%rip),%rax
  mov    %rsp,%rsi
  movslq (%rax),%rax
  mov    %rax,%r8
  add    $0xf,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rcx
  cmp    %rsi,%rsp
  je     L97
L71:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L71
L97:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L59
L81:
  mov    D30(%rip),%rcx
  mov    (%rdx),%eax
  mov    %rsp,%r15
  mov    (%rcx),%r13d
  mov    D59(%rip),%rcx
  or     (%rcx),%r13d
  mov    D56(%rip),%rcx
  or     (%rcx),%r13d
  and    %eax,%r13d
  jne    L17
  mov    D66(%rip),%rcx
  and    (%rcx),%eax
  je     L45
  mov    D2(%rip),%r14
  mov    0x4(%rdx),%edi
  mov    %rsp,%rsi
  mov    %r8d,%edx
  movq   $0x0,(%r14)
  call   <read@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  jle    L9
  nopl   0x0(%rax)
L102:
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %r12d,%edi
  call   <write@plt>
  test   %eax,%eax
  jle    L17
  movslq %eax,%rdx
  add    %rdx,%r15
  sub    %eax,%ebx
  jne    L102
  nopl   0x0(%rax,%rax,1)
L45:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L39
  lea    -0x28(%rbp),%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax)
L59:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L81
  nopl   0x0(%rax,%rax,1)
L9:
  mov    D0(%rip),%rax
  xor    %r13d,%r13d
  mov    (%rax),%rax
  cmp    %rax,(%r14)
  setne  %r13b
  neg    %r13d
  jmp    L45
  nopl   0x0(%rax)
L17:
  mov    $0xffffffff,%r13d
  jmp    L45
L39:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int checkfd(struct pollfd *fdp, int outfd) {
  int nr, nw;
  char buf[BUFSIZ];
  if (fdp->revents & (POLLNVAL | POLLERR | POLLHUP))
    return -1;
  if ((fdp->revents & POLLIN) == 0)
    return 0;
  errno = 0;
  nr = read(fdp->fd, buf, sizeof buf);
  if (nr <= 0) {
    if (errno != EAGAIN)
      return -1;
    else
      return 0;
  } else {
    char *bc = buf;
    while (nr) {
      if ((nw = write(outfd, bc, nr)) <= 0)
        return -1;
      nr -= nw;
      bc += nw;
    }
    return 0;
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<checkfd>:
  endbr64
  push   %rbp
  mov    %rdi,%rdx
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    D39(%rip),%rax
  mov    %rsp,%rsi
  movslq (%rax),%rax
  mov    %rax,%r8
  add    $0xf,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rcx
  cmp    %rsi,%rsp
  je     L42
L66:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L66
L42:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L55
L79:
  mov    D47(%rip),%rcx
  mov    (%rdx),%eax
  mov    %rsp,%r15
  mov    (%rcx),%r13d
  mov    D7(%rip),%rcx
  or     (%rcx),%r13d
  mov    D25(%rip),%rcx
  or     (%rcx),%r13d
  and    %eax,%r13d
  jne    L35
  mov    D46(%rip),%rcx
  and    (%rcx),%eax
  je     L22
  mov    D29(%rip),%r14
  mov    0x4(%rdx),%edi
  mov    %rsp,%rsi
  mov    %r8d,%edx
  movq   $0x0,(%r14)
  call   <read@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  jle    L67
  nopl   0x0(%rax)
L41:
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %r12d,%edi
  call   <write@plt>
  test   %eax,%eax
  jle    L35
  movslq %eax,%rdx
  add    %rdx,%r15
  sub    %eax,%ebx
  jne    L41
  nopl   0x0(%rax,%rax,1)
L22:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L70
  lea    -0x28(%rbp),%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax)
L55:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L79
  nopl   0x0(%rax,%rax,1)
L67:
  mov    D18(%rip),%rax
  xor    %r13d,%r13d
  mov    (%rax),%rax
  cmp    %rax,(%r14)
  setne  %r13b
  neg    %r13d
  jmp    L22
  nopl   0x0(%rax)
L35:
  mov    $0xffffffff,%r13d
  jmp    L22
L70:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int checkfd(struct pollfd *fdp, int outfd) {
  int nr, nw;
  char buf[BUFSIZ];
  if (fdp->revents & (POLLNVAL | POLLERR | POLLHUP))
    return -1;
  if ((fdp->revents & POLLIN) == 0)
    return 0;
  errno = 0;
  nr = read(fdp->fd, buf, sizeof buf);
  if (nr <= 0) {
    if (errno != EAGAIN)
      return -1;
    else
      return 0;
  } else {
    char *bc = buf;
    while (nr) {
      if ((nw = write(outfd, bc, nr)) <= 0)
        return -1;
      nr -= nw;
      bc += nw;
    }
    return 0;
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<free_mat4D_int>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    %ecx,-0x24(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L35
L21:
  movl   $0x0,-0x8(%rbp)
  jmp    L45
L13:
  movl   $0x0,-0x4(%rbp)
  jmp    L14
L54:
  mov    -0xc(%rbp),%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x4(%rbp),%eax
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <free@plt>
  addl   $0x1,-0x4(%rbp)
L14:
  mov    -0x24(%rbp),%eax
  cmp    %eax,-0x4(%rbp)
  jb     L54
  mov    -0xc(%rbp),%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <free@plt>
  addl   $0x1,-0x8(%rbp)
L45:
  mov    -0x20(%rbp),%eax
  cmp    %eax,-0x8(%rbp)
  jb     L13
  mov    -0xc(%rbp),%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <free@plt>
  addl   $0x1,-0xc(%rbp)
L35:
  mov    -0x1c(%rbp),%eax
  cmp    %eax,-0xc(%rbp)
  jb     L21
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  leave
  ret
```

assistant: ```c
void free_mat4D_int(int ****mat4D_int, int w, int x, int y) {
  unsigned int h, i, j;
  for (h = 0; h < w; ++h) {
    for (i = 0; i < x; ++i) {
      for (j = 0; j < y; ++j)
        free(mat4D_int[h][i][j]);
      free(mat4D_int[h][i]);
    }
    free(mat4D_int[h]);
  }
  free(mat4D_int);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<free_mat4D_int>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %edx,0x14(%rsp)
  test   %esi,%esi
  je     L40
  mov    %ecx,%r14d
  mov    %rdi,%r12
  lea    -0x1(%rsi),%eax
  lea    0x8(%rdi,%rax,8),%rax
  mov    %rax,0x8(%rsp)
  lea    -0x1(%rdx),%eax
  lea    0x8(,%rax,8),%r15
  lea    -0x1(%rcx),%eax
  lea    0x8(,%rax,8),%r13
  jmp    L30
L75:
  mov    (%r12),%rax
  mov    (%rax,%rbp,1),%rax
  mov    (%rax,%rbx,1),%rdi
  call   <free@plt>
  add    $0x8,%rbx
  cmp    %r13,%rbx
  jne    L75
L68:
  mov    (%r12),%rax
  mov    (%rax,%rbp,1),%rdi
  call   <free@plt>
  add    $0x8,%rbp
  cmp    %r15,%rbp
  je     L79
L8:
  mov    $0x0,%ebx
  test   %r14d,%r14d
  jne    L75
  jmp    L68
L79:
  mov    (%r12),%rdi
  call   <free@plt>
  add    $0x8,%r12
  cmp    0x8(%rsp),%r12
  je     L40
L30:
  mov    $0x0,%ebp
  cmpl   $0x0,0x14(%rsp)
  jne    L8
  jmp    L79
L40:
  mov    0x18(%rsp),%rdi
  call   <free@plt>
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void free_mat4D_int(int ****mat4D_int, int w, int x, int y) {
  unsigned int h, i, j;
  for (h = 0; h < w; ++h) {
    for (i = 0; i < x; ++i) {
      for (j = 0; j < y; ++j)
        free(mat4D_int[h][i][j]);
      free(mat4D_int[h][i]);
    }
    free(mat4D_int[h]);
  }
  free(mat4D_int);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<free_mat4D_int>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %edx,0x14(%rsp)
  test   %esi,%esi
  je     L24
  mov    %esi,%eax
  mov    %ecx,%r12d
  mov    %rdi,%r15
  sub    $0x1,%eax
  lea    0x8(%rdi,%rax,8),%rax
  mov    %rax,0x8(%rsp)
  lea    -0x1(%rdx),%eax
  lea    0x8(,%rax,8),%r13
  lea    -0x1(%rcx),%eax
  lea    0x8(,%rax,8),%rbp
  xchg   %ax,%ax
L13:
  mov    0x14(%rsp),%eax
  xor    %ebx,%ebx
  test   %eax,%eax
  je     L17
  nopw   0x0(%rax,%rax,1)
L11:
  xor    %r14d,%r14d
  test   %r12d,%r12d
  je     L18
  nopl   0x0(%rax,%rax,1)
L33:
  mov    (%r15),%rdx
  mov    (%rdx,%rbx,1),%rdx
  mov    (%rdx,%r14,1),%rdi
  add    $0x8,%r14
  call   <free@plt>
  cmp    %r14,%rbp
  jne    L33
L18:
  mov    (%r15),%rax
  mov    (%rax,%rbx,1),%rdi
  add    $0x8,%rbx
  call   <free@plt>
  cmp    %rbx,%r13
  jne    L11
L17:
  mov    (%r15),%rdi
  add    $0x8,%r15
  call   <free@plt>
  cmp    %r15,0x8(%rsp)
  jne    L13
L24:
  mov    0x18(%rsp),%rdi
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1050 <free@plt>
```

assistant: ```c
void free_mat4D_int(int ****mat4D_int, int w, int x, int y) {
  unsigned int h, i, j;
  for (h = 0; h < w; ++h) {
    for (i = 0; i < x; ++i) {
      for (j = 0; j < y; ++j)
        free(mat4D_int[h][i][j]);
      free(mat4D_int[h][i]);
    }
    free(mat4D_int[h]);
  }
  free(mat4D_int);
}
```