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

```asm
<malloc_stub>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x1,%edi
  call   <malloc@plt>
  add    $0x8,%rsp
  mov    %rax,%rdi
  jmp    1060 <free@plt>
```

assistant: ```c
void malloc_stub(void) {
  void *p = malloc(1);
  free(p);
}
```
user: What is the c source code of the assembly code below?

```asm
<malloc_stub>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x1,%edi
  call   <malloc@plt>
  add    $0x8,%rsp
  mov    %rax,%rdi
  jmp    1060 <free@plt>
```

assistant: ```c
void malloc_stub(void) {
  void *p = malloc(1);
  free(p);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<H5Gcreate>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  mov    %r8,-0x38(%rbp)
  mov    $0xa,%edi
  call   <__coverity_alloc__@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <__coverity_mark_as_afm_allocated__@plt>
  mov    -0x8(%rbp),%rax
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D2
type_guessed: string

tool: D2: H5Gclose

assistant: ```c
void *H5Gcreate(void *loc_id, const char *name, void *lcpl_id, void *gcpl_id, void *gapl_id) {
  void *id = __coverity_alloc__(10);
  __coverity_mark_as_afm_allocated__(id, "H5Gclose");
  return id;
}
```
user: Translate the below assembly code into C programming language:

```asm
<H5Gcreate>:
  endbr64
  push   %rbx
  mov    $0xa,%edi
  call   <__coverity_alloc__@plt>
  mov    %rax,%rbx
  lea    D3(%rip),%rsi
  mov    %rax,%rdi
  call   <__coverity_mark_as_afm_allocated__@plt>
  mov    %rbx,%rax
  pop    %rbx
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D3
datatype: string

tool: D3: H5Gclose

assistant: ```c
void *H5Gcreate(void *loc_id, const char *name, void *lcpl_id, void *gcpl_id, void *gapl_id) {
  void *id = __coverity_alloc__(10);
  __coverity_mark_as_afm_allocated__(id, "H5Gclose");
  return id;
}
```
user: What is the c source code of the assembly code below?

```asm
<H5Gcreate>:
  endbr64
  push   %r12
  mov    $0xa,%edi
  call   <__coverity_alloc__@plt>
  lea    D2(%rip),%rsi
  mov    %rax,%r12
  mov    %rax,%rdi
  call   <__coverity_mark_as_afm_allocated__@plt>
  mov    %r12,%rax
  pop    %r12
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D2
datatype: string

tool: D2: H5Gclose

assistant: ```c
void *H5Gcreate(void *loc_id, const char *name, void *lcpl_id, void *gcpl_id, void *gapl_id) {
  void *id = __coverity_alloc__(10);
  __coverity_mark_as_afm_allocated__(id, "H5Gclose");
  return id;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<H5Gcreate>:
  endbr64
  push   %r12
  mov    $0xa,%edi
  call   <__coverity_alloc__@plt>
  lea    D8(%rip),%rsi
  mov    %rax,%r12
  mov    %rax,%rdi
  call   <__coverity_mark_as_afm_allocated__@plt>
  mov    %r12,%rax
  pop    %r12
  ret
```

tool_calls: name: read_data
arguments: label: D8
type_guessed: string

tool: D8: H5Gclose

assistant: ```c
void *H5Gcreate(void *loc_id, const char *name, void *lcpl_id, void *gcpl_id, void *gapl_id) {
  void *id = __coverity_alloc__(10);
  __coverity_mark_as_afm_allocated__(id, "H5Gclose");
  return id;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<rand_range>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  movsd  %xmm0,-0x28(%rbp)
  movsd  %xmm1,-0x30(%rbp)
  movsd  -0x30(%rbp),%xmm0
  subsd  -0x28(%rbp),%xmm0
  movsd  %xmm0,-0x20(%rbp)
  mov    $0x0,%eax
  call   <rand@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  mov    D9(%rip),%rax
  movsd  (%rax),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x18(%rbp)
  movsd  -0x18(%rbp),%xmm0
  mulsd  -0x20(%rbp),%xmm0
  movsd  %xmm0,-0x10(%rbp)
  movsd  -0x10(%rbp),%xmm0
  addsd  -0x28(%rbp),%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  leave
  ret
```

assistant: ```c
double rand_range(double low, double high) {
  double range = high - low;
  double root = ((double)rand()) / RAND_MAX;
  double expanded = root * range;
  double shifted = expanded + low;
  return shifted;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<rand_range>:
  endbr64
  sub    $0x18,%rsp
  movsd  %xmm0,0x8(%rsp)
  subsd  %xmm0,%xmm1
  movsd  %xmm1,(%rsp)
  mov    $0x0,%eax
  call   <rand@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  mov    D0(%rip),%rax
  divsd  (%rax),%xmm0
  mulsd  (%rsp),%xmm0
  addsd  0x8(%rsp),%xmm0
  add    $0x18,%rsp
  ret
```

assistant: ```c
double rand_range(double low, double high) {
  double range = high - low;
  double root = ((double)rand()) / RAND_MAX;
  double expanded = root * range;
  double shifted = expanded + low;
  return shifted;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<rand_range>:
  endbr64
  subsd  %xmm0,%xmm1
  sub    $0x18,%rsp
  xor    %eax,%eax
  movsd  %xmm0,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  call   <rand@plt>
  pxor   %xmm0,%xmm0
  movsd  0x8(%rsp),%xmm2
  cvtsi2sd %rax,%xmm0
  mov    D8(%rip),%rax
  divsd  (%rax),%xmm0
  mulsd  (%rsp),%xmm0
  add    $0x18,%rsp
  addsd  %xmm2,%xmm0
  ret
```

assistant: ```c
double rand_range(double low, double high) {
  double range = high - low;
  double root = ((double)rand()) / RAND_MAX;
  double expanded = root * range;
  double shifted = expanded + low;
  return shifted;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<rand_range>:
  endbr64
  subsd  %xmm0,%xmm1
  sub    $0x18,%rsp
  xor    %eax,%eax
  movsd  %xmm0,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  call   <rand@plt>
  pxor   %xmm0,%xmm0
  movsd  0x8(%rsp),%xmm2
  cvtsi2sd %rax,%xmm0
  mov    D3(%rip),%rax
  divsd  (%rax),%xmm0
  mulsd  (%rsp),%xmm0
  add    $0x18,%rsp
  addsd  %xmm2,%xmm0
  ret
```

assistant: ```c
double rand_range(double low, double high) {
  double range = high - low;
  double root = ((double)rand()) / RAND_MAX;
  double expanded = root * range;
  double shifted = expanded + low;
  return shifted;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<ipow>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  movl   $0x1,-0x4(%rbp)
  cmpl   $0x0,-0x18(%rbp)
  jne    L33
  mov    $0x1,%eax
  jmp    L38
L33:
  movl   $0x0,-0x8(%rbp)
  jmp    L34
L32:
  mov    -0x4(%rbp),%eax
  imul   -0x14(%rbp),%eax
  mov    %eax,-0x4(%rbp)
  addl   $0x1,-0x8(%rbp)
L34:
  mov    -0x8(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L32
  mov    -0x4(%rbp),%eax
L38:
  pop    %rbp
  ret
```

assistant: ```c
int ipow(int base, int exp) {
  int i, res;
  res = 1;
  if (exp == 0) {
    return 1;
  }
  for (i = 0; i < exp; i++) {
    res *= base;
  }
  return res;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<ipow>:
  endbr64
  test   %esi,%esi
  jle    L14
  mov    $0x1,%edx
  mov    $0x0,%eax
L22:
  imul   %edi,%edx
  add    $0x1,%eax
  cmp    %eax,%esi
  jne    L22
L6:
  mov    %edx,%eax
  ret
L14:
  mov    $0x1,%edx
  jmp    L6
```

assistant: ```c
int ipow(int base, int exp) {
  int i, res;
  res = 1;
  if (exp == 0) {
    return 1;
  }
  for (i = 0; i < exp; i++) {
    res *= base;
  }
  return res;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<ipow>:
  endbr64
  mov    $0x1,%r8d
  test   %esi,%esi
  jle    L6
  xor    %eax,%eax
L15:
  add    $0x1,%eax
  imul   %edi,%r8d
  cmp    %eax,%esi
  jne    L15
L6:
  mov    %r8d,%eax
  ret
```

assistant: ```c
int ipow(int base, int exp) {
  int i, res;
  res = 1;
  if (exp == 0) {
    return 1;
  }
  for (i = 0; i < exp; i++) {
    res *= base;
  }
  return res;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<ipow>:
  endbr64
  mov    $0x1,%r8d
  test   %esi,%esi
  jle    L5
  xor    %eax,%eax
L7:
  add    $0x1,%eax
  imul   %edi,%r8d
  cmp    %eax,%esi
  jne    L7
L5:
  mov    %r8d,%eax
  ret
```

assistant: ```c
int ipow(int base, int exp) {
  int i, res;
  res = 1;
  if (exp == 0) {
    return 1;
  }
  for (i = 0; i < exp; i++) {
    res *= base;
  }
  return res;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<printRange>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %eax,%esi
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  leave
  ret
```

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

tool: D8: Scheduling policy valid priority ranges: %d-%d


assistant: ```c
extern int printRange(int min, int max) {
  int ret = printf("Scheduling policy valid priority ranges: %d-%d\n", min, max);
  return ret;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<printRange>:
  endbr64
  sub    $0x8,%rsp
  mov    %esi,%edx
  mov    %edi,%esi
  lea    D8(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  ret
```

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

tool: D8: Scheduling policy valid priority ranges: %d-%d


assistant: ```c
extern int printRange(int min, int max) {
  int ret = printf("Scheduling policy valid priority ranges: %d-%d\n", min, max);
  return ret;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<printRange>:
  endbr64
  mov    %esi,%edx
  mov    %edi,%esi
  lea    D3(%rip),%rdi
  jmp    1050 <printf@plt>
```

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

tool: D3: Scheduling policy valid priority ranges: %d-%d


assistant: ```c
extern int printRange(int min, int max) {
  int ret = printf("Scheduling policy valid priority ranges: %d-%d\n", min, max);
  return ret;
}
```
user: Translate the below assembly code into C programming language:

```asm
<printRange>:
  endbr64
  mov    %esi,%edx
  mov    %edi,%esi
  lea    D0(%rip),%rdi
  jmp    1050 <printf@plt>
```

tool_calls: name: unpack_data
arguments: label: D0
type_guessed: string

tool: D0: Scheduling policy valid priority ranges: %d-%d


assistant: ```c
extern int printRange(int min, int max) {
  int ret = printf("Scheduling policy valid priority ranges: %d-%d\n", min, max);
  return ret;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<strnumcount>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L0
L23:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L15
  addl   $0x1,-0x4(%rbp)
L15:
  addq   $0x1,-0x18(%rbp)
L0:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L23
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
int strnumcount(const char *str) {
  int count = 0;
  for (; *str; str++)
    if (isdigit(*str))
      count++;
  return count;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<strnumcount>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  movzbl (%rdi),%edi
  test   %dil,%dil
  je     L6
  mov    $0x0,%ebp
L12:
  movsbl %dil,%edi
  call   <isdigit@plt>
  cmp    $0x1,%rax
  sbb    $0xffffffff,%ebp
  add    $0x1,%rbx
  movzbl (%rbx),%edi
  test   %dil,%dil
  jne    L12
L27:
  mov    %ebp,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L6:
  mov    $0x0,%ebp
  jmp    L27
```

assistant: ```c
int strnumcount(const char *str) {
  int count = 0;
  for (; *str; str++)
    if (isdigit(*str))
      count++;
  return count;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<strnumcount>:
  endbr64
  push   %r12
  xor    %r12d,%r12d
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  movsbl (%rdi),%edi
  test   %dil,%dil
  je     L7
  nopl   0x0(%rax)
L4:
  call   <isdigit@plt>
  cmp    $0x1,%rax
  sbb    $0xffffffff,%r12d
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  jne    L4
L7:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %r12
  ret
```

assistant: ```c
int strnumcount(const char *str) {
  int count = 0;
  for (; *str; str++)
    if (isdigit(*str))
      count++;
  return count;
}
```
user: What is the c source code of the assembly code below?

```asm
<strnumcount>:
  endbr64
  push   %r12
  xor    %r12d,%r12d
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  movsbl (%rdi),%edi
  test   %dil,%dil
  je     L14
  nopl   0x0(%rax)
L13:
  call   <isdigit@plt>
  cmp    $0x1,%rax
  sbb    $0xffffffff,%r12d
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  jne    L13
L14:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %r12
  ret
```

assistant: ```c
int strnumcount(const char *str) {
  int count = 0;
  for (; *str; str++)
    if (isdigit(*str))
      count++;
  return count;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<nsock_unblock_socket>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    D6(%rip),%rax
  mov    (%rax),%edx
  mov    -0x14(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <fcntl@plt>
  mov    %eax,%edx
  mov    D3(%rip),%rax
  mov    (%rax),%eax
  or     %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    D24(%rip),%rax
  mov    (%rax),%ecx
  mov    -0x4(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <fcntl@plt>
  mov    $0x1,%eax
  leave
  ret
```

assistant: ```c
int nsock_unblock_socket(int sd) {
  int options;
  options = O_NONBLOCK | fcntl(sd, F_GETFL);
  fcntl(sd, F_SETFL, options);
  return 1;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<nsock_unblock_socket>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  mov    D20(%rip),%rax
  mov    (%rax),%esi
  mov    $0x0,%eax
  call   <fcntl@plt>
  mov    D1(%rip),%rdx
  or     (%rdx),%eax
  mov    %eax,%edx
  mov    D3(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  mov    $0x0,%eax
  call   <fcntl@plt>
  mov    $0x1,%eax
  pop    %rbx
  ret
```

assistant: ```c
int nsock_unblock_socket(int sd) {
  int options;
  options = O_NONBLOCK | fcntl(sd, F_GETFL);
  fcntl(sd, F_SETFL, options);
  return 1;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<nsock_unblock_socket>:
  endbr64
  mov    D1(%rip),%rax
  push   %rbp
  mov    %edi,%ebp
  mov    (%rax),%esi
  xor    %eax,%eax
  call   <fcntl@plt>
  mov    D19(%rip),%rdx
  mov    %ebp,%edi
  or     (%rdx),%eax
  mov    %eax,%edx
  mov    D23(%rip),%rax
  mov    (%rax),%esi
  xor    %eax,%eax
  call   <fcntl@plt>
  mov    $0x1,%eax
  pop    %rbp
  ret
```

assistant: ```c
int nsock_unblock_socket(int sd) {
  int options;
  options = O_NONBLOCK | fcntl(sd, F_GETFL);
  fcntl(sd, F_SETFL, options);
  return 1;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<nsock_unblock_socket>:
  endbr64
  mov    D13(%rip),%rax
  push   %rbp
  mov    %edi,%ebp
  mov    (%rax),%esi
  xor    %eax,%eax
  call   <fcntl@plt>
  mov    D5(%rip),%rdx
  mov    %ebp,%edi
  or     (%rdx),%eax
  mov    %eax,%edx
  mov    D24(%rip),%rax
  mov    (%rax),%esi
  xor    %eax,%eax
  call   <fcntl@plt>
  mov    $0x1,%eax
  pop    %rbp
  ret
```

assistant: ```c
int nsock_unblock_socket(int sd) {
  int options;
  options = O_NONBLOCK | fcntl(sd, F_GETFL);
  fcntl(sd, F_SETFL, options);
  return 1;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<rfc1035QuestionPack>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,%eax
  mov    %r8d,%edx
  mov    %ax,-0x3c(%rbp)
  mov    %edx,%eax
  mov    %ax,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  sub    -0x10(%rbp),%rax
  mov    -0x28(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  add    %rdx,%rcx
  mov    -0x38(%rbp),%rdx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <rfc1035NamePack@plt>
  add    %rax,-0x10(%rbp)
  movzwl -0x3c(%rbp),%eax
  mov    %eax,%edi
  call   <htons@plt>
  mov    %ax,-0x12(%rbp)
  mov    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  lea    -0x12(%rbp),%rax
  mov    $0x2,%edx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  addq   $0x2,-0x10(%rbp)
  movzwl -0x40(%rbp),%eax
  mov    %eax,%edi
  call   <htons@plt>
  mov    %ax,-0x12(%rbp)
  mov    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  lea    -0x12(%rbp),%rax
  mov    $0x2,%edx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  addq   $0x2,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  setbe  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x10(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L3
  call   <__stack_chk_fail@plt>
L3:
  leave
  ret
```

assistant: ```c
off_t rfc1035QuestionPack(char *buf, size_t sz, const char *name, unsigned short type, unsigned short class) {
  off_t off = 0;
  unsigned short s;
  off += rfc1035NamePack(buf + off, sz - off, name);
  s = htons(type);
  memcpy(buf + off, &s, sizeof(s));
  off += sizeof(s);
  s = htons(class);
  memcpy(buf + off, &s, sizeof(s));
  off += sizeof(s);
  assert(off <= sz);
  return off;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<rfc1035QuestionPack>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r14
  mov    %ecx,%r13d
  mov    %r8d,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <rfc1035NamePack@plt>
  mov    %rax,%rbx
  movzwl %r13w,%edi
  call   <htons@plt>
  mov    %ax,0x6(%rsp)
  lea    0x6(%rsp),%r13
  lea    0x0(%rbp,%rbx,1),%rdi
  mov    $0x2,%edx
  mov    %r13,%rsi
  call   <memcpy@plt>
  movzwl %r12w,%edi
  call   <htons@plt>
  mov    %ax,0x6(%rsp)
  lea    0x2(%rbp,%rbx,1),%rdi
  mov    $0x2,%edx
  mov    %r13,%rsi
  call   <memcpy@plt>
  add    $0x4,%rbx
  cmp    %rbx,%r14
  setae  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L8
  mov    %rbx,%rax
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L8:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
off_t rfc1035QuestionPack(char *buf, size_t sz, const char *name, unsigned short type, unsigned short class) {
  off_t off = 0;
  unsigned short s;
  off += rfc1035NamePack(buf + off, sz - off, name);
  s = htons(type);
  memcpy(buf + off, &s, sizeof(s));
  off += sizeof(s);
  s = htons(class);
  memcpy(buf + off, &s, sizeof(s));
  off += sizeof(s);
  assert(off <= sz);
  return off;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<rfc1035QuestionPack>:
  endbr64
  push   %r14
  mov    %rsi,%r14
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %r8d,%ebp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <rfc1035NamePack@plt>
  movzwl %r13w,%edi
  lea    0x6(%rsp),%r13
  mov    %rax,%rbx
  call   <htons@plt>
  lea    (%r12,%rbx,1),%rdi
  mov    $0x2,%edx
  mov    %r13,%rsi
  mov    %ax,0x6(%rsp)
  call   <memcpy@plt>
  movzwl %bp,%edi
  call   <htons@plt>
  lea    0x2(%r12,%rbx,1),%rdi
  mov    $0x2,%edx
  mov    %r13,%rsi
  lea    0x4(%rbx),%r12
  mov    %ax,0x6(%rsp)
  call   <memcpy@plt>
  xor    %edi,%edi
  cmp    %r12,%r14
  setae  %dil
  call   <assert@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L7
  add    $0x10,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L7:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
off_t rfc1035QuestionPack(char *buf, size_t sz, const char *name, unsigned short type, unsigned short class) {
  off_t off = 0;
  unsigned short s;
  off += rfc1035NamePack(buf + off, sz - off, name);
  s = htons(type);
  memcpy(buf + off, &s, sizeof(s));
  off += sizeof(s);
  s = htons(class);
  memcpy(buf + off, &s, sizeof(s));
  off += sizeof(s);
  assert(off <= sz);
  return off;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<rfc1035QuestionPack>:
  endbr64
  push   %r14
  mov    %rsi,%r14
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %r8d,%ebp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <rfc1035NamePack@plt>
  movzwl %r13w,%edi
  lea    0x6(%rsp),%r13
  mov    %rax,%rbx
  call   <htons@plt>
  lea    (%r12,%rbx,1),%rdi
  mov    $0x2,%edx
  mov    %r13,%rsi
  mov    %ax,0x6(%rsp)
  call   <memcpy@plt>
  movzwl %bp,%edi
  call   <htons@plt>
  lea    0x2(%r12,%rbx,1),%rdi
  mov    $0x2,%edx
  mov    %r13,%rsi
  lea    0x4(%rbx),%r12
  mov    %ax,0x6(%rsp)
  call   <memcpy@plt>
  xor    %edi,%edi
  cmp    %r12,%r14
  setae  %dil
  call   <assert@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L9
  add    $0x10,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L9:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
off_t rfc1035QuestionPack(char *buf, size_t sz, const char *name, unsigned short type, unsigned short class) {
  off_t off = 0;
  unsigned short s;
  off += rfc1035NamePack(buf + off, sz - off, name);
  s = htons(type);
  memcpy(buf + off, &s, sizeof(s));
  off += sizeof(s);
  s = htons(class);
  memcpy(buf + off, &s, sizeof(s));
  off += sizeof(s);
  assert(off <= sz);
  return off;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<utf8_is_valid>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rdx,%r13
  mov    %rcx,%r12
  movslq %esi,%rsi
  lea    (%rdi,%rsi,4),%rbp
  movl   $0x0,(%rcx)
  cmp    %rbp,%rdi
  jb     L19
L124:
  mov    $0x0,%ebx
  mov    $0x1,%eax
  jmp    L90
L36:
  mov    %rbp,%rdx
  mov    $0x1,%esi
  mov    %rbx,%rdi
  call   <utf8_check_boundary@plt>
  test   %rax,%rax
  jne    L31
  mov    %rbx,%rdi
  call   <utf8_check_2@plt>
  test   %rax,%rax
  je     L122
  add    $0x8,%rbx
L77:
  cmp    %rbp,%rbx
  jae    L124
L19:
  mov    %rbx,%rdi
  call   <utf8_check_1@plt>
  test   %rax,%rax
  je     L36
  add    $0x4,%rbx
  jmp    L77
L31:
  movl   $0x3,(%r12)
  jmp    L116
L122:
  mov    %rbp,%rdx
  mov    $0x2,%esi
  mov    %rbx,%rdi
  call   <utf8_check_boundary@plt>
  test   %rax,%rax
  jne    L107
  mov    %rbx,%rdi
  call   <utf8_check_3@plt>
  test   %rax,%rax
  je     L133
  add    $0xc,%rbx
  jmp    L77
L107:
  movl   $0x2,(%r12)
  jmp    L116
L133:
  mov    %rbp,%rdx
  mov    $0x3,%esi
  mov    %rbx,%rdi
  call   <utf8_check_boundary@plt>
  test   %rax,%rax
  jne    L28
  mov    %rbx,%rdi
  call   <utf8_check_4@plt>
  test   %rax,%rax
  jne    L56
L116:
  mov    $0x0,%eax
L90:
  mov    %rbx,0x0(%r13)
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L28:
  movl   $0x1,(%r12)
  jmp    L116
L56:
  add    $0x10,%rbx
  jmp    L77
```

assistant: ```c
bool utf8_is_valid(uint8_t *input, uint32_t length, uint8_t **bad, uint32_t *missing) {
  uint8_t *position;
  uint8_t *max;
  uint32_t n;
  position = input;
  max = input + length;
  *missing = 0;
  while (position < max) {
    n = 0;
    if (utf8_check_1(position)) {
      position++;
      continue;
    }
    n++;
    if (utf8_check_boundary(position, n, max)) {
      *missing = 4 - n;
      goto BOUNDARY;
    }
    if (utf8_check_2(position)) {
      position += n + 1;
      continue;
    }
    n++;
    if (utf8_check_boundary(position, n, max)) {
      *missing = 4 - n;
      goto BOUNDARY;
    }
    if (utf8_check_3(position)) {
      position += n + 1;
      continue;
    }
    n++;
    if (utf8_check_boundary(position, n, max)) {
      *missing = 4 - n;
      goto BOUNDARY;
    }
    if (utf8_check_4(position)) {
      position += n + 1;
      continue;
    }
  BOUNDARY:
    *bad = position;
    return (false);
  }
  *bad = NULL;
  return (true);
}
```