ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<dow2bmap>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D8(%rip),%rax
  mov    %rax,-0x28(%rbp)
  movb   $0x0,-0x2e(%rbp)
  movb   $0x1,-0x2d(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    $0x7,%eax
  je     L12
  mov    $0xffffffff,%eax
  jmp    L72
L12:
  mov    -0x38(%rbp),%rcx
  lea    -0x20(%rbp),%rax
  mov    $0xf,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy2@plt>
  lea    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <strlower@plt>
  movl   $0x0,-0x2c(%rbp)
  jmp    L9
L86:
  mov    -0x2c(%rbp),%eax
  cltq
  movzbl -0x20(%rbp,%rax,1),%edx
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L68
  movzbl -0x2d(%rbp),%eax
  or     %al,-0x2e(%rbp)
  shlb   -0x2d(%rbp)
  jmp    L64
L68:
  mov    -0x2c(%rbp),%eax
  cltq
  movzbl -0x20(%rbp,%rax,1),%eax
  cmp    $0x2e,%al
  jne    L82
  shlb   -0x2d(%rbp)
  jmp    L64
L82:
  mov    $0xffffffff,%eax
  jmp    L72
L64:
  addl   $0x1,-0x2c(%rbp)
L9:
  cmpl   $0x6,-0x2c(%rbp)
  jle    L86
  movzbl -0x2e(%rbp),%eax
L72:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L59
  call   <__stack_chk_fail@plt>
L59:
  leave
  ret
```

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

tool: D8: smtwtfs

assistant: ```c
unsigned char dow2bmap(char *dow) {
  char *pattern = "smtwtfs";
  unsigned char bmap = 0;
  unsigned char mask = 0x01;
  char buffer[16];
  int j;
  if (strlen(dow) != 7)
    return 0xff;
  strncpy2(buffer, dow, sizeof(buffer) - 1);
  strlower(buffer);
  for (j = 0; j < 7; j++) {
    if (buffer[j] == pattern[j]) {
      bmap |= mask;
      mask = mask << 1;
    } else if (buffer[j] == '.')
      mask = mask << 1;
    else
      return 0xff;
  }
  return bmap;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<dow2bmap>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    $0xffffffff,%esi
  cmp    $0x7,%eax
  je     L0
L33:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L10
  mov    %esi,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
L0:
  mov    %rsp,%rbp
  mov    $0xf,%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <strncpy2@plt>
  mov    %rbp,%rdi
  call   <strlower@plt>
  mov    $0x0,%eax
  mov    $0x1,%ecx
  mov    $0x0,%esi
  lea    D5(%rip),%rdi
  jmp    L40
L39:
  or     %ecx,%esi
  add    %ecx,%ecx
L58:
  add    $0x1,%rax
  cmp    $0x7,%rax
  je     L33
L40:
  movzbl (%rsp,%rax,1),%edx
  cmp    (%rdi,%rax,1),%dl
  je     L39
  cmp    $0x2e,%dl
  jne    L1
  add    %ecx,%ecx
  jmp    L58
L1:
  mov    $0xffffffff,%esi
  jmp    L33
L10:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D5
data_type: string

tool: D5: smtwtfs

assistant: ```c
unsigned char dow2bmap(char *dow) {
  char *pattern = "smtwtfs";
  unsigned char bmap = 0;
  unsigned char mask = 0x01;
  char buffer[16];
  int j;
  if (strlen(dow) != 7)
    return 0xff;
  strncpy2(buffer, dow, sizeof(buffer) - 1);
  strlower(buffer);
  for (j = 0; j < 7; j++) {
    if (buffer[j] == pattern[j]) {
      bmap |= mask;
      mask = mask << 1;
    } else if (buffer[j] == '.')
      mask = mask << 1;
    else
      return 0xff;
  }
  return bmap;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<dow2bmap>:
  endbr64
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  cmp    $0x7,%eax
  je     L39
L38:
  mov    $0xffffffff,%r8d
L56:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L9
  add    $0x28,%rsp
  mov    %r8d,%eax
  pop    %rbx
  pop    %rbp
  ret
  nopw   0x0(%rax,%rax,1)
L39:
  mov    %rsp,%rbx
  mov    %rbp,%rsi
  mov    $0xf,%edx
  mov    %rbx,%rdi
  call   <strncpy2@plt>
  mov    %rbx,%rdi
  call   <strlower@plt>
  xor    %eax,%eax
  mov    $0x73,%esi
  xor    %r8d,%r8d
  mov    $0x1,%ecx
  lea    D9(%rip),%rdi
  jmp    L21
  nopl   0x0(%rax,%rax,1)
L2:
  cmp    $0x2e,%dl
  jne    L38
  add    %ecx,%ecx
L57:
  add    $0x1,%rax
  cmp    $0x7,%rax
  je     L56
  movzbl (%rdi,%rax,1),%esi
L21:
  movzbl (%rbx,%rax,1),%edx
  cmp    %sil,%dl
  jne    L2
  or     %ecx,%r8d
  add    %ecx,%ecx
  jmp    L57
L9:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D9
type_infered: string

tool: D9: smtwtfs

assistant: ```c
unsigned char dow2bmap(char *dow) {
  char *pattern = "smtwtfs";
  unsigned char bmap = 0;
  unsigned char mask = 0x01;
  char buffer[16];
  int j;
  if (strlen(dow) != 7)
    return 0xff;
  strncpy2(buffer, dow, sizeof(buffer) - 1);
  strlower(buffer);
  for (j = 0; j < 7; j++) {
    if (buffer[j] == pattern[j]) {
      bmap |= mask;
      mask = mask << 1;
    } else if (buffer[j] == '.')
      mask = mask << 1;
    else
      return 0xff;
  }
  return bmap;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<dow2bmap>:
  endbr64
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  cmp    $0x7,%eax
  je     L37
L157:
  mov    $0xffffffff,%eax
L117:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L14
  add    $0x28,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L37:
  mov    %rsp,%r12
  mov    $0xf,%edx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <strncpy2@plt>
  mov    %r12,%rdi
  call   <strlower@plt>
  movzbl (%rsp),%eax
  cmp    $0x73,%al
  je     L212
  cmp    $0x2e,%al
  jne    L157
  movzbl 0x1(%rsp),%edx
  xor    %eax,%eax
  cmp    $0x6d,%dl
  je     L63
L60:
  cmp    $0x2e,%dl
  jne    L157
  movzbl 0x2(%rsp),%edx
  cmp    $0x74,%dl
  je     L205
L55:
  cmp    $0x2e,%dl
  jne    L157
  movzbl 0x3(%rsp),%edx
  cmp    $0x77,%dl
  je     L141
L100:
  cmp    $0x2e,%dl
  jne    L157
  movzbl 0x4(%rsp),%edx
  cmp    $0x74,%dl
  je     L77
L187:
  cmp    $0x2e,%dl
  jne    L157
  movzbl 0x5(%rsp),%edx
  cmp    $0x66,%dl
  je     L105
L31:
  cmp    $0x2e,%dl
  jne    L157
  movzbl 0x6(%rsp),%edx
  cmp    $0x73,%dl
  je     L160
L88:
  cmp    $0x2e,%dl
  je     L117
  jmp    L157
  nopl   0x0(%rax)
L212:
  movzbl 0x1(%rsp),%edx
  mov    $0x1,%eax
  cmp    $0x6d,%dl
  jne    L60
L63:
  movzbl 0x2(%rsp),%edx
  or     $0x2,%eax
  cmp    $0x74,%dl
  jne    L55
L205:
  movzbl 0x3(%rsp),%edx
  or     $0x4,%eax
  cmp    $0x77,%dl
  jne    L100
L141:
  movzbl 0x4(%rsp),%edx
  or     $0x8,%eax
  cmp    $0x74,%dl
  jne    L187
L77:
  movzbl 0x5(%rsp),%edx
  or     $0x10,%eax
  cmp    $0x66,%dl
  jne    L31
L105:
  movzbl 0x6(%rsp),%edx
  or     $0x20,%eax
  cmp    $0x73,%dl
  jne    L88
L160:
  or     $0x40,%eax
  jmp    L117
L14:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned char dow2bmap(char *dow) {
  char *pattern = "smtwtfs";
  unsigned char bmap = 0;
  unsigned char mask = 0x01;
  char buffer[16];
  int j;
  if (strlen(dow) != 7)
    return 0xff;
  strncpy2(buffer, dow, sizeof(buffer) - 1);
  strlower(buffer);
  for (j = 0; j < 7; j++) {
    if (buffer[j] == pattern[j]) {
      bmap |= mask;
      mask = mask << 1;
    } else if (buffer[j] == '.')
      mask = mask << 1;
    else
      return 0xff;
  }
  return bmap;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<MSB>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  bsr    %rax,%rdx
  jne    L2
  mov    $0x40,%rdx
L2:
  mov    %rdx,-0x10(%rbp)
  mov    %rax,-0x8(%rbp)
  mov    -0x10(%rbp),%rax
  pop    %rbp
  ret
```

assistant: ```c
int MSB(long word) {
  long dummy, dummy2;
  asm("          bsrq    %1, %0     "
      "\n\t"
      "          jnz     1f         "
      "\n\t"
      "          movq    $64, %0    "
      "\n\t"
      "1:                           "
      "\n\t"
      : "=&r"(dummy), "=&r"(dummy2)
      : "1"((long)(word))
      : "cc");
  return (dummy);
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<MSB>:
  endbr64
  bsr    %rdi,%rax
  jne    L3
  mov    $0x40,%rax
L3:
  ret
```

assistant: ```c
int MSB(long word) {
  long dummy, dummy2;
  asm("          bsrq    %1, %0     "
      "\n\t"
      "          jnz     1f         "
      "\n\t"
      "          movq    $64, %0    "
      "\n\t"
      "1:                           "
      "\n\t"
      : "=&r"(dummy), "=&r"(dummy2)
      : "1"((long)(word))
      : "cc");
  return (dummy);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<MSB>:
  endbr64
  bsr    %rdi,%rax
  jne    L4
  mov    $0x40,%rax
L4:
  ret
```

assistant: ```c
int MSB(long word) {
  long dummy, dummy2;
  asm("          bsrq    %1, %0     "
      "\n\t"
      "          jnz     1f         "
      "\n\t"
      "          movq    $64, %0    "
      "\n\t"
      "1:                           "
      "\n\t"
      : "=&r"(dummy), "=&r"(dummy2)
      : "1"((long)(word))
      : "cc");
  return (dummy);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<MSB>:
  endbr64
  bsr    %rdi,%rax
  jne    L2
  mov    $0x40,%rax
L2:
  ret
```

assistant: ```c
int MSB(long word) {
  long dummy, dummy2;
  asm("          bsrq    %1, %0     "
      "\n\t"
      "          jnz     1f         "
      "\n\t"
      "          movq    $64, %0    "
      "\n\t"
      "1:                           "
      "\n\t"
      : "=&r"(dummy), "=&r"(dummy2)
      : "1"((long)(word))
      : "cc");
  return (dummy);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<skip_space>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
L16:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  cmp    $0x23,%al
  jne    L64
  jmp    L32
L24:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,(%rax)
L32:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L24
  jmp    L60
L64:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L2
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  jg     L39
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,(%rax)
  jmp    L16
L2:
  nop
  jmp    L60
L39:
  nop
L60:
  nop
  pop    %rbp
  ret
```

assistant: ```c
void skip_space(const char **s) {
  for (;;) {
    if (**s == '#') {
      while (**s != '\0')
        (*s)++;
      break;
    }
    if (**s == '\0')
      break;
    if (**s > ' ')
      break;
    (*s)++;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<skip_space>:
  endbr64
  mov    (%rdi),%rax
  movzbl (%rax),%edx
  add    $0x1,%rax
  cmp    $0x23,%dl
  je     L38
L1:
  cmp    $0x20,%dl
  jg     L48
  test   %dl,%dl
  je     L48
  mov    %rax,(%rdi)
  add    $0x1,%rax
  movzbl -0x1(%rax),%edx
  cmp    $0x23,%dl
  jne    L1
L38:
  mov    (%rdi),%rax
  add    $0x1,%rax
L40:
  mov    %rax,(%rdi)
  add    $0x1,%rax
  cmpb   $0x0,-0x1(%rax)
  jne    L40
  ret
L48:
  ret
```

assistant: ```c
void skip_space(const char **s) {
  for (;;) {
    if (**s == '#') {
      while (**s != '\0')
        (*s)++;
      break;
    }
    if (**s == '\0')
      break;
    if (**s > ' ')
      break;
    (*s)++;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<skip_space>:
  endbr64
  mov    (%rdi),%rcx
  movzbl (%rcx),%edx
  lea    0x1(%rcx),%rax
  cmp    $0x23,%dl
  jne    L59
  jmp    L28
  nopl   (%rax)
L32:
  cmp    $0x20,%dl
  jg     L48
  mov    %rax,(%rdi)
  mov    %rax,%rcx
  movzbl (%rax),%edx
  add    $0x1,%rax
  cmp    $0x23,%dl
  je     L28
L59:
  test   %dl,%dl
  jne    L32
L48:
  ret
  nopl   0x0(%rax)
L28:
  add    $0x1,%rcx
  nopl   0x0(%rax)
L4:
  mov    %rcx,(%rdi)
  add    $0x1,%rcx
  cmpb   $0x0,-0x1(%rcx)
  jne    L4
  ret
```

assistant: ```c
void skip_space(const char **s) {
  for (;;) {
    if (**s == '#') {
      while (**s != '\0')
        (*s)++;
      break;
    }
    if (**s == '\0')
      break;
    if (**s > ' ')
      break;
    (*s)++;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<skip_space>:
  endbr64
  mov    (%rdi),%rcx
  movzbl (%rcx),%edx
  lea    0x1(%rcx),%rax
  cmp    $0x23,%dl
  jne    L1
  jmp    L26
  nopl   (%rax)
L34:
  cmp    $0x20,%dl
  jg     L40
  mov    %rax,(%rdi)
  mov    %rax,%rcx
  movzbl (%rax),%edx
  add    $0x1,%rax
  cmp    $0x23,%dl
  je     L26
L1:
  test   %dl,%dl
  jne    L34
L40:
  ret
  nopl   0x0(%rax)
L26:
  add    $0x1,%rcx
  nopl   0x0(%rax)
L33:
  mov    %rcx,(%rdi)
  add    $0x1,%rcx
  cmpb   $0x0,-0x1(%rcx)
  jne    L33
  ret
```

assistant: ```c
void skip_space(const char **s) {
  for (;;) {
    if (**s == '#') {
      while (**s != '\0')
        (*s)++;
      break;
    }
    if (**s == '\0')
      break;
    if (**s > ' ')
      break;
    (*s)++;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<_validate_utf8>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r14
  mov    %esi,%r12d
  mov    %rdx,0x8(%rsp)
  mov    (%rdi),%r15
  movzbl (%r15),%esi
  test   %sil,%sil
  jle    L50
  movsbl %sil,%esi
  mov    %rdx,%rdi
  call   <buf_putchar@plt>
  test   %eax,%eax
  je     L16
  lea    0x1(%r15),%rax
  mov    $0x1,%ebx
L130:
  mov    %rax,(%r14)
  mov    %ebx,%eax
L16:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L50:
  movzbl %sil,%edi
  call   <mb_num_chars@plt>
  mov    %eax,%r13d
  cmp    $0x1,%eax
  jbe    L165
  cmp    $0x1,%r12d
  jbe    L30
  lea    0x1(%r15),%rbp
  mov    $0x1,%ebx
L152:
  movzbl 0x0(%rbp),%edi
  call   <mb_is_cont@plt>
  test   %rax,%rax
  je     L84
  add    $0x1,%ebx
  cmp    %ebx,%r13d
  jb     L197
  add    $0x1,%rbp
  cmp    %r12d,%ebx
  jne    L152
  mov    %r12d,%ebx
L84:
  lea    -0x5(%r13),%eax
  cmp    $0x1,%eax
  jbe    L19
  cmp    %ebx,%r13d
  jne    L178
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <mb_is_shortest@plt>
  test   %eax,%eax
  je     L178
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <mb_is_surrogate@plt>
  test   %eax,%eax
  jne    L178
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <mb_is_illegal@plt>
  test   %eax,%eax
  jne    L178
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    0x8(%rsp),%rdi
  call   <buf_append@plt>
  test   %eax,%eax
  jne    L159
  jmp    L16
L19:
  mov    $0x3f,%esi
  mov    0x8(%rsp),%rdi
  call   <buf_putchar@plt>
  test   %eax,%eax
  jne    L159
  jmp    L16
L165:
  mov    $0x3f,%esi
  mov    0x8(%rsp),%rdi
  call   <buf_putchar@plt>
  test   %eax,%eax
  je     L16
  lea    0x1(%r15),%rax
  mov    $0x1,%ebx
  jmp    L130
L30:
  mov    $0x1,%ebx
L197:
  sub    $0x5,%r13d
  cmp    $0x1,%r13d
  jbe    L19
L178:
  mov    $0x3f,%esi
  mov    0x8(%rsp),%rdi
  call   <buf_putchar@plt>
  test   %eax,%eax
  je     L16
L159:
  mov    %ebx,%eax
  add    %r15,%rax
  jmp    L130
```

assistant: ```c
int _validate_utf8(unsigned char **s, int l, struct template_buffer *buf) {
  unsigned char *ptr = *s;
  unsigned int o = 0, v, n;
  if ((*(ptr + 0) >= 0x01) && (*(ptr + 0) <= 0x7F)) {
    if (!buf_putchar(buf, *ptr++))
      return 0;
    o = 1;
  } else if ((n = mb_num_chars(*ptr)) > 1) {
    for (v = 1; (v <= n) && ((o + v) < l) && mb_is_cont(*(ptr + v)); v++)
      ;
    switch (n) {
    case 6:
    case 5:
      if (!buf_putchar(buf, '?'))
        return 0;
      break;
    default:
      if ((v == n) && mb_is_shortest(ptr, n) && !mb_is_surrogate(ptr, n) && !mb_is_illegal(ptr, n)) {
        if (!buf_append(buf, ptr, n))
          return 0;
      } else {
        if (!buf_putchar(buf, '?'))
          return 0;
      }
      break;
    }
    o = v;
    ptr += v;
  } else {
    if (!buf_putchar(buf, '?'))
      return 0;
    o = 1;
    ptr++;
  }
  *s = ptr;
  return o;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<_validate_utf8>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  sub    $0x18,%rsp
  mov    (%rdi),%r15
  mov    %rdi,0x8(%rsp)
  movsbl (%r15),%esi
  test   %sil,%sil
  jle    L17
L81:
  mov    %r14,%rdi
  call   <buf_putchar@plt>
  test   %eax,%eax
  je     L60
  lea    0x1(%r15),%rdx
  mov    $0x1,%eax
L41:
  mov    0x8(%rsp),%rcx
  mov    %rdx,(%rcx)
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L17:
  movzbl %sil,%edi
  call   <mb_num_chars@plt>
  mov    %eax,%r12d
  cmp    $0x1,%eax
  jbe    L78
  lea    0x1(%r15),%r13
  mov    $0x1,%ebx
  cs nopw 0x0(%rax,%rax,1)
L118:
  cmp    %ebx,%ebp
  jbe    L52
  movzbl 0x0(%r13),%edi
  call   <mb_is_cont@plt>
  test   %rax,%rax
  je     L52
  add    $0x1,%ebx
  add    $0x1,%r13
  cmp    %ebx,%r12d
  jae    L118
L0:
  mov    $0x3f,%esi
  mov    %r14,%rdi
  call   <buf_putchar@plt>
  test   %eax,%eax
  jne    L25
L60:
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L52:
  lea    -0x5(%r12),%eax
  cmp    $0x1,%eax
  jbe    L0
  cmp    %ebx,%r12d
  jne    L0
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <mb_is_shortest@plt>
  test   %eax,%eax
  je     L0
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <mb_is_surrogate@plt>
  test   %eax,%eax
  jne    L0
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <mb_is_illegal@plt>
  test   %eax,%eax
  jne    L0
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <buf_append@plt>
  test   %eax,%eax
  je     L60
  nopw   0x0(%rax,%rax,1)
L25:
  mov    %ebx,%edx
  mov    %ebx,%eax
  add    %r15,%rdx
  jmp    L41
  nopl   0x0(%rax)
L78:
  mov    $0x3f,%esi
  jmp    L81
```

assistant: ```c
int _validate_utf8(unsigned char **s, int l, struct template_buffer *buf) {
  unsigned char *ptr = *s;
  unsigned int o = 0, v, n;
  if ((*(ptr + 0) >= 0x01) && (*(ptr + 0) <= 0x7F)) {
    if (!buf_putchar(buf, *ptr++))
      return 0;
    o = 1;
  } else if ((n = mb_num_chars(*ptr)) > 1) {
    for (v = 1; (v <= n) && ((o + v) < l) && mb_is_cont(*(ptr + v)); v++)
      ;
    switch (n) {
    case 6:
    case 5:
      if (!buf_putchar(buf, '?'))
        return 0;
      break;
    default:
      if ((v == n) && mb_is_shortest(ptr, n) && !mb_is_surrogate(ptr, n) && !mb_is_illegal(ptr, n)) {
        if (!buf_append(buf, ptr, n))
          return 0;
      } else {
        if (!buf_putchar(buf, '?'))
          return 0;
      }
      break;
    }
    o = v;
    ptr += v;
  } else {
    if (!buf_putchar(buf, '?'))
      return 0;
    o = 1;
    ptr++;
  }
  *s = ptr;
  return o;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<_validate_utf8>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  sub    $0x18,%rsp
  mov    (%rdi),%r15
  mov    %rdi,0x8(%rsp)
  movsbl (%r15),%esi
  test   %sil,%sil
  jle    L14
L18:
  mov    %r14,%rdi
  call   <buf_putchar@plt>
  test   %eax,%eax
  je     L145
  lea    0x1(%r15),%rdx
  mov    $0x1,%eax
L141:
  mov    0x8(%rsp),%rcx
  mov    %rdx,(%rcx)
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L14:
  movzbl %sil,%edi
  call   <mb_num_chars@plt>
  mov    %eax,%r12d
  cmp    $0x1,%eax
  jbe    L102
  lea    0x1(%r15),%r13
  mov    $0x1,%ebx
  cs nopw 0x0(%rax,%rax,1)
L90:
  cmp    %ebx,%ebp
  jbe    L135
  movzbl 0x0(%r13),%edi
  call   <mb_is_cont@plt>
  test   %rax,%rax
  je     L135
  add    $0x1,%ebx
  add    $0x1,%r13
  cmp    %ebx,%r12d
  jae    L90
L22:
  mov    $0x3f,%esi
  mov    %r14,%rdi
  call   <buf_putchar@plt>
  test   %eax,%eax
  jne    L61
L145:
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L135:
  lea    -0x5(%r12),%eax
  cmp    $0x1,%eax
  jbe    L22
  cmp    %ebx,%r12d
  jne    L22
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <mb_is_shortest@plt>
  test   %eax,%eax
  je     L22
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <mb_is_surrogate@plt>
  test   %eax,%eax
  jne    L22
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <mb_is_illegal@plt>
  test   %eax,%eax
  jne    L22
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <buf_append@plt>
  test   %eax,%eax
  je     L145
  nopw   0x0(%rax,%rax,1)
L61:
  mov    %ebx,%edx
  mov    %ebx,%eax
  add    %r15,%rdx
  jmp    L141
  nopl   0x0(%rax)
L102:
  mov    $0x3f,%esi
  jmp    L18
```

assistant: ```c
int _validate_utf8(unsigned char **s, int l, struct template_buffer *buf) {
  unsigned char *ptr = *s;
  unsigned int o = 0, v, n;
  if ((*(ptr + 0) >= 0x01) && (*(ptr + 0) <= 0x7F)) {
    if (!buf_putchar(buf, *ptr++))
      return 0;
    o = 1;
  } else if ((n = mb_num_chars(*ptr)) > 1) {
    for (v = 1; (v <= n) && ((o + v) < l) && mb_is_cont(*(ptr + v)); v++)
      ;
    switch (n) {
    case 6:
    case 5:
      if (!buf_putchar(buf, '?'))
        return 0;
      break;
    default:
      if ((v == n) && mb_is_shortest(ptr, n) && !mb_is_surrogate(ptr, n) && !mb_is_illegal(ptr, n)) {
        if (!buf_append(buf, ptr, n))
          return 0;
      } else {
        if (!buf_putchar(buf, '?'))
          return 0;
      }
      break;
    }
    o = v;
    ptr += v;
  } else {
    if (!buf_putchar(buf, '?'))
      return 0;
    o = 1;
    ptr++;
  }
  *s = ptr;
  return o;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<RandomFunc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x18(%rbp),%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  shr    $0x3,%rax
  or     $0xbab5,%ax
  mov    %ax,-0xa(%rbp)
  movw   $0x0,-0xc(%rbp)
  nop
  movw   $0x0,-0xc(%rbp)
  nop
  movzwl -0xa(%rbp),%eax
  shl    $0x5,%eax
  xor    $0x3ae0,%ax
  mov    %eax,%edx
  mov    -0x20(%rbp),%rax
  mov    %dx,(%rax)
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L6
  call   <__stack_chk_fail@plt>
L6:
  leave
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local1;
  {
    state[0UL] = (input[0UL] | 51238316UL) >> (unsigned short)3;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      state[0UL] <<= ((state[0UL] >> (unsigned short)3) & (unsigned short)7) | 1UL;
      local1 += 2UL;
    }
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      state[0UL] <<= ((state[0UL] >> (unsigned short)3) & (unsigned short)7) | 1UL;
      local1 += 2UL;
    }
    output[0UL] = (state[0UL] ^ 736209367UL) << (unsigned short)5;
  }
}
```
user: What is the c source code of the assembly code below?

```asm
<RandomFunc>:
  endbr64
  movzwl (%rdi),%eax
  shr    $0x3,%rax
  shl    $0x5,%eax
  or     $0x56a0,%ax
  xor    $0x3ae0,%ax
  mov    %ax,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local1;
  {
    state[0UL] = (input[0UL] | 51238316UL) >> (unsigned short)3;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      state[0UL] <<= ((state[0UL] >> (unsigned short)3) & (unsigned short)7) | 1UL;
      local1 += 2UL;
    }
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      state[0UL] <<= ((state[0UL] >> (unsigned short)3) & (unsigned short)7) | 1UL;
      local1 += 2UL;
    }
    output[0UL] = (state[0UL] ^ 736209367UL) << (unsigned short)5;
  }
}
```