ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Demonstrate the C code that generates the assembly output below:

```asm
<flash_read>:
  endbr64
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %edi,%ebp
  mov    $0x1,%edi
  push   %rbx
  mov    %rsi,%rbx
  xor    %esi,%esi
  call   <bbspi_transfer@plt>
  xor    %edi,%edi
  mov    $0xb,%esi
  call   <bbspi_transfer@plt>
  mov    %ebp,%esi
  xor    %edi,%edi
  sar    $0x10,%esi
  movzbl %sil,%esi
  call   <bbspi_transfer@plt>
  mov    %ebp,%eax
  xor    %edi,%edi
  movzbl %ah,%esi
  call   <bbspi_transfer@plt>
  xor    %edi,%edi
  movzbl %bpl,%esi
  call   <bbspi_transfer@plt>
  xor    %esi,%esi
  xor    %edi,%edi
  call   <bbspi_transfer@plt>
  test   %r12d,%r12d
  jle    L16
  lea    -0x1(%r12),%eax
  lea    0x4(%rbx,%rax,4),%rbp
  nopw   0x0(%rax,%rax,1)
L12:
  xor    %esi,%esi
  xor    %edi,%edi
  add    $0x4,%rbx
  call   <bbspi_transfer@plt>
  mov    %eax,-0x4(%rbx)
  cmp    %rbp,%rbx
  jne    L12
L16:
  xor    %esi,%esi
  mov    $0x1,%edi
  call   <bbspi_transfer@plt>
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int flash_read(uint32_t addr, uint8_t *buf, int count) {
  int i;
  bbspi_transfer(1, 0);
  bbspi_transfer(0, 0x0b);
  bbspi_transfer(0, (addr & 0xFF0000) >> 16);
  bbspi_transfer(0, (addr & 0xFF00) >> 8);
  bbspi_transfer(0, (addr & 0xFF));
  bbspi_transfer(0, 0);
  for (i = 0; i < count; i++) {
    buf[i] = bbspi_transfer(0, 0);
  }
  bbspi_transfer(1, 0);
  return count;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  lea    D35(%rip),%rax
  mov    %rax,(%rsp)
  lea    D86(%rip),%rax
  mov    %rax,0x8(%rsp)
  lea    D104(%rip),%rax
  mov    %rax,0x10(%rsp)
  lea    D17(%rip),%rax
  mov    %rax,0x18(%rsp)
  lea    D59(%rip),%rax
  mov    %rax,0x20(%rsp)
  lea    D23(%rip),%rax
  mov    %rax,0x28(%rsp)
  lea    D85(%rip),%rax
  mov    %rax,0x30(%rsp)
  lea    D83(%rip),%rax
  mov    %rax,0x38(%rsp)
  lea    D65(%rip),%rax
  mov    %rax,0x40(%rsp)
  cmp    $0x1,%edi
  jle    L77
  lea    0x8(%rsi),%r12
  lea    -0x2(%rdi),%eax
  lea    0x10(%rsi,%rax,8),%r14
  lea    D12(%rip),%r15
  jmp    L51
L66:
  lea    0x1(%rbx),%edx
  mov    0x0(%r13),%rsi
  mov    %r15,%rdi
  call   <printf@plt>
L12:
  cmp    $0x9,%ebp
  je     L87
L25:
  add    $0x8,%r12
  cmp    %r14,%r12
  je     L77
L51:
  mov    $0x0,%ebx
  mov    %r12,%r13
L7:
  mov    %ebx,%ebp
  mov    (%rsp,%rbx,8),%rsi
  mov    (%r12),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L66
  lea    0x1(%rbx),%ebp
  add    $0x1,%rbx
  cmp    $0x9,%rbx
  jne    L7
  jmp    L12
L87:
  mov    0x0(%r13),%rsi
  lea    D64(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L25
L77:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L3
  mov    $0x0,%eax
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L3:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D35
data_type: string
name: disassemble_data
arguments: data_tag: D86
data_type: string
name: disassemble_data
arguments: data_tag: D104
data_type: string
name: disassemble_data
arguments: data_tag: D17
data_type: string
name: disassemble_data
arguments: data_tag: D59
data_type: string
name: disassemble_data
arguments: data_tag: D23
data_type: string
name: disassemble_data
arguments: data_tag: D85
data_type: string
name: disassemble_data
arguments: data_tag: D83
data_type: string
name: disassemble_data
arguments: data_tag: D65
data_type: string
name: disassemble_data
arguments: data_tag: D12
data_type: string
name: disassemble_data
arguments: data_tag: D64
data_type: string

tool: D35: Mecury

tool: D86: Vernus

tool: D104: Earth

tool: D17: Mars

tool: D59: Jupiter

tool: D23: Saturn

tool: D85: Uranus

tool: D83: Neptune

tool: D65: Pluto

tool: D12: %s is planet %d


tool: D64: %s is not a planet


assistant: ```c
int main(int argc, char *argv[]) {
  char *planets[] = {"Mecury", "Vernus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"};
  int i, j;
  for (i = 1; i < argc; i++) {
    for (j = 0; j < 9; j++)
      if (strcmp(argv[i], planets[j]) == 0) {
        printf("%s is planet %d\n", argv[i], j + 1);
        break;
      }
    if (j == 9)
      printf("%s is not a planet\n", argv[i]);
  }
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  lea    D71(%rip),%r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  lea    D18(%rip),%rax
  mov    %r12,(%rsp)
  mov    %rax,0x8(%rsp)
  lea    D34(%rip),%rax
  mov    %rax,0x10(%rsp)
  lea    D74(%rip),%rax
  mov    %rax,0x18(%rsp)
  lea    D83(%rip),%rax
  mov    %rax,0x20(%rsp)
  lea    D41(%rip),%rax
  mov    %rax,0x28(%rsp)
  lea    D35(%rip),%rax
  mov    %rax,0x30(%rsp)
  lea    D92(%rip),%rax
  mov    %rax,0x38(%rsp)
  lea    D2(%rip),%rax
  mov    %rax,0x40(%rsp)
  cmp    $0x1,%edi
  jle    L62
  lea    -0x2(%rdi),%eax
  lea    0x8(%rsi),%rbp
  lea    0x10(%rsi,%rax,8),%r13
  lea    D3(%rip),%r15
  lea    D91(%rip),%r14
  nopl   0x0(%rax)
L32:
  mov    $0x1,%ebx
  mov    %r12,%rsi
  jmp    L56
  nopw   0x0(%rax,%rax,1)
L10:
  mov    (%rsp,%rbx,8),%rsi
  add    $0x1,%rbx
L56:
  mov    0x0(%rbp),%rdi
  call   <strcmp@plt>
  mov    %ebx,%edx
  test   %rax,%rax
  je     L42
  cmp    $0x9,%rbx
  jne    L10
  mov    0x0(%rbp),%rsi
  mov    %r15,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L64:
  add    $0x8,%rbp
  cmp    %r13,%rbp
  jne    L32
L62:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  add    $0x58,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L42:
  mov    0x0(%rbp),%rsi
  mov    %r14,%rdi
  call   <printf@plt>
  jmp    L64
L2:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D71
type_infered: string
name: unpack_data
arguments: label: D18
type_infered: string
name: unpack_data
arguments: label: D34
type_infered: string
name: unpack_data
arguments: label: D74
type_infered: string
name: unpack_data
arguments: label: D83
type_infered: string
name: unpack_data
arguments: label: D41
type_infered: string
name: unpack_data
arguments: label: D35
type_infered: string
name: unpack_data
arguments: label: D92
type_infered: string
name: unpack_data
arguments: label: D2
type_infered: string
name: unpack_data
arguments: label: D3
type_infered: string
name: unpack_data
arguments: label: D91
type_infered: string

tool: D71: Mecury

tool: D18: Vernus

tool: D34: Earth

tool: D74: Mars

tool: D83: Jupiter

tool: D41: Saturn

tool: D35: Uranus

tool: D92: Neptune

tool: D2: Pluto

tool: D3: %s is not a planet


tool: D91: %s is planet %d


assistant: ```c
int main(int argc, char *argv[]) {
  char *planets[] = {"Mecury", "Vernus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"};
  int i, j;
  for (i = 1; i < argc; i++) {
    for (j = 0; j < 9; j++)
      if (strcmp(argv[i], planets[j]) == 0) {
        printf("%s is planet %d\n", argv[i], j + 1);
        break;
      }
    if (j == 9)
      printf("%s is not a planet\n", argv[i]);
  }
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  push   %r15
  lea    D33(%rip),%rcx
  push   %r14
  movq   %rcx,%xmm0
  lea    D34(%rip),%rcx
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  lea    D102(%rip),%rax
  movq   %rax,%xmm1
  lea    D17(%rip),%rax
  punpcklqdq %xmm1,%xmm0
  movq   %rax,%xmm2
  lea    D43(%rip),%rax
  movaps %xmm0,(%rsp)
  movq   %rcx,%xmm0
  lea    D65(%rip),%rcx
  movq   %rax,%xmm3
  punpcklqdq %xmm2,%xmm0
  lea    D20(%rip),%rax
  movaps %xmm0,0x10(%rsp)
  movq   %rcx,%xmm0
  movq   %rax,%xmm4
  lea    D63(%rip),%rcx
  punpcklqdq %xmm3,%xmm0
  lea    D91(%rip),%rax
  movaps %xmm0,0x20(%rsp)
  movq   %rcx,%xmm0
  punpcklqdq %xmm4,%xmm0
  mov    %rax,0x40(%rsp)
  movaps %xmm0,0x30(%rsp)
  cmp    $0x1,%edi
  jle    L1
  lea    -0x2(%rdi),%eax
  lea    0x8(%rsi),%rbp
  mov    %rsp,%r12
  lea    0x10(%rsi,%rax,8),%r13
  lea    D45(%rip),%r15
  lea    D74(%rip),%r14
  nopl   0x0(%rax)
L25:
  mov    $0x1,%ebx
  nopl   (%rax)
L58:
  mov    -0x8(%r12,%rbx,8),%rsi
  mov    0x0(%rbp),%rdi
  call   <strcmp@plt>
  mov    %ebx,%edx
  test   %rax,%rax
  je     L51
  add    $0x1,%rbx
  cmp    $0xa,%rbx
  jne    L58
  mov    0x0(%rbp),%rsi
  mov    %r15,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L5:
  add    $0x8,%rbp
  cmp    %r13,%rbp
  jne    L25
L1:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L15
  add    $0x58,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L51:
  mov    0x0(%rbp),%rsi
  mov    %r14,%rdi
  call   <printf@plt>
  jmp    L5
L15:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D33
type: string
name: disassemble_data
arguments: data_label: D34
type: string
name: disassemble_data
arguments: data_label: D102
type: string
name: disassemble_data
arguments: data_label: D17
type: string
name: disassemble_data
arguments: data_label: D43
type: string
name: disassemble_data
arguments: data_label: D65
type: string
name: disassemble_data
arguments: data_label: D20
type: string
name: disassemble_data
arguments: data_label: D63
type: string
name: disassemble_data
arguments: data_label: D91
type: string
name: disassemble_data
arguments: data_label: D45
type: string
name: disassemble_data
arguments: data_label: D74
type: string

tool: D33: Mecury

tool: D34: Earth

tool: D102: Vernus

tool: D17: Mars

tool: D43: Saturn

tool: D65: Jupiter

tool: D20: Neptune

tool: D63: Uranus

tool: D91: Pluto

tool: D45: %s is not a planet


tool: D74: %s is planet %d


assistant: ```c
int main(int argc, char *argv[]) {
  char *planets[] = {"Mecury", "Vernus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"};
  int i, j;
  for (i = 1; i < argc; i++) {
    for (j = 0; j < 9; j++)
      if (strcmp(argv[i], planets[j]) == 0) {
        printf("%s is planet %d\n", argv[i], j + 1);
        break;
      }
    if (j == 9)
      printf("%s is not a planet\n", argv[i]);
  }
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<vasprintf>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  movl   $0xf0,-0x18(%rbp)
  mov    $0xf0,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L69
  mov    $0xffffffff,%eax
  jmp    L68
L69:
  mov    -0x34(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <va_copy@plt>
  mov    -0x14(%rbp),%ecx
  mov    -0x30(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    $0xf0,%esi
  mov    %rax,%rdi
  call   <vsnprintf@plt>
  mov    %eax,-0x18(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <va_end@plt>
  mov    -0x18(%rbp),%eax
  cmp    $0xef,%eax
  ja     L8
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L82
  mov    -0x8(%rbp),%rax
  jmp    L24
L82:
  mov    -0x10(%rbp),%rax
L24:
  mov    -0x28(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x18(%rbp),%eax
  jmp    L68
L8:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  cmpl   $0x0,-0x18(%rbp)
  js     L32
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    -0x28(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L87
L32:
  mov    $0xffffffff,%eax
  jmp    L68
L87:
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%esi
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x34(%rbp),%ecx
  mov    -0x30(%rbp),%rdx
  mov    %rax,%rdi
  call   <vsnprintf@plt>
L68:
  leave
  ret
```

assistant: ```c
int vasprintf(char **s, const char *fmt, va_list ap) {
  va_list ap2;
  char *a;
  int l = 240U;
  if (!(a = malloc(240U)))
    return -1;
  va_copy(ap2, ap);
  l = vsnprintf(a, 240U, fmt, ap2);
  va_end(ap2);
  if (l < 240U) {
    char *b = realloc(a, l + 1U);
    *s = b ? b : a;
    return l;
  }
  free(a);
  if (l < 0 || !(*s = malloc(l + 1U)))
    return -1;
  return vsnprintf(*s, l + 1U, fmt, ap);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<vasprintf>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r14
  mov    %rsi,%r12
  mov    %edx,%r13d
  mov    $0xf0,%edi
  call   <malloc@plt>
  test   %rax,%rax
  je     L5
  mov    %rax,%rbp
  mov    %r13d,%esi
  mov    $0x0,%r15d
  mov    %r15d,%edi
  call   <va_copy@plt>
  mov    %r15d,%ecx
  mov    %r12,%rdx
  mov    $0xf0,%esi
  mov    %rbp,%rdi
  call   <vsnprintf@plt>
  mov    %eax,%ebx
  mov    %r15d,%edi
  call   <va_end@plt>
  mov    %ebx,%r15d
  cmp    $0xef,%ebx
  jbe    L28
  mov    %rbp,%rdi
  call   <free@plt>
  test   %ebx,%ebx
  js     L26
  add    $0x1,%r15d
  mov    %r15d,%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,(%r14)
  test   %rax,%rax
  je     L43
  mov    %r13d,%ecx
  mov    %r12,%rdx
  mov    %r15d,%esi
  call   <vsnprintf@plt>
  mov    %eax,%ebx
L7:
  mov    %ebx,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L28:
  lea    0x1(%rbx),%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  test   %rax,%rax
  cmove  %rbp,%rax
  mov    %rax,(%r14)
  jmp    L7
L5:
  mov    $0xffffffff,%ebx
  jmp    L7
L26:
  mov    $0xffffffff,%ebx
  jmp    L7
L43:
  mov    $0xffffffff,%ebx
  jmp    L7
```

assistant: ```c
int vasprintf(char **s, const char *fmt, va_list ap) {
  va_list ap2;
  char *a;
  int l = 240U;
  if (!(a = malloc(240U)))
    return -1;
  va_copy(ap2, ap);
  l = vsnprintf(a, 240U, fmt, ap2);
  va_end(ap2);
  if (l < 240U) {
    char *b = realloc(a, l + 1U);
    *s = b ? b : a;
    return l;
  }
  free(a);
  if (l < 0 || !(*s = malloc(l + 1U)))
    return -1;
  return vsnprintf(*s, l + 1U, fmt, ap);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<vasprintf>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    $0xf0,%edi
  sub    $0x8,%rsp
  call   <malloc@plt>
  test   %rax,%rax
  je     L13
  xor    %r15d,%r15d
  mov    %rax,%rbp
  mov    %r14d,%esi
  mov    %r15d,%edi
  call   <va_copy@plt>
  mov    %rbp,%rdi
  mov    %r15d,%ecx
  mov    %r13,%rdx
  mov    $0xf0,%esi
  call   <vsnprintf@plt>
  mov    %r15d,%edi
  mov    %eax,%r12d
  call   <va_end@plt>
  cmp    $0xef,%r12d
  jbe    L32
  mov    %rbp,%rdi
  call   <free@plt>
  test   %r12d,%r12d
  js     L13
  add    $0x1,%r12d
  mov    %r12d,%edi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  mov    %rax,%rdi
  test   %rax,%rax
  je     L13
  add    $0x8,%rsp
  mov    %r14d,%ecx
  mov    %r13,%rdx
  mov    %r12d,%esi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10c0 <vsnprintf@plt>
  cs nopw 0x0(%rax,%rax,1)
L32:
  lea    0x1(%r12),%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  test   %rax,%rax
  cmove  %rbp,%rax
  mov    %rax,(%rbx)
L2:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L13:
  mov    $0xffffffff,%r12d
  jmp    L2
```

assistant: ```c
int vasprintf(char **s, const char *fmt, va_list ap) {
  va_list ap2;
  char *a;
  int l = 240U;
  if (!(a = malloc(240U)))
    return -1;
  va_copy(ap2, ap);
  l = vsnprintf(a, 240U, fmt, ap2);
  va_end(ap2);
  if (l < 240U) {
    char *b = realloc(a, l + 1U);
    *s = b ? b : a;
    return l;
  }
  free(a);
  if (l < 0 || !(*s = malloc(l + 1U)))
    return -1;
  return vsnprintf(*s, l + 1U, fmt, ap);
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<vasprintf>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    $0xf0,%edi
  sub    $0x8,%rsp
  call   <malloc@plt>
  test   %rax,%rax
  je     L33
  xor    %r15d,%r15d
  mov    %rax,%rbp
  mov    %r14d,%esi
  mov    %r15d,%edi
  call   <va_copy@plt>
  mov    %rbp,%rdi
  mov    %r15d,%ecx
  mov    %r13,%rdx
  mov    $0xf0,%esi
  call   <vsnprintf@plt>
  mov    %r15d,%edi
  mov    %eax,%r12d
  call   <va_end@plt>
  cmp    $0xef,%r12d
  jbe    L43
  mov    %rbp,%rdi
  call   <free@plt>
  test   %r12d,%r12d
  js     L33
  add    $0x1,%r12d
  mov    %r12d,%edi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  mov    %rax,%rdi
  test   %rax,%rax
  je     L33
  add    $0x8,%rsp
  mov    %r14d,%ecx
  mov    %r13,%rdx
  mov    %r12d,%esi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10c0 <vsnprintf@plt>
  cs nopw 0x0(%rax,%rax,1)
L43:
  lea    0x1(%r12),%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  test   %rax,%rax
  cmove  %rbp,%rax
  mov    %rax,(%rbx)
L45:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L33:
  mov    $0xffffffff,%r12d
  jmp    L45
```

assistant: ```c
int vasprintf(char **s, const char *fmt, va_list ap) {
  va_list ap2;
  char *a;
  int l = 240U;
  if (!(a = malloc(240U)))
    return -1;
  va_copy(ap2, ap);
  l = vsnprintf(a, 240U, fmt, ap2);
  va_end(ap2);
  if (l < 240U) {
    char *b = realloc(a, l + 1U);
    *s = b ? b : a;
    return l;
  }
  free(a);
  if (l < 0 || !(*s = malloc(l + 1U)))
    return -1;
  return vsnprintf(*s, l + 1U, fmt, ap);
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<write_pwm>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x24(%rbp)
  movsd  %xmm0,-0x30(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x0,-0x24(%rbp)
  setg   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  movsd  -0x30(%rbp),%xmm0
  pxor   %xmm1,%xmm1
  comisd %xmm1,%xmm0
  setae  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  movsd  D19(%rip),%xmm0
  comisd -0x30(%rbp),%xmm0
  setae  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  movsd  -0x30(%rbp),%xmm0
  movsd  D19(%rip),%xmm2
  movapd %xmm0,%xmm1
  divsd  %xmm2,%xmm1
  movsd  D1(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%edx
  lea    -0xd(%rbp),%rax
  mov    %edx,%ecx
  lea    D11(%rip),%rdx
  mov    $0x5,%esi
  mov    %rax,%rdi
  call   <snprintf@plt>
  lea    -0xd(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  lea    -0xd(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D19
data_type: f64
name: extract_symbolic_data
arguments: data_tag: D1
data_type: byte[8]
name: extract_symbolic_data
arguments: data_tag: D11
data_type: string

tool: D19: 100

tool: {"D1": [0x00,0x00,0x00,0x00,0x00,0x40,0x8f,0x40]}

tool: D11: %d

assistant: ```c
void write_pwm(int pwm_fd, double percent) {
  assert(pwm_fd > 0);
  assert(percent >= 0);
  assert(percent <= 100.0);
  int value = (percent / 100.0) * (double)(1000);
  char buf[5];
  snprintf(buf, 5, "%d", value);
  write(pwm_fd, buf, strlen(buf));
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<write_pwm>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,%ebx
  movsd  %xmm0,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  setg   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movsd  0x8(%rsp),%xmm1
  comisd D10(%rip),%xmm1
  setae  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movsd  D24(%rip),%xmm2
  comisd 0x8(%rsp),%xmm2
  setae  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movsd  0x8(%rsp),%xmm0
  divsd  D24(%rip),%xmm0
  mulsd  D41(%rip),%xmm0
  cvttsd2si %xmm0,%ecx
  lea    0x13(%rsp),%rbp
  lea    D12(%rip),%rdx
  mov    $0x5,%esi
  mov    %rbp,%rdi
  call   <snprintf@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <write@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L6
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
L6:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D10
datatype: byte[16]
name: retrieve_data
arguments: data_label: D24
datatype: f64
name: retrieve_data
arguments: data_label: D41
datatype: byte[8]
name: retrieve_data
arguments: data_label: D12
datatype: string

tool: {"D10": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x40]}

tool: D24: 100

tool: {"D41": [0x00,0x00,0x00,0x00,0x00,0x40,0x8f,0x40]}

tool: D12: %d

assistant: ```c
void write_pwm(int pwm_fd, double percent) {
  assert(pwm_fd > 0);
  assert(percent >= 0);
  assert(percent <= 100.0);
  int value = (percent / 100.0) * (double)(1000);
  char buf[5];
  snprintf(buf, 5, "%d", value);
  write(pwm_fd, buf, strlen(buf));
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<write_pwm>:
  endbr64
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  sub    $0x28,%rsp
  movsd  %xmm0,0x8(%rsp)
  lea    0x13(%rsp),%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  setg   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movsd  0x8(%rsp),%xmm1
  xor    %edi,%edi
  comisd D32(%rip),%xmm1
  setae  %dil
  call   <assert@plt>
  movsd  D37(%rip),%xmm2
  xor    %edi,%edi
  comisd 0x8(%rsp),%xmm2
  setae  %dil
  call   <assert@plt>
  movsd  0x8(%rsp),%xmm0
  mov    $0x5,%esi
  mov    %r12,%rdi
  divsd  D37(%rip),%xmm0
  mulsd  D40(%rip),%xmm0
  lea    D7(%rip),%rdx
  cvttsd2si %xmm0,%ecx
  call   <snprintf@plt>
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %r12,%rsi
  mov    %ebp,%edi
  mov    %eax,%edx
  call   <write@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L7
  add    $0x28,%rsp
  pop    %rbp
  pop    %r12
  ret
L7:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D32
data_type: byte[16]
name: disassemble_data
arguments: data_label: D37
data_type: f64
name: disassemble_data
arguments: data_label: D40
data_type: byte[8]
name: disassemble_data
arguments: data_label: D7
data_type: string

tool: {"D32": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x40]}

tool: D37: 100

tool: {"D40": [0x00,0x00,0x00,0x00,0x00,0x40,0x8f,0x40]}

tool: D7: %d

assistant: ```c
void write_pwm(int pwm_fd, double percent) {
  assert(pwm_fd > 0);
  assert(percent >= 0);
  assert(percent <= 100.0);
  int value = (percent / 100.0) * (double)(1000);
  char buf[5];
  snprintf(buf, 5, "%d", value);
  write(pwm_fd, buf, strlen(buf));
}
```