ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<remove_first_X_packets>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x18(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpq   $0x0,-0x20(%rbp)
  je     L54
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L54
  cmpl   $0x0,-0x14(%rbp)
  jns    L65
L54:
  mov    D21(%rip),%rax
  mov    (%rax),%eax
  jmp    L9
L65:
  cmpl   $0x0,-0x14(%rbp)
  jne    L40
  mov    D29(%rip),%rax
  mov    (%rax),%eax
  jmp    L9
L40:
  mov    -0x20(%rbp),%rdx
  mov    -0x14(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <get_packets@plt>
  mov    %rax,-0x10(%rbp)
  lea    -0x10(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <free_pcap_packet@plt>
  mov    D29(%rip),%rax
  mov    (%rax),%eax
L9:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L61
  call   <__stack_chk_fail@plt>
L61:
  leave
  ret
```

assistant: ```c
int remove_first_X_packets(int nb_packets, struct packet_list **list, int use_mutex) {
  struct pcap_packet *packets;
  if (list == NULL || *list == NULL || nb_packets < 0) {
    return EXIT_FAILURE;
  }
  if (nb_packets == 0) {
    return EXIT_SUCCESS;
  }
  packets = get_packets(nb_packets, list);
  free_pcap_packet(&packets, 1);
  return EXIT_SUCCESS;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<remove_first_X_packets>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L3
  cmpq   $0x0,(%rsi)
  je     L3
  test   %edi,%edi
  js     L3
  jne    L18
  mov    D11(%rip),%rax
  mov    (%rax),%eax
  jmp    L8
L3:
  mov    D23(%rip),%rax
  mov    (%rax),%eax
L8:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L59
  add    $0x18,%rsp
  ret
L18:
  call   <get_packets@plt>
  mov    %rax,(%rsp)
  mov    %rsp,%rdi
  mov    $0x1,%esi
  call   <free_pcap_packet@plt>
  mov    D11(%rip),%rax
  mov    (%rax),%eax
  jmp    L8
L59:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int remove_first_X_packets(int nb_packets, struct packet_list **list, int use_mutex) {
  struct pcap_packet *packets;
  if (list == NULL || *list == NULL || nb_packets < 0) {
    return EXIT_FAILURE;
  }
  if (nb_packets == 0) {
    return EXIT_SUCCESS;
  }
  packets = get_packets(nb_packets, list);
  free_pcap_packet(&packets, 1);
  return EXIT_SUCCESS;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<remove_first_X_packets>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L27
  cmpq   $0x0,(%rsi)
  je     L27
  test   %edi,%edi
  js     L27
  je     L40
  call   <get_packets@plt>
  mov    %rsp,%rdi
  mov    $0x1,%esi
  mov    %rax,(%rsp)
  call   <free_pcap_packet@plt>
L40:
  mov    D15(%rip),%rax
  mov    (%rax),%eax
  jmp    L16
  nopw   0x0(%rax,%rax,1)
L27:
  mov    D17(%rip),%rax
  mov    (%rax),%eax
L16:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L39
  add    $0x18,%rsp
  ret
L39:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int remove_first_X_packets(int nb_packets, struct packet_list **list, int use_mutex) {
  struct pcap_packet *packets;
  if (list == NULL || *list == NULL || nb_packets < 0) {
    return EXIT_FAILURE;
  }
  if (nb_packets == 0) {
    return EXIT_SUCCESS;
  }
  packets = get_packets(nb_packets, list);
  free_pcap_packet(&packets, 1);
  return EXIT_SUCCESS;
}
```
user: What is the c source code of the assembly code below?

```asm
<remove_first_X_packets>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L52
  cmpq   $0x0,(%rsi)
  je     L52
  test   %edi,%edi
  js     L52
  je     L4
  call   <get_packets@plt>
  mov    %rsp,%rdi
  mov    $0x1,%esi
  mov    %rax,(%rsp)
  call   <free_pcap_packet@plt>
L4:
  mov    D1(%rip),%rax
  mov    (%rax),%eax
  jmp    L15
  nopw   0x0(%rax,%rax,1)
L52:
  mov    D5(%rip),%rax
  mov    (%rax),%eax
L15:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L18
  add    $0x18,%rsp
  ret
L18:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int remove_first_X_packets(int nb_packets, struct packet_list **list, int use_mutex) {
  struct pcap_packet *packets;
  if (list == NULL || *list == NULL || nb_packets < 0) {
    return EXIT_FAILURE;
  }
  if (nb_packets == 0) {
    return EXIT_SUCCESS;
  }
  packets = get_packets(nb_packets, list);
  free_pcap_packet(&packets, 1);
  return EXIT_SUCCESS;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<tf2>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%esi
  call   <pthread_join@plt>
  mov    $0x2b,%edi
  call   <exit@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
void *tf2(void *arg) {
  pthread_join((pthread_t)arg, NULL);
  exit(43);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<tf2>:
  endbr64
  sub    $0x8,%rsp
  xor    %esi,%esi
  call   <pthread_join@plt>
  mov    $0x2b,%edi
  call   <exit@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
void *tf2(void *arg) {
  pthread_join((pthread_t)arg, NULL);
  exit(43);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<tf2>:
  endbr64
  sub    $0x8,%rsp
  xor    %esi,%esi
  call   <pthread_join@plt>
  mov    $0x2b,%edi
  call   <exit@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
void *tf2(void *arg) {
  pthread_join((pthread_t)arg, NULL);
  exit(43);
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<help_query>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %esi,-0xc(%rbp)
  mov    %edx,-0x10(%rbp)
  mov    %rcx,-0x18(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  jne    L4
  lea    D20(%rip),%rax
  mov    %rax,%rsi
  mov    $0x2,%edi
  call   <dprintf@plt>
L4:
  mov    -0x8(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  lea    D28(%rip),%rdx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <help_shortcmdline@plt>
  test   %rax,%rax
  jne    L12
  lea    D27(%rip),%rax
  mov    %rax,%rsi
  mov    $0x2,%edi
  call   <dprintf@plt>
  jmp    L24
L12:
  nop
L24:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D20
type_infered: string
name: extract_symbolic_data
arguments: label: D28
type_infered: string
name: extract_symbolic_data
arguments: label: D27
type_infered: string

tool: D20: 
 querying devices ('query')
 ==========================

tool: D28: query <device>

tool: D27: 
 <device>	can be given one more more times (to query multiple devices at once).
         	either specify a device name (e.g. '/dev/video1') or a device number ('1').

assistant: ```c
void help_query(const char *program, int brief, int argc, char **argv) {
  if (!brief)
    dprintf(2, "\n querying devices ('query')"
               "\n ==========================");
  if (help_shortcmdline(brief, program, "query <device>"))
    return;
  dprintf(2, "\n <device>\tcan be given one more more times (to query multiple devices at once)."
             "\n         \teither specify a device name (e.g. '/dev/video1') or a device number ('1').");
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<help_query>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  mov    %esi,%ebx
  test   %esi,%esi
  je     L28
L30:
  lea    D17(%rip),%rdx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <help_shortcmdline@plt>
  test   %rax,%rax
  je     L22
L18:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L28:
  lea    D20(%rip),%rsi
  mov    $0x2,%edi
  call   <dprintf@plt>
  jmp    L30
L22:
  lea    D29(%rip),%rsi
  mov    $0x2,%edi
  call   <dprintf@plt>
  jmp    L18
```

tool_calls: name: disassemble_data
arguments: tag: D17
type_guessed: string
name: disassemble_data
arguments: tag: D20
type_guessed: string
name: disassemble_data
arguments: tag: D29
type_guessed: string

tool: D17: query <device>

tool: D20: 
 querying devices ('query')
 ==========================

tool: D29: 
 <device>	can be given one more more times (to query multiple devices at once).
         	either specify a device name (e.g. '/dev/video1') or a device number ('1').

assistant: ```c
void help_query(const char *program, int brief, int argc, char **argv) {
  if (!brief)
    dprintf(2, "\n querying devices ('query')"
               "\n ==========================");
  if (help_shortcmdline(brief, program, "query <device>"))
    return;
  dprintf(2, "\n <device>\tcan be given one more more times (to query multiple devices at once)."
             "\n         \teither specify a device name (e.g. '/dev/video1') or a device number ('1').");
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<help_query>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %esi,%ebp
  sub    $0x8,%rsp
  test   %esi,%esi
  je     L18
L26:
  lea    D7(%rip),%rdx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <help_shortcmdline@plt>
  test   %rax,%rax
  je     L23
  add    $0x8,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L23:
  add    $0x8,%rsp
  lea    D5(%rip),%rsi
  mov    $0x2,%edi
  pop    %rbp
  pop    %r12
  jmp    1060 <dprintf@plt>
L18:
  lea    D25(%rip),%rsi
  mov    $0x2,%edi
  call   <dprintf@plt>
  jmp    L26
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D7
type_guessed: string
name: extract_symbolic_data
arguments: data_label: D5
type_guessed: string
name: extract_symbolic_data
arguments: data_label: D25
type_guessed: string

tool: D7: query <device>

tool: D5: 
 <device>	can be given one more more times (to query multiple devices at once).
         	either specify a device name (e.g. '/dev/video1') or a device number ('1').

tool: D25: 
 querying devices ('query')
 ==========================

assistant: ```c
void help_query(const char *program, int brief, int argc, char **argv) {
  if (!brief)
    dprintf(2, "\n querying devices ('query')"
               "\n ==========================");
  if (help_shortcmdline(brief, program, "query <device>"))
    return;
  dprintf(2, "\n <device>\tcan be given one more more times (to query multiple devices at once)."
             "\n         \teither specify a device name (e.g. '/dev/video1') or a device number ('1').");
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<help_query>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %esi,%ebp
  sub    $0x8,%rsp
  test   %esi,%esi
  je     L9
L1:
  lea    D4(%rip),%rdx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <help_shortcmdline@plt>
  test   %rax,%rax
  je     L3
  add    $0x8,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L3:
  add    $0x8,%rsp
  lea    D2(%rip),%rsi
  mov    $0x2,%edi
  pop    %rbp
  pop    %r12
  jmp    1060 <dprintf@plt>
L9:
  lea    D10(%rip),%rsi
  mov    $0x2,%edi
  call   <dprintf@plt>
  jmp    L1
```

tool_calls: name: unpack_data
arguments: data_label: D4
data_type: string
name: unpack_data
arguments: data_label: D2
data_type: string
name: unpack_data
arguments: data_label: D10
data_type: string

tool: D4: query <device>

tool: D2: 
 <device>	can be given one more more times (to query multiple devices at once).
         	either specify a device name (e.g. '/dev/video1') or a device number ('1').

tool: D10: 
 querying devices ('query')
 ==========================

assistant: ```c
void help_query(const char *program, int brief, int argc, char **argv) {
  if (!brief)
    dprintf(2, "\n querying devices ('query')"
               "\n ==========================");
  if (help_shortcmdline(brief, program, "query <device>"))
    return;
  dprintf(2, "\n <device>\tcan be given one more more times (to query multiple devices at once)."
             "\n         \teither specify a device name (e.g. '/dev/video1') or a device number ('1').");
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<nand_read>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x28(%rbp)
  mov    -0x24(%rbp),%eax
  and    $0x7ff,%eax
  mov    %eax,-0x18(%rbp)
  movl   $0x0,-0x14(%rbp)
  mov    $0x0,%eax
  call   <nand_select@plt>
  jmp    L4
L25:
  mov    $0x0,%edi
  call   <nand_cmd@plt>
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <nand_addr@plt>
  mov    $0x30,%edi
  call   <nand_cmd@plt>
  mov    $0x0,%eax
  call   <nand_wait_read@plt>
  jmp    L36
L27:
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  lea    (%rdx,%rax,1),%rbx
  mov    $0x0,%eax
  call   <nand_data@plt>
  mov    %al,(%rbx)
  addl   $0x1,-0x14(%rbp)
  addl   $0x1,-0x24(%rbp)
  addl   $0x1,-0x18(%rbp)
L36:
  cmpl   $0x7ff,-0x18(%rbp)
  setle  %dl
  mov    -0x14(%rbp),%eax
  cmp    %eax,-0x28(%rbp)
  seta   %al
  and    %edx,%eax
  test   %al,%al
  jne    L27
  movl   $0x0,-0x18(%rbp)
L4:
  mov    -0x14(%rbp),%eax
  cmp    %eax,-0x28(%rbp)
  ja     L25
  mov    $0x0,%eax
  call   <nand_deselect@plt>
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void nand_read(unsigned int addr, unsigned char *buf, unsigned int len) {
  int col = addr % 2048;
  int i = 0;
  nand_select();
  while (i < len) {
    nand_cmd(0x00);
    nand_addr(addr);
    nand_cmd(0x30);
    nand_wait_read();
    for (; (col < 2048) & (i < len); col++) {
      buf[i] = nand_data();
      i++;
      addr++;
    }
    col = 0;
  }
  nand_deselect();
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<nand_read>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,%r14d
  mov    %rsi,%r15
  mov    %edx,%r12d
  mov    %edi,%r13d
  and    $0x7ff,%r13d
  mov    $0x0,%eax
  call   <nand_select@plt>
  test   %r12d,%r12d
  je     L68
  mov    $0x0,%ebp
  jmp    L25
L45:
  mov    %ecx,%r14d
L67:
  mov    $0x0,%r13d
  cmp    %r12d,%ebp
  jae    L68
L25:
  mov    $0x0,%edi
  call   <nand_cmd@plt>
  mov    %r14d,%edi
  call   <nand_addr@plt>
  mov    $0x30,%edi
  call   <nand_cmd@plt>
  mov    $0x0,%eax
  call   <nand_wait_read@plt>
  mov    %ebp,%eax
  mov    %ebp,0xc(%rsp)
  cmp    %ebp,%r12d
  jbe    L67
  add    $0x1,%ebp
  movslq %ebp,%rbx
  sub    %eax,%r14d
L48:
  mov    $0x0,%eax
  call   <nand_data@plt>
  mov    %al,-0x1(%r15,%rbx,1)
  mov    %ebx,%edx
  mov    %ebx,%ebp
  lea    (%r14,%rbx,1),%ecx
  mov    %r13d,%eax
  sub    0xc(%rsp),%eax
  add    %ebx,%eax
  add    $0x1,%rbx
  cmp    $0x7ff,%eax
  jg     L45
  cmp    %r12d,%edx
  jb     L48
  jmp    L45
L68:
  mov    $0x0,%eax
  call   <nand_deselect@plt>
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void nand_read(unsigned int addr, unsigned char *buf, unsigned int len) {
  int col = addr % 2048;
  int i = 0;
  nand_select();
  while (i < len) {
    nand_cmd(0x00);
    nand_addr(addr);
    nand_cmd(0x30);
    nand_wait_read();
    for (; (col < 2048) & (i < len); col++) {
      buf[i] = nand_data();
      i++;
      addr++;
    }
    col = 0;
  }
  nand_deselect();
}
```
user: What is the c source code of the assembly code below?

```asm
<nand_read>:
  endbr64
  push   %r15
  xor    %eax,%eax
  mov    %rsi,%r15
  push   %r14
  mov    %edi,%r14d
  push   %r13
  mov    %edx,%r13d
  and    $0x7ff,%r14d
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  sub    $0x18,%rsp
  call   <nand_select@plt>
  xor    %ecx,%ecx
  test   %r13d,%r13d
  je     L51
  nopw   0x0(%rax,%rax,1)
L54:
  xor    %edi,%edi
  mov    %ecx,0xc(%rsp)
  call   <nand_cmd@plt>
  mov    %ebp,%edi
  call   <nand_addr@plt>
  mov    $0x30,%edi
  call   <nand_cmd@plt>
  xor    %eax,%eax
  call   <nand_wait_read@plt>
  mov    0xc(%rsp),%r12d
  cmp    %r12d,%r13d
  jbe    L51
  lea    0x1(%r12),%ebx
  sub    %r12d,%ebp
  movslq %ebx,%rbx
L17:
  xor    %eax,%eax
  call   <nand_data@plt>
  mov    %ebx,%edx
  mov    %ebx,%ecx
  lea    0x0(%rbp,%rbx,1),%esi
  mov    %al,-0x1(%r15,%rbx,1)
  mov    %r14d,%eax
  sub    %r12d,%eax
  add    %ebx,%eax
  add    $0x1,%rbx
  cmp    $0x7ff,%eax
  jg     L7
  cmp    %r13d,%edx
  jb     L17
L7:
  xor    %r14d,%r14d
  cmp    %r13d,%edx
  jae    L51
  mov    %esi,%ebp
  jmp    L54
  nopl   0x0(%rax,%rax,1)
L51:
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10c0 <nand_deselect@plt>
```

assistant: ```c
void nand_read(unsigned int addr, unsigned char *buf, unsigned int len) {
  int col = addr % 2048;
  int i = 0;
  nand_select();
  while (i < len) {
    nand_cmd(0x00);
    nand_addr(addr);
    nand_cmd(0x30);
    nand_wait_read();
    for (; (col < 2048) & (i < len); col++) {
      buf[i] = nand_data();
      i++;
      addr++;
    }
    col = 0;
  }
  nand_deselect();
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<nand_read>:
  endbr64
  push   %r15
  xor    %eax,%eax
  mov    %rsi,%r15
  push   %r14
  mov    %edi,%r14d
  push   %r13
  mov    %edx,%r13d
  and    $0x7ff,%r14d
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  sub    $0x18,%rsp
  call   <nand_select@plt>
  xor    %ecx,%ecx
  test   %r13d,%r13d
  je     L26
  nopw   0x0(%rax,%rax,1)
L38:
  xor    %edi,%edi
  mov    %ecx,0xc(%rsp)
  call   <nand_cmd@plt>
  mov    %ebp,%edi
  call   <nand_addr@plt>
  mov    $0x30,%edi
  call   <nand_cmd@plt>
  xor    %eax,%eax
  call   <nand_wait_read@plt>
  mov    0xc(%rsp),%r12d
  cmp    %r12d,%r13d
  jbe    L26
  lea    0x1(%r12),%ebx
  sub    %r12d,%ebp
  movslq %ebx,%rbx
L47:
  xor    %eax,%eax
  call   <nand_data@plt>
  mov    %ebx,%edx
  mov    %ebx,%ecx
  lea    0x0(%rbp,%rbx,1),%esi
  mov    %al,-0x1(%r15,%rbx,1)
  mov    %r14d,%eax
  sub    %r12d,%eax
  add    %ebx,%eax
  add    $0x1,%rbx
  cmp    $0x7ff,%eax
  jg     L58
  cmp    %edx,%r13d
  ja     L47
L58:
  xor    %r14d,%r14d
  cmp    %edx,%r13d
  jbe    L26
  mov    %esi,%ebp
  jmp    L38
  nopl   0x0(%rax,%rax,1)
L26:
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10c0 <nand_deselect@plt>
```

assistant: ```c
void nand_read(unsigned int addr, unsigned char *buf, unsigned int len) {
  int col = addr % 2048;
  int i = 0;
  nand_select();
  while (i < len) {
    nand_cmd(0x00);
    nand_addr(addr);
    nand_cmd(0x30);
    nand_wait_read();
    for (; (col < 2048) & (i < len); col++) {
      buf[i] = nand_data();
      i++;
      addr++;
    }
    col = 0;
  }
  nand_deselect();
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<CountSortedDouble>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  mov    %r8,-0x38(%rbp)
  mov    %r9,-0x40(%rbp)
  mov    -0x20(%rbp),%rax
  movsd  (%rax),%xmm0
  mov    -0x30(%rbp),%rax
  movsd  %xmm0,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  mov    0x10(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    0x10(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  movl   $0x0,-0x8(%rbp)
  movl   $0x1,-0x4(%rbp)
  jmp    L24
L32:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x4(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  ucomisd %xmm1,%xmm0
  jp     L28
  ucomisd %xmm1,%xmm0
  je     L23
L28:
  addl   $0x1,-0x8(%rbp)
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
L23:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  add    $0x1,%edx
  mov    %edx,(%rax)
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x4(%rbp)
L24:
  mov    -0x4(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L32
  addl   $0x1,-0x8(%rbp)
  mov    -0x8(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int CountSortedDouble(int M, double *sorted, int *sort_idx, double *uni_list, int *uni_i, int *uni_j, int *cnt) {
  int u, m;
  uni_list[0] = sorted[0];
  uni_i[0] = sort_idx[0];
  cnt[0]++;
  uni_j[sort_idx[0]] = 0;
  u = 0;
  for (m = 1; m < M; m++) {
    if (sorted[m] != sorted[m - 1]) {
      u++;
      uni_list[u] = sorted[m];
      uni_i[u] = sort_idx[m];
    }
    cnt[u]++;
    uni_j[sort_idx[m]] = u;
  }
  u++;
  return u;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<CountSortedDouble>:
  endbr64
  push   %r14
  push   %rbx
  mov    %edi,%r11d
  mov    0x18(%rsp),%rdi
  movsd  (%rsi),%xmm0
  movsd  %xmm0,(%rcx)
  mov    (%rdx),%eax
  mov    %eax,(%r8)
  addl   $0x1,(%rdi)
  movslq (%rdx),%rax
  movl   $0x0,(%r9,%rax,4)
  cmp    $0x1,%r11d
  jle    L10
  mov    %rdx,%r10
  mov    %rcx,%rbx
  mov    %r11d,%r11d
  mov    $0x1,%edx
  mov    $0x0,%eax
  jmp    L52
L2:
  add    $0x1,%eax
  movslq %eax,%rcx
  movsd  %xmm0,(%rbx,%rcx,8)
  mov    (%r10,%rdx,4),%r14d
  mov    %r14d,(%r8,%rcx,4)
L53:
  movslq %eax,%rcx
  addl   $0x1,(%rdi,%rcx,4)
  movslq (%r10,%rdx,4),%rcx
  mov    %eax,(%r9,%rcx,4)
  add    $0x1,%rdx
  cmp    %r11,%rdx
  je     L48
L52:
  movsd  (%rsi,%rdx,8),%xmm0
  ucomisd -0x8(%rsi,%rdx,8),%xmm0
  jp     L2
  je     L53
  jmp    L2
L10:
  mov    $0x0,%eax
L48:
  add    $0x1,%eax
  pop    %rbx
  pop    %r14
  ret
```

assistant: ```c
int CountSortedDouble(int M, double *sorted, int *sort_idx, double *uni_list, int *uni_i, int *uni_j, int *cnt) {
  int u, m;
  uni_list[0] = sorted[0];
  uni_i[0] = sort_idx[0];
  cnt[0]++;
  uni_j[sort_idx[0]] = 0;
  u = 0;
  for (m = 1; m < M; m++) {
    if (sorted[m] != sorted[m - 1]) {
      u++;
      uni_list[u] = sorted[m];
      uni_i[u] = sort_idx[m];
    }
    cnt[u]++;
    uni_j[sort_idx[m]] = u;
  }
  u++;
  return u;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<CountSortedDouble>:
  endbr64
  push   %r14
  movsd  (%rsi),%xmm0
  push   %rbp
  push   %rbx
  movslq %edi,%rbx
  mov    (%rdx),%eax
  mov    0x20(%rsp),%rdi
  movsd  %xmm0,(%rcx)
  mov    %eax,(%r8)
  addl   $0x1,(%rdi)
  movslq (%rdx),%rax
  movl   $0x0,(%r9,%rax,4)
  cmp    $0x1,%ebx
  jle    L10
  mov    %rdx,%r10
  mov    %rcx,%rbp
  mov    $0x1,%edx
  xor    %eax,%eax
  jmp    L14
  nop
L48:
  movslq %eax,%rcx
  shl    $0x2,%rcx
L57:
  addl   $0x1,(%rdi,%rcx,1)
  movslq (%r10,%rdx,4),%rcx
  add    $0x1,%rdx
  mov    %eax,(%r9,%rcx,4)
  cmp    %rdx,%rbx
  je     L0
L14:
  movsd  (%rsi,%rdx,8),%xmm0
  ucomisd -0x8(%rsi,%rdx,8),%xmm0
  jp     L32
  je     L48
L32:
  mov    (%r10,%rdx,4),%r14d
  add    $0x1,%eax
  movslq %eax,%r11
  movsd  %xmm0,0x0(%rbp,%r11,8)
  lea    0x0(,%r11,4),%rcx
  mov    %r14d,(%r8,%r11,4)
  jmp    L57
  nopw   0x0(%rax,%rax,1)
L0:
  pop    %rbx
  add    $0x1,%eax
  pop    %rbp
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L10:
  pop    %rbx
  mov    $0x1,%eax
  pop    %rbp
  pop    %r14
  ret
```

assistant: ```c
int CountSortedDouble(int M, double *sorted, int *sort_idx, double *uni_list, int *uni_i, int *uni_j, int *cnt) {
  int u, m;
  uni_list[0] = sorted[0];
  uni_i[0] = sort_idx[0];
  cnt[0]++;
  uni_j[sort_idx[0]] = 0;
  u = 0;
  for (m = 1; m < M; m++) {
    if (sorted[m] != sorted[m - 1]) {
      u++;
      uni_list[u] = sorted[m];
      uni_i[u] = sort_idx[m];
    }
    cnt[u]++;
    uni_j[sort_idx[m]] = u;
  }
  u++;
  return u;
}
```