ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<nand_read>:
  endbr64
  push   %r15
  xor    %eax,%eax
  push   %r14
  push   %r13
  mov    %esi,%r13d
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,0xc(%rsp)
  call   <nand_select@plt>
  test   %r12d,%r12d
  je     L18
  xor    %r15d,%r15d
  nopl   0x0(%rax,%rax,1)
L15:
  xor    %edi,%edi
  call   <nand_cmd@plt>
  mov    0xc(%rsp),%edi
  call   <nand_send_addr@plt>
  mov    $0x30,%edi
  call   <nand_cmd@plt>
  xor    %eax,%eax
  call   <wait_ready@plt>
  cmp    %r15d,%r12d
  jbe    L18
  lea    0x1(%r15),%ebx
  xor    %r14d,%r14d
  movslq %ebx,%rbx
L38:
  xor    %eax,%eax
  add    $0x1,%r14d
  mov    %ebx,%ebp
  mov    %ebx,%r15d
  call   <nand_get_data@plt>
  add    $0x1,%rbx
  mov    %al,-0x2(%rbx,%r13,1)
  cmp    $0xfff,%r14d
  jg     L5
  cmp    %r12d,%ebp
  jb     L38
L5:
  addl   $0x1000,0xc(%rsp)
  cmp    %r12d,%ebp
  jb     L15
L18:
  xor    %eax,%eax
  call   <nand_deselect@plt>
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int nand_read(unsigned int nand_start, unsigned int ddr_start, unsigned int len) {
  unsigned int addr = nand_start;
  int i, count = 0;
  unsigned char *dest = (unsigned char *)ddr_start;
  nand_select();
  while (count < len) {
    nand_cmd(0x00);
    nand_send_addr(addr);
    nand_cmd(0x30);
    wait_ready();
    for (i = 0; i < 4096 && count < len; i++) {
      dest[count++] = nand_get_data();
    }
    addr += 4096;
  }
  nand_deselect();
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<nand_read>:
  endbr64
  push   %r15
  xor    %eax,%eax
  push   %r14
  push   %r13
  mov    %esi,%r13d
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,0xc(%rsp)
  call   <nand_select@plt>
  test   %r12d,%r12d
  je     L5
  xor    %r15d,%r15d
  nopl   0x0(%rax,%rax,1)
L32:
  xor    %edi,%edi
  call   <nand_cmd@plt>
  mov    0xc(%rsp),%edi
  call   <nand_send_addr@plt>
  mov    $0x30,%edi
  call   <nand_cmd@plt>
  xor    %eax,%eax
  call   <wait_ready@plt>
  cmp    %r15d,%r12d
  jbe    L5
  lea    0x1(%r15),%ebx
  xor    %r14d,%r14d
  movslq %ebx,%rbx
L40:
  xor    %eax,%eax
  add    $0x1,%r14d
  mov    %ebx,%ebp
  mov    %ebx,%r15d
  call   <nand_get_data@plt>
  add    $0x1,%rbx
  mov    %al,-0x2(%rbx,%r13,1)
  cmp    $0xfff,%r14d
  jg     L12
  cmp    %ebp,%r12d
  ja     L40
L12:
  addl   $0x1000,0xc(%rsp)
  cmp    %ebp,%r12d
  ja     L32
L5:
  xor    %eax,%eax
  call   <nand_deselect@plt>
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int nand_read(unsigned int nand_start, unsigned int ddr_start, unsigned int len) {
  unsigned int addr = nand_start;
  int i, count = 0;
  unsigned char *dest = (unsigned char *)ddr_start;
  nand_select();
  while (count < len) {
    nand_cmd(0x00);
    nand_send_addr(addr);
    nand_cmd(0x30);
    wait_ready();
    for (i = 0; i < 4096 && count < len; i++) {
      dest[count++] = nand_get_data();
    }
    addr += 4096;
  }
  nand_deselect();
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<decrypt>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  movl   $0x0,-0x14(%rbp)
  jmp    L15
L4:
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %eax,%ebx
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%esi
  mov    -0x14(%rbp),%eax
  cltd
  idiv   %esi
  mov    %edx,%ecx
  mov    %ecx,%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    $0x4f,%ecx
  mov    %ecx,%eax
  imul   %dl
  shr    $0x8,%ax
  sar    $0x3,%al
  mov    %edx,%ecx
  sar    $0x7,%cl
  sub    %ecx,%eax
  mov    $0x1a,%ecx
  imul   %ecx,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  lea    (%rbx,%rax,1),%ecx
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  addl   $0x1,-0x14(%rbp)
L15:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    %eax,-0x14(%rbp)
  jl     L4
  nop
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void decrypt(char arr[], char key[]) {
  int i;
  for (i = 0; i < strlen(arr); i++) {
    arr[i] = arr[i] + key[i % strlen(key)] % 26;
  }
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<decrypt>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r12
  mov    $0x0,%ebx
  mov    $0x4f,%r14d
  jmp    L8
L5:
  movzbl 0x0(%rbp,%rbx,1),%r13d
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %eax,%ecx
  mov    %r15d,%eax
  cltd
  idiv   %ecx
  movslq %edx,%rdx
  movzbl (%r12,%rdx,1),%edx
  mov    %edx,%eax
  imul   %r14b
  sar    $0xb,%ax
  mov    %edx,%ecx
  sar    $0x7,%cl
  sub    %ecx,%eax
  mov    $0x1a,%ecx
  imul   %ecx,%eax
  sub    %eax,%edx
  add    %r13d,%edx
  mov    %dl,0x0(%rbp,%rbx,1)
  add    $0x1,%rbx
L8:
  mov    %ebx,%r15d
  mov    %rbp,%rdi
  call   <strlen@plt>
  cmp    %ebx,%eax
  jg     L5
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void decrypt(char arr[], char key[]) {
  int i;
  for (i = 0; i < strlen(arr); i++) {
    arr[i] = arr[i] + key[i % strlen(key)] % 26;
  }
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<decrypt>:
  endbr64
  push   %r15
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  push   %r12
  mov    $0x4f,%r12d
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  jmp    L8
  nopl   0x0(%rax,%rax,1)
L0:
  mov    %rbp,%rdi
  movzbl (%rbx,%r14,1),%r13d
  call   <strlen@plt>
  mov    %eax,%r8d
  mov    %r15d,%eax
  cltd
  idiv   %r8d
  movslq %edx,%rdx
  movzbl 0x0(%rbp,%rdx,1),%edx
  mov    %edx,%eax
  mov    %edx,%ecx
  imul   %r12b
  sar    $0x7,%cl
  sar    $0xb,%ax
  sub    %ecx,%eax
  mov    $0x1a,%ecx
  imul   %ecx,%eax
  sub    %eax,%edx
  add    %r13d,%edx
  mov    %dl,(%rbx,%r14,1)
  add    $0x1,%r14
L8:
  mov    %rbx,%rdi
  mov    %r14d,%r15d
  call   <strlen@plt>
  cmp    %r14d,%eax
  jg     L0
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void decrypt(char arr[], char key[]) {
  int i;
  for (i = 0; i < strlen(arr); i++) {
    arr[i] = arr[i] + key[i % strlen(key)] % 26;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<decrypt>:
  endbr64
  push   %r15
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  push   %r12
  mov    $0x4f,%r12d
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  jmp    L19
  nopl   0x0(%rax,%rax,1)
L8:
  mov    %rbp,%rdi
  movzbl (%rbx,%r14,1),%r13d
  call   <strlen@plt>
  mov    %eax,%r8d
  mov    %r15d,%eax
  cltd
  idiv   %r8d
  movslq %edx,%rdx
  movzbl 0x0(%rbp,%rdx,1),%edx
  mov    %edx,%eax
  mov    %edx,%ecx
  imul   %r12b
  sar    $0x7,%cl
  sar    $0xb,%ax
  sub    %ecx,%eax
  mov    $0x1a,%ecx
  imul   %ecx,%eax
  sub    %eax,%edx
  add    %r13d,%edx
  mov    %dl,(%rbx,%r14,1)
  add    $0x1,%r14
L19:
  mov    %rbx,%rdi
  mov    %r14d,%r15d
  call   <strlen@plt>
  cmp    %r14d,%eax
  jg     L8
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void decrypt(char arr[], char key[]) {
  int i;
  for (i = 0; i < strlen(arr); i++) {
    arr[i] = arr[i] + key[i % strlen(key)] % 26;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<strcpy_wchar_to_char>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L18
L4:
  mov    -0x20(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  mov    (%rax),%rcx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
L18:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L4
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
  pop    %rbp
  ret
```

assistant: ```c
char *strcpy_wchar_to_char(char *dst, const wchar_t *src) {
  char *ret = dst;
  while (*src)
    *dst++ = *src++ & 0xff;
  *dst = 0;
  return ret;
}
```
user: Translate the below assembly code into C programming language:

```asm
<strcpy_wchar_to_char>:
  endbr64
  mov    %rdi,%rax
  mov    (%rsi),%rdx
  test   %rdx,%rdx
  je     L18
  mov    %rdi,%rcx
L17:
  add    $0x8,%rsi
  add    $0x1,%rcx
  mov    %dl,-0x1(%rcx)
  mov    (%rsi),%rdx
  test   %rdx,%rdx
  jne    L17
L19:
  movb   $0x0,(%rcx)
  ret
L18:
  mov    %rdi,%rcx
  jmp    L19
```

assistant: ```c
char *strcpy_wchar_to_char(char *dst, const wchar_t *src) {
  char *ret = dst;
  while (*src)
    *dst++ = *src++ & 0xff;
  *dst = 0;
  return ret;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<strcpy_wchar_to_char>:
  endbr64
  mov    (%rsi),%rdx
  mov    %rdi,%rax
  mov    %rdi,%rcx
  test   %rdx,%rdx
  je     L4
  nopw   0x0(%rax,%rax,1)
L16:
  add    $0x8,%rsi
  mov    %dl,(%rcx)
  add    $0x1,%rcx
  mov    (%rsi),%rdx
  test   %rdx,%rdx
  jne    L16
L4:
  movb   $0x0,(%rcx)
  ret
```

assistant: ```c
char *strcpy_wchar_to_char(char *dst, const wchar_t *src) {
  char *ret = dst;
  while (*src)
    *dst++ = *src++ & 0xff;
  *dst = 0;
  return ret;
}
```
user: What is the c source code of the assembly code below?

```asm
<strcpy_wchar_to_char>:
  endbr64
  mov    (%rsi),%rdx
  mov    %rdi,%rax
  mov    %rdi,%rcx
  test   %rdx,%rdx
  je     L9
  nopw   0x0(%rax,%rax,1)
L18:
  add    $0x8,%rsi
  mov    %dl,(%rcx)
  add    $0x1,%rcx
  mov    (%rsi),%rdx
  test   %rdx,%rdx
  jne    L18
L9:
  movb   $0x0,(%rcx)
  ret
```

assistant: ```c
char *strcpy_wchar_to_char(char *dst, const wchar_t *src) {
  char *ret = dst;
  while (*src)
    *dst++ = *src++ & 0xff;
  *dst = 0;
  return ret;
}
```
user: What is the c source code of the assembly code below?

```asm
<hash_isexist_file>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x10(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L9
  call   <__stack_chk_fail@plt>
L9:
  leave
  ret
```

assistant: ```c
int hash_isexist_file(const char *filepath) {
  struct stat st;
  int result = stat(filepath, &st);
  return result == 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<hash_isexist_file>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  call   <stat@plt>
  test   %eax,%eax
  sete   %al
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L9
  movzbl %al,%eax
  add    $0x18,%rsp
  ret
L9:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int hash_isexist_file(const char *filepath) {
  struct stat st;
  int result = stat(filepath, &st);
  return result == 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<hash_isexist_file>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  call   <stat@plt>
  test   %eax,%eax
  sete   %al
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L6
  movzbl %al,%eax
  add    $0x18,%rsp
  ret
L6:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int hash_isexist_file(const char *filepath) {
  struct stat st;
  int result = stat(filepath, &st);
  return result == 0;
}
```
user: What is the c source code of the assembly code below?

```asm
<hash_isexist_file>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  call   <stat@plt>
  test   %eax,%eax
  sete   %al
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L3
  movzbl %al,%eax
  add    $0x18,%rsp
  ret
L3:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int hash_isexist_file(const char *filepath) {
  struct stat st;
  int result = stat(filepath, &st);
  return result == 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<serv_listen>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    D0(%rip),%rax
  mov    (%rax),%ecx
  mov    D11(%rip),%rax
  mov    (%rax),%eax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <socket@plt>
  mov    %eax,-0x18(%rbp)
  cmpl   $0x0,-0x18(%rbp)
  jns    L20
  mov    $0xffffffff,%eax
  jmp    L81
L20:
  mov    D44(%rip),%rax
  mov    (%rax),%edx
  mov    D15(%rip),%rax
  mov    (%rax),%ecx
  mov    -0x18(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <fcntl@plt>
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <unlink@plt>
  lea    -0x10(%rbp),%rax
  mov    $0x8,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    D11(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x10(%rbp),%eax
  mov    -0x28(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <strcpy@plt>
  mov    -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <strlen@plt>
  add    $0x4,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%edx
  lea    -0x10(%rbp),%rcx
  mov    -0x18(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <bind@plt>
  test   %rax,%rax
  js     L68
  mov    -0x28(%rbp),%rax
  mov    $0x1b6,%esi
  mov    %rax,%rdi
  call   <chmod@plt>
  test   %rax,%rax
  js     L27
  mov    -0x18(%rbp),%eax
  mov    $0x5,%esi
  mov    %eax,%edi
  call   <listen@plt>
  test   %rax,%rax
  js     L79
  mov    -0x18(%rbp),%eax
  jmp    L81
L68:
  nop
  jmp    L28
L27:
  nop
  jmp    L28
L79:
  nop
L28:
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0xffffffff,%eax
L81:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L29
  call   <__stack_chk_fail@plt>
L29:
  leave
  ret
```

assistant: ```c
int serv_listen(const char *name) {
  int fd, len;
  struct sockaddr_un unix_addr;
  if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
    return (-1);
  fcntl(fd, F_SETFD, FD_CLOEXEC);
  unlink(name);
  memset(&unix_addr, 0, sizeof(unix_addr));
  unix_addr.sun_family = AF_UNIX;
  strcpy(unix_addr.sun_path, name);
  len = sizeof(unix_addr.sun_family) + strlen(unix_addr.sun_path);
  if (bind(fd, (struct sockaddr *)&unix_addr, len) < 0)
    goto error;
  if (chmod(name, 0666) < 0)
    goto error;
  if (listen(fd, 5) < 0)
    goto error;
  return (fd);
error:
  close(fd);
  return (-1);
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<serv_listen>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %rdi,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    $0x0,%edx
  mov    D34(%rip),%rax
  mov    (%rax),%esi
  mov    D12(%rip),%rax
  mov    (%rax),%edi
  call   <socket@plt>
  test   %eax,%eax
  js     L25
  mov    %eax,%ebx
  mov    D26(%rip),%rax
  mov    (%rax),%edx
  mov    D31(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  call   <fcntl@plt>
  mov    %r12,%rdi
  call   <unlink@plt>
  mov    %rsp,%rbp
  mov    $0x8,%edx
  mov    $0x0,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    D12(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x4(%rsp)
  mov    %r12,%rsi
  mov    (%rsp),%edi
  call   <strcpy@plt>
  mov    (%rsp),%edi
  call   <strlen@plt>
  lea    0x4(%rax),%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <bind@plt>
  test   %rax,%rax
  js     L34
  mov    $0x1b6,%esi
  mov    %r12,%rdi
  call   <chmod@plt>
  test   %rax,%rax
  js     L34
  mov    $0x5,%esi
  mov    %ebx,%edi
  call   <listen@plt>
  test   %rax,%rax
  js     L34
L18:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L37
  mov    %ebx,%eax
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L34:
  mov    %ebx,%edi
  call   <close@plt>
  mov    $0xffffffff,%ebx
  jmp    L18
L25:
  mov    $0xffffffff,%ebx
  jmp    L18
L37:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int serv_listen(const char *name) {
  int fd, len;
  struct sockaddr_un unix_addr;
  if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
    return (-1);
  fcntl(fd, F_SETFD, FD_CLOEXEC);
  unlink(name);
  memset(&unix_addr, 0, sizeof(unix_addr));
  unix_addr.sun_family = AF_UNIX;
  strcpy(unix_addr.sun_path, name);
  len = sizeof(unix_addr.sun_family) + strlen(unix_addr.sun_path);
  if (bind(fd, (struct sockaddr *)&unix_addr, len) < 0)
    goto error;
  if (chmod(name, 0666) < 0)
    goto error;
  if (listen(fd, 5) < 0)
    goto error;
  return (fd);
error:
  close(fd);
  return (-1);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<serv_listen>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  xor    %edx,%edx
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    D33(%rip),%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    D5(%rip),%rax
  mov    (%rbx),%edi
  mov    (%rax),%esi
  call   <socket@plt>
  test   %eax,%eax
  js     L51
  mov    %eax,%r12d
  mov    D13(%rip),%rax
  mov    %rsp,%rbp
  mov    %r12d,%edi
  mov    (%rax),%edx
  mov    D23(%rip),%rax
  mov    (%rax),%esi
  call   <fcntl@plt>
  mov    %r13,%rdi
  call   <unlink@plt>
  mov    $0x8,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    (%rbx),%eax
  mov    (%rsp),%edi
  mov    %r13,%rsi
  mov    %eax,0x4(%rsp)
  call   <strcpy@plt>
  mov    (%rsp),%edi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %r12d,%edi
  lea    0x4(%rax),%edx
  call   <bind@plt>
  test   %rax,%rax
  js     L69
  mov    $0x1b6,%esi
  mov    %r13,%rdi
  call   <chmod@plt>
  test   %rax,%rax
  js     L69
  mov    $0x5,%esi
  mov    %r12d,%edi
  call   <listen@plt>
  test   %rax,%rax
  js     L69
L41:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L6
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L69:
  mov    %r12d,%edi
  mov    $0xffffffff,%r12d
  call   <close@plt>
  jmp    L41
L51:
  mov    $0xffffffff,%r12d
  jmp    L41
L6:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int serv_listen(const char *name) {
  int fd, len;
  struct sockaddr_un unix_addr;
  if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
    return (-1);
  fcntl(fd, F_SETFD, FD_CLOEXEC);
  unlink(name);
  memset(&unix_addr, 0, sizeof(unix_addr));
  unix_addr.sun_family = AF_UNIX;
  strcpy(unix_addr.sun_path, name);
  len = sizeof(unix_addr.sun_family) + strlen(unix_addr.sun_path);
  if (bind(fd, (struct sockaddr *)&unix_addr, len) < 0)
    goto error;
  if (chmod(name, 0666) < 0)
    goto error;
  if (listen(fd, 5) < 0)
    goto error;
  return (fd);
error:
  close(fd);
  return (-1);
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<serv_listen>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  xor    %edx,%edx
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    D10(%rip),%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    D30(%rip),%rax
  mov    (%rbx),%edi
  mov    (%rax),%esi
  call   <socket@plt>
  test   %eax,%eax
  js     L28
  mov    %eax,%r12d
  mov    D6(%rip),%rax
  mov    %rsp,%rbp
  mov    %r12d,%edi
  mov    (%rax),%edx
  mov    D28(%rip),%rax
  mov    (%rax),%esi
  call   <fcntl@plt>
  mov    %r13,%rdi
  call   <unlink@plt>
  mov    $0x8,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    (%rbx),%eax
  mov    (%rsp),%edi
  mov    %r13,%rsi
  mov    %eax,0x4(%rsp)
  call   <strcpy@plt>
  mov    (%rsp),%edi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %r12d,%edi
  lea    0x4(%rax),%edx
  call   <bind@plt>
  test   %rax,%rax
  js     L5
  mov    $0x1b6,%esi
  mov    %r13,%rdi
  call   <chmod@plt>
  test   %rax,%rax
  js     L5
  mov    $0x5,%esi
  mov    %r12d,%edi
  call   <listen@plt>
  test   %rax,%rax
  js     L5
L24:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L66
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L5:
  mov    %r12d,%edi
  mov    $0xffffffff,%r12d
  call   <close@plt>
  jmp    L24
L28:
  mov    $0xffffffff,%r12d
  jmp    L24
L66:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int serv_listen(const char *name) {
  int fd, len;
  struct sockaddr_un unix_addr;
  if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
    return (-1);
  fcntl(fd, F_SETFD, FD_CLOEXEC);
  unlink(name);
  memset(&unix_addr, 0, sizeof(unix_addr));
  unix_addr.sun_family = AF_UNIX;
  strcpy(unix_addr.sun_path, name);
  len = sizeof(unix_addr.sun_family) + strlen(unix_addr.sun_path);
  if (bind(fd, (struct sockaddr *)&unix_addr, len) < 0)
    goto error;
  if (chmod(name, 0666) < 0)
    goto error;
  if (listen(fd, 5) < 0)
    goto error;
  return (fd);
error:
  close(fd);
  return (-1);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<lstrcatn>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    %edx,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jle    L75
  jmp    L71
L30:
  subl   $0x1,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jle    L19
  addq   $0x1,-0x8(%rbp)
L71:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L30
  jmp    L66
L29:
  mov    -0x10(%rbp),%rdx
  lea    0x1(%rdx),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rcx
  mov    %rcx,-0x8(%rbp)
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
L66:
  subl   $0x1,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jle    L14
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L29
L14:
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L75
L19:
  nop
L75:
  pop    %rbp
  ret
```

assistant: ```c
void lstrcatn(char *o, const char *in, int count) {
  if (count > 0) {
    while (*o) {
      if (--count < 1)
        return;
      o++;
    }
    while (--count > 0 && *in)
      *o++ = *in++;
    *o = 0;
  }
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<lstrcatn>:
  endbr64
  test   %edx,%edx
  jle    L22
  cmpb   $0x0,(%rdi)
  je     L28
  sub    $0x1,%edx
  test   %edx,%edx
  jle    L26
L51:
  add    $0x1,%rdi
  cmpb   $0x0,(%rdi)
  je     L28
  sub    $0x1,%edx
  jne    L51
  jmp    L22
L26:
  ret
L28:
  cmp    $0x1,%edx
  jle    L7
  lea    -0x2(%rdx),%eax
  lea    0x1(%rdi,%rax,1),%rdx
L45:
  movzbl (%rsi),%eax
  test   %al,%al
  je     L7
  add    $0x1,%rsi
  add    $0x1,%rdi
  mov    %al,-0x1(%rdi)
  cmp    %rdi,%rdx
  jne    L45
  mov    %rdx,%rdi
L7:
  movb   $0x0,(%rdi)
L22:
  ret
```

assistant: ```c
void lstrcatn(char *o, const char *in, int count) {
  if (count > 0) {
    while (*o) {
      if (--count < 1)
        return;
      o++;
    }
    while (--count > 0 && *in)
      *o++ = *in++;
    *o = 0;
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<lstrcatn>:
  endbr64
  test   %edx,%edx
  jle    L87
  cmpb   $0x0,(%rdi)
  lea    -0x1(%rdx),%eax
  je     L96
  test   %eax,%eax
  jne    L84
  jmp    L53
  cs nopw 0x0(%rax,%rax,1)
L31:
  test   %eax,%eax
  je     L87
L84:
  add    $0x1,%rdi
  mov    %eax,%edx
  sub    $0x1,%eax
  cmpb   $0x0,(%rdi)
  jne    L31
L96:
  cmp    $0x1,%edx
  je     L69
  sub    $0x1,%edx
  add    %rdi,%rdx
  jmp    L10
  nop
L22:
  add    $0x1,%rdi
  add    $0x1,%rsi
  mov    %al,-0x1(%rdi)
  cmp    %rdi,%rdx
  je     L69
L10:
  movzbl (%rsi),%eax
  test   %al,%al
  jne    L22
L69:
  movb   $0x0,(%rdi)
L87:
  ret
L53:
  ret
```

assistant: ```c
void lstrcatn(char *o, const char *in, int count) {
  if (count > 0) {
    while (*o) {
      if (--count < 1)
        return;
      o++;
    }
    while (--count > 0 && *in)
      *o++ = *in++;
    *o = 0;
  }
}
```