ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Translate the below assembly code into C programming language:

```asm
<has_suffix>:
  endbr64
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  call   <strstr@plt>
  test   %rax,%rax
  je     L1
  mov    %rbx,%rdi
  mov    %rax,%r12
  call   <strlen@plt>
  mov    %r13,%rdi
  mov    %rax,%rbp
  call   <strlen@plt>
  sub    %rax,%rbp
  xor    %eax,%eax
  add    %rbp,%rbx
  cmp    %rbx,%r12
  sete   %al
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L1:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int has_suffix(const char *str, const char *suffix) {
  const char *tmp = strstr(str, suffix);
  if (!tmp)
    return 0;
  return str + strlen(str) - strlen(suffix) == tmp;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<check_built>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  movl   $0x0,-0x14(%rbp)
  lea    D2(%rip),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  mov    $0x20,%esi
  mov    %rax,%rdi
  call   <my_str_to_wordtab@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L42
  mov    $0x0,%eax
  jmp    L19
L40:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <my_strncmp@plt>
  test   %rax,%rax
  jne    L20
  mov    $0x1,%eax
  jmp    L19
L20:
  addl   $0x1,-0x14(%rbp)
L42:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L40
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
L19:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: label: D2
type_guessed: string

tool: D2: cd .. env exit setenv unsetenv

assistant: ```c
int check_built(char **save) {
  int i;
  char *str;
  char **tab;
  i = 0;
  str = "cd .. env exit setenv unsetenv";
  tab = my_str_to_wordtab(str, ' ');
  if (save == NULL)
    return (0);
  while (tab[i]) {
    if ((my_strncmp(tab[i], save[0])) == 0)
      return (1);
    i++;
  }
  free(tab);
  return (0);
}
```
user: What is the c source code of the assembly code below?

```asm
<check_built>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  mov    $0x20,%esi
  lea    D9(%rip),%rdi
  call   <my_str_to_wordtab@plt>
  test   %rbp,%rbp
  je     L4
  mov    %rax,%r12
  mov    (%rax),%rdi
  test   %rdi,%rdi
  je     L45
  lea    0x8(%rax),%rbx
L58:
  mov    0x0(%rbp),%rsi
  call   <my_strncmp@plt>
  test   %rax,%rax
  je     L23
  add    $0x8,%rbx
  mov    -0x8(%rbx),%rdi
  test   %rdi,%rdi
  jne    L58
L45:
  mov    %r12,%rdi
  call   <free@plt>
  mov    $0x0,%eax
L14:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L4:
  mov    $0x0,%eax
  jmp    L14
L23:
  mov    $0x1,%eax
  jmp    L14
```

tool_calls: name: parse_data
arguments: tag: D9
type_guessed: string

tool: D9: cd .. env exit setenv unsetenv

assistant: ```c
int check_built(char **save) {
  int i;
  char *str;
  char **tab;
  i = 0;
  str = "cd .. env exit setenv unsetenv";
  tab = my_str_to_wordtab(str, ' ');
  if (save == NULL)
    return (0);
  while (tab[i]) {
    if ((my_strncmp(tab[i], save[0])) == 0)
      return (1);
    i++;
  }
  free(tab);
  return (0);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<check_built>:
  endbr64
  push   %r12
  mov    $0x20,%esi
  push   %rbp
  mov    %rdi,%rbp
  lea    D9(%rip),%rdi
  push   %rbx
  call   <my_str_to_wordtab@plt>
  test   %rbp,%rbp
  je     L27
  mov    (%rax),%rdi
  mov    %rax,%r12
  test   %rdi,%rdi
  je     L7
  lea    0x8(%rax),%rbx
  jmp    L2
  nopw   0x0(%rax,%rax,1)
L12:
  mov    (%rbx),%rdi
  add    $0x8,%rbx
  test   %rdi,%rdi
  je     L7
L2:
  mov    0x0(%rbp),%rsi
  call   <my_strncmp@plt>
  test   %rax,%rax
  jne    L12
  pop    %rbx
  mov    $0x1,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L7:
  mov    %r12,%rdi
  call   <free@plt>
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
  nop
L27:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: read_data
arguments: data_label: D9
type_guessed: string

tool: D9: cd .. env exit setenv unsetenv

assistant: ```c
int check_built(char **save) {
  int i;
  char *str;
  char **tab;
  i = 0;
  str = "cd .. env exit setenv unsetenv";
  tab = my_str_to_wordtab(str, ' ');
  if (save == NULL)
    return (0);
  while (tab[i]) {
    if ((my_strncmp(tab[i], save[0])) == 0)
      return (1);
    i++;
  }
  free(tab);
  return (0);
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<check_built>:
  endbr64
  push   %r12
  mov    $0x20,%esi
  push   %rbp
  mov    %rdi,%rbp
  lea    D7(%rip),%rdi
  push   %rbx
  call   <my_str_to_wordtab@plt>
  test   %rbp,%rbp
  je     L12
  mov    (%rax),%rdi
  mov    %rax,%r12
  test   %rdi,%rdi
  je     L22
  lea    0x8(%rax),%rbx
  jmp    L42
  nopw   0x0(%rax,%rax,1)
L19:
  mov    (%rbx),%rdi
  add    $0x8,%rbx
  test   %rdi,%rdi
  je     L22
L42:
  mov    0x0(%rbp),%rsi
  call   <my_strncmp@plt>
  test   %rax,%rax
  jne    L19
  pop    %rbx
  mov    $0x1,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L22:
  mov    %r12,%rdi
  call   <free@plt>
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
  nop
L12:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
```

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

tool: D7: cd .. env exit setenv unsetenv

assistant: ```c
int check_built(char **save) {
  int i;
  char *str;
  char **tab;
  i = 0;
  str = "cd .. env exit setenv unsetenv";
  tab = my_str_to_wordtab(str, ' ');
  if (save == NULL)
    return (0);
  while (tab[i]) {
    if ((my_strncmp(tab[i], save[0])) == 0)
      return (1);
    i++;
  }
  free(tab);
  return (0);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<ssd1306_delay>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x34(%rbp),%eax
  mov    %eax,%eax
  imul   $0x10624dd3,%rax,%rax
  shr    $0x20,%rax
  shr    $0x6,%eax
  mov    %eax,%eax
  mov    %rax,-0x28(%rbp)
  mov    -0x34(%rbp),%edx
  mov    %edx,%eax
  imul   $0x10624dd3,%rax,%rax
  shr    $0x20,%rax
  shr    $0x6,%eax
  imul   $0x3e8,%eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,%eax
  imul   $0xf4240,%rax,%rax
  mov    %rax,-0x30(%rbp)
  lea    -0x20(%rbp),%rdx
  lea    -0x30(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <nanosleep@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L7
  call   <__stack_chk_fail@plt>
L7:
  leave
  ret
```

assistant: ```c
void ssd1306_delay(unsigned int ms) {
  struct timespec sleeper, dummy;
  sleeper.tv_sec = (time_t)(ms / 1000);
  sleeper.tv_nsec = (long)(ms % 1000) * 1000000;
  nanosleep(&sleeper, &dummy);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<ssd1306_delay>:
  endbr64
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  mov    %edi,%eax
  imul   $0x10624dd3,%rax,%rax
  shr    $0x26,%rax
  mov    %eax,%edx
  mov    %rdx,0x8(%rsp)
  imul   $0x3e8,%eax,%eax
  sub    %eax,%edi
  imul   $0xf4240,%rdi,%rdi
  mov    %rdi,(%rsp)
  lea    0x10(%rsp),%rsi
  mov    %rsp,%rdi
  call   <nanosleep@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  add    $0x38,%rsp
  ret
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void ssd1306_delay(unsigned int ms) {
  struct timespec sleeper, dummy;
  sleeper.tv_sec = (time_t)(ms / 1000);
  sleeper.tv_nsec = (long)(ms % 1000) * 1000000;
  nanosleep(&sleeper, &dummy);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<ssd1306_delay>:
  endbr64
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  mov    %edi,%eax
  lea    0x10(%rsp),%rsi
  imul   $0x10624dd3,%rax,%rax
  shr    $0x26,%rax
  mov    %eax,%edx
  imul   $0x3e8,%eax,%eax
  mov    %rdx,0x8(%rsp)
  sub    %eax,%edi
  imul   $0xf4240,%rdi,%rdi
  mov    %rdi,(%rsp)
  mov    %rsp,%rdi
  call   <nanosleep@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L1
  add    $0x38,%rsp
  ret
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void ssd1306_delay(unsigned int ms) {
  struct timespec sleeper, dummy;
  sleeper.tv_sec = (time_t)(ms / 1000);
  sleeper.tv_nsec = (long)(ms % 1000) * 1000000;
  nanosleep(&sleeper, &dummy);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<ssd1306_delay>:
  endbr64
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  mov    %edi,%eax
  lea    0x10(%rsp),%rsi
  imul   $0x10624dd3,%rax,%rax
  shr    $0x26,%rax
  imul   $0x3e8,%eax,%edx
  movd   %eax,%xmm1
  sub    %edx,%edi
  imul   $0xf4240,%rdi,%rcx
  mov    %rsp,%rdi
  movq   %rcx,%xmm0
  punpcklqdq %xmm1,%xmm0
  movaps %xmm0,(%rsp)
  call   <nanosleep@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L3
  add    $0x38,%rsp
  ret
L3:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void ssd1306_delay(unsigned int ms) {
  struct timespec sleeper, dummy;
  sleeper.tv_sec = (time_t)(ms / 1000);
  sleeper.tv_nsec = (long)(ms % 1000) * 1000000;
  nanosleep(&sleeper, &dummy);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<cpu_uint8_write>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %dl,(%rax)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void cpu_uint8_write(void *ptr, unsigned v) {
  unsigned char *ptr8 = (unsigned char *)ptr;
  ptr8[0] = (unsigned char)v;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<cpu_uint8_write>:
  endbr64
  mov    %sil,(%rdi)
  ret
```

assistant: ```c
void cpu_uint8_write(void *ptr, unsigned v) {
  unsigned char *ptr8 = (unsigned char *)ptr;
  ptr8[0] = (unsigned char)v;
}
```
user: What is the c source code of the assembly code below:

```asm
<cpu_uint8_write>:
  endbr64
  mov    %sil,(%rdi)
  ret
```

assistant: ```c
void cpu_uint8_write(void *ptr, unsigned v) {
  unsigned char *ptr8 = (unsigned char *)ptr;
  ptr8[0] = (unsigned char)v;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<cpu_uint8_write>:
  endbr64
  mov    %sil,(%rdi)
  ret
```

assistant: ```c
void cpu_uint8_write(void *ptr, unsigned v) {
  unsigned char *ptr8 = (unsigned char *)ptr;
  ptr8[0] = (unsigned char)v;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<bmp_clrrange>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    -0x40(%rbp),%rax
  and    $0x7,%eax
  mov    %rax,-0x30(%rbp)
  mov    -0x40(%rbp),%rax
  shr    $0x3,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x48(%rbp),%rax
  and    $0x7,%eax
  mov    %rax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x48(%rbp),%rax
  shr    $0x3,%rax
  mov    %rax,%rdx
  mov    -0x20(%rbp),%rax
  shr    $0x3,%rax
  add    %rdx,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  andq   $0x7,-0x20(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %eax,%edx
  mov    $0x8,%eax
  sub    %edx,%eax
  mov    $0xff,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  cltq
  mov    %rax,-0x10(%rbp)
  mov    -0x20(%rbp),%rax
  mov    $0xff,%edx
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  cltq
  mov    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jne    L14
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%rax
  or     -0x8(%rbp),%rax
  and    %rax,%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,(%rax)
  jmp    L12
L14:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  and    -0x10(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x18(%rbp),%rax
  sub    -0x28(%rbp),%rax
  sar    $0x3,%rax
  sub    $0x1,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  and    -0x8(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,(%rax)
L12:
  nop
  leave
  ret
```

assistant: ```c
void bmp_clrrange(uint8_t *buf, size_t start, size_t len) {
  uint8_t first_bit_id;
  uint8_t *first_byte_clear;
  uint8_t last_bit_id;
  uint8_t *last_byte_clear;
  uint8_t first_byte_mask, last_byte_mask;
  do {
    first_bit_id = (start & 0x7);
    first_byte_clear = buf + (start >> 3);
    last_bit_id = (len & 0x7) + first_bit_id;
    last_byte_clear = first_byte_clear + (len >> 3) + (last_bit_id >> 3);
    last_bit_id &= 0x7;
  } while (0);
  first_byte_mask = (uint8_t)(0xFF << (8 - first_bit_id));
  last_byte_mask = (uint8_t)(0xFF >> last_bit_id);
  if (first_byte_clear == last_byte_clear) {
    *first_byte_clear &= (first_byte_mask | last_byte_mask);
  } else {
    *first_byte_clear &= first_byte_mask;
    memset(first_byte_clear + 1, 0x00, (size_t)(last_byte_clear - first_byte_clear - 1));
    *last_byte_clear &= last_byte_mask;
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<bmp_clrrange>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rsi,%r8
  and    $0x7,%r8d
  and    $0xfffffffffffffff8,%rsi
  add    %rsi,%rdi
  mov    %rdx,%rax
  and    $0x7,%eax
  add    %r8,%rax
  shr    $0x3,%rdx
  mov    %rax,%rcx
  shr    $0x3,%rcx
  add    %rcx,%rdx
  shl    $0x3,%rdx
  lea    (%rdi,%rdx,1),%rbx
  mov    $0x8,%ecx
  sub    %r8d,%ecx
  mov    $0xff,%ebp
  mov    %ebp,%esi
  shl    %cl,%esi
  and    $0x7,%eax
  mov    %rax,%rcx
  sar    %cl,%ebp
  cmp    %rbx,%rdi
  je     L18
  movslq %esi,%rsi
  and    %rsi,(%rdi)
  sar    $0x3,%rdx
  sub    $0x1,%rdx
  add    $0x8,%rdi
  mov    $0x0,%esi
  call   <memset@plt>
  movslq %ebp,%rbp
  and    %rbp,(%rbx)
L10:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L18:
  or     %ebp,%esi
  movslq %esi,%rsi
  and    %rsi,(%rdi)
  jmp    L10
```

assistant: ```c
void bmp_clrrange(uint8_t *buf, size_t start, size_t len) {
  uint8_t first_bit_id;
  uint8_t *first_byte_clear;
  uint8_t last_bit_id;
  uint8_t *last_byte_clear;
  uint8_t first_byte_mask, last_byte_mask;
  do {
    first_bit_id = (start & 0x7);
    first_byte_clear = buf + (start >> 3);
    last_bit_id = (len & 0x7) + first_bit_id;
    last_byte_clear = first_byte_clear + (len >> 3) + (last_bit_id >> 3);
    last_bit_id &= 0x7;
  } while (0);
  first_byte_mask = (uint8_t)(0xFF << (8 - first_bit_id));
  last_byte_mask = (uint8_t)(0xFF >> last_bit_id);
  if (first_byte_clear == last_byte_clear) {
    *first_byte_clear &= (first_byte_mask | last_byte_mask);
  } else {
    *first_byte_clear &= first_byte_mask;
    memset(first_byte_clear + 1, 0x00, (size_t)(last_byte_clear - first_byte_clear - 1));
    *last_byte_clear &= last_byte_mask;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<bmp_clrrange>:
  endbr64
  mov    %rsi,%r8
  mov    %rdx,%rax
  shr    $0x3,%rdx
  and    $0xfffffffffffffff8,%rsi
  and    $0x7,%r8d
  and    $0x7,%eax
  push   %rbp
  add    %rsi,%rdi
  add    %r8,%rax
  push   %rbx
  mov    %rax,%rcx
  and    $0x7,%eax
  shr    $0x3,%rcx
  add    %rcx,%rdx
  mov    $0x8,%ecx
  sub    $0x8,%rsp
  sub    %r8d,%ecx
  mov    $0xff,%r8d
  shl    $0x3,%rdx
  mov    %r8d,%esi
  lea    (%rdi,%rdx,1),%rbx
  shl    %cl,%esi
  mov    %rax,%rcx
  mov    (%rdi),%rax
  sar    %cl,%r8d
  mov    %r8d,%ebp
  cmp    %rbx,%rdi
  je     L0
  movslq %esi,%rsi
  sar    $0x3,%rdx
  add    $0x8,%rdi
  and    %rax,%rsi
  sub    $0x1,%rdx
  mov    %rsi,-0x8(%rdi)
  xor    %esi,%esi
  call   <memset@plt>
  movslq %ebp,%r8
  and    %r8,(%rbx)
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L0:
  or     %r8d,%esi
  movslq %esi,%rsi
  and    %rax,%rsi
  mov    %rsi,(%rdi)
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void bmp_clrrange(uint8_t *buf, size_t start, size_t len) {
  uint8_t first_bit_id;
  uint8_t *first_byte_clear;
  uint8_t last_bit_id;
  uint8_t *last_byte_clear;
  uint8_t first_byte_mask, last_byte_mask;
  do {
    first_bit_id = (start & 0x7);
    first_byte_clear = buf + (start >> 3);
    last_bit_id = (len & 0x7) + first_bit_id;
    last_byte_clear = first_byte_clear + (len >> 3) + (last_bit_id >> 3);
    last_bit_id &= 0x7;
  } while (0);
  first_byte_mask = (uint8_t)(0xFF << (8 - first_bit_id));
  last_byte_mask = (uint8_t)(0xFF >> last_bit_id);
  if (first_byte_clear == last_byte_clear) {
    *first_byte_clear &= (first_byte_mask | last_byte_mask);
  } else {
    *first_byte_clear &= first_byte_mask;
    memset(first_byte_clear + 1, 0x00, (size_t)(last_byte_clear - first_byte_clear - 1));
    *last_byte_clear &= last_byte_mask;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<bmp_clrrange>:
  endbr64
  mov    %rsi,%r8
  mov    %rdx,%rax
  shr    $0x3,%rdx
  and    $0xfffffffffffffff8,%rsi
  and    $0x7,%r8d
  and    $0x7,%eax
  push   %rbp
  add    %rsi,%rdi
  add    %r8,%rax
  push   %rbx
  mov    %rax,%rcx
  and    $0x7,%eax
  shr    $0x3,%rcx
  add    %rcx,%rdx
  mov    $0x8,%ecx
  sub    $0x8,%rsp
  sub    %r8d,%ecx
  mov    $0xff,%r8d
  shl    $0x3,%rdx
  mov    %r8d,%esi
  lea    (%rdi,%rdx,1),%rbx
  shl    %cl,%esi
  mov    %rax,%rcx
  mov    (%rdi),%rax
  sar    %cl,%r8d
  mov    %r8d,%ebp
  cmp    %rbx,%rdi
  je     L2
  movslq %esi,%rsi
  sar    $0x3,%rdx
  add    $0x8,%rdi
  and    %rax,%rsi
  sub    $0x1,%rdx
  mov    %rsi,-0x8(%rdi)
  xor    %esi,%esi
  call   <memset@plt>
  movslq %ebp,%r8
  and    %r8,(%rbx)
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L2:
  or     %r8d,%esi
  movslq %esi,%rsi
  and    %rax,%rsi
  mov    %rsi,(%rdi)
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void bmp_clrrange(uint8_t *buf, size_t start, size_t len) {
  uint8_t first_bit_id;
  uint8_t *first_byte_clear;
  uint8_t last_bit_id;
  uint8_t *last_byte_clear;
  uint8_t first_byte_mask, last_byte_mask;
  do {
    first_bit_id = (start & 0x7);
    first_byte_clear = buf + (start >> 3);
    last_bit_id = (len & 0x7) + first_bit_id;
    last_byte_clear = first_byte_clear + (len >> 3) + (last_bit_id >> 3);
    last_bit_id &= 0x7;
  } while (0);
  first_byte_mask = (uint8_t)(0xFF << (8 - first_bit_id));
  last_byte_mask = (uint8_t)(0xFF >> last_bit_id);
  if (first_byte_clear == last_byte_clear) {
    *first_byte_clear &= (first_byte_mask | last_byte_mask);
  } else {
    *first_byte_clear &= first_byte_mask;
    memset(first_byte_clear + 1, 0x00, (size_t)(last_byte_clear - first_byte_clear - 1));
    *last_byte_clear &= last_byte_mask;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<isFartherThan_l2_double>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  movsd  %xmm0,-0x40(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x10(%rbp)
  movsd  -0x40(%rbp),%xmm0
  mulsd  %xmm0,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movl   $0x0,-0x14(%rbp)
  movl   $0x0,-0x14(%rbp)
  jmp    L14
L7:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  movq   %xmm0,%rax
  mov    $0x2,%edi
  movq   %rax,%xmm0
  call   <pow@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  movsd  -0x10(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x10(%rbp)
  movsd  -0x10(%rbp),%xmm0
  comisd -0x8(%rbp),%xmm0
  jbe    L20
  mov    D7(%rip),%rax
  mov    (%rax),%rax
  jmp    L3
L20:
  addl   $0x1,-0x14(%rbp)
L14:
  mov    -0x14(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L7
  mov    -0x10(%rbp),%rax
  movq   %rax,%xmm0
  call   <sqrt@plt>
  movq   %xmm0,%rax
L3:
  movq   %rax,%xmm0
  leave
  ret
```

assistant: ```c
double isFartherThan_l2_double(double *p1, double *p2, int len, double dist) {
  double ret = 0;
  double dist2 = dist * dist;
  int i = 0;
  for (i = 0; i < len; i++) {
    ret += pow((p1[i] - p2[i]), 2);
    if (ret > dist2)
      return NAN;
  }
  return sqrt(ret);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<isFartherThan_l2_double>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mulsd  %xmm0,%xmm0
  movsd  %xmm0,0x8(%rsp)
  test   %edx,%edx
  jle    L3
  mov    %rdi,%r12
  mov    %rsi,%r13
  mov    %edx,%ebp
  mov    $0x0,%ebx
  pxor   %xmm3,%xmm3
  movsd  %xmm3,(%rsp)
L10:
  movsd  (%r12,%rbx,8),%xmm0
  subsd  0x0(%r13,%rbx,8),%xmm0
  mov    $0x2,%edi
  call   <pow@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  (%rsp),%xmm0
  movsd  %xmm0,(%rsp)
  comisd 0x8(%rsp),%xmm0
  ja     L38
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L10
  pxor   %xmm0,%xmm0
  ucomisd (%rsp),%xmm0
  ja     L69
L15:
  movsd  (%rsp),%xmm0
  sqrtsd %xmm0,%xmm0
L40:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L38:
  mov    D4(%rip),%rax
  movsd  (%rax),%xmm0
  jmp    L40
L3:
  pxor   %xmm5,%xmm5
  movsd  %xmm5,(%rsp)
  jmp    L15
L69:
  movsd  (%rsp),%xmm0
  call   <sqrt@plt>
  jmp    L40
```

assistant: ```c
double isFartherThan_l2_double(double *p1, double *p2, int len, double dist) {
  double ret = 0;
  double dist2 = dist * dist;
  int i = 0;
  for (i = 0; i < len; i++) {
    ret += pow((p1[i] - p2[i]), 2);
    if (ret > dist2)
      return NAN;
  }
  return sqrt(ret);
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<isFartherThan_l2_double>:
  endbr64
  mulsd  %xmm0,%xmm0
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  movsd  %xmm0,0x8(%rsp)
  test   %edx,%edx
  jle    L3
  mov    %rdi,%r13
  mov    %rsi,%r12
  movslq %edx,%rbp
  xor    %ebx,%ebx
  pxor   %xmm1,%xmm1
  jmp    L37
  nopl   0x0(%rax)
L10:
  add    $0x1,%rbx
  cmp    %rbx,%rbp
  je     L4
L37:
  movsd  0x0(%r13,%rbx,8),%xmm0
  subsd  (%r12,%rbx,8),%xmm0
  mov    $0x2,%edi
  movsd  %xmm1,(%rsp)
  call   <pow@plt>
  pxor   %xmm0,%xmm0
  movsd  (%rsp),%xmm1
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm1
  comisd 0x8(%rsp),%xmm1
  jbe    L10
  mov    D9(%rip),%rax
  movsd  (%rax),%xmm0
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L4:
  pxor   %xmm3,%xmm3
  ucomisd %xmm1,%xmm3
  ja     L14
L0:
  sqrtsd %xmm1,%xmm1
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  movapd %xmm1,%xmm0
  ret
L3:
  pxor   %xmm1,%xmm1
  jmp    L0
L14:
  add    $0x18,%rsp
  movapd %xmm1,%xmm0
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1060 <sqrt@plt>
```

assistant: ```c
double isFartherThan_l2_double(double *p1, double *p2, int len, double dist) {
  double ret = 0;
  double dist2 = dist * dist;
  int i = 0;
  for (i = 0; i < len; i++) {
    ret += pow((p1[i] - p2[i]), 2);
    if (ret > dist2)
      return NAN;
  }
  return sqrt(ret);
}
```