ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请从给定的汇编指令推导出C源代码:

```asm
<printUsaging>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D16(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D36(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  nop
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D5
data_type: string
name: read_data
arguments: data_label: D3
data_type: string
name: read_data
arguments: data_label: D16
data_type: string
name: read_data
arguments: data_label: D36
data_type: string
name: read_data
arguments: data_label: D21
data_type: string

tool: D5: usaging: %s <mode> [dest mac] [loop] [pkt size]


tool: D3:     <mode>:  t: only TX; r: only RX; t8: TX and RX; r8: RX and TX.

tool: D16: [dest mac]:  dest board mac address, format: xx:xx:xx:xx:xx:xx. only valid in Tx mode.

tool: D36:     [loop]:  Tx packet count, only valid in t and t8 mode.

tool: D21: [pkt size]:  Tx packet size(byte), only valid in t and t8 mode.

assistant: ```c
void printUsaging(char *argv) {
  printf("usaging: %s <mode> [dest mac] [loop] [pkt size]\n", argv);
  printf("    <mode>:  t: only TX; r: only RX; t8: TX and RX; r8: RX and TX.\n");
  printf("[dest mac]:  dest board mac address, format: xx:xx:xx:xx:xx:xx. only valid in Tx mode.\n");
  printf("    [loop]:  Tx packet count, only valid in t and t8 mode.\n");
  printf("[pkt size]:  Tx packet size(byte), only valid in t and t8 mode.\n");
}
```
user: What is the c source code of the assembly code below?

```asm
<printUsaging>:
  endbr64
  sub    $0x8,%rsp
  mov    %rdi,%rsi
  lea    D21(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D20(%rip),%rdi
  call   <puts@plt>
  lea    D7(%rip),%rdi
  call   <puts@plt>
  lea    D30(%rip),%rdi
  call   <puts@plt>
  lea    D31(%rip),%rdi
  call   <puts@plt>
  add    $0x8,%rsp
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D21
type: string
name: retrieve_data
arguments: data_tag: D20
type: string
name: retrieve_data
arguments: data_tag: D7
type: string
name: retrieve_data
arguments: data_tag: D30
type: string
name: retrieve_data
arguments: data_tag: D31
type: string

tool: D21: usaging: %s <mode> [dest mac] [loop] [pkt size]


tool: D20:     <mode>:  t: only TX; r: only RX; t8: TX and RX; r8: RX and TX.

tool: D7: [dest mac]:  dest board mac address, format: xx:xx:xx:xx:xx:xx. only valid in Tx mode.

tool: D30:     [loop]:  Tx packet count, only valid in t and t8 mode.

tool: D31: [pkt size]:  Tx packet size(byte), only valid in t and t8 mode.

assistant: ```c
void printUsaging(char *argv) {
  printf("usaging: %s <mode> [dest mac] [loop] [pkt size]\n", argv);
  printf("    <mode>:  t: only TX; r: only RX; t8: TX and RX; r8: RX and TX.\n");
  printf("[dest mac]:  dest board mac address, format: xx:xx:xx:xx:xx:xx. only valid in Tx mode.\n");
  printf("    [loop]:  Tx packet count, only valid in t and t8 mode.\n");
  printf("[pkt size]:  Tx packet size(byte), only valid in t and t8 mode.\n");
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<printUsaging>:
  endbr64
  sub    $0x8,%rsp
  mov    %rdi,%rsi
  lea    D14(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D5(%rip),%rdi
  call   <puts@plt>
  lea    D20(%rip),%rdi
  call   <puts@plt>
  lea    D11(%rip),%rdi
  call   <puts@plt>
  lea    D18(%rip),%rdi
  add    $0x8,%rsp
  jmp    1060 <puts@plt>
```

tool_calls: name: parse_data
arguments: label: D14
datatype: string
name: parse_data
arguments: label: D5
datatype: string
name: parse_data
arguments: label: D20
datatype: string
name: parse_data
arguments: label: D11
datatype: string
name: parse_data
arguments: label: D18
datatype: string

tool: D14: usaging: %s <mode> [dest mac] [loop] [pkt size]


tool: D5:     <mode>:  t: only TX; r: only RX; t8: TX and RX; r8: RX and TX.

tool: D20: [dest mac]:  dest board mac address, format: xx:xx:xx:xx:xx:xx. only valid in Tx mode.

tool: D11:     [loop]:  Tx packet count, only valid in t and t8 mode.

tool: D18: [pkt size]:  Tx packet size(byte), only valid in t and t8 mode.

assistant: ```c
void printUsaging(char *argv) {
  printf("usaging: %s <mode> [dest mac] [loop] [pkt size]\n", argv);
  printf("    <mode>:  t: only TX; r: only RX; t8: TX and RX; r8: RX and TX.\n");
  printf("[dest mac]:  dest board mac address, format: xx:xx:xx:xx:xx:xx. only valid in Tx mode.\n");
  printf("    [loop]:  Tx packet count, only valid in t and t8 mode.\n");
  printf("[pkt size]:  Tx packet size(byte), only valid in t and t8 mode.\n");
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<printUsaging>:
  endbr64
  sub    $0x8,%rsp
  mov    %rdi,%rsi
  lea    D11(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D24(%rip),%rdi
  call   <puts@plt>
  lea    D47(%rip),%rdi
  call   <puts@plt>
  lea    D30(%rip),%rdi
  call   <puts@plt>
  lea    D34(%rip),%rdi
  add    $0x8,%rsp
  jmp    1060 <puts@plt>
```

tool_calls: name: read_data
arguments: tag: D11
type_infered: string
name: read_data
arguments: tag: D24
type_infered: string
name: read_data
arguments: tag: D47
type_infered: string
name: read_data
arguments: tag: D30
type_infered: string
name: read_data
arguments: tag: D34
type_infered: string

tool: D11: usaging: %s <mode> [dest mac] [loop] [pkt size]


tool: D24:     <mode>:  t: only TX; r: only RX; t8: TX and RX; r8: RX and TX.

tool: D47: [dest mac]:  dest board mac address, format: xx:xx:xx:xx:xx:xx. only valid in Tx mode.

tool: D30:     [loop]:  Tx packet count, only valid in t and t8 mode.

tool: D34: [pkt size]:  Tx packet size(byte), only valid in t and t8 mode.

assistant: ```c
void printUsaging(char *argv) {
  printf("usaging: %s <mode> [dest mac] [loop] [pkt size]\n", argv);
  printf("    <mode>:  t: only TX; r: only RX; t8: TX and RX; r8: RX and TX.\n");
  printf("[dest mac]:  dest board mac address, format: xx:xx:xx:xx:xx:xx. only valid in Tx mode.\n");
  printf("    [loop]:  Tx packet count, only valid in t and t8 mode.\n");
  printf("[pkt size]:  Tx packet size(byte), only valid in t and t8 mode.\n");
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<countingSortMain>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    %rcx,-0x28(%rbp)
  mov    %r8,-0x30(%rbp)
  movl   $0x0,-0x4(%rbp)
  mov    -0x20(%rbp),%eax
  add    $0x1,%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x1c(%rbp),%eax
  add    $0x1,%eax
  mov    $0x4,%esi
  mov    %eax,%edi
  call   <calloc@plt>
  mov    %rax,-0x30(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L33
L18:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  add    $0x1,%edx
  mov    %edx,(%rax)
  addl   $0x1,-0xc(%rbp)
L33:
  mov    -0xc(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jl     L18
  movl   $0x0,-0xc(%rbp)
  jmp    L37
L46:
  movl   $0x0,-0x8(%rbp)
  jmp    L5
L54:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x4(%rbp)
  addl   $0x1,-0x8(%rbp)
L5:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  jl     L54
  addl   $0x1,-0xc(%rbp)
L37:
  mov    -0xc(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jle    L46
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  leave
  ret
```

assistant: ```c
void countingSortMain(int *numbers, int k, int size, int *B, int *C) {
  int i, j, indexB = 0;
  B = (int *)malloc(sizeof(int) * (size + 1));
  C = (int *)calloc((k + 1), sizeof(int));
  for (i = 0; i < size; i++) {
    C[numbers[i]] = C[numbers[i]] + 1;
  }
  for (i = 0; i <= k; ++i) {
    for (j = 0; j < C[i]; ++j) {
      B[indexB] = i;
      indexB++;
    }
  }
  free(B);
  free(C);
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<countingSortMain>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r14
  mov    %esi,%r12d
  mov    %edx,%r13d
  lea    0x4(,%rdx,4),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  lea    0x1(%r12),%edi
  mov    $0x4,%esi
  call   <calloc@plt>
  mov    %rax,%rbx
  test   %r13d,%r13d
  jle    L9
  mov    %r14,%rax
  lea    -0x1(%r13),%edx
  lea    0x4(%r14,%rdx,4),%rcx
L62:
  movslq (%rax),%rdx
  addl   $0x1,(%rbx,%rdx,4)
  add    $0x4,%rax
  cmp    %rcx,%rax
  jne    L62
L9:
  test   %r12d,%r12d
  js     L59
  mov    %rbx,%r9
  lea    0x1(%r12),%r10d
  mov    $0x0,%ecx
  mov    $0x0,%esi
  jmp    L2
L20:
  movslq %ecx,%rax
  lea    0x0(%rbp,%rax,4),%rdx
  mov    $0x0,%eax
  lea    0x1(%rcx),%r8d
L73:
  mov    %esi,(%rdx)
  lea    (%r8,%rax,1),%ecx
  add    $0x1,%eax
  add    $0x4,%rdx
  cmp    %eax,(%rdi)
  jg     L73
L78:
  add    $0x1,%esi
  add    $0x4,%r9
  cmp    %r10d,%esi
  je     L59
L2:
  mov    %r9,%rdi
  cmpl   $0x0,(%r9)
  jg     L20
  jmp    L78
L59:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %rbx,%rdi
  call   <free@plt>
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
void countingSortMain(int *numbers, int k, int size, int *B, int *C) {
  int i, j, indexB = 0;
  B = (int *)malloc(sizeof(int) * (size + 1));
  C = (int *)calloc((k + 1), sizeof(int));
  for (i = 0; i < size; i++) {
    C[numbers[i]] = C[numbers[i]] + 1;
  }
  for (i = 0; i <= k; ++i) {
    for (j = 0; j < C[i]; ++j) {
      B[indexB] = i;
      indexB++;
    }
  }
  free(B);
  free(C);
}
```
user: Translate the below assembly code into C programming language:

```asm
<countingSortMain>:
  endbr64
  push   %r14
  mov    %edx,%r14d
  push   %r13
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %rdi,%rbx
  lea    0x4(,%rdx,4),%edi
  call   <malloc@plt>
  lea    0x1(%rbp),%edi
  mov    $0x4,%esi
  mov    %rax,%r12
  call   <calloc@plt>
  mov    %rax,%r13
  test   %r14d,%r14d
  jle    L30
  lea    -0x1(%r14),%edx
  mov    %rbx,%rax
  lea    0x4(%rbx,%rdx,4),%rcx
  nopl   0x0(%rax)
L66:
  movslq (%rax),%rdx
  add    $0x4,%rax
  addl   $0x1,0x0(%r13,%rdx,4)
  cmp    %rcx,%rax
  jne    L66
L30:
  test   %ebp,%ebp
  js     L11
  mov    %r13,%rsi
  xor    %ecx,%ecx
  xor    %edi,%edi
  nopl   (%rax)
L20:
  mov    (%rsi),%eax
  test   %eax,%eax
  jle    L4
  movslq %ecx,%rax
  lea    0x1(%rcx),%r8d
  lea    (%r12,%rax,4),%rdx
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L65:
  mov    %edi,(%rdx)
  lea    (%r8,%rax,1),%ecx
  add    $0x4,%rdx
  add    $0x1,%eax
  cmp    %eax,(%rsi)
  jg     L65
L4:
  lea    0x1(%rdi),%eax
  add    $0x4,%rsi
  cmp    %edi,%ebp
  je     L11
  mov    %eax,%edi
  jmp    L20
L11:
  mov    %r12,%rdi
  call   <free@plt>
  pop    %rbx
  mov    %r13,%rdi
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1070 <free@plt>
```

assistant: ```c
void countingSortMain(int *numbers, int k, int size, int *B, int *C) {
  int i, j, indexB = 0;
  B = (int *)malloc(sizeof(int) * (size + 1));
  C = (int *)calloc((k + 1), sizeof(int));
  for (i = 0; i < size; i++) {
    C[numbers[i]] = C[numbers[i]] + 1;
  }
  for (i = 0; i <= k; ++i) {
    for (j = 0; j < C[i]; ++j) {
      B[indexB] = i;
      indexB++;
    }
  }
  free(B);
  free(C);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<countingSortMain>:
  endbr64
  push   %r14
  mov    %edx,%r14d
  push   %r13
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %rdi,%rbx
  lea    0x4(,%rdx,4),%edi
  call   <malloc@plt>
  lea    0x1(%rbp),%edi
  mov    $0x4,%esi
  mov    %rax,%r12
  call   <calloc@plt>
  mov    %rax,%r13
  test   %r14d,%r14d
  jle    L38
  lea    -0x1(%r14),%edx
  mov    %rbx,%rax
  lea    0x4(%rbx,%rdx,4),%rcx
  nopl   0x0(%rax)
L36:
  movslq (%rax),%rdx
  add    $0x4,%rax
  addl   $0x1,0x0(%r13,%rdx,4)
  cmp    %rax,%rcx
  jne    L36
L38:
  test   %ebp,%ebp
  js     L50
  mov    %r13,%rsi
  xor    %ecx,%ecx
  xor    %edi,%edi
  nopl   (%rax)
L63:
  mov    (%rsi),%eax
  test   %eax,%eax
  jle    L48
  movslq %ecx,%rax
  lea    0x1(%rcx),%r8d
  lea    (%r12,%rax,4),%rdx
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L44:
  mov    %edi,(%rdx)
  lea    (%r8,%rax,1),%ecx
  add    $0x4,%rdx
  add    $0x1,%eax
  cmp    %eax,(%rsi)
  jg     L44
L48:
  lea    0x1(%rdi),%eax
  add    $0x4,%rsi
  cmp    %edi,%ebp
  je     L50
  mov    %eax,%edi
  jmp    L63
L50:
  mov    %r12,%rdi
  call   <free@plt>
  pop    %rbx
  mov    %r13,%rdi
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1070 <free@plt>
```

assistant: ```c
void countingSortMain(int *numbers, int k, int size, int *B, int *C) {
  int i, j, indexB = 0;
  B = (int *)malloc(sizeof(int) * (size + 1));
  C = (int *)calloc((k + 1), sizeof(int));
  for (i = 0; i < size; i++) {
    C[numbers[i]] = C[numbers[i]] + 1;
  }
  for (i = 0; i <= k; ++i) {
    for (j = 0; j < C[i]; ++j) {
      B[indexB] = i;
      indexB++;
    }
  }
  free(B);
  free(C);
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<file_writer_write>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
L8:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <file_writer_wavail@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  cmp    %rax,%rdx
  cmovbe %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <file_writer_wloc@plt>
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  mov    %ecx,%edi
  call   <memcpy@plt>
  mov    -0x8(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <file_writer_wseek@plt>
  mov    -0x8(%rbp),%rax
  sub    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  je     L5
  mov    -0x8(%rbp),%rax
  add    %rax,-0x20(%rbp)
  jmp    L8
L5:
  nop
  mov    $0x0,%eax
  leave
  ret
```

assistant: ```c
int file_writer_write(struct file_writer *fw, const void *buf, size_t size) {
  for (;;) {
    size_t wav = file_writer_wavail(fw);
    size_t n = wav >= size ? size : wav;
    memcpy(file_writer_wloc(fw), buf, n);
    file_writer_wseek(fw, n);
    size -= n;
    if (0 == size)
      break;
    buf += n;
  }
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<file_writer_write>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r12
  mov    %rsi,%r13
  mov    %rdx,%rbp
  jmp    L0
L17:
  add    %rbx,%r13
L0:
  mov    %r12,%rdi
  call   <file_writer_wavail@plt>
  cmp    %rax,%rbp
  cmovbe %rbp,%rax
  mov    %rax,%rbx
  mov    %r12,%rdi
  call   <file_writer_wloc@plt>
  mov    %eax,%edi
  mov    %rbx,%rdx
  mov    %r13,%rsi
  call   <memcpy@plt>
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <file_writer_wseek@plt>
  sub    %rbx,%rbp
  jne    L17
  mov    $0x0,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int file_writer_write(struct file_writer *fw, const void *buf, size_t size) {
  for (;;) {
    size_t wav = file_writer_wavail(fw);
    size_t n = wav >= size ? size : wav;
    memcpy(file_writer_wloc(fw), buf, n);
    file_writer_wseek(fw, n);
    size -= n;
    if (0 == size)
      break;
    buf += n;
  }
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<file_writer_write>:
  endbr64
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x8,%rsp
  jmp    L10
  nopl   0x0(%rax)
L16:
  add    %rbx,%r13
L10:
  mov    %r12,%rdi
  call   <file_writer_wavail@plt>
  mov    %r12,%rdi
  cmp    %rax,%rbp
  cmovbe %rbp,%rax
  mov    %rax,%rbx
  call   <file_writer_wloc@plt>
  mov    %r13,%rsi
  mov    %rbx,%rdx
  mov    %eax,%edi
  call   <memcpy@plt>
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <file_writer_wseek@plt>
  sub    %rbx,%rbp
  jne    L16
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int file_writer_write(struct file_writer *fw, const void *buf, size_t size) {
  for (;;) {
    size_t wav = file_writer_wavail(fw);
    size_t n = wav >= size ? size : wav;
    memcpy(file_writer_wloc(fw), buf, n);
    file_writer_wseek(fw, n);
    size -= n;
    if (0 == size)
      break;
    buf += n;
  }
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<file_writer_write>:
  endbr64
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x8,%rsp
  jmp    L16
  nopl   0x0(%rax)
L11:
  add    %rbx,%r13
L16:
  mov    %r12,%rdi
  call   <file_writer_wavail@plt>
  mov    %r12,%rdi
  cmp    %rax,%rbp
  cmovbe %rbp,%rax
  mov    %rax,%rbx
  call   <file_writer_wloc@plt>
  mov    %r13,%rsi
  mov    %rbx,%rdx
  mov    %eax,%edi
  call   <memcpy@plt>
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <file_writer_wseek@plt>
  sub    %rbx,%rbp
  jne    L11
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int file_writer_write(struct file_writer *fw, const void *buf, size_t size) {
  for (;;) {
    size_t wav = file_writer_wavail(fw);
    size_t n = wav >= size ? size : wav;
    memcpy(file_writer_wloc(fw), buf, n);
    file_writer_wseek(fw, n);
    size -= n;
    if (0 == size)
      break;
    buf += n;
  }
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<NextState>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x18(%rbp)
  mov    %ecx,-0x24(%rbp)
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L27
  mov    -0x18(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    %eax,-0x24(%rbp)
  jne    L27
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  jmp    L39
L27:
  mov    -0x18(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x4(%rbp)
  movl   $0x0,-0x8(%rbp)
  jmp    L66
L68:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    %eax,-0x24(%rbp)
  jne    L113
  movl   $0x0,-0x8(%rbp)
  jmp    L4
L29:
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x18(%rbp),%eax
  sub    -0xc(%rbp),%eax
  lea    0x1(%rax),%ecx
  mov    -0x8(%rbp),%eax
  add    %ecx,%eax
  movslq %eax,%rcx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L94
  addl   $0x1,-0x8(%rbp)
L4:
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jl     L29
  jmp    L8
L94:
  nop
L8:
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jne    L113
  mov    -0xc(%rbp),%eax
  jmp    L39
L113:
  subl   $0x1,-0xc(%rbp)
L66:
  cmpl   $0x0,-0xc(%rbp)
  jg     L68
  mov    $0x0,%eax
L39:
  pop    %rbp
  ret
```

assistant: ```c
int NextState(int m, char *pattern, int state, int symbol) {
  if (state < m && pattern[state] == symbol) {
    return state + 1;
  }
  for (int next = state, prev = next - 1, i = 0; next > 0; next--) {
    if (pattern[prev] == symbol) {
      for (i = 0; i < prev; i++) {
        if (pattern[i] != pattern[state - next + 1 + i]) {
          break;
        }
      }
      if (i == prev) {
        return next;
      }
    }
  }
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<NextState>:
  endbr64
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  mov    %ecx,%r10d
  cmp    %edi,%edx
  jge    L12
  movslq %edx,%rax
  movsbl (%rsi,%rax,1),%eax
  lea    0x1(%rdx),%esi
  cmp    %ecx,%eax
  je     L27
L12:
  lea    -0x1(%rdx),%ebp
  test   %edx,%edx
  jle    L104
  movslq %ebp,%rax
  movsbl (%rbx,%rax,1),%r11d
  movslq %edx,%r9
  mov    %r9,%rcx
  neg    %rcx
  mov    %edx,%esi
  mov    %ebp,%r8d
  jmp    L81
L66:
  mov    $0x0,%edx
L54:
  cmp    %edx,%ebp
  je     L27
L33:
  add    $0x1,%rcx
  sub    $0x1,%esi
  je     L27
L81:
  cmp    %r10d,%r11d
  jne    L33
  test   %ebp,%ebp
  jle    L66
  mov    %rbx,%rax
  mov    $0x0,%edx
L51:
  lea    (%rax,%r9,1),%rdi
  movzbl 0x1(%rcx,%rdi,1),%edi
  cmp    %dil,(%rax)
  jne    L54
  add    $0x1,%edx
  add    $0x1,%rax
  cmp    %r8d,%edx
  jne    L51
  mov    %r8d,%edx
  jmp    L54
L104:
  mov    $0x0,%esi
L27:
  mov    %esi,%eax
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
int NextState(int m, char *pattern, int state, int symbol) {
  if (state < m && pattern[state] == symbol) {
    return state + 1;
  }
  for (int next = state, prev = next - 1, i = 0; next > 0; next--) {
    if (pattern[prev] == symbol) {
      for (i = 0; i < prev; i++) {
        if (pattern[i] != pattern[state - next + 1 + i]) {
          break;
        }
      }
      if (i == prev) {
        return next;
      }
    }
  }
  return 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<NextState>:
  endbr64
  mov    %edx,%r8d
  cmp    %edi,%edx
  jge    L78
  movslq %edx,%rax
  movsbl (%rsi,%rax,1),%eax
  cmp    %ecx,%eax
  je     L112
L78:
  lea    -0x1(%r8),%r11d
  test   %r8d,%r8d
  jle    L96
  movslq %r11d,%rax
  lea    -0x2(%r8),%edi
  mov    %rsi,%rdx
  movsbl (%rsi,%rax,1),%r10d
  add    $0x2,%rdi
  jmp    L4
  nopl   0x0(%rax)
L123:
  add    $0x1,%rdx
  sub    $0x1,%r8d
  je     L43
L4:
  cmp    %ecx,%r10d
  jne    L123
  test   %r11d,%r11d
  jle    L103
  mov    $0x1,%eax
  nopl   0x0(%rax)
L124:
  movzbl (%rdx,%rax,1),%r9d
  cmp    %r9b,-0x1(%rsi,%rax,1)
  jne    L123
  mov    %eax,%r9d
  add    $0x1,%rax
  cmp    %rdi,%rax
  jne    L124
  cmp    %r9d,%r11d
  jne    L123
L43:
  mov    %r8d,%eax
  ret
L112:
  add    $0x1,%r8d
  mov    %r8d,%eax
  ret
L103:
  xor    %r9d,%r9d
  cmp    %r9d,%r11d
  jne    L123
  jmp    L43
L96:
  xor    %r8d,%r8d
  jmp    L43
```

assistant: ```c
int NextState(int m, char *pattern, int state, int symbol) {
  if (state < m && pattern[state] == symbol) {
    return state + 1;
  }
  for (int next = state, prev = next - 1, i = 0; next > 0; next--) {
    if (pattern[prev] == symbol) {
      for (i = 0; i < prev; i++) {
        if (pattern[i] != pattern[state - next + 1 + i]) {
          break;
        }
      }
      if (i == prev) {
        return next;
      }
    }
  }
  return 0;
}
```