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

```asm
<rabin_karp_search>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%rbx
  mov    %rdi,0x18(%rsp)
  mov    %rsi,%r15
  mov    %edx,%ebp
  mov    %rsi,%rdi
  call   <strlen@plt>
  mov    %eax,%r14d
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %eax,0x14(%rsp)
  cmp    $0x1,%eax
  jle    L68
  lea    -0x1(%rax),%esi
  mov    $0x0,%ecx
  mov    $0x1,%r13d
  mov    %r13d,%edx
L30:
  mov    %edx,%eax
  shl    $0x8,%eax
  cltd
  idiv   %ebp
  add    $0x1,%ecx
  cmp    %esi,%ecx
  jne    L30
  mov    %edx,%r13d
L94:
  mov    0x14(%rsp),%eax
  test   %eax,%eax
  jle    L38
  mov    %eax,%esi
  mov    $0x0,%ecx
  mov    $0x0,%ebx
  mov    $0x0,%r12d
  mov    0x18(%rsp),%rdi
L102:
  mov    %r12d,%edx
  shl    $0x8,%edx
  movsbl (%rdi,%rcx,1),%eax
  add    %edx,%eax
  cltd
  idiv   %ebp
  mov    %edx,%r12d
  mov    %ebx,%eax
  shl    $0x8,%eax
  movsbl (%r15,%rcx,1),%edx
  add    %edx,%eax
  cltd
  idiv   %ebp
  mov    %edx,%ebx
  add    $0x1,%rcx
  cmp    %rsi,%rcx
  jne    L102
L23:
  mov    0x14(%rsp),%eax
  sub    %eax,%r14d
  test   %r14d,%r14d
  jle    L89
  mov    %r14d,%edi
  mov    %rdi,(%rsp)
  mov    $0x0,%r14d
  cltq
  add    %r15,%rax
  mov    %rax,0x8(%rsp)
  jmp    L87
L68:
  mov    $0x1,%r13d
  jmp    L94
L38:
  mov    $0x0,%ebx
  mov    $0x0,%r12d
  jmp    L23
L98:
  movsbl (%r15,%r14,1),%eax
  imul   %r13d,%eax
  sub    %eax,%ebx
  shl    $0x8,%ebx
  mov    0x8(%rsp),%rax
  movsbl (%rax,%r14,1),%eax
  add    %ebx,%eax
  cltd
  idiv   %ebp
  lea    (%rdx,%rbp,1),%ebx
  test   %edx,%edx
  cmovns %edx,%ebx
  add    $0x1,%r14
  cmp    %r14,(%rsp)
  je     L89
L87:
  mov    %r14d,0x10(%rsp)
  mov    %r14d,%edx
  cmp    %ebx,%r12d
  jne    L98
  mov    0x14(%rsp),%ecx
  mov    %r15,%rsi
  mov    0x18(%rsp),%rdi
  call   <is_str_equal@plt>
  test   %rax,%rax
  je     L98
  mov    0x10(%rsp),%esi
  add    $0x1,%esi
  lea    D5(%rip),%rdi
  call   <printf@plt>
  jmp    L98
L89:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: label: D5
datatype: string

tool: D5: String found at location: %d


assistant: ```c
void rabin_karp_search(char pat[], char txt[], int q) {
  int n = strlen(txt);
  int m = strlen(pat);
  int p = 0;
  int t = 0;
  int h = 1;
  int i, s;
  for (i = 0; i < m - 1; i++) {
    h = (h * 256) % q;
  }
  for (i = 0; i < m; i++) {
    p = (256 * p + pat[i]) % q;
    t = (256 * t + txt[i]) % q;
  }
  for (s = 0; s < n - m; s++) {
    if ((p == t) && (is_str_equal(pat, txt, s, m))) {
      printf("String found at location: %d\n", s + 1);
    }
    if (s < n - m) {
      t = (256 * (t - txt[s] * h) + txt[s + m]) % q;
      if (t < 0)
        t += q;
    }
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<rabin_karp_search>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rsi,%rdi
  mov    %rsi,0x10(%rsp)
  call   <strlen@plt>
  mov    0x8(%rsp),%rdi
  mov    %eax,%r14d
  call   <strlen@plt>
  mov    0x8(%rsp),%r10
  mov    0x10(%rsp),%r9
  lea    -0x1(%rax),%edi
  mov    %eax,%ecx
  test   %edi,%edi
  jle    L68
  xor    %esi,%esi
  mov    $0x1,%edx
  nopl   0x0(%rax)
L103:
  mov    %edx,%eax
  add    $0x1,%esi
  shl    $0x8,%eax
  cltd
  idiv   %ebp
  cmp    %edi,%esi
  jne    L103
  mov    %edx,%r13d
  test   %ecx,%ecx
  jle    L0
L104:
  movslq %ecx,%r8
  xor    %esi,%esi
  xor    %ebx,%ebx
  xor    %r12d,%r12d
  nopl   0x0(%rax)
L25:
  movsbl (%r10,%rsi,1),%eax
  mov    %r12d,%edx
  shl    $0x8,%edx
  add    %edx,%eax
  cltd
  idiv   %ebp
  mov    %ebx,%eax
  shl    $0x8,%eax
  mov    %edx,%r12d
  movsbl (%r9,%rsi,1),%edx
  add    $0x1,%rsi
  add    %edx,%eax
  cltd
  idiv   %ebp
  mov    %edx,%ebx
  cmp    %rsi,%r8
  jne    L25
L62:
  mov    %r14d,%r11d
  mov    %r9,%r15
  xor    %r14d,%r14d
  movslq %ecx,%r8
  sub    %ecx,%r11d
  test   %r11d,%r11d
  jle    L83
  mov    %ecx,0x1c(%rsp)
  mov    %r10,0x20(%rsp)
  mov    %r9,0x28(%rsp)
  jmp    L81
  nopl   (%rax)
L30:
  movsbl (%r15),%eax
  imul   %r13d,%eax
  sub    %eax,%ebx
  movsbl (%r15,%r8,1),%eax
  shl    $0x8,%ebx
  add    %ebx,%eax
  cltd
  idiv   %ebp
  test   %edx,%edx
  lea    (%rdx,%rbp,1),%ebx
  cmovns %edx,%ebx
  add    $0x1,%r15
  cmp    %r14d,%r11d
  je     L83
L81:
  mov    %r14d,%edx
  add    $0x1,%r14d
  cmp    %ebx,%r12d
  jne    L30
  mov    0x1c(%rsp),%ecx
  mov    0x28(%rsp),%rsi
  mov    %r8,0x10(%rsp)
  mov    0x20(%rsp),%rdi
  mov    %r11d,0x8(%rsp)
  call   <is_str_equal@plt>
  mov    0x8(%rsp),%r11d
  mov    0x10(%rsp),%r8
  test   %rax,%rax
  je     L30
  mov    %r14d,%esi
  lea    D3(%rip),%rdi
  call   <printf@plt>
  mov    0x10(%rsp),%r8
  mov    0x8(%rsp),%r11d
  jmp    L30
  nopl   0x0(%rax,%rax,1)
L83:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L68:
  mov    $0x1,%r13d
  test   %ecx,%ecx
  jg     L104
  xchg   %ax,%ax
L0:
  xor    %ebx,%ebx
  xor    %r12d,%r12d
  jmp    L62
```

tool_calls: name: unpack_data
arguments: data_tag: D3
type_guessed: string

tool: D3: String found at location: %d


assistant: ```c
void rabin_karp_search(char pat[], char txt[], int q) {
  int n = strlen(txt);
  int m = strlen(pat);
  int p = 0;
  int t = 0;
  int h = 1;
  int i, s;
  for (i = 0; i < m - 1; i++) {
    h = (h * 256) % q;
  }
  for (i = 0; i < m; i++) {
    p = (256 * p + pat[i]) % q;
    t = (256 * t + txt[i]) % q;
  }
  for (s = 0; s < n - m; s++) {
    if ((p == t) && (is_str_equal(pat, txt, s, m))) {
      printf("String found at location: %d\n", s + 1);
    }
    if (s < n - m) {
      t = (256 * (t - txt[s] * h) + txt[s + m]) % q;
      if (t < 0)
        t += q;
    }
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<rabin_karp_search>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rsi,%rdi
  mov    %rsi,0x10(%rsp)
  call   <strlen@plt>
  mov    0x8(%rsp),%rdi
  mov    %eax,%r14d
  call   <strlen@plt>
  mov    0x8(%rsp),%r10
  mov    0x10(%rsp),%r9
  lea    -0x1(%rax),%edi
  mov    %eax,%ecx
  test   %edi,%edi
  jle    L74
  xor    %esi,%esi
  mov    $0x1,%edx
  nopl   0x0(%rax)
L66:
  mov    %edx,%eax
  add    $0x1,%esi
  shl    $0x8,%eax
  cltd
  idiv   %ebp
  cmp    %edi,%esi
  jne    L66
  mov    %edx,%r13d
  test   %ecx,%ecx
  jle    L15
L63:
  movslq %ecx,%r8
  xor    %esi,%esi
  xor    %ebx,%ebx
  xor    %r12d,%r12d
  nopl   0x0(%rax)
L45:
  movsbl (%r10,%rsi,1),%eax
  mov    %r12d,%edx
  shl    $0x8,%edx
  add    %edx,%eax
  cltd
  idiv   %ebp
  mov    %ebx,%eax
  shl    $0x8,%eax
  mov    %edx,%r12d
  movsbl (%r9,%rsi,1),%edx
  add    $0x1,%rsi
  add    %edx,%eax
  cltd
  idiv   %ebp
  mov    %edx,%ebx
  cmp    %rsi,%r8
  jne    L45
L8:
  mov    %r14d,%r11d
  mov    %r9,%r15
  xor    %r14d,%r14d
  movslq %ecx,%r8
  sub    %ecx,%r11d
  test   %r11d,%r11d
  jle    L31
  mov    %ecx,0x1c(%rsp)
  mov    %r10,0x20(%rsp)
  mov    %r9,0x28(%rsp)
  jmp    L58
  nopl   (%rax)
L35:
  movsbl (%r15),%eax
  imul   %r13d,%eax
  sub    %eax,%ebx
  movsbl (%r15,%r8,1),%eax
  shl    $0x8,%ebx
  add    %ebx,%eax
  cltd
  idiv   %ebp
  test   %edx,%edx
  lea    (%rdx,%rbp,1),%ebx
  cmovns %edx,%ebx
  add    $0x1,%r15
  cmp    %r14d,%r11d
  je     L31
L58:
  mov    %r14d,%edx
  add    $0x1,%r14d
  cmp    %ebx,%r12d
  jne    L35
  mov    0x1c(%rsp),%ecx
  mov    0x28(%rsp),%rsi
  mov    %r8,0x10(%rsp)
  mov    0x20(%rsp),%rdi
  mov    %r11d,0x8(%rsp)
  call   <is_str_equal@plt>
  mov    0x8(%rsp),%r11d
  mov    0x10(%rsp),%r8
  test   %rax,%rax
  je     L35
  mov    %r14d,%esi
  lea    D9(%rip),%rdi
  call   <printf@plt>
  mov    0x10(%rsp),%r8
  mov    0x8(%rsp),%r11d
  jmp    L35
  nopl   0x0(%rax,%rax,1)
L31:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L74:
  mov    $0x1,%r13d
  test   %ecx,%ecx
  jg     L63
  xchg   %ax,%ax
L15:
  xor    %ebx,%ebx
  xor    %r12d,%r12d
  jmp    L8
```

tool_calls: name: unpack_data
arguments: label: D9
type: string

tool: D9: String found at location: %d


assistant: ```c
void rabin_karp_search(char pat[], char txt[], int q) {
  int n = strlen(txt);
  int m = strlen(pat);
  int p = 0;
  int t = 0;
  int h = 1;
  int i, s;
  for (i = 0; i < m - 1; i++) {
    h = (h * 256) % q;
  }
  for (i = 0; i < m; i++) {
    p = (256 * p + pat[i]) % q;
    t = (256 * t + txt[i]) % q;
  }
  for (s = 0; s < n - m; s++) {
    if ((p == t) && (is_str_equal(pat, txt, s, m))) {
      printf("String found at location: %d\n", s + 1);
    }
    if (s < n - m) {
      t = (256 * (t - txt[s] * h) + txt[s + m]) % q;
      if (t < 0)
        t += q;
    }
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<moto_send>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %ax,-0x22(%rbp)
  movzwl -0x22(%rbp),%eax
  add    $0x7,%eax
  movzwl %ax,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L58
  mov    $0xffffffff,%eax
  jmp    L41
L58:
  movzwl -0x22(%rbp),%eax
  add    $0x7,%eax
  movzwl %ax,%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <bzero@plt>
  mov    -0x20(%rbp),%rax
  movb   $0x40,(%rax)
  mov    -0x20(%rbp),%rax
  add    $0x1,%rax
  movb   $0x40,(%rax)
  mov    -0x20(%rbp),%rax
  lea    0x2(%rax),%rdx
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  mov    -0x20(%rbp),%rax
  lea    0x3(%rax),%rdx
  mov    -0x40(%rbp),%rax
  movzbl 0x1(%rax),%eax
  mov    %al,(%rdx)
  cmpw   $0x0,-0x22(%rbp)
  je     L7
  movzwl -0x22(%rbp),%edx
  mov    -0x20(%rbp),%rax
  lea    0x4(%rax),%rcx
  mov    -0x48(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <gpsd_hexpack@plt>
  cmp    $0xffffffff,%eax
  jne    L7
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
  jmp    L41
L7:
  movzwl -0x22(%rbp),%eax
  add    $0x2,%eax
  movzwl %ax,%eax
  mov    -0x20(%rbp),%rdx
  add    $0x2,%rdx
  movzwl -0x22(%rbp),%ecx
  lea    0x4(%rcx),%rsi
  mov    -0x20(%rbp),%rcx
  lea    (%rsi,%rcx,1),%rbx
  mov    %eax,%esi
  mov    %rdx,%rdi
  call   <moto_gen_checksum@plt>
  mov    %al,(%rbx)
  movzwl -0x22(%rbp),%eax
  lea    0x5(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0xd,(%rax)
  movzwl -0x22(%rbp),%eax
  lea    0x6(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0xa,(%rax)
  movzwl -0x22(%rbp),%eax
  add    $0x7,%eax
  movzwl %ax,%edx
  mov    -0x20(%rbp),%rcx
  mov    -0x34(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0xffffffffffffffff,-0x18(%rbp)
  jne    L25
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
L25:
  mov    -0x18(%rbp),%rax
L41:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: parse_data
arguments: label: D9
data_type: string

tool: D9: moto_send

assistant: ```c
int moto_send(int fd, char *type, char *body) {
  size_t status;
  char *buf;
  unsigned short l;
  l = strlen(body) / 2;
  if ((buf = malloc(l + 7)) == NULL)
    return -1;
  bzero(buf, l + 7);
  buf[0] = '@';
  buf[1] = '@';
  buf[2] = type[0];
  buf[3] = type[1];
  if (l)
    if (gpsd_hexpack(body, buf + 4, l) == -1) {
      free(buf);
      return -1;
    }
  buf[l + 4] = moto_gen_checksum(buf + 2, l + 2);
  buf[l + 5] = '\r';
  buf[l + 6] = '\n';
  status = write(fd, buf, l + 7);
  if (status == -1)
    perror("moto_send");
  return (int)status;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<moto_send>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edi,%r13d
  mov    %rsi,%r14
  mov    %rdx,%r15
  mov    %rdx,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  shr    $0x1f,%edx
  lea    (%rdx,%rax,1),%ebp
  sar    %ebp
  lea    0x7(%rbp),%r12d
  movzwl %r12w,%r12d
  mov    %r12d,%edi
  call   <malloc@plt>
  test   %rax,%rax
  je     L5
  mov    %rax,%rbx
  mov    %r12d,%esi
  mov    %rax,%rdi
  call   <bzero@plt>
  movb   $0x40,(%rbx)
  movb   $0x40,0x1(%rbx)
  movzbl (%r14),%eax
  mov    %al,0x2(%rbx)
  movzbl 0x1(%r14),%eax
  mov    %al,0x3(%rbx)
  test   %bp,%bp
  je     L33
  movzwl %bp,%edx
  lea    0x4(%rbx),%rsi
  mov    %r15,%rdi
  call   <gpsd_hexpack@plt>
  mov    %eax,%r14d
  cmp    $0xffffffff,%eax
  je     L65
L33:
  movzwl %bp,%r14d
  lea    0x4(%rbx,%r14,1),%r15
  lea    0x2(%rbp),%esi
  movzwl %si,%esi
  lea    0x2(%rbx),%rdi
  call   <moto_gen_checksum@plt>
  mov    %al,(%r15)
  movb   $0xd,0x5(%rbx,%r14,1)
  movb   $0xa,0x6(%rbx,%r14,1)
  mov    %r12d,%edx
  mov    %rbx,%rsi
  mov    %r13d,%edi
  call   <write@plt>
  mov    %rax,%r14
  cmp    $0xffffffffffffffff,%rax
  je     L29
L34:
  mov    %r14d,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L65:
  mov    %rbx,%rdi
  call   <free@plt>
  jmp    L34
L29:
  lea    D4(%rip),%rdi
  call   <perror@plt>
  jmp    L34
L5:
  mov    $0xffffffff,%r14d
  jmp    L34
```

tool_calls: name: retrieve_data
arguments: data_tag: D4
data_type: string

tool: D4: moto_send

assistant: ```c
int moto_send(int fd, char *type, char *body) {
  size_t status;
  char *buf;
  unsigned short l;
  l = strlen(body) / 2;
  if ((buf = malloc(l + 7)) == NULL)
    return -1;
  bzero(buf, l + 7);
  buf[0] = '@';
  buf[1] = '@';
  buf[2] = type[0];
  buf[3] = type[1];
  if (l)
    if (gpsd_hexpack(body, buf + 4, l) == -1) {
      free(buf);
      return -1;
    }
  buf[l + 4] = moto_gen_checksum(buf + 2, l + 2);
  buf[l + 5] = '\r';
  buf[l + 6] = '\n';
  status = write(fd, buf, l + 7);
  if (status == -1)
    perror("moto_send");
  return (int)status;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<moto_send>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %edi,%r13d
  mov    %rdx,%rdi
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  call   <strlen@plt>
  mov    %eax,%edx
  shr    $0x1f,%edx
  lea    (%rdx,%rax,1),%ebx
  sar    %ebx
  lea    0x7(%rbx),%r12d
  movzwl %r12w,%r12d
  mov    %r12d,%edi
  call   <malloc@plt>
  test   %rax,%rax
  je     L51
  mov    %r12d,%esi
  mov    %rax,%rdi
  mov    %rax,%rbp
  call   <bzero@plt>
  mov    $0x4040,%eax
  mov    %ax,0x0(%rbp)
  movzbl (%r15),%eax
  mov    %al,0x2(%rbp)
  movzbl 0x1(%r15),%eax
  mov    %al,0x3(%rbp)
  test   %bx,%bx
  jne    L17
L61:
  lea    0x2(%rbx),%esi
  movzwl %bx,%r14d
  lea    0x2(%rbp),%rdi
  movzwl %si,%esi
  lea    0x4(%rbp,%r14,1),%r15
  call   <moto_gen_checksum@plt>
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %r13d,%edi
  mov    %al,(%r15)
  movb   $0xd,0x5(%rbp,%r14,1)
  movb   $0xa,0x6(%rbp,%r14,1)
  call   <write@plt>
  mov    %rax,%r14
  cmp    $0xffffffffffffffff,%rax
  je     L3
L34:
  add    $0x8,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L17:
  mov    %r14,%rdi
  movzwl %bx,%edx
  lea    0x4(%rbp),%rsi
  call   <gpsd_hexpack@plt>
  mov    %eax,%r14d
  cmp    $0xffffffff,%eax
  jne    L61
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L34
  nopl   0x0(%rax)
L3:
  lea    D4(%rip),%rdi
  call   <perror@plt>
  jmp    L34
L51:
  mov    $0xffffffff,%r14d
  jmp    L34
```

tool_calls: name: read_data
arguments: label: D4
type_infered: string

tool: D4: moto_send

assistant: ```c
int moto_send(int fd, char *type, char *body) {
  size_t status;
  char *buf;
  unsigned short l;
  l = strlen(body) / 2;
  if ((buf = malloc(l + 7)) == NULL)
    return -1;
  bzero(buf, l + 7);
  buf[0] = '@';
  buf[1] = '@';
  buf[2] = type[0];
  buf[3] = type[1];
  if (l)
    if (gpsd_hexpack(body, buf + 4, l) == -1) {
      free(buf);
      return -1;
    }
  buf[l + 4] = moto_gen_checksum(buf + 2, l + 2);
  buf[l + 5] = '\r';
  buf[l + 6] = '\n';
  status = write(fd, buf, l + 7);
  if (status == -1)
    perror("moto_send");
  return (int)status;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<moto_send>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %edi,%r13d
  mov    %rdx,%rdi
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  call   <strlen@plt>
  mov    %eax,%edx
  shr    $0x1f,%edx
  lea    (%rdx,%rax,1),%ebx
  sar    %ebx
  lea    0x7(%rbx),%r12d
  movzwl %r12w,%r12d
  mov    %r12d,%edi
  call   <malloc@plt>
  test   %rax,%rax
  je     L8
  mov    %r12d,%esi
  mov    %rax,%rdi
  mov    %rax,%rbp
  call   <bzero@plt>
  mov    $0x4040,%eax
  mov    %ax,0x0(%rbp)
  movzbl (%r15),%eax
  mov    %al,0x2(%rbp)
  movzbl 0x1(%r15),%eax
  mov    %al,0x3(%rbp)
  test   %bx,%bx
  jne    L52
L59:
  lea    0x2(%rbx),%esi
  movzwl %bx,%r14d
  lea    0x2(%rbp),%rdi
  movzwl %si,%esi
  lea    0x4(%rbp,%r14,1),%r15
  call   <moto_gen_checksum@plt>
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %r13d,%edi
  mov    %al,(%r15)
  movb   $0xd,0x5(%rbp,%r14,1)
  movb   $0xa,0x6(%rbp,%r14,1)
  call   <write@plt>
  mov    %rax,%r14
  cmp    $0xffffffffffffffff,%rax
  je     L36
L7:
  add    $0x8,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L52:
  mov    %r14,%rdi
  movzwl %bx,%edx
  lea    0x4(%rbp),%rsi
  call   <gpsd_hexpack@plt>
  mov    %eax,%r14d
  cmp    $0xffffffff,%eax
  jne    L59
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L7
  nopl   0x0(%rax)
L36:
  lea    D7(%rip),%rdi
  call   <perror@plt>
  jmp    L7
L8:
  mov    $0xffffffff,%r14d
  jmp    L7
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D7
datatype: string

tool: D7: moto_send

assistant: ```c
int moto_send(int fd, char *type, char *body) {
  size_t status;
  char *buf;
  unsigned short l;
  l = strlen(body) / 2;
  if ((buf = malloc(l + 7)) == NULL)
    return -1;
  bzero(buf, l + 7);
  buf[0] = '@';
  buf[1] = '@';
  buf[2] = type[0];
  buf[3] = type[1];
  if (l)
    if (gpsd_hexpack(body, buf + 4, l) == -1) {
      free(buf);
      return -1;
    }
  buf[l + 4] = moto_gen_checksum(buf + 2, l + 2);
  buf[l + 5] = '\r';
  buf[l + 6] = '\n';
  status = write(fd, buf, l + 7);
  if (status == -1)
    perror("moto_send");
  return (int)status;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<BasisFuns>:
  endbr64
  push   %rbx
  mov    D9(%rip),%rbx
  mov    %rbx,(%rcx)
  test   %esi,%esi
  jle    L27
  mov    %edi,%eax
  lea    0x8(%r8),%rdi
  lea    0x1(%rsi),%ebx
  cltq
  lea    (%rdx,%rax,8),%r11
  mov    $0x8,%r8d
  mov    $0x1,%r10d
L22:
  mov    %r8,%rax
  neg    %rax
  movapd %xmm0,%xmm1
  subsd  0x8(%r11,%rax,1),%xmm1
  movsd  %xmm1,(%rdi)
  movsd  (%r11,%r8,1),%xmm1
  subsd  %xmm0,%xmm1
  movsd  %xmm1,(%r9,%r8,1)
  movsd  0x8(%r9),%xmm1
  movapd %xmm1,%xmm2
  addsd  (%rdi),%xmm2
  movsd  (%rcx),%xmm3
  divsd  %xmm2,%xmm3
  mulsd  %xmm3,%xmm1
  movsd  %xmm1,(%rcx)
  mulsd  (%rdi),%xmm3
  cmp    $0x1,%r10d
  jle    L19
  mov    %r10d,%esi
  mov    %rdi,%rdx
  mov    $0x1,%eax
L28:
  movsd  0x8(%r9,%rax,8),%xmm1
  movapd %xmm1,%xmm4
  addsd  -0x8(%rdx),%xmm4
  movsd  (%rcx,%rax,8),%xmm2
  divsd  %xmm4,%xmm2
  mulsd  %xmm2,%xmm1
  addsd  %xmm3,%xmm1
  movsd  %xmm1,(%rcx,%rax,8)
  movapd %xmm2,%xmm3
  mulsd  -0x8(%rdx),%xmm3
  add    $0x1,%rax
  sub    $0x8,%rdx
  cmp    %rsi,%rax
  jne    L28
L19:
  movsd  %xmm3,(%rcx,%r8,1)
  add    $0x1,%r10d
  add    $0x8,%rdi
  add    $0x8,%r8
  cmp    %ebx,%r10d
  jne    L22
L27:
  pop    %rbx
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D9
type_guessed: f64

tool: D9: 1

assistant: ```c
void BasisFuns(int i, double u, int p, double *U, double *N, double *left, double *right) {
  int j;
  double saved, temp;
  int r;
  N[0] = 1.0;
  for (j = 1; j <= p; j++) {
    left[j] = u - U[i + 1 - j];
    right[j] = U[i + j] - u;
    temp = N[0] / (right[1] + left[j]);
    N[0] = right[1] * temp;
    saved = left[j] * temp;
    for (r = 1; r < j; r++) {
      temp = N[r] / (right[r + 1] + left[j - r]);
      N[r] = saved + right[r + 1] * temp;
      saved = left[j - r] * temp;
    }
    N[j] = saved;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<BasisFuns>:
  endbr64
  push   %rbx
  mov    D3(%rip),%rbx
  mov    %rbx,(%rcx)
  test   %esi,%esi
  jle    L6
  movslq %edi,%rax
  lea    0x1(%rsi),%ebx
  lea    0x8(%r8),%rdi
  mov    $0x1,%r10d
  lea    (%rdx,%rax,8),%r11
  mov    $0x8,%r8d
  nopl   0x0(%rax)
L2:
  mov    %r8,%rax
  movapd %xmm0,%xmm1
  neg    %rax
  subsd  0x8(%r11,%rax,1),%xmm1
  movsd  %xmm1,(%rdi)
  movsd  (%r11,%r8,1),%xmm1
  subsd  %xmm0,%xmm1
  movsd  %xmm1,(%r9,%r8,1)
  movsd  0x8(%r9),%xmm1
  movsd  (%rdi),%xmm2
  movsd  (%rcx),%xmm3
  addsd  %xmm1,%xmm2
  divsd  %xmm2,%xmm3
  mulsd  %xmm3,%xmm1
  movsd  %xmm1,(%rcx)
  mulsd  (%rdi),%xmm3
  cmp    $0x1,%r10d
  je     L24
  movslq %r10d,%rsi
  mov    %rdi,%rdx
  mov    $0x1,%eax
L4:
  movsd  0x8(%r9,%rax,8),%xmm1
  movsd  -0x8(%rdx),%xmm4
  sub    $0x8,%rdx
  movsd  (%rcx,%rax,8),%xmm2
  addsd  %xmm1,%xmm4
  divsd  %xmm4,%xmm2
  mulsd  %xmm2,%xmm1
  addsd  %xmm3,%xmm1
  movsd  %xmm1,(%rcx,%rax,8)
  movsd  (%rdx),%xmm3
  add    $0x1,%rax
  mulsd  %xmm2,%xmm3
  cmp    %rax,%rsi
  jne    L4
L24:
  add    $0x1,%r10d
  movsd  %xmm3,(%rcx,%r8,1)
  add    $0x8,%rdi
  add    $0x8,%r8
  cmp    %ebx,%r10d
  jne    L2
L6:
  pop    %rbx
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D3
datatype: f64

tool: D3: 1

assistant: ```c
void BasisFuns(int i, double u, int p, double *U, double *N, double *left, double *right) {
  int j;
  double saved, temp;
  int r;
  N[0] = 1.0;
  for (j = 1; j <= p; j++) {
    left[j] = u - U[i + 1 - j];
    right[j] = U[i + j] - u;
    temp = N[0] / (right[1] + left[j]);
    N[0] = right[1] * temp;
    saved = left[j] * temp;
    for (r = 1; r < j; r++) {
      temp = N[r] / (right[r + 1] + left[j - r]);
      N[r] = saved + right[r + 1] * temp;
      saved = left[j - r] * temp;
    }
    N[j] = saved;
  }
}
```