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

```asm
<print_imm_22>:
  endbr64
  sub    $0x8,%rsp
  mov    D14(%rip),%eax
  lea    0x4(%rax),%esi
  and    $0x3fffff,%esi
  mov    %esi,D2(%rip)
  lea    D2(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  ret
```

tool_calls: name: unpack_data
arguments: tag: D2
type_guessed: string

tool: D2: 0x%x

assistant: ```c
void print_imm_22(void) {
  static int val = 0;
  val = (val + 4) & 0x3fffff;
  printf("0x%x", val);
}
```
user: What is the c source code of the assembly code below?

```asm
<gf8mul_11110111>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  pxor   %xmm7,%xmm5
  pxor   %xmm6,%xmm4
  pxor   %xmm5,%xmm3
  pxor   %xmm4,%xmm2
  pxor   %xmm3,%xmm1
  pxor   %xmm2,%xmm0
  pxor   %xmm1,%xmm7
  pxor   %xmm1,%xmm6
  pxor   %xmm1,%xmm5
  pxor   %xmm1,%xmm4
  pxor   %xmm1,%xmm2
  pxor   %xmm1,%xmm0
  pxor   %xmm0,%xmm7
  pxor   %xmm0,%xmm5
  pxor   %xmm0,%xmm2
  pxor   %xmm0,%xmm1
  pxor   %xmm1,%xmm0
  pxor   %xmm7,%xmm3
  pxor   %xmm7,%xmm1
  pxor   %xmm7,%xmm0
  pxor   %xmm6,%xmm7
  pxor   %xmm5,%xmm6
  pxor   %xmm4,%xmm5
  pxor   %xmm3,%xmm4
  pxor   %xmm2,%xmm3
  pxor   %xmm1,%xmm2
  pxor   %xmm0,%xmm1
  nop
  pop    %rbp
  ret
```

assistant: ```c
void gf8mul_11110111(void) {
  __asm__ __volatile__("\tpxor    %xmm7, %xmm5\n"
                       "\tpxor    %xmm6, %xmm4\n"
                       "\tpxor    %xmm5, %xmm3\n"
                       "\tpxor    %xmm4, %xmm2\n"
                       "\tpxor    %xmm3, %xmm1\n"
                       "\tpxor    %xmm2, %xmm0\n"
                       "\tpxor    %xmm1, %xmm7\n"
                       "\tpxor    %xmm1, %xmm6\n"
                       "\tpxor    %xmm1, %xmm5\n"
                       "\tpxor    %xmm1, %xmm4\n"
                       "\tpxor    %xmm1, %xmm2\n"
                       "\tpxor    %xmm1, %xmm0\n"
                       "\tpxor    %xmm0, %xmm7\n"
                       "\tpxor    %xmm0, %xmm5\n"
                       "\tpxor    %xmm0, %xmm2\n"
                       "\tpxor    %xmm0, %xmm1\n"
                       "\tpxor    %xmm1, %xmm0\n"
                       "\tpxor    %xmm7, %xmm3\n"
                       "\tpxor    %xmm7, %xmm1\n"
                       "\tpxor    %xmm7, %xmm0\n"
                       "\tpxor    %xmm6, %xmm7\n"
                       "\tpxor    %xmm5, %xmm6\n"
                       "\tpxor    %xmm4, %xmm5\n"
                       "\tpxor    %xmm3, %xmm4\n"
                       "\tpxor    %xmm2, %xmm3\n"
                       "\tpxor    %xmm1, %xmm2\n"
                       "\tpxor    %xmm0, %xmm1\n");
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<gf8mul_11110111>:
  endbr64
  pxor   %xmm7,%xmm5
  pxor   %xmm6,%xmm4
  pxor   %xmm5,%xmm3
  pxor   %xmm4,%xmm2
  pxor   %xmm3,%xmm1
  pxor   %xmm2,%xmm0
  pxor   %xmm1,%xmm7
  pxor   %xmm1,%xmm6
  pxor   %xmm1,%xmm5
  pxor   %xmm1,%xmm4
  pxor   %xmm1,%xmm2
  pxor   %xmm1,%xmm0
  pxor   %xmm0,%xmm7
  pxor   %xmm0,%xmm5
  pxor   %xmm0,%xmm2
  pxor   %xmm0,%xmm1
  pxor   %xmm1,%xmm0
  pxor   %xmm7,%xmm3
  pxor   %xmm7,%xmm1
  pxor   %xmm7,%xmm0
  pxor   %xmm6,%xmm7
  pxor   %xmm5,%xmm6
  pxor   %xmm4,%xmm5
  pxor   %xmm3,%xmm4
  pxor   %xmm2,%xmm3
  pxor   %xmm1,%xmm2
  pxor   %xmm0,%xmm1
  ret
```

assistant: ```c
void gf8mul_11110111(void) {
  __asm__ __volatile__("\tpxor    %xmm7, %xmm5\n"
                       "\tpxor    %xmm6, %xmm4\n"
                       "\tpxor    %xmm5, %xmm3\n"
                       "\tpxor    %xmm4, %xmm2\n"
                       "\tpxor    %xmm3, %xmm1\n"
                       "\tpxor    %xmm2, %xmm0\n"
                       "\tpxor    %xmm1, %xmm7\n"
                       "\tpxor    %xmm1, %xmm6\n"
                       "\tpxor    %xmm1, %xmm5\n"
                       "\tpxor    %xmm1, %xmm4\n"
                       "\tpxor    %xmm1, %xmm2\n"
                       "\tpxor    %xmm1, %xmm0\n"
                       "\tpxor    %xmm0, %xmm7\n"
                       "\tpxor    %xmm0, %xmm5\n"
                       "\tpxor    %xmm0, %xmm2\n"
                       "\tpxor    %xmm0, %xmm1\n"
                       "\tpxor    %xmm1, %xmm0\n"
                       "\tpxor    %xmm7, %xmm3\n"
                       "\tpxor    %xmm7, %xmm1\n"
                       "\tpxor    %xmm7, %xmm0\n"
                       "\tpxor    %xmm6, %xmm7\n"
                       "\tpxor    %xmm5, %xmm6\n"
                       "\tpxor    %xmm4, %xmm5\n"
                       "\tpxor    %xmm3, %xmm4\n"
                       "\tpxor    %xmm2, %xmm3\n"
                       "\tpxor    %xmm1, %xmm2\n"
                       "\tpxor    %xmm0, %xmm1\n");
}
```
user: Translate the below assembly code into C programming language:

```asm
<gf8mul_11110111>:
  endbr64
  pxor   %xmm7,%xmm5
  pxor   %xmm6,%xmm4
  pxor   %xmm5,%xmm3
  pxor   %xmm4,%xmm2
  pxor   %xmm3,%xmm1
  pxor   %xmm2,%xmm0
  pxor   %xmm1,%xmm7
  pxor   %xmm1,%xmm6
  pxor   %xmm1,%xmm5
  pxor   %xmm1,%xmm4
  pxor   %xmm1,%xmm2
  pxor   %xmm1,%xmm0
  pxor   %xmm0,%xmm7
  pxor   %xmm0,%xmm5
  pxor   %xmm0,%xmm2
  pxor   %xmm0,%xmm1
  pxor   %xmm1,%xmm0
  pxor   %xmm7,%xmm3
  pxor   %xmm7,%xmm1
  pxor   %xmm7,%xmm0
  pxor   %xmm6,%xmm7
  pxor   %xmm5,%xmm6
  pxor   %xmm4,%xmm5
  pxor   %xmm3,%xmm4
  pxor   %xmm2,%xmm3
  pxor   %xmm1,%xmm2
  pxor   %xmm0,%xmm1
  ret
```

assistant: ```c
void gf8mul_11110111(void) {
  __asm__ __volatile__("\tpxor    %xmm7, %xmm5\n"
                       "\tpxor    %xmm6, %xmm4\n"
                       "\tpxor    %xmm5, %xmm3\n"
                       "\tpxor    %xmm4, %xmm2\n"
                       "\tpxor    %xmm3, %xmm1\n"
                       "\tpxor    %xmm2, %xmm0\n"
                       "\tpxor    %xmm1, %xmm7\n"
                       "\tpxor    %xmm1, %xmm6\n"
                       "\tpxor    %xmm1, %xmm5\n"
                       "\tpxor    %xmm1, %xmm4\n"
                       "\tpxor    %xmm1, %xmm2\n"
                       "\tpxor    %xmm1, %xmm0\n"
                       "\tpxor    %xmm0, %xmm7\n"
                       "\tpxor    %xmm0, %xmm5\n"
                       "\tpxor    %xmm0, %xmm2\n"
                       "\tpxor    %xmm0, %xmm1\n"
                       "\tpxor    %xmm1, %xmm0\n"
                       "\tpxor    %xmm7, %xmm3\n"
                       "\tpxor    %xmm7, %xmm1\n"
                       "\tpxor    %xmm7, %xmm0\n"
                       "\tpxor    %xmm6, %xmm7\n"
                       "\tpxor    %xmm5, %xmm6\n"
                       "\tpxor    %xmm4, %xmm5\n"
                       "\tpxor    %xmm3, %xmm4\n"
                       "\tpxor    %xmm2, %xmm3\n"
                       "\tpxor    %xmm1, %xmm2\n"
                       "\tpxor    %xmm0, %xmm1\n");
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<gf8mul_11110111>:
  endbr64
  pxor   %xmm7,%xmm5
  pxor   %xmm6,%xmm4
  pxor   %xmm5,%xmm3
  pxor   %xmm4,%xmm2
  pxor   %xmm3,%xmm1
  pxor   %xmm2,%xmm0
  pxor   %xmm1,%xmm7
  pxor   %xmm1,%xmm6
  pxor   %xmm1,%xmm5
  pxor   %xmm1,%xmm4
  pxor   %xmm1,%xmm2
  pxor   %xmm1,%xmm0
  pxor   %xmm0,%xmm7
  pxor   %xmm0,%xmm5
  pxor   %xmm0,%xmm2
  pxor   %xmm0,%xmm1
  pxor   %xmm1,%xmm0
  pxor   %xmm7,%xmm3
  pxor   %xmm7,%xmm1
  pxor   %xmm7,%xmm0
  pxor   %xmm6,%xmm7
  pxor   %xmm5,%xmm6
  pxor   %xmm4,%xmm5
  pxor   %xmm3,%xmm4
  pxor   %xmm2,%xmm3
  pxor   %xmm1,%xmm2
  pxor   %xmm0,%xmm1
  ret
```

assistant: ```c
void gf8mul_11110111(void) {
  __asm__ __volatile__("\tpxor    %xmm7, %xmm5\n"
                       "\tpxor    %xmm6, %xmm4\n"
                       "\tpxor    %xmm5, %xmm3\n"
                       "\tpxor    %xmm4, %xmm2\n"
                       "\tpxor    %xmm3, %xmm1\n"
                       "\tpxor    %xmm2, %xmm0\n"
                       "\tpxor    %xmm1, %xmm7\n"
                       "\tpxor    %xmm1, %xmm6\n"
                       "\tpxor    %xmm1, %xmm5\n"
                       "\tpxor    %xmm1, %xmm4\n"
                       "\tpxor    %xmm1, %xmm2\n"
                       "\tpxor    %xmm1, %xmm0\n"
                       "\tpxor    %xmm0, %xmm7\n"
                       "\tpxor    %xmm0, %xmm5\n"
                       "\tpxor    %xmm0, %xmm2\n"
                       "\tpxor    %xmm0, %xmm1\n"
                       "\tpxor    %xmm1, %xmm0\n"
                       "\tpxor    %xmm7, %xmm3\n"
                       "\tpxor    %xmm7, %xmm1\n"
                       "\tpxor    %xmm7, %xmm0\n"
                       "\tpxor    %xmm6, %xmm7\n"
                       "\tpxor    %xmm5, %xmm6\n"
                       "\tpxor    %xmm4, %xmm5\n"
                       "\tpxor    %xmm3, %xmm4\n"
                       "\tpxor    %xmm2, %xmm3\n"
                       "\tpxor    %xmm1, %xmm2\n"
                       "\tpxor    %xmm0, %xmm1\n");
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<ao_fec_crc_byte>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L1
L7:
  mov    -0x18(%rbp),%eax
  sar    $0x8,%eax
  xor    -0x14(%rbp),%eax
  and    $0x80,%eax
  test   %eax,%eax
  je     L4
  mov    -0x18(%rbp),%eax
  add    %eax,%eax
  xor    $0x8005,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L17
L4:
  shll   -0x18(%rbp)
L17:
  shll   -0x14(%rbp)
  addl   $0x1,-0x4(%rbp)
L1:
  cmpl   $0x7,-0x4(%rbp)
  jle    L7
  mov    -0x18(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
uint16_t ao_fec_crc_byte(uint8_t byte, uint16_t crc) {
  uint8_t bit;
  for (bit = 0; bit < 8; bit++) {
    if (((crc & 0x8000) >> 8) ^ (byte & 0x80))
      crc = (crc << 1) ^ 0x8005;
    else
      crc = (crc << 1);
    byte <<= 1;
  }
  return crc;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<ao_fec_crc_byte>:
  endbr64
  mov    %esi,%eax
  mov    $0x8,%esi
L8:
  mov    %eax,%ecx
  sar    $0x8,%ecx
  xor    %edi,%ecx
  lea    (%rax,%rax,1),%edx
  xor    $0x8005,%edx
  add    %eax,%eax
  test   $0x80,%cl
  cmovne %edx,%eax
  add    %edi,%edi
  sub    $0x1,%esi
  jne    L8
  ret
```

assistant: ```c
uint16_t ao_fec_crc_byte(uint8_t byte, uint16_t crc) {
  uint8_t bit;
  for (bit = 0; bit < 8; bit++) {
    if (((crc & 0x8000) >> 8) ^ (byte & 0x80))
      crc = (crc << 1) ^ 0x8005;
    else
      crc = (crc << 1);
    byte <<= 1;
  }
  return crc;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<ao_fec_crc_byte>:
  endbr64
  mov    %esi,%eax
  mov    $0x8,%ecx
  nopl   0x0(%rax,%rax,1)
L1:
  mov    %eax,%edx
  add    %eax,%eax
  sar    $0x8,%edx
  mov    %eax,%esi
  xor    %edi,%edx
  xor    $0x8005,%esi
  and    $0x80,%edx
  cmovne %esi,%eax
  add    %edi,%edi
  sub    $0x1,%ecx
  jne    L1
  ret
```

assistant: ```c
uint16_t ao_fec_crc_byte(uint8_t byte, uint16_t crc) {
  uint8_t bit;
  for (bit = 0; bit < 8; bit++) {
    if (((crc & 0x8000) >> 8) ^ (byte & 0x80))
      crc = (crc << 1) ^ 0x8005;
    else
      crc = (crc << 1);
    byte <<= 1;
  }
  return crc;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<ao_fec_crc_byte>:
  endbr64
  lea    (%rsi,%rsi,1),%edx
  sar    $0x8,%esi
  mov    %edi,%eax
  xor    %edi,%esi
  mov    %edx,%ecx
  xor    $0x8005,%ecx
  and    $0x80,%esi
  lea    (%rdi,%rdi,1),%esi
  cmovne %ecx,%edx
  lea    (%rdx,%rdx,1),%ecx
  sar    $0x8,%edx
  xor    %esi,%edx
  mov    %ecx,%esi
  xor    $0x8005,%esi
  and    $0x80,%edx
  cmovne %esi,%ecx
  lea    0x0(,%rdi,4),%esi
  lea    (%rcx,%rcx,1),%edx
  sar    $0x8,%ecx
  xor    %esi,%ecx
  mov    %edx,%esi
  xor    $0x8005,%esi
  and    $0x80,%ecx
  cmovne %esi,%edx
  lea    0x0(,%rdi,8),%esi
  lea    (%rdx,%rdx,1),%ecx
  sar    $0x8,%edx
  xor    %esi,%edx
  mov    %ecx,%esi
  xor    $0x8005,%esi
  and    $0x80,%edx
  cmovne %esi,%ecx
  mov    %edi,%esi
  shl    $0x4,%esi
  lea    (%rcx,%rcx,1),%edx
  sar    $0x8,%ecx
  xor    %esi,%ecx
  mov    %edx,%esi
  xor    $0x8005,%esi
  and    $0x80,%ecx
  cmovne %esi,%edx
  mov    %edi,%esi
  shl    $0x5,%esi
  lea    (%rdx,%rdx,1),%ecx
  sar    $0x8,%edx
  xor    %esi,%edx
  mov    %ecx,%esi
  xor    $0x8005,%esi
  and    $0x80,%edx
  cmovne %esi,%ecx
  mov    %edi,%esi
  shl    $0x6,%esi
  lea    (%rcx,%rcx,1),%edx
  sar    $0x8,%ecx
  xor    %esi,%ecx
  mov    %edx,%esi
  xor    $0x8005,%esi
  and    $0x80,%ecx
  cmovne %esi,%edx
  shl    $0x7,%eax
  lea    (%rdx,%rdx,1),%r8d
  sar    $0x8,%edx
  xor    %eax,%edx
  mov    %r8d,%eax
  xor    $0x8005,%eax
  and    $0x80,%edx
  cmovne %eax,%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
uint16_t ao_fec_crc_byte(uint8_t byte, uint16_t crc) {
  uint8_t bit;
  for (bit = 0; bit < 8; bit++) {
    if (((crc & 0x8000) >> 8) ^ (byte & 0x80))
      crc = (crc << 1) ^ 0x8005;
    else
      crc = (crc << 1);
    byte <<= 1;
  }
  return crc;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<timeval_to_milliseconds>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  imul   $0x3e8,%eax,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x18(%rbp),%rax
  mov    0x4(%rax),%eax
  movslq %eax,%rdx
  imul   $0x10624dd3,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x6,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  add    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
int timeval_to_milliseconds(const struct timeval *time) {
  int milliseconds;
  assert(time != NULL);
  milliseconds = time->tv_sec * 1000;
  milliseconds += time->tv_usec / 1000;
  return milliseconds;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<timeval_to_milliseconds>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  test   %rdi,%rdi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  imul   $0x3e8,(%rbx),%ecx
  mov    0x4(%rbx),%edx
  movslq %edx,%rax
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  sar    $0x1f,%edx
  sub    %edx,%eax
  add    %ecx,%eax
  pop    %rbx
  ret
```

assistant: ```c
int timeval_to_milliseconds(const struct timeval *time) {
  int milliseconds;
  assert(time != NULL);
  milliseconds = time->tv_sec * 1000;
  milliseconds += time->tv_usec / 1000;
  return milliseconds;
}
```
user: What is the c source code of the assembly code below:

```asm
<timeval_to_milliseconds>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  xor    %edi,%edi
  test   %rbx,%rbx
  setne  %dil
  call   <assert@plt>
  movslq 0x4(%rbx),%rax
  imul   $0x3e8,(%rbx),%ecx
  pop    %rbx
  mov    %rax,%rdx
  imul   $0x10624dd3,%rax,%rax
  sar    $0x1f,%edx
  sar    $0x26,%rax
  sub    %edx,%eax
  add    %ecx,%eax
  ret
```

assistant: ```c
int timeval_to_milliseconds(const struct timeval *time) {
  int milliseconds;
  assert(time != NULL);
  milliseconds = time->tv_sec * 1000;
  milliseconds += time->tv_usec / 1000;
  return milliseconds;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<timeval_to_milliseconds>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  xor    %edi,%edi
  test   %rbx,%rbx
  setne  %dil
  call   <assert@plt>
  movslq 0x4(%rbx),%rax
  imul   $0x3e8,(%rbx),%ecx
  pop    %rbx
  mov    %rax,%rdx
  imul   $0x10624dd3,%rax,%rax
  sar    $0x1f,%edx
  sar    $0x26,%rax
  sub    %edx,%eax
  add    %ecx,%eax
  ret
```

assistant: ```c
int timeval_to_milliseconds(const struct timeval *time) {
  int milliseconds;
  assert(time != NULL);
  milliseconds = time->tv_sec * 1000;
  milliseconds += time->tv_usec / 1000;
  return milliseconds;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<xstrtostr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  movq   $0x0,-0x10(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L61
  mov    -0x20(%rbp),%rax
  mov    -0x18(%rbp),%rdx
  mov    %rdx,(%rax)
L61:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L42
  mov    $0x0,%eax
  jmp    L31
L42:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x22,%al
  jne    L16
  addq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L121
L125:
  addq   $0x1,-0x8(%rbp)
  addq   $0x1,-0x10(%rbp)
L121:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L99
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x22,%al
  jne    L125
L99:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L11
  mov    $0x0,%eax
  jmp    L31
L11:
  addq   $0x1,-0x8(%rbp)
  jmp    L87
L16:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x10(%rbp)
  jmp    L4
L116:
  subq   $0x1,-0x10(%rbp)
L4:
  mov    -0x10(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L116
  mov    -0x18(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
L87:
  cmpq   $0x0,-0x20(%rbp)
  je     L38
  mov    -0x20(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
L38:
  mov    -0x10(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <xstrndup@plt>
L31:
  leave
  ret
```

assistant: ```c
char *xstrtostr(const char *str, const char **endptr) {
  size_t cnt = 0;
  const char *ptr;
  if (endptr)
    *endptr = str;
  if (!*str)
    return NULL;
  if (*str == '"') {
    ptr = ++str;
    while (*ptr && *ptr != '"') {
      ptr++;
      cnt++;
    }
    if (!*ptr)
      return NULL;
    ptr++;
  } else {
    cnt = strlen(str);
    while (isspace(str[cnt - 1]))
      cnt--;
    ptr = str + cnt;
  }
  if (endptr)
    *endptr = ptr;
  return xstrndup(str, cnt);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<xstrtostr>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r13
  test   %rsi,%rsi
  je     L135
  mov    %rdi,0x0(%r13)
L135:
  movzbl 0x0(%rbp),%eax
  test   %al,%al
  je     L94
  cmp    $0x22,%al
  je     L33
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
L73:
  mov    %rbx,%r12
  sub    $0x1,%rbx
  movsbl 0x0(%rbp,%rbx,1),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L73
  lea    0x0(%rbp,%r12,1),%rax
L57:
  test   %r13,%r13
  je     L65
  mov    %rax,0x0(%r13)
L65:
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <xstrndup@plt>
L24:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L33:
  lea    0x1(%rbp),%rcx
  movzbl 0x1(%rbp),%edx
  test   %dl,%dl
  je     L111
  cmp    $0x22,%dl
  je     L111
  mov    %rcx,%rax
L30:
  add    $0x1,%rax
  lea    -0x1(%rax),%r12
  sub    %rbp,%r12
  movzbl (%rax),%edx
  test   %dl,%dl
  je     L76
  cmp    $0x22,%dl
  jne    L30
L76:
  test   %dl,%dl
  je     L95
  add    $0x1,%rax
  mov    %rcx,%rbp
  jmp    L57
L111:
  mov    %rcx,%rax
  mov    $0x0,%r12d
  jmp    L76
L94:
  mov    $0x0,%eax
  jmp    L24
L95:
  mov    $0x0,%eax
  jmp    L24
```

assistant: ```c
char *xstrtostr(const char *str, const char **endptr) {
  size_t cnt = 0;
  const char *ptr;
  if (endptr)
    *endptr = str;
  if (!*str)
    return NULL;
  if (*str == '"') {
    ptr = ++str;
    while (*ptr && *ptr != '"') {
      ptr++;
      cnt++;
    }
    if (!*ptr)
      return NULL;
    ptr++;
  } else {
    cnt = strlen(str);
    while (isspace(str[cnt - 1]))
      cnt--;
    ptr = str + cnt;
  }
  if (endptr)
    *endptr = ptr;
  return xstrndup(str, cnt);
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<xstrtostr>:
  endbr64
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %rsi,%rsi
  je     L10
  mov    %rdi,0x0(%r13)
L10:
  movzbl (%r12),%eax
  test   %al,%al
  je     L117
  cmp    $0x22,%al
  je     L110
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  nopl   0x0(%rax)
L64:
  mov    %rbx,%rbp
  lea    -0x1(%rbx),%rbx
  movsbl -0x1(%r12,%rbp,1),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L64
  lea    (%r12,%rbp,1),%rax
L0:
  test   %r13,%r13
  je     L107
  mov    %rax,0x0(%r13)
L107:
  add    $0x8,%rsp
  mov    %rbp,%rsi
  mov    %r12,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1090 <xstrndup@plt>
  nopl   0x0(%rax)
L110:
  movzbl 0x1(%r12),%edx
  lea    0x1(%r12),%rcx
  mov    %rcx,%rax
  test   %dl,%dl
  je     L98
  cmp    $0x22,%dl
  je     L98
  nopw   0x0(%rax,%rax,1)
L47:
  add    $0x1,%rax
  movzbl (%rax),%edx
  lea    -0x1(%rax),%rbp
  sub    %r12,%rbp
  test   %dl,%dl
  je     L117
  cmp    $0x22,%dl
  jne    L47
L112:
  test   %dl,%dl
  je     L117
  add    $0x1,%rax
  mov    %rcx,%r12
  jmp    L0
  nopl   0x0(%rax)
L117:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L98:
  xor    %ebp,%ebp
  jmp    L112
```

assistant: ```c
char *xstrtostr(const char *str, const char **endptr) {
  size_t cnt = 0;
  const char *ptr;
  if (endptr)
    *endptr = str;
  if (!*str)
    return NULL;
  if (*str == '"') {
    ptr = ++str;
    while (*ptr && *ptr != '"') {
      ptr++;
      cnt++;
    }
    if (!*ptr)
      return NULL;
    ptr++;
  } else {
    cnt = strlen(str);
    while (isspace(str[cnt - 1]))
      cnt--;
    ptr = str + cnt;
  }
  if (endptr)
    *endptr = ptr;
  return xstrndup(str, cnt);
}
```
user: Translate the below assembly code into C programming language:

```asm
<xstrtostr>:
  endbr64
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %rsi,%rsi
  je     L27
  mov    %rdi,0x0(%r13)
L27:
  movzbl (%r12),%eax
  test   %al,%al
  je     L33
  cmp    $0x22,%al
  je     L47
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  nopl   0x0(%rax)
L14:
  mov    %rbx,%rbp
  lea    -0x1(%rbx),%rbx
  movsbl -0x1(%r12,%rbp,1),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L14
  lea    (%r12,%rbp,1),%rax
L113:
  test   %r13,%r13
  je     L110
  mov    %rax,0x0(%r13)
L110:
  add    $0x8,%rsp
  mov    %rbp,%rsi
  mov    %r12,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1090 <xstrndup@plt>
  nopl   0x0(%rax)
L47:
  movzbl 0x1(%r12),%edx
  lea    0x1(%r12),%rcx
  mov    %rcx,%rax
  test   %dl,%dl
  je     L60
  cmp    $0x22,%dl
  je     L60
  nopw   0x0(%rax,%rax,1)
L106:
  add    $0x1,%rax
  movzbl (%rax),%edx
  lea    -0x1(%rax),%rbp
  sub    %r12,%rbp
  test   %dl,%dl
  je     L33
  cmp    $0x22,%dl
  jne    L106
L56:
  test   %dl,%dl
  je     L33
  add    $0x1,%rax
  mov    %rcx,%r12
  jmp    L113
  nopl   0x0(%rax)
L33:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L60:
  xor    %ebp,%ebp
  jmp    L56
```

assistant: ```c
char *xstrtostr(const char *str, const char **endptr) {
  size_t cnt = 0;
  const char *ptr;
  if (endptr)
    *endptr = str;
  if (!*str)
    return NULL;
  if (*str == '"') {
    ptr = ++str;
    while (*ptr && *ptr != '"') {
      ptr++;
      cnt++;
    }
    if (!*ptr)
      return NULL;
    ptr++;
  } else {
    cnt = strlen(str);
    while (isspace(str[cnt - 1]))
      cnt--;
    ptr = str + cnt;
  }
  if (endptr)
    *endptr = ptr;
  return xstrndup(str, cnt);
}
```