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

```asm
<decode_short_entry>:
  endbr64
  push   %r12
  movzbl 0x1(%rdi),%eax
  mov    %rsi,%r10
  mov    %rcx,%r12
  mov    %rdx,%r11
  mov    %eax,(%r9)
  movzbl 0x2(%rdi),%esi
  movzbl 0x3(%rdi),%eax
  movzbl 0x5(%rdi),%ecx
  shl    $0x8,%esi
  movzbl 0x4(%rdi),%edx
  add    %eax,%esi
  mov    %ecx,%eax
  and    $0x3f,%ecx
  shr    $0x6,%al
  movslq %esi,%rsi
  movzbl %al,%eax
  lea    (%rax,%rdx,4),%r9d
  movzbl 0x6(%rdi),%eax
  mov    %eax,%edx
  shl    $0x8,%eax
  shr    $0x4,%dl
  and    $0x300,%eax
  movzbl %dl,%edx
  shl    $0x6,%edx
  or     %ecx,%edx
  movzbl 0x7(%rdi),%ecx
  add    %ecx,%eax
  mov    $0x1ff,%ecx
  mov    %ecx,%edi
  sub    %r9d,%edi
  cmp    $0x1ff,%r9d
  cmovg  %edi,%r9d
  mov    %ecx,%edi
  sub    %edx,%edi
  cmp    $0x1ff,%edx
  cmovg  %edi,%edx
  sub    %eax,%ecx
  cmp    $0x1ff,%eax
  cmovg  %ecx,%eax
  add    %rsi,(%r10)
  add    %r9d,(%r11)
  add    %edx,(%r12)
  pop    %r12
  add    %eax,(%r8)
  ret
```

assistant: ```c
void decode_short_entry(const unsigned char *d, long *time, int *ecef_x, int *ecef_y, int *ecef_z, int *speed) {
  int dt, dx, dy, dz;
  *speed = d[1];
  dt = (d[2] << 8) + d[3];
  dx = (d[4] << 2) + ((d[5] >> 6) & 0x3);
  dy = (d[5] & 0x3f) | (((d[6] >> 4) & 0xf) << 6);
  dz = ((d[6] & 3) << 8) + d[7];
  if (dx >= 512) {
    dx = 511 - dx;
  }
  if (dy >= 512) {
    dy = 511 - dy;
  }
  if (dz >= 512) {
    dz = 511 - dz;
  }
  *time = *time + dt;
  *ecef_x = *ecef_x + dx;
  *ecef_y = *ecef_y + dy;
  *ecef_z = *ecef_z + dz;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xc0,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x70(%rbp),%rax
  lea    D18(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    -0xb4(%rbp),%rdi
  lea    -0xb8(%rbp),%rsi
  lea    -0x90(%rbp),%rcx
  lea    -0xb0(%rbp),%rdx
  lea    -0x70(%rbp),%rax
  mov    %rdi,%r9
  mov    %rsi,%r8
  lea    D4(%rip),%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  mov    -0xb4(%rbp),%ecx
  mov    -0xb8(%rbp),%edx
  lea    -0xb0(%rbp),%rsi
  lea    -0x90(%rbp),%rax
  mov    %rsi,%r8
  mov    %rax,%rsi
  lea    D17(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L1
  call   <__stack_chk_fail@plt>
L1:
  leave
  ret
```

tool_calls: name: parse_data
arguments: label: D18
datatype: string
name: parse_data
arguments: label: D4
datatype: string
name: parse_data
arguments: label: D17
datatype: string

tool: D18: Saturday March 25 1989

tool: D4: %s %s %d  %d

tool: D17: %s %d, %d = %s


assistant: ```c
int main() {
  int day, year;
  char weekday[20], month[20], dtm[100];
  strcpy(dtm, "Saturday March 25 1989");
  sscanf(dtm, "%s %s %d  %d", weekday, month, &day, &year);
  printf("%s %d, %d = %s\n", month, day, year, weekday);
  return (0);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xc0,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xb8(%rsp)
  xor    %eax,%eax
  lea    0x50(%rsp),%r12
  lea    D14(%rip),%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  lea    0x30(%rsp),%rbx
  lea    0x10(%rsp),%rbp
  lea    0xc(%rsp),%r9
  lea    0x8(%rsp),%r8
  mov    %rbx,%rcx
  mov    %rbp,%rdx
  lea    D7(%rip),%rsi
  mov    %r12,%rdi
  call   <sscanf@plt>
  mov    %rbp,%r8
  mov    0xc(%rsp),%ecx
  mov    0x8(%rsp),%edx
  mov    %rbx,%rsi
  lea    D19(%rip),%rdi
  call   <printf@plt>
  mov    0xb8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L8
  mov    $0x0,%eax
  add    $0xc0,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L8:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D14
data_type: string
name: read_data
arguments: label: D7
data_type: string
name: read_data
arguments: label: D19
data_type: string

tool: D14: Saturday March 25 1989

tool: D7: %s %s %d  %d

tool: D19: %s %d, %d = %s


assistant: ```c
int main() {
  int day, year;
  char weekday[20], month[20], dtm[100];
  strcpy(dtm, "Saturday March 25 1989");
  sscanf(dtm, "%s %s %d  %d", weekday, month, &day, &year);
  printf("%s %d, %d = %s\n", month, day, year, weekday);
  return (0);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<main>:
  endbr64
  push   %r12
  lea    D8(%rip),%rsi
  push   %rbp
  push   %rbx
  sub    $0xc0,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xb8(%rsp)
  xor    %eax,%eax
  lea    0x50(%rsp),%r12
  lea    0x30(%rsp),%rbp
  mov    %r12,%rdi
  lea    0x10(%rsp),%rbx
  call   <strcpy@plt>
  lea    0x8(%rsp),%r8
  mov    %rbp,%rcx
  mov    %rbx,%rdx
  lea    D10(%rip),%rsi
  mov    %r12,%rdi
  lea    0xc(%rsp),%r9
  call   <sscanf@plt>
  mov    0xc(%rsp),%ecx
  mov    0x8(%rsp),%edx
  mov    %rbx,%r8
  mov    %rbp,%rsi
  lea    D12(%rip),%rdi
  call   <printf@plt>
  mov    0xb8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L1
  add    $0xc0,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L1:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D8
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D10
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D12
type_infered: string

tool: D8: Saturday March 25 1989

tool: D10: %s %s %d  %d

tool: D12: %s %d, %d = %s


assistant: ```c
int main() {
  int day, year;
  char weekday[20], month[20], dtm[100];
  strcpy(dtm, "Saturday March 25 1989");
  sscanf(dtm, "%s %s %d  %d", weekday, month, &day, &year);
  printf("%s %d, %d = %s\n", month, day, year, weekday);
  return (0);
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<main>:
  endbr64
  push   %r12
  lea    D13(%rip),%rsi
  push   %rbp
  push   %rbx
  sub    $0xc0,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xb8(%rsp)
  xor    %eax,%eax
  lea    0x50(%rsp),%r12
  lea    0x30(%rsp),%rbp
  mov    %r12,%rdi
  lea    0x10(%rsp),%rbx
  call   <strcpy@plt>
  lea    0x8(%rsp),%r8
  mov    %rbp,%rcx
  mov    %rbx,%rdx
  lea    D12(%rip),%rsi
  mov    %r12,%rdi
  lea    0xc(%rsp),%r9
  call   <sscanf@plt>
  mov    0xc(%rsp),%ecx
  mov    0x8(%rsp),%edx
  mov    %rbx,%r8
  mov    %rbp,%rsi
  lea    D28(%rip),%rdi
  call   <printf@plt>
  mov    0xb8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  add    $0xc0,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L4:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D13
datatype: string
name: read_data
arguments: data_tag: D12
datatype: string
name: read_data
arguments: data_tag: D28
datatype: string

tool: D13: Saturday March 25 1989

tool: D12: %s %s %d  %d

tool: D28: %s %d, %d = %s


assistant: ```c
int main() {
  int day, year;
  char weekday[20], month[20], dtm[100];
  strcpy(dtm, "Saturday March 25 1989");
  sscanf(dtm, "%s %s %d  %d", weekday, month, &day, &year);
  printf("%s %d, %d = %s\n", month, day, year, weekday);
  return (0);
}
```
user: What is the c source code of the assembly code below?

```asm
<eh_fmt_unsigned>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,%ebx
  mov    $0xa,%esi
  mov    %ebx,%edi
  call   <eh_fmt_unsigned_len@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x28(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x20(%rbp)
  jmp    L13
L14:
  mov    %ebx,%edx
  mov    $0xcccccccd,%eax
  imul   %rdx,%rax
  shr    $0x20,%rax
  mov    %eax,%edx
  shr    $0x3,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  mov    %ebx,%edx
  sub    %eax,%edx
  mov    %edx,%eax
  add    $0x30,%eax
  subq   $0x1,-0x20(%rbp)
  mov    %eax,%edx
  mov    -0x20(%rbp),%rax
  mov    %dl,(%rax)
  mov    %ebx,%edx
  mov    $0xcccccccd,%eax
  imul   %rdx,%rax
  shr    $0x20,%rax
  shr    $0x3,%eax
  mov    %eax,%ebx
L13:
  mov    -0x20(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  ja     L14
  mov    -0x18(%rbp),%rax
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
size_t eh_fmt_unsigned(char *buf, register unsigned n) {
  size_t l = eh_fmt_unsigned_len(n, 10);
  char *p = buf + l;
  for (; p > buf; n /= 10)
    *--p = n % 10 + '0';
  return l;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<eh_fmt_unsigned>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  mov    %esi,%ebx
  mov    $0xa,%esi
  mov    %ebx,%edi
  call   <eh_fmt_unsigned_len@plt>
  lea    0x0(%rbp,%rax,1),%rcx
  cmp    %rcx,%rbp
  jae    L2
  mov    $0xcccccccd,%edi
L6:
  sub    $0x1,%rcx
  mov    %ebx,%edx
  imul   %rdi,%rdx
  shr    $0x23,%rdx
  lea    (%rdx,%rdx,4),%esi
  add    %esi,%esi
  sub    %esi,%ebx
  add    $0x30,%ebx
  mov    %bl,(%rcx)
  mov    %edx,%ebx
  cmp    %rcx,%rbp
  jne    L6
L2:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
size_t eh_fmt_unsigned(char *buf, register unsigned n) {
  size_t l = eh_fmt_unsigned_len(n, 10);
  char *p = buf + l;
  for (; p > buf; n /= 10)
    *--p = n % 10 + '0';
  return l;
}
```
user: What is the c source code of the assembly code below?

```asm
<eh_fmt_unsigned>:
  endbr64
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %esi,%ebx
  mov    $0xa,%esi
  mov    %ebx,%edi
  sub    $0x8,%rsp
  call   <eh_fmt_unsigned_len@plt>
  lea    0x0(%rbp,%rax,1),%rcx
  cmp    %rcx,%rbp
  jae    L7
  mov    $0xcccccccd,%edi
  nopw   0x0(%rax,%rax,1)
L9:
  mov    %ebx,%edx
  sub    $0x1,%rcx
  imul   %rdi,%rdx
  shr    $0x23,%rdx
  lea    (%rdx,%rdx,4),%esi
  add    %esi,%esi
  sub    %esi,%ebx
  add    $0x30,%ebx
  mov    %bl,(%rcx)
  mov    %edx,%ebx
  cmp    %rcx,%rbp
  jne    L9
L7:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
size_t eh_fmt_unsigned(char *buf, register unsigned n) {
  size_t l = eh_fmt_unsigned_len(n, 10);
  char *p = buf + l;
  for (; p > buf; n /= 10)
    *--p = n % 10 + '0';
  return l;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<eh_fmt_unsigned>:
  endbr64
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %esi,%ebx
  mov    $0xa,%esi
  mov    %ebx,%edi
  sub    $0x8,%rsp
  call   <eh_fmt_unsigned_len@plt>
  lea    0x0(%rbp,%rax,1),%rcx
  cmp    %rcx,%rbp
  jae    L5
  mov    $0xcccccccd,%edi
  nopw   0x0(%rax,%rax,1)
L8:
  mov    %ebx,%edx
  sub    $0x1,%rcx
  imul   %rdi,%rdx
  shr    $0x23,%rdx
  lea    (%rdx,%rdx,4),%esi
  add    %esi,%esi
  sub    %esi,%ebx
  add    $0x30,%ebx
  mov    %bl,(%rcx)
  mov    %edx,%ebx
  cmp    %rcx,%rbp
  jne    L8
L5:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
size_t eh_fmt_unsigned(char *buf, register unsigned n) {
  size_t l = eh_fmt_unsigned_len(n, 10);
  char *p = buf + l;
  for (; p > buf; n /= 10)
    *--p = n % 10 + '0';
  return l;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<stoken>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  mov    %r8,-0x38(%rbp)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L22
L95:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
L22:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L56
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L95
L56:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L94
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L94
L62:
  addl   $0x1,-0x8(%rbp)
L94:
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jae    L2
  mov    -0x8(%rbp),%edx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L62
  jmp    L2
L34:
  subl   $0x1,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L2:
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jae    L60
  mov    -0x4(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L34
L60:
  mov    -0x8(%rbp),%edx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  leave
  ret
```

assistant: ```c
const char *stoken(char *c, int *p, char *s, const char *sep, const char *ignore) {
  unsigned begin;
  unsigned end;
  begin = *p;
  while (s[*p] && strchr(sep, s[*p]) == 0)
    ++*p;
  end = *p;
  *c = s[*p];
  if (s[*p]) {
    s[*p] = 0;
    ++*p;
  }
  while (begin < end && strchr(ignore, s[begin]) != 0) {
    ++begin;
  }
  while (begin < end && strchr(ignore, s[end - 1]) != 0) {
    --end;
    s[end] = 0;
  }
  return s + begin;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<stoken>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r15
  mov    %rsi,%rbp
  mov    %rdx,%r13
  mov    %rcx,%r14
  mov    %r8,%r12
  mov    (%rsi),%ebx
  movslq %ebx,%rax
  movzbl (%rdx,%rax,1),%esi
  test   %sil,%sil
  je     L119
L5:
  movsbl %sil,%esi
  mov    %r14,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L1
  mov    0x0(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,0x0(%rbp)
  cltq
  movzbl 0x0(%r13,%rax,1),%esi
  test   %sil,%sil
  jne    L5
L1:
  mov    0x0(%rbp),%r14d
  movslq %r14d,%rax
  movzbl 0x0(%r13,%rax,1),%eax
  mov    %al,(%r15)
  movslq 0x0(%rbp),%rax
  add    %r13,%rax
  cmpb   $0x0,(%rax)
  je     L72
L14:
  movb   $0x0,(%rax)
  addl   $0x1,0x0(%rbp)
L72:
  mov    %ebx,%ebp
  add    %r13,%rbp
  cmp    %r14d,%ebx
  jae    L0
L43:
  movsbl 0x0(%rbp),%esi
  mov    %r12,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L79
  add    $0x1,%ebx
  add    $0x1,%rbp
  cmp    %r14d,%ebx
  jb     L43
  jmp    L0
L79:
  cmp    %r14d,%ebx
  jae    L0
  sub    $0x1,%r14d
  mov    %r14d,%eax
  lea    0x0(%r13,%rax,1),%rbp
  lea    -0x1(%r13,%rax,1),%r15
  sub    %ebx,%r14d
  sub    %r14,%r15
L42:
  movsbl 0x0(%rbp),%esi
  mov    %r12,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L0
  movb   $0x0,0x0(%rbp)
  sub    $0x1,%rbp
  cmp    %r15,%rbp
  jne    L42
L0:
  mov    %ebx,%ebx
  lea    0x0(%r13,%rbx,1),%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L119:
  mov    0x0(%rbp),%r14d
  movslq %r14d,%rax
  movzbl (%rdx,%rax,1),%eax
  mov    %al,(%rdi)
  movslq 0x0(%rbp),%rax
  add    %rdx,%rax
  cmpb   $0x0,(%rax)
  jne    L14
  jmp    L0
```

assistant: ```c
const char *stoken(char *c, int *p, char *s, const char *sep, const char *ignore) {
  unsigned begin;
  unsigned end;
  begin = *p;
  while (s[*p] && strchr(sep, s[*p]) == 0)
    ++*p;
  end = *p;
  *c = s[*p];
  if (s[*p]) {
    s[*p] = 0;
    ++*p;
  }
  while (begin < end && strchr(ignore, s[begin]) != 0) {
    ++begin;
  }
  while (begin < end && strchr(ignore, s[end - 1]) != 0) {
    --end;
    s[end] = 0;
  }
  return s + begin;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<stoken>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %r8,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x18,%rsp
  movslq (%rsi),%rax
  mov    %rdi,0x8(%rsp)
  movsbl (%rdx,%rax,1),%esi
  mov    %eax,%r12d
  mov    %rax,%rbp
  add    %rdx,%r12
  test   %sil,%sil
  jne    L99
  jmp    L37
  nopl   (%rax)
L33:
  mov    (%r15),%eax
  add    $0x1,%eax
  movslq %eax,%rdx
  mov    %eax,(%r15)
  movsbl (%r14,%rdx,1),%esi
  test   %sil,%sil
  je     L42
L99:
  mov    %rbx,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L33
  movslq (%r15),%rdx
  movzbl (%r14,%rdx,1),%esi
  mov    %rdx,%rax
L42:
  mov    %eax,%ebx
  mov    0x8(%rsp),%rax
  mov    %sil,(%rax)
  movslq (%r15),%rax
  add    %r14,%rax
  cmpb   $0x0,(%rax)
  jne    L107
L7:
  mov    %r12,%rax
  cmp    %ebx,%ebp
  jb     L152
  jmp    L35
L56:
  add    $0x1,%ebp
  lea    0x1(%r12),%rax
  cmp    %ebx,%ebp
  jae    L120
L152:
  movsbl (%rax),%esi
  mov    %r13,%rdi
  mov    %rax,%r12
  call   <strchr@plt>
  test   %rax,%rax
  jne    L56
  cmp    %ebx,%ebp
  jae    L35
  lea    -0x1(%rbx),%eax
  mov    %rax,%rbx
  lea    (%r14,%rax,1),%r15
  lea    -0x1(%r14,%rax,1),%rax
  sub    %ebp,%ebx
  sub    %rbx,%rax
  mov    %rax,%rbp
  jmp    L113
L23:
  movb   $0x0,(%r15)
  sub    $0x1,%r15
  cmp    %rbp,%r15
  je     L35
L113:
  movsbl (%r15),%esi
  mov    %r13,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L23
L35:
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L37:
  mov    0x8(%rsp),%rax
  movb   $0x0,(%rax)
  movslq (%r15),%rax
  add    %rdx,%rax
  cmpb   $0x0,(%rax)
  je     L35
  mov    %ebp,%ebx
  nopl   (%rax)
L107:
  movb   $0x0,(%rax)
  addl   $0x1,(%r15)
  jmp    L7
  nopl   0x0(%rax)
L120:
  mov    %ebp,%r12d
  add    %r14,%r12
  jmp    L35
```

assistant: ```c
const char *stoken(char *c, int *p, char *s, const char *sep, const char *ignore) {
  unsigned begin;
  unsigned end;
  begin = *p;
  while (s[*p] && strchr(sep, s[*p]) == 0)
    ++*p;
  end = *p;
  *c = s[*p];
  if (s[*p]) {
    s[*p] = 0;
    ++*p;
  }
  while (begin < end && strchr(ignore, s[begin]) != 0) {
    ++begin;
  }
  while (begin < end && strchr(ignore, s[end - 1]) != 0) {
    --end;
    s[end] = 0;
  }
  return s + begin;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<stoken>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %r8,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x18,%rsp
  movslq (%rsi),%rax
  mov    %rdi,0x8(%rsp)
  movsbl (%rdx,%rax,1),%esi
  mov    %eax,%r12d
  mov    %rax,%rbp
  add    %rdx,%r12
  test   %sil,%sil
  jne    L32
  jmp    L89
  nopl   (%rax)
L117:
  mov    (%r15),%eax
  add    $0x1,%eax
  movslq %eax,%rdx
  mov    %eax,(%r15)
  movsbl (%r14,%rdx,1),%esi
  test   %sil,%sil
  je     L138
L32:
  mov    %rbx,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L117
  movslq (%r15),%rdx
  movzbl (%r14,%rdx,1),%esi
  mov    %rdx,%rax
L138:
  mov    %eax,%ebx
  mov    0x8(%rsp),%rax
  mov    %sil,(%rax)
  movslq (%r15),%rax
  add    %r14,%rax
  cmpb   $0x0,(%rax)
  jne    L140
L2:
  mov    %r12,%rax
  cmp    %ebx,%ebp
  jb     L26
  jmp    L102
L99:
  add    $0x1,%ebp
  lea    0x1(%r12),%rax
  cmp    %ebx,%ebp
  jae    L34
L26:
  movsbl (%rax),%esi
  mov    %r13,%rdi
  mov    %rax,%r12
  call   <strchr@plt>
  test   %rax,%rax
  jne    L99
  cmp    %ebx,%ebp
  jae    L102
  lea    -0x1(%rbx),%eax
  mov    %rax,%rbx
  lea    (%r14,%rax,1),%r15
  lea    -0x1(%r14,%rax,1),%rax
  sub    %ebp,%ebx
  sub    %rbx,%rax
  mov    %rax,%rbp
  jmp    L48
L105:
  movb   $0x0,(%r15)
  sub    $0x1,%r15
  cmp    %r15,%rbp
  je     L102
L48:
  movsbl (%r15),%esi
  mov    %r13,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L105
L102:
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L89:
  movb   $0x0,(%rdi)
  movslq (%r15),%rax
  add    %rdx,%rax
  cmpb   $0x0,(%rax)
  je     L102
  mov    %ebp,%ebx
L140:
  movb   $0x0,(%rax)
  addl   $0x1,(%r15)
  jmp    L2
  nopl   0x0(%rax)
L34:
  mov    %ebp,%r12d
  add    %r14,%r12
  jmp    L102
```

assistant: ```c
const char *stoken(char *c, int *p, char *s, const char *sep, const char *ignore) {
  unsigned begin;
  unsigned end;
  begin = *p;
  while (s[*p] && strchr(sep, s[*p]) == 0)
    ++*p;
  end = *p;
  *c = s[*p];
  if (s[*p]) {
    s[*p] = 0;
    ++*p;
  }
  while (begin < end && strchr(ignore, s[begin]) != 0) {
    ++begin;
  }
  while (begin < end && strchr(ignore, s[end - 1]) != 0) {
    --end;
    s[end] = 0;
  }
  return s + begin;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<is_heap_index_valid>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L3
L17:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  setne  %al
  movzbl %al,%eax
  add    %eax,-0x8(%rbp)
  addl   $0x1,-0x4(%rbp)
L3:
  mov    -0x4(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L17
  cmpl   $0x0,-0x8(%rbp)
  sete   %al
  movzbl %al,%eax
  pop    %rbp
  ret
```

assistant: ```c
int is_heap_index_valid(unsigned int *heap, unsigned int *index, const int size) {
  unsigned int sum = 0;
  for (int i = 0; i <= size; i++) {
    sum += (heap[index[heap[i]]] != heap[i]);
  }
  return (0 == sum);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<is_heap_index_valid>:
  endbr64
  test   %edx,%edx
  js     L0
  mov    %rdi,%rax
  mov    %edx,%edx
  lea    0x4(%rdi,%rdx,4),%r9
  mov    $0x0,%ecx
L2:
  mov    (%rax),%edx
  mov    %edx,%r8d
  mov    (%rsi,%r8,4),%r8d
  cmp    %edx,(%rdi,%r8,4)
  setne  %dl
  movzbl %dl,%edx
  add    %edx,%ecx
  add    $0x4,%rax
  cmp    %r9,%rax
  jne    L2
L17:
  test   %ecx,%ecx
  sete   %al
  movzbl %al,%eax
  ret
L0:
  mov    $0x0,%ecx
  jmp    L17
```

assistant: ```c
int is_heap_index_valid(unsigned int *heap, unsigned int *index, const int size) {
  unsigned int sum = 0;
  for (int i = 0; i <= size; i++) {
    sum += (heap[index[heap[i]]] != heap[i]);
  }
  return (0 == sum);
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<is_heap_index_valid>:
  endbr64
  test   %edx,%edx
  js     L17
  movslq %edx,%rdx
  mov    %rdi,%rax
  xor    %ecx,%ecx
  lea    0x4(%rdi,%rdx,4),%r9
  nopl   (%rax)
L14:
  mov    (%rax),%r8d
  mov    %r8,%rdx
  mov    (%rsi,%r8,4),%r8d
  cmp    %edx,(%rdi,%r8,4)
  setne  %dl
  add    $0x4,%rax
  movzbl %dl,%edx
  add    %edx,%ecx
  cmp    %rax,%r9
  jne    L14
  xor    %eax,%eax
  test   %ecx,%ecx
  sete   %al
  ret
  nop
L17:
  mov    $0x1,%eax
  ret
```

assistant: ```c
int is_heap_index_valid(unsigned int *heap, unsigned int *index, const int size) {
  unsigned int sum = 0;
  for (int i = 0; i <= size; i++) {
    sum += (heap[index[heap[i]]] != heap[i]);
  }
  return (0 == sum);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<is_heap_index_valid>:
  endbr64
  test   %edx,%edx
  js     L2
  movslq %edx,%rdx
  mov    %rdi,%rax
  xor    %ecx,%ecx
  lea    0x4(%rdi,%rdx,4),%r9
  nopl   (%rax)
L13:
  mov    (%rax),%r8d
  mov    %r8,%rdx
  mov    (%rsi,%r8,4),%r8d
  cmp    %edx,(%rdi,%r8,4)
  setne  %dl
  add    $0x4,%rax
  movzbl %dl,%edx
  add    %edx,%ecx
  cmp    %rax,%r9
  jne    L13
  xor    %eax,%eax
  test   %ecx,%ecx
  sete   %al
  ret
  nop
L2:
  mov    $0x1,%eax
  ret
```

assistant: ```c
int is_heap_index_valid(unsigned int *heap, unsigned int *index, const int size) {
  unsigned int sum = 0;
  for (int i = 0; i <= size; i++) {
    sum += (heap[index[heap[i]]] != heap[i]);
  }
  return (0 == sum);
}
```