ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What is the c source code of the assembly code below?

```asm
<pdist_jaccard>:
  endbr64
  test   %edx,%edx
  jle    L4
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rsi,%rbx
  mov    %ecx,%r14d
  lea    -0x2(%rdx),%r15d
  movslq %ecx,%rax
  lea    0x0(,%rax,8),%rcx
  mov    %rcx,0x8(%rsp)
  add    %rcx,%rdi
  mov    %rdi,0x10(%rsp)
  neg    %rax
  shl    $0x3,%rax
  mov    %rax,0x18(%rsp)
L35:
  cmp    $0xffffffff,%r15d
  je     L19
  mov    0x10(%rsp),%rbp
  mov    %rbp,%r13
  add    0x18(%rsp),%r13
  mov    %r15d,%eax
  lea    0x8(%rbx,%rax,8),%r12
L31:
  mov    %r14d,%edx
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <jaccard_distance@plt>
  movsd  %xmm0,(%rbx)
  add    $0x8,%rbx
  add    0x8(%rsp),%rbp
  cmp    %r12,%rbx
  jne    L31
  sub    $0x1,%r15d
  mov    0x8(%rsp),%rcx
  add    %rcx,0x10(%rsp)
  mov    %r12,%rbx
  jmp    L35
L19:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L4:
  ret
```

assistant: ```c
void pdist_jaccard(const double *X, double *dm, int m, int n) {
  int i, j;
  const double *u, *v;
  double *it = dm;
  for (i = 0; i < m; i++) {
    for (j = i + 1; j < m; j++, it++) {
      u = X + (n * i);
      v = X + (n * j);
      *it = jaccard_distance(u, v, n);
    }
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<pdist_jaccard>:
  endbr64
  test   %edx,%edx
  jle    L24
  push   %r15
  lea    -0x2(%rdx),%eax
  mov    %rsi,%r15
  push   %r14
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  movslq %ecx,%rbx
  shl    $0x3,%rbx
  sub    $0x18,%rsp
  mov    %eax,0x4(%rsp)
  lea    (%rdi,%rbx,1),%rax
  mov    %rax,0x8(%rsp)
  mov    0x4(%rsp),%eax
  cmp    $0xffffffff,%eax
  je     L27
L15:
  mov    0x8(%rsp),%r14
  lea    0x1(%rax),%edx
  lea    (%r15,%rdx,8),%rbp
  mov    %r14,%r12
  sub    %rbx,%r12
  nopw   0x0(%rax,%rax,1)
L33:
  mov    %r14,%rsi
  mov    %r13d,%edx
  mov    %r12,%rdi
  add    $0x8,%r15
  call   <jaccard_distance@plt>
  add    %rbx,%r14
  movsd  %xmm0,-0x8(%r15)
  cmp    %rbp,%r15
  jne    L33
  subl   $0x1,0x4(%rsp)
  mov    0x4(%rsp),%eax
  add    %rbx,0x8(%rsp)
  cmp    $0xffffffff,%eax
  jne    L15
L27:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L24:
  ret
```

assistant: ```c
void pdist_jaccard(const double *X, double *dm, int m, int n) {
  int i, j;
  const double *u, *v;
  double *it = dm;
  for (i = 0; i < m; i++) {
    for (j = i + 1; j < m; j++, it++) {
      u = X + (n * i);
      v = X + (n * j);
      *it = jaccard_distance(u, v, n);
    }
  }
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<pdist_jaccard>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %edx,0x4(%rsp)
  cmp    $0x1,%edx
  jle    L15
  movslq %ecx,%rbx
  mov    %edx,%eax
  movl   $0x1,0x18(%rsp)
  mov    %ecx,%r13d
  shl    $0x3,%rbx
  sub    $0x1,%eax
  lea    (%rdi,%rbx,1),%rsi
  mov    %eax,0x1c(%rsp)
  mov    %rsi,0x10(%rsp)
  nopl   0x0(%rax,%rax,1)
L19:
  mov    0x10(%rsp),%rbp
  mov    0x8(%rsp),%r14
  mov    0x18(%rsp),%r15d
  mov    %rbp,%r12
  sub    %rbx,%r12
  nopl   (%rax)
L0:
  mov    %rbp,%rsi
  mov    %r13d,%edx
  mov    %r12,%rdi
  add    $0x1,%r15d
  call   <jaccard_distance@plt>
  add    $0x8,%r14
  add    %rbx,%rbp
  movsd  %xmm0,-0x8(%r14)
  cmp    %r15d,0x4(%rsp)
  jg     L0
  mov    0x18(%rsp),%ecx
  mov    0x1c(%rsp),%eax
  mov    0x8(%rsp),%rdx
  add    %rbx,0x10(%rsp)
  sub    %ecx,%eax
  add    $0x1,%ecx
  lea    0x8(%rdx,%rax,8),%rax
  mov    %ecx,0x18(%rsp)
  mov    %rax,0x8(%rsp)
  cmp    %ecx,0x4(%rsp)
  jne    L19
L15:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void pdist_jaccard(const double *X, double *dm, int m, int n) {
  int i, j;
  const double *u, *v;
  double *it = dm;
  for (i = 0; i < m; i++) {
    for (j = i + 1; j < m; j++, it++) {
      u = X + (n * i);
      v = X + (n * j);
      *it = jaccard_distance(u, v, n);
    }
  }
}
```
user: What is the c source code of the assembly code below?

```asm
<print_array>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L5
L2:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%esi
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  addl   $0x1,-0x4(%rbp)
L5:
  mov    -0x4(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L2
  nop
  nop
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D5
type_guessed: string

tool: D5: %d


assistant: ```c
void print_array(int *arr, int length) {
  for (int i = 0; i < length; i++)
    printf("%d\n", arr[i]);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<print_array>:
  endbr64
  test   %esi,%esi
  jle    L19
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  lea    -0x1(%rsi),%eax
  lea    0x4(%rdi,%rax,4),%r12
  lea    D0(%rip),%rbp
L18:
  mov    (%rbx),%esi
  mov    %rbp,%rdi
  call   <printf@plt>
  add    $0x4,%rbx
  cmp    %r12,%rbx
  jne    L18
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L19:
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D0
type: string

tool: D0: %d


assistant: ```c
void print_array(int *arr, int length) {
  for (int i = 0; i < length; i++)
    printf("%d\n", arr[i]);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<print_array>:
  endbr64
  test   %esi,%esi
  jle    L0
  lea    -0x1(%rsi),%eax
  push   %r12
  lea    0x4(%rdi,%rax,4),%r12
  push   %rbp
  lea    D7(%rip),%rbp
  push   %rbx
  mov    %rdi,%rbx
  xchg   %ax,%ax
L15:
  mov    (%rbx),%esi
  mov    %rbp,%rdi
  add    $0x4,%rbx
  call   <printf@plt>
  cmp    %r12,%rbx
  jne    L15
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L0:
  ret
```

tool_calls: name: parse_data
arguments: data_label: D7
type: string

tool: D7: %d


assistant: ```c
void print_array(int *arr, int length) {
  for (int i = 0; i < length; i++)
    printf("%d\n", arr[i]);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<print_array>:
  endbr64
  test   %esi,%esi
  jle    L13
  lea    -0x1(%rsi),%eax
  push   %r12
  lea    0x4(%rdi,%rax,4),%r12
  push   %rbp
  lea    D5(%rip),%rbp
  push   %rbx
  mov    %rdi,%rbx
  xchg   %ax,%ax
L6:
  mov    (%rbx),%esi
  mov    %rbp,%rdi
  add    $0x4,%rbx
  call   <printf@plt>
  cmp    %r12,%rbx
  jne    L6
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L13:
  ret
```

tool_calls: name: read_data
arguments: data_tag: D5
datatype: string

tool: D5: %d


assistant: ```c
void print_array(int *arr, int length) {
  for (int i = 0; i < length; i++)
    printf("%d\n", arr[i]);
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<skip_nonspace>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L17
L30:
  addq   $0x1,-0x8(%rbp)
L17:
  cmpq   $0x0,-0x8(%rbp)
  je     L31
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L31
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isspace@plt>
  test   %eax,%eax
  je     L30
L31:
  mov    -0x8(%rbp),%rax
  leave
  ret
```

assistant: ```c
char *skip_nonspace(char *str) {
  char *p;
  for (p = str; p != NULL && *p != '\0' && !isspace((int)*p); p++)
    ;
  return p;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<skip_nonspace>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  test   %rdi,%rdi
  jne    L8
  jmp    L16
L27:
  add    $0x1,%rbx
L8:
  movzbl (%rbx),%edi
  test   %dil,%dil
  je     L16
  movsbl %dil,%edi
  call   <isspace@plt>
  test   %eax,%eax
  je     L27
L16:
  mov    %rbx,%rax
  pop    %rbx
  ret
```

assistant: ```c
char *skip_nonspace(char *str) {
  char *p;
  for (p = str; p != NULL && *p != '\0' && !isspace((int)*p); p++)
    ;
  return p;
}
```
user: What is the c source code of the assembly code below?

```asm
<skip_nonspace>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  test   %rdi,%rdi
  jne    L11
  jmp    L12
L20:
  call   <isspace@plt>
  test   %eax,%eax
  jne    L12
  add    $0x1,%r12
L11:
  movsbl (%r12),%edi
  test   %dil,%dil
  jne    L20
L12:
  mov    %r12,%rax
  pop    %r12
  ret
```

assistant: ```c
char *skip_nonspace(char *str) {
  char *p;
  for (p = str; p != NULL && *p != '\0' && !isspace((int)*p); p++)
    ;
  return p;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<skip_nonspace>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  test   %rdi,%rdi
  jne    L34
  jmp    L37
L30:
  call   <isspace@plt>
  test   %eax,%eax
  jne    L37
  add    $0x1,%r12
L34:
  movsbl (%r12),%edi
  test   %dil,%dil
  jne    L30
L37:
  mov    %r12,%rax
  pop    %r12
  ret
```

assistant: ```c
char *skip_nonspace(char *str) {
  char *p;
  for (p = str; p != NULL && *p != '\0' && !isspace((int)*p); p++)
    ;
  return p;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<anetPeerToString>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x8,-0x24(%rbp)
  lea    -0x24(%rbp),%rdx
  lea    -0x20(%rbp),%rcx
  mov    -0x34(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <getpeername@plt>
  cmp    $0xffffffff,%eax
  jne    L32
  cmpq   $0x0,-0x50(%rbp)
  je     L29
  mov    -0x50(%rbp),%rax
  movl   $0x0,(%rax)
L29:
  mov    -0x40(%rbp),%rax
  movb   $0x3f,(%rax)
  mov    -0x40(%rbp),%rax
  add    $0x1,%rax
  movb   $0x0,(%rax)
  mov    $0xffffffff,%eax
  jmp    L21
L32:
  mov    -0x20(%rbp),%rdx
  mov    D14(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L73
  lea    -0x20(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x40(%rbp)
  je     L81
  mov    -0x10(%rbp),%rax
  lea    0x4(%rax),%rsi
  mov    D14(%rip),%rax
  mov    (%rax),%rax
  mov    -0x48(%rbp),%rcx
  mov    -0x40(%rbp),%rdx
  mov    %rax,%rdi
  call   <inet_ntop@plt>
L81:
  cmpq   $0x0,-0x50(%rbp)
  je     L47
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <ntohs@plt>
  mov    -0x50(%rbp),%rdx
  mov    %eax,(%rdx)
  jmp    L47
L73:
  lea    -0x20(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x40(%rbp)
  je     L15
  mov    -0x18(%rbp),%rax
  lea    0x4(%rax),%rsi
  mov    D7(%rip),%rax
  mov    (%rax),%rax
  mov    -0x48(%rbp),%rcx
  mov    -0x40(%rbp),%rdx
  mov    %rax,%rdi
  call   <inet_ntop@plt>
L15:
  cmpq   $0x0,-0x50(%rbp)
  je     L47
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <ntohs@plt>
  mov    -0x50(%rbp),%rdx
  mov    %eax,(%rdx)
L47:
  mov    $0x0,%eax
L21:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L64
  call   <__stack_chk_fail@plt>
L64:
  leave
  ret
```

assistant: ```c
int anetPeerToString(int fd, char *ip, size_t ip_len, int *port) {
  struct sockaddr_storage sa;
  socklen_t salen = sizeof(sa);
  if (getpeername(fd, (struct sockaddr *)&sa, &salen) == -1) {
    if (port)
      *port = 0;
    ip[0] = '?';
    ip[1] = '\0';
    return -1;
  }
  if (sa.ss_family == AF_INET) {
    struct sockaddr_in *s = (struct sockaddr_in *)&sa;
    if (ip)
      inet_ntop(AF_INET, (void *)&(s->sin_addr), ip, ip_len);
    if (port)
      *port = ntohs(s->sin_port);
  } else {
    struct sockaddr_in6 *s = (struct sockaddr_in6 *)&sa;
    if (ip)
      inet_ntop(AF_INET6, (void *)&(s->sin6_addr), ip, ip_len);
    if (port)
      *port = ntohs(s->sin6_port);
  }
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<anetPeerToString>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %rsi,%rbx
  mov    %rdx,%r12
  mov    %rcx,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movl   $0x8,0xc(%rsp)
  lea    0xc(%rsp),%rdx
  lea    0x10(%rsp),%rsi
  call   <getpeername@plt>
  cmp    $0xffffffff,%eax
  je     L55
  mov    D1(%rip),%rax
  mov    (%rax),%rdi
  cmp    %rdi,0x10(%rsp)
  je     L72
  test   %rbx,%rbx
  je     L26
  lea    0x14(%rsp),%rsi
  mov    %r12,%rcx
  mov    %rbx,%rdx
  mov    D14(%rip),%rax
  mov    (%rax),%rdi
  call   <inet_ntop@plt>
L26:
  mov    $0x0,%eax
  test   %rbp,%rbp
  je     L64
  mov    0x10(%rsp),%edi
  call   <ntohs@plt>
  mov    %eax,0x0(%rbp)
  mov    $0x0,%eax
L64:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L38
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L55:
  test   %rbp,%rbp
  je     L80
  movl   $0x0,0x0(%rbp)
L80:
  movb   $0x3f,(%rbx)
  movb   $0x0,0x1(%rbx)
  jmp    L64
L72:
  test   %rbx,%rbx
  je     L98
  lea    0x14(%rsp),%rsi
  mov    %r12,%rcx
  mov    %rbx,%rdx
  call   <inet_ntop@plt>
L98:
  mov    $0x0,%eax
  test   %rbp,%rbp
  je     L64
  mov    0x10(%rsp),%edi
  call   <ntohs@plt>
  mov    %eax,0x0(%rbp)
  mov    $0x0,%eax
  jmp    L64
L38:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int anetPeerToString(int fd, char *ip, size_t ip_len, int *port) {
  struct sockaddr_storage sa;
  socklen_t salen = sizeof(sa);
  if (getpeername(fd, (struct sockaddr *)&sa, &salen) == -1) {
    if (port)
      *port = 0;
    ip[0] = '?';
    ip[1] = '\0';
    return -1;
  }
  if (sa.ss_family == AF_INET) {
    struct sockaddr_in *s = (struct sockaddr_in *)&sa;
    if (ip)
      inet_ntop(AF_INET, (void *)&(s->sin_addr), ip, ip_len);
    if (port)
      *port = ntohs(s->sin_port);
  } else {
    struct sockaddr_in6 *s = (struct sockaddr_in6 *)&sa;
    if (ip)
      inet_ntop(AF_INET6, (void *)&(s->sin6_addr), ip, ip_len);
    if (port)
      *port = ntohs(s->sin6_port);
  }
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<anetPeerToString>:
  endbr64
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rdx
  lea    0x10(%rsp),%rsi
  movl   $0x8,0xc(%rsp)
  call   <getpeername@plt>
  cmp    $0xffffffff,%eax
  je     L17
  mov    D7(%rip),%rax
  mov    (%rax),%rdi
  cmp    %rdi,0x10(%rsp)
  je     L83
  test   %r12,%r12
  je     L62
  mov    D10(%rip),%rax
  lea    0x14(%rsp),%rsi
  mov    %r13,%rcx
  mov    %r12,%rdx
  mov    (%rax),%rdi
  call   <inet_ntop@plt>
L62:
  test   %rbx,%rbx
  je     L55
  mov    0x10(%rsp),%edi
  call   <ntohs@plt>
  mov    %eax,(%rbx)
L55:
  xor    %eax,%eax
L69:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L10
  add    $0x20,%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  ret
  xchg   %ax,%ax
L83:
  test   %r12,%r12
  je     L62
  lea    0x14(%rsp),%rsi
  mov    %r13,%rcx
  mov    %r12,%rdx
  call   <inet_ntop@plt>
  jmp    L62
L17:
  test   %rbx,%rbx
  je     L34
  movl   $0x0,(%rbx)
L34:
  mov    $0x3f,%edx
  mov    %dx,(%r12)
  jmp    L69
L10:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int anetPeerToString(int fd, char *ip, size_t ip_len, int *port) {
  struct sockaddr_storage sa;
  socklen_t salen = sizeof(sa);
  if (getpeername(fd, (struct sockaddr *)&sa, &salen) == -1) {
    if (port)
      *port = 0;
    ip[0] = '?';
    ip[1] = '\0';
    return -1;
  }
  if (sa.ss_family == AF_INET) {
    struct sockaddr_in *s = (struct sockaddr_in *)&sa;
    if (ip)
      inet_ntop(AF_INET, (void *)&(s->sin_addr), ip, ip_len);
    if (port)
      *port = ntohs(s->sin_port);
  } else {
    struct sockaddr_in6 *s = (struct sockaddr_in6 *)&sa;
    if (ip)
      inet_ntop(AF_INET6, (void *)&(s->sin6_addr), ip, ip_len);
    if (port)
      *port = ntohs(s->sin6_port);
  }
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<anetPeerToString>:
  endbr64
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rdx
  lea    0x10(%rsp),%rsi
  movl   $0x8,0xc(%rsp)
  call   <getpeername@plt>
  cmp    $0xffffffff,%eax
  je     L86
  mov    D8(%rip),%rax
  mov    (%rax),%rdi
  cmp    %rdi,0x10(%rsp)
  je     L11
  test   %r12,%r12
  je     L50
  mov    D15(%rip),%rax
  lea    0x14(%rsp),%rsi
  mov    %r13,%rcx
  mov    %r12,%rdx
  mov    (%rax),%rdi
  call   <inet_ntop@plt>
L50:
  test   %rbx,%rbx
  je     L77
  mov    0x10(%rsp),%edi
  call   <ntohs@plt>
  mov    %eax,(%rbx)
L77:
  xor    %eax,%eax
L20:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L68
  add    $0x20,%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  ret
  xchg   %ax,%ax
L11:
  test   %r12,%r12
  je     L50
  lea    0x14(%rsp),%rsi
  mov    %r13,%rcx
  mov    %r12,%rdx
  call   <inet_ntop@plt>
  jmp    L50
L86:
  test   %rbx,%rbx
  je     L66
  movl   $0x0,(%rbx)
L66:
  mov    $0x3f,%edx
  mov    %dx,(%r12)
  jmp    L20
L68:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int anetPeerToString(int fd, char *ip, size_t ip_len, int *port) {
  struct sockaddr_storage sa;
  socklen_t salen = sizeof(sa);
  if (getpeername(fd, (struct sockaddr *)&sa, &salen) == -1) {
    if (port)
      *port = 0;
    ip[0] = '?';
    ip[1] = '\0';
    return -1;
  }
  if (sa.ss_family == AF_INET) {
    struct sockaddr_in *s = (struct sockaddr_in *)&sa;
    if (ip)
      inet_ntop(AF_INET, (void *)&(s->sin_addr), ip, ip_len);
    if (port)
      *port = ntohs(s->sin_port);
  } else {
    struct sockaddr_in6 *s = (struct sockaddr_in6 *)&sa;
    if (ip)
      inet_ntop(AF_INET6, (void *)&(s->sin6_addr), ip, ip_len);
    if (port)
      *port = ntohs(s->sin6_port);
  }
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<bbm_com_word_read>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,%eax
  mov    %rdx,-0x28(%rbp)
  mov    %ax,-0x1c(%rbp)
  movzwl -0x1c(%rbp),%ecx
  mov    -0x28(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <bbm_word_read@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
signed int bbm_com_word_read(void *handle, unsigned short addr, unsigned short *data) {
  signed int res;
  res = bbm_word_read(handle, addr, data);
  return res;
}
```
user: What is the c source code of the assembly code below:

```asm
<bbm_com_word_read>:
  endbr64
  sub    $0x8,%rsp
  movzwl %si,%esi
  call   <bbm_word_read@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
signed int bbm_com_word_read(void *handle, unsigned short addr, unsigned short *data) {
  signed int res;
  res = bbm_word_read(handle, addr, data);
  return res;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<bbm_com_word_read>:
  endbr64
  movzwl %si,%esi
  jmp    1050 <bbm_word_read@plt>
```

assistant: ```c
signed int bbm_com_word_read(void *handle, unsigned short addr, unsigned short *data) {
  signed int res;
  res = bbm_word_read(handle, addr, data);
  return res;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<bbm_com_word_read>:
  endbr64
  movzwl %si,%esi
  jmp    1050 <bbm_word_read@plt>
```

assistant: ```c
signed int bbm_com_word_read(void *handle, unsigned short addr, unsigned short *data) {
  signed int res;
  res = bbm_word_read(handle, addr, data);
  return res;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<selection_sort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L11
L28:
  mov    -0x10(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x10(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L33
L12:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jge    L44
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x8(%rbp)
L44:
  addl   $0x1,-0xc(%rbp)
L33:
  mov    -0xc(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L12
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x10(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x4(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x10(%rbp)
L11:
  mov    -0x10(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L28
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void selection_sort(int *a, int n) {
  int i, j, m, t;
  for (i = 0; i < n; i++) {
    for (j = i, m = i; j < n; j++) {
      if (a[j] < a[m]) {
        m = j;
      }
    }
    t = a[i];
    a[i] = a[m];
    a[m] = t;
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<selection_sort>:
  endbr64
  test   %esi,%esi
  jle    L4
  mov    %esi,%r9d
  mov    $0x0,%r8d
  jmp    L18
L41:
  movslq %edx,%rcx
  mov    (%rdi,%rcx,4),%ecx
  cmp    %ecx,(%rdi,%rax,4)
  cmovl  %eax,%edx
  add    $0x1,%rax
  cmp    %eax,%esi
  jg     L41
L53:
  mov    (%rdi,%r8,4),%ecx
  movslq %edx,%rdx
  lea    (%rdi,%rdx,4),%rax
  mov    (%rax),%edx
  mov    %edx,(%rdi,%r8,4)
  mov    %ecx,(%rax)
  add    $0x1,%r8
  cmp    %r9,%r8
  je     L4
L18:
  mov    %r8d,%edx
  mov    %r8,%rax
  cmp    %r8d,%esi
  jg     L41
  jmp    L53
L4:
  ret
```

assistant: ```c
void selection_sort(int *a, int n) {
  int i, j, m, t;
  for (i = 0; i < n; i++) {
    for (j = i, m = i; j < n; j++) {
      if (a[j] < a[m]) {
        m = j;
      }
    }
    t = a[i];
    a[i] = a[m];
    a[m] = t;
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<selection_sort>:
  endbr64
  test   %esi,%esi
  jle    L17
  push   %rbp
  xor    %r11d,%r11d
  push   %rbx
  mov    %rdi,%rbx
L29:
  mov    (%rdi),%ebp
  mov    %rdi,%rdx
  mov    %r11d,%r10d
  mov    %r11d,%eax
  mov    %ebp,%ecx
  mov    %ebp,%r8d
  jmp    L11
  nopw   0x0(%rax,%rax,1)
L41:
  movslq %r10d,%rcx
  add    $0x1,%eax
  add    $0x4,%rdx
  lea    (%rbx,%rcx,4),%r9
  cmp    %eax,%esi
  jle    L25
L42:
  mov    (%rdx),%ecx
L11:
  cmp    %ecx,%r8d
  jle    L41
  mov    %eax,%r10d
  add    $0x1,%eax
  mov    %rdx,%r9
  mov    %ecx,%r8d
  add    $0x4,%rdx
  cmp    %eax,%esi
  jg     L42
L25:
  add    $0x1,%r11d
  mov    %r8d,(%rdi)
  add    $0x4,%rdi
  mov    %ebp,(%r9)
  cmp    %r11d,%esi
  jne    L29
  pop    %rbx
  pop    %rbp
  ret
L17:
  ret
```

assistant: ```c
void selection_sort(int *a, int n) {
  int i, j, m, t;
  for (i = 0; i < n; i++) {
    for (j = i, m = i; j < n; j++) {
      if (a[j] < a[m]) {
        m = j;
      }
    }
    t = a[i];
    a[i] = a[m];
    a[m] = t;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<selection_sort>:
  endbr64
  test   %esi,%esi
  jle    L25
  push   %rbp
  xor    %r11d,%r11d
  push   %rbx
  mov    %rdi,%rbx
L35:
  mov    (%rdi),%ebp
  mov    %rdi,%rax
  mov    %r11d,%r10d
  mov    %r11d,%edx
  mov    %ebp,%r8d
  jmp    L3
L37:
  movslq %r10d,%rcx
  add    $0x1,%edx
  add    $0x4,%rax
  lea    (%rbx,%rcx,4),%r9
  cmp    %edx,%esi
  jle    L36
L3:
  mov    (%rax),%ecx
  mov    %rax,%r9
  cmp    %ecx,%r8d
  jle    L37
  mov    %edx,%r10d
  add    $0x1,%edx
  mov    %ecx,%r8d
  add    $0x4,%rax
  cmp    %edx,%esi
  jg     L3
L36:
  add    $0x1,%r11d
  mov    %r8d,(%rdi)
  add    $0x4,%rdi
  mov    %ebp,(%r9)
  cmp    %r11d,%esi
  jne    L35
  pop    %rbx
  pop    %rbp
  ret
L25:
  ret
```

assistant: ```c
void selection_sort(int *a, int n) {
  int i, j, m, t;
  for (i = 0; i < n; i++) {
    for (j = i, m = i; j < n; j++) {
      if (a[j] < a[m]) {
        m = j;
      }
    }
    t = a[i];
    a[i] = a[m];
    a[m] = t;
  }
}
```