ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 这段汇编代码用C语言表示是什么样的：

```asm
<modificar_bien_monto>:
  endbr64
  push   %r12
  xor    %edi,%edi
  push   %rbp
  sub    $0x278,%rsp
  movss  %xmm0,0xc(%rsp)
  movss  %xmm1,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x268(%rsp)
  xor    %eax,%eax
  call   <mysql_init@plt>
  push   $0x0
  xor    %r9d,%r9d
  lea    D13(%rip),%r8
  push   $0x0
  lea    D6(%rip),%rcx
  mov    %rax,%rdi
  mov    %rax,%rbp
  lea    D37(%rip),%rdx
  lea    D36(%rip),%rsi
  call   <mysql_real_connect@plt>
  movss  0x1c(%rsp),%xmm2
  movss  0x18(%rsp),%xmm0
  lea    0x20(%rsp),%r12
  lea    D19(%rip),%rdx
  lea    D68(%rip),%rcx
  mov    %r12,%rdi
  movaps %xmm2,%xmm1
  lea    D55(%rip),%rsi
  call   <sprintf@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <mysql_query@plt>
  mov    %rbp,%rdi
  call   <mysql_close@plt>
  pop    %rax
  pop    %rdx
  mov    0x268(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  add    $0x278,%rsp
  pop    %rbp
  pop    %r12
  ret
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D13
type_infered: string
name: disassemble_data
arguments: tag: D6
type_infered: string
name: disassemble_data
arguments: tag: D37
type_infered: string
name: disassemble_data
arguments: tag: D36
type_infered: string
name: disassemble_data
arguments: tag: D19
type_infered: string
name: disassemble_data
arguments: tag: D68
type_infered: string
name: disassemble_data
arguments: tag: D55
type_infered: string

tool: D13: casaempenio

tool: D6: 1234

tool: D37: root

tool: D36: localhost

tool: D19: update bienes set monto=

tool: D68: where monto=

tool: D55: %s %f %s %f;

assistant: ```c
void modificar_bien_monto(float monto, float nvo_monto) {
  MYSQL *conexion;
  MYSQL_RES *R;
  MYSQL_ROW COL;
  char *servidor = "localhost";
  char *usuario = "root";
  char *pass = "1234";
  char *base = "casaempenio";
  conexion = mysql_init(NULL);
  mysql_real_connect(conexion, servidor, usuario, pass, base, 0, NULL, 0);
  char *sentencia = "update bienes set monto=";
  char *sentencia2 = "where monto=";
  char buffer[600];
  sprintf(buffer, "%s %f %s %f;", sentencia, nvo_monto, sentencia2, monto);
  mysql_query(conexion, buffer);
  mysql_close(conexion);
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<isPrime>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jne    L33
  mov    $0x1,%eax
  jmp    L55
L33:
  movl   $0x2,-0x4(%rbp)
  jmp    L31
L0:
  mov    -0x14(%rbp),%eax
  cltd
  idivl  -0x4(%rbp)
  mov    %edx,%eax
  test   %eax,%eax
  jne    L41
  mov    $0x0,%eax
  jmp    L55
L41:
  addl   $0x1,-0x4(%rbp)
L31:
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x14(%rbp),%xmm1
  movq   %xmm1,%rax
  movq   %rax,%xmm0
  call   <sqrt@plt>
  cmp    %eax,-0x4(%rbp)
  jle    L0
  mov    $0x1,%eax
L55:
  leave
  ret
```

assistant: ```c
int isPrime(int num) {
  int i;
  if (num == 0)
    return 1;
  for (i = 2; i <= (int)sqrt((double)num); i++)
    if (num % i == 0)
      return 0;
  return 1;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<isPrime>:
  endbr64
  mov    $0x1,%eax
  test   %edi,%edi
  je     L38
  push   %r14
  push   %rbp
  push   %rbx
  mov    %edi,%ebp
  mov    $0x2,%ebx
  pxor   %xmm1,%xmm1
  cvtsi2sd %edi,%xmm1
  movq   %xmm1,%r14
L27:
  movq   %r14,%xmm0
  call   <sqrt@plt>
  cmp    %eax,%ebx
  jg     L5
  mov    %ebp,%eax
  cltd
  idiv   %ebx
  mov    %edx,%eax
  test   %edx,%edx
  je     L12
  add    $0x1,%ebx
  jmp    L27
L5:
  mov    $0x1,%eax
L12:
  pop    %rbx
  pop    %rbp
  pop    %r14
  ret
L38:
  ret
```

assistant: ```c
int isPrime(int num) {
  int i;
  if (num == 0)
    return 1;
  for (i = 2; i <= (int)sqrt((double)num); i++)
    if (num % i == 0)
      return 0;
  return 1;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<isPrime>:
  endbr64
  test   %edi,%edi
  je     L12
  pxor   %xmm1,%xmm1
  push   %r14
  cvtsi2sd %edi,%xmm1
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    $0x2,%ebx
  movq   %xmm1,%r14
  jmp    L23
  nopw   0x0(%rax,%rax,1)
L9:
  mov    %ebp,%eax
  cltd
  idiv   %ebx
  test   %edx,%edx
  je     L1
  add    $0x1,%ebx
L23:
  movq   %r14,%xmm0
  call   <sqrt@plt>
  cmp    %eax,%ebx
  jle    L9
  mov    $0x1,%edx
L1:
  pop    %rbx
  mov    %edx,%eax
  pop    %rbp
  pop    %r14
  ret
  xchg   %ax,%ax
L12:
  mov    $0x1,%eax
  ret
```

assistant: ```c
int isPrime(int num) {
  int i;
  if (num == 0)
    return 1;
  for (i = 2; i <= (int)sqrt((double)num); i++)
    if (num % i == 0)
      return 0;
  return 1;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<isPrime>:
  endbr64
  test   %edi,%edi
  je     L24
  pxor   %xmm1,%xmm1
  push   %r14
  cvtsi2sd %edi,%xmm1
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    $0x2,%ebx
  movq   %xmm1,%r14
  jmp    L38
  nopw   0x0(%rax,%rax,1)
L28:
  mov    %ebp,%eax
  cltd
  idiv   %ebx
  test   %edx,%edx
  je     L0
  add    $0x1,%ebx
L38:
  movq   %r14,%xmm0
  call   <sqrt@plt>
  cmp    %eax,%ebx
  jle    L28
  mov    $0x1,%edx
L0:
  pop    %rbx
  mov    %edx,%eax
  pop    %rbp
  pop    %r14
  ret
  xchg   %ax,%ax
L24:
  mov    $0x1,%eax
  ret
```

assistant: ```c
int isPrime(int num) {
  int i;
  if (num == 0)
    return 1;
  for (i = 2; i <= (int)sqrt((double)num); i++)
    if (num % i == 0)
      return 0;
  return 1;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<StrRegionalShuffle>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    -0x28(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  je     L3
  mov    -0x30(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
L3:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x8(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L15
L29:
  mov    -0x10(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x8(%rbp)
  jge    L25
  mov    -0x8(%rbp),%eax
  sub    $0x1,%eax
  jmp    L8
L25:
  mov    -0x10(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  sub    $0x1,%eax
L8:
  mov    %eax,-0xc(%rbp)
  jmp    L6
L56:
  mov    $0x0,%eax
  call   <sre_random@plt>
  mov    -0xc(%rbp),%edx
  sub    -0x10(%rbp),%edx
  imul   %eax,%edx
  mov    -0x10(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x11(%rbp)
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x4(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  movzbl -0x11(%rbp),%eax
  mov    %al,(%rdx)
  subl   $0x1,-0xc(%rbp)
L6:
  mov    -0xc(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jg     L56
  mov    -0x34(%rbp),%eax
  add    %eax,-0x10(%rbp)
L15:
  mov    -0x10(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jl     L29
  mov    $0x1,%eax
  leave
  ret
```

assistant: ```c
int StrRegionalShuffle(char *s1, char *s2, int w) {
  int len;
  char c;
  int pos;
  int i, j;
  if (s1 != s2)
    strcpy(s1, s2);
  len = strlen(s1);
  for (i = 0; i < len; i += w)
    for (j = (((len - 1) < (i + w - 1)) ? (len - 1) : (i + w - 1)); j > i; j--) {
      pos = i + ((int)(sre_random() * (j - i)));
      c = s1[pos];
      s1[pos] = s1[j];
      s1[j] = c;
    }
  return 1;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<StrRegionalShuffle>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r13
  mov    %edx,0x8(%rsp)
  cmp    %rsi,%rdi
  je     L9
  call   <strcpy@plt>
L9:
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %eax,%r15d
  test   %eax,%eax
  jle    L7
  mov    $0x0,%r14d
  lea    -0x1(%rax),%eax
  mov    %eax,0xc(%rsp)
L29:
  mov    %r14d,%r12d
  add    0x8(%rsp),%r14d
  lea    -0x1(%r14),%eax
  cmp    %r15d,%r14d
  cmovg  0xc(%rsp),%eax
  mov    %eax,%ebp
  sub    %r12d,%ebp
  movslq %eax,%rbx
  add    %r13,%rbx
  cmp    %r12d,%eax
  jle    L0
L20:
  mov    $0x0,%eax
  call   <sre_random@plt>
  imul   %ebp,%eax
  add    %r12d,%eax
  cltq
  add    %r13,%rax
  movzbl (%rax),%edx
  movzbl (%rbx),%ecx
  mov    %cl,(%rax)
  mov    %dl,(%rbx)
  sub    $0x1,%rbx
  sub    $0x1,%ebp
  jne    L20
L0:
  cmp    %r15d,%r14d
  jl     L29
L7:
  mov    $0x1,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int StrRegionalShuffle(char *s1, char *s2, int w) {
  int len;
  char c;
  int pos;
  int i, j;
  if (s1 != s2)
    strcpy(s1, s2);
  len = strlen(s1);
  for (i = 0; i < len; i += w)
    for (j = (((len - 1) < (i + w - 1)) ? (len - 1) : (i + w - 1)); j > i; j--) {
      pos = i + ((int)(sre_random() * (j - i)));
      c = s1[pos];
      s1[pos] = s1[j];
      s1[j] = c;
    }
  return 1;
}
```
user: What is the c source code of the assembly code below?

```asm
<StrRegionalShuffle>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edx,0x8(%rsp)
  cmp    %rsi,%rdi
  je     L0
  call   <strcpy@plt>
L0:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%r13d
  test   %eax,%eax
  jle    L13
  lea    -0x1(%rax),%eax
  xor    %r12d,%r12d
  mov    %eax,0xc(%rsp)
  nopl   0x0(%rax)
L17:
  mov    %r12d,%ebx
  add    0x8(%rsp),%r12d
  cmp    %r13d,%r12d
  lea    -0x1(%r12),%eax
  cmovg  0xc(%rsp),%eax
  mov    %eax,%r14d
  movslq %eax,%rdx
  sub    %ebx,%r14d
  lea    0x0(%rbp,%rdx,1),%r15
  cmp    %ebx,%eax
  jle    L38
  nopw   0x0(%rax,%rax,1)
L3:
  xor    %eax,%eax
  sub    $0x1,%r15
  call   <sre_random@plt>
  movzbl 0x1(%r15),%edi
  imul   %r14d,%eax
  add    %ebx,%eax
  cltq
  add    %rbp,%rax
  movzbl (%rax),%esi
  mov    %dil,(%rax)
  mov    %sil,0x1(%r15)
  sub    $0x1,%r14d
  jne    L3
L38:
  cmp    %r13d,%r12d
  jl     L17
L13:
  add    $0x18,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int StrRegionalShuffle(char *s1, char *s2, int w) {
  int len;
  char c;
  int pos;
  int i, j;
  if (s1 != s2)
    strcpy(s1, s2);
  len = strlen(s1);
  for (i = 0; i < len; i += w)
    for (j = (((len - 1) < (i + w - 1)) ? (len - 1) : (i + w - 1)); j > i; j--) {
      pos = i + ((int)(sre_random() * (j - i)));
      c = s1[pos];
      s1[pos] = s1[j];
      s1[j] = c;
    }
  return 1;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<StrRegionalShuffle>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edx,0x8(%rsp)
  cmp    %rsi,%rdi
  je     L4
  call   <strcpy@plt>
L4:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%r13d
  test   %eax,%eax
  jle    L42
  lea    -0x1(%rax),%eax
  xor    %r12d,%r12d
  mov    %eax,0xc(%rsp)
  nopl   0x0(%rax)
L31:
  mov    %r12d,%ebx
  add    0x8(%rsp),%r12d
  cmp    %r13d,%r12d
  lea    -0x1(%r12),%eax
  cmovg  0xc(%rsp),%eax
  mov    %eax,%r14d
  movslq %eax,%rdx
  sub    %ebx,%r14d
  lea    0x0(%rbp,%rdx,1),%r15
  cmp    %ebx,%eax
  jle    L19
  nopw   0x0(%rax,%rax,1)
L33:
  xor    %eax,%eax
  sub    $0x1,%r15
  call   <sre_random@plt>
  movzbl 0x1(%r15),%edi
  imul   %r14d,%eax
  add    %ebx,%eax
  cltq
  add    %rbp,%rax
  movzbl (%rax),%esi
  mov    %dil,(%rax)
  mov    %sil,0x1(%r15)
  sub    $0x1,%r14d
  jne    L33
L19:
  cmp    %r13d,%r12d
  jl     L31
L42:
  add    $0x18,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int StrRegionalShuffle(char *s1, char *s2, int w) {
  int len;
  char c;
  int pos;
  int i, j;
  if (s1 != s2)
    strcpy(s1, s2);
  len = strlen(s1);
  for (i = 0; i < len; i += w)
    for (j = (((len - 1) < (i + w - 1)) ? (len - 1) : (i + w - 1)); j > i; j--) {
      pos = i + ((int)(sre_random() * (j - i)));
      c = s1[pos];
      s1[pos] = s1[j];
      s1[j] = c;
    }
  return 1;
}
```
user: Translate the below assembly code into C programming language:

```asm
<pthread_setcancelstate>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  pop    %rbp
  ret
```

assistant: ```c
int pthread_setcancelstate(int state, int *oldstate) {
  (void)state;
  (void)oldstate;
  return EINVAL;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<pthread_setcancelstate>:
  endbr64
  mov    D9(%rip),%rax
  mov    (%rax),%eax
  ret
```

assistant: ```c
int pthread_setcancelstate(int state, int *oldstate) {
  (void)state;
  (void)oldstate;
  return EINVAL;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<pthread_setcancelstate>:
  endbr64
  mov    D6(%rip),%rax
  mov    (%rax),%eax
  ret
```

assistant: ```c
int pthread_setcancelstate(int state, int *oldstate) {
  (void)state;
  (void)oldstate;
  return EINVAL;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<pthread_setcancelstate>:
  endbr64
  mov    D2(%rip),%rax
  mov    (%rax),%eax
  ret
```

assistant: ```c
int pthread_setcancelstate(int state, int *oldstate) {
  (void)state;
  (void)oldstate;
  return EINVAL;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<get_line_len>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  jmp    L37
L8:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xa,%al
  je     L11
  addq   $0x1,-0x10(%rbp)
L37:
  mov    -0x10(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  jb     L8
  jmp    L16
L11:
  nop
L16:
  mov    -0x10(%rbp),%rax
  sub    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  pop    %rbp
  ret
```

assistant: ```c
size_t get_line_len(char *pos, char *max) {
  char *cur = pos;
  for (cur = pos; cur < max; cur++) {
    if (*cur == '\n')
      break;
  }
  size_t len = cur - pos;
  return (len);
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<get_line_len>:
  endbr64
  cmp    %rsi,%rdi
  jae    L38
  mov    %rdi,%rax
L30:
  cmpb   $0xa,(%rax)
  je     L39
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L30
  mov    %rsi,%rax
L39:
  sub    %rdi,%rax
  ret
L38:
  mov    %rdi,%rax
  jmp    L39
```

assistant: ```c
size_t get_line_len(char *pos, char *max) {
  char *cur = pos;
  for (cur = pos; cur < max; cur++) {
    if (*cur == '\n')
      break;
  }
  size_t len = cur - pos;
  return (len);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<get_line_len>:
  endbr64
  cmp    %rsi,%rdi
  jae    L30
  mov    %rdi,%rax
  jmp    L5
  xchg   %ax,%ax
L6:
  add    $0x1,%rax
  cmp    %rax,%rsi
  je     L17
L5:
  cmpb   $0xa,(%rax)
  jne    L6
  sub    %rdi,%rax
  ret
  nopw   0x0(%rax,%rax,1)
L17:
  mov    %rsi,%rax
  sub    %rdi,%rax
  ret
L30:
  xor    %eax,%eax
  ret
```

assistant: ```c
size_t get_line_len(char *pos, char *max) {
  char *cur = pos;
  for (cur = pos; cur < max; cur++) {
    if (*cur == '\n')
      break;
  }
  size_t len = cur - pos;
  return (len);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<get_line_len>:
  endbr64
  cmp    %rsi,%rdi
  jae    L19
  mov    %rdi,%rax
  jmp    L17
  xchg   %ax,%ax
L3:
  add    $0x1,%rax
  cmp    %rax,%rsi
  je     L39
L17:
  cmpb   $0xa,(%rax)
  jne    L3
  sub    %rdi,%rax
  ret
  nopw   0x0(%rax,%rax,1)
L39:
  mov    %rsi,%rax
  sub    %rdi,%rax
  ret
L19:
  xor    %eax,%eax
  ret
```

assistant: ```c
size_t get_line_len(char *pos, char *max) {
  char *cur = pos;
  for (cur = pos; cur < max; cur++) {
    if (*cur == '\n')
      break;
  }
  size_t len = cur - pos;
  return (len);
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<sort_addresses>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x18(%rbp)
  jmp    L47
L68:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  lea    -0x20(%rbp),%rax
  mov    $0x4,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x34(%rbp),%edx
  mov    -0x30(%rbp),%rcx
  lea    -0x20(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <get_address_index@plt>
  mov    %eax,-0x10(%rbp)
  mov    -0x18(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x14(%rbp)
  jmp    L20
L12:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  lea    -0x1c(%rbp),%rax
  mov    $0x4,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x34(%rbp),%edx
  mov    -0x30(%rbp),%rcx
  lea    -0x1c(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <get_address_index@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jle    L63
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  cltq
  add    $0x1,%rax
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    -0x1c(%rbp),%rcx
  mov    $0x4,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  subl   $0x1,-0x14(%rbp)
L20:
  cmpl   $0x0,-0x14(%rbp)
  jns    L12
  jmp    L24
L63:
  nop
L24:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  cltq
  add    $0x1,%rax
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    -0x20(%rbp),%rcx
  mov    $0x4,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  addl   $0x1,-0x18(%rbp)
L47:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L68
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L2
  call   <__stack_chk_fail@plt>
L2:
  leave
  ret
```

assistant: ```c
void sort_addresses(struct hostent *host, struct apattern *sortlist, int nsort) {
  struct in_addr a1, a2;
  int i1, i2, ind1, ind2;
  for (i1 = 0; host->h_addr_list[i1]; i1++) {
    memcpy(&a1, host->h_addr_list[i1], sizeof(struct in_addr));
    ind1 = get_address_index(&a1, sortlist, nsort);
    for (i2 = i1 - 1; i2 >= 0; i2--) {
      memcpy(&a2, host->h_addr_list[i2], sizeof(struct in_addr));
      ind2 = get_address_index(&a2, sortlist, nsort);
      if (ind2 <= ind1)
        break;
      memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct in_addr));
    }
    memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct in_addr));
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<sort_addresses>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  mov    (%rdi),%rax
  mov    (%rax),%rsi
  test   %rsi,%rsi
  je     L0
  mov    %rdi,%r13
  mov    %edx,%r15d
  lea    0x20(%rsp),%rbx
  mov    $0x4,%edx
  mov    %rbx,%rdi
  call   <memcpy@plt>
  mov    %r15d,%edx
  mov    0x8(%rsp),%rsi
  mov    %rbx,%rdi
  call   <get_address_index@plt>
  movq   $0x0,0x10(%rsp)
  mov    $0xffffffff,%eax
  mov    %rbx,0x18(%rsp)
  jmp    L7
L38:
  addq   $0x1,0x10(%rsp)
  mov    %ebp,%eax
L7:
  mov    0x10(%rsp),%rbx
  mov    %ebx,%ebp
  cltq
  mov    0x0(%r13),%rdx
  mov    0x8(%rdx,%rax,8),%rdi
  mov    $0x4,%edx
  mov    0x18(%rsp),%rsi
  call   <memcpy@plt>
  lea    0x1(%rbx),%rax
  lea    0x0(,%rax,8),%rbx
  mov    0x0(%r13),%rdx
  mov    (%rdx,%rax,8),%rsi
  test   %rsi,%rsi
  je     L0
  mov    $0x4,%edx
  mov    0x18(%rsp),%r14
  mov    %r14,%rdi
  call   <memcpy@plt>
  mov    %r15d,%edx
  mov    0x8(%rsp),%rsi
  mov    %r14,%rdi
  call   <get_address_index@plt>
  mov    %eax,%r14d
  cmpl   $0x0,0x10(%rsp)
  js     L38
  sub    $0x8,%rbx
  lea    0x24(%rsp),%r12
L57:
  mov    0x0(%r13),%rax
  mov    (%rax,%rbx,1),%rsi
  mov    $0x4,%edx
  mov    %r12,%rdi
  call   <memcpy@plt>
  mov    %r15d,%edx
  mov    0x8(%rsp),%rsi
  mov    %r12,%rdi
  call   <get_address_index@plt>
  cmp    %eax,%r14d
  jge    L38
  mov    0x0(%r13),%rax
  mov    0x8(%rax,%rbx,1),%rdi
  mov    $0x4,%edx
  mov    %r12,%rsi
  call   <memcpy@plt>
  sub    $0x1,%ebp
  sub    $0x8,%rbx
  cmp    $0xffffffff,%ebp
  jne    L57
  jmp    L38
L0:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L49
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L49:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void sort_addresses(struct hostent *host, struct apattern *sortlist, int nsort) {
  struct in_addr a1, a2;
  int i1, i2, ind1, ind2;
  for (i1 = 0; host->h_addr_list[i1]; i1++) {
    memcpy(&a1, host->h_addr_list[i1], sizeof(struct in_addr));
    ind1 = get_address_index(&a1, sortlist, nsort);
    for (i2 = i1 - 1; i2 >= 0; i2--) {
      memcpy(&a2, host->h_addr_list[i2], sizeof(struct in_addr));
      ind2 = get_address_index(&a2, sortlist, nsort);
      if (ind2 <= ind1)
        break;
      memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct in_addr));
    }
    memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct in_addr));
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<sort_addresses>:
  endbr64
  push   %r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  mov    (%rdi),%rax
  mov    (%rax),%rsi
  test   %rsi,%rsi
  je     L30
  lea    0x20(%rsp),%rbx
  mov    %edx,%r15d
  mov    %rdi,%r13
  mov    $0x4,%edx
  mov    %rbx,%rdi
  mov    %rbx,0x10(%rsp)
  lea    0x24(%rsp),%r12
  call   <memcpy@plt>
  mov    %r15d,%edx
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <get_address_index@plt>
  mov    $0xffffffff,%eax
  movq   $0x0,0x18(%rsp)
L43:
  mov    0x0(%r13),%rdx
  add    $0x1,%eax
  mov    0x10(%rsp),%rsi
  cltq
  mov    0x18(%rsp),%rbx
  mov    (%rdx,%rax,8),%rdi
  mov    $0x4,%edx
  mov    %ebx,%ebp
  shl    $0x3,%rbx
  call   <memcpy@plt>
  mov    0x0(%r13),%rax
  mov    0x8(%rax,%rbx,1),%rsi
  test   %rsi,%rsi
  je     L30
  mov    0x10(%rsp),%rdi
  mov    $0x4,%edx
  call   <memcpy@plt>
  mov    0x10(%rsp),%rdi
  mov    %r15d,%edx
  mov    %r14,%rsi
  call   <get_address_index@plt>
  mov    %eax,0xc(%rsp)
  jmp    L26
  xchg   %ax,%ax
L41:
  mov    0x0(%r13),%rax
  mov    $0x4,%edx
  mov    %r12,%rsi
  sub    $0x1,%ebp
  mov    0x8(%rax,%rbx,1),%rdi
  sub    $0x8,%rbx
  call   <memcpy@plt>
  cmp    $0xffffffff,%ebp
  je     L24
L26:
  mov    0x0(%r13),%rax
  mov    $0x4,%edx
  mov    %r12,%rdi
  mov    (%rax,%rbx,1),%rsi
  call   <memcpy@plt>
  mov    %r15d,%edx
  mov    %r14,%rsi
  mov    %r12,%rdi
  call   <get_address_index@plt>
  cmp    %eax,0xc(%rsp)
  jl     L41
L24:
  addq   $0x1,0x18(%rsp)
  mov    %ebp,%eax
  jmp    L43
  nopl   0x0(%rax,%rax,1)
L30:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L69
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L69:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void sort_addresses(struct hostent *host, struct apattern *sortlist, int nsort) {
  struct in_addr a1, a2;
  int i1, i2, ind1, ind2;
  for (i1 = 0; host->h_addr_list[i1]; i1++) {
    memcpy(&a1, host->h_addr_list[i1], sizeof(struct in_addr));
    ind1 = get_address_index(&a1, sortlist, nsort);
    for (i2 = i1 - 1; i2 >= 0; i2--) {
      memcpy(&a2, host->h_addr_list[i2], sizeof(struct in_addr));
      ind2 = get_address_index(&a2, sortlist, nsort);
      if (ind2 <= ind1)
        break;
      memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct in_addr));
    }
    memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct in_addr));
  }
}
```