ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What would the C source look like for the assembly code provided here?

```asm
<write_lpsolve>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x28,%rsp
  mov    %esi,0x18(%rsp)
  mov    %edx,0xc(%rsp)
  cmp    $0x1,%edx
  jle    L117
  movslq 0xc(%rsp),%r14
  mov    $0x1,%ebp
  pxor   %xmm1,%xmm1
  lea    D12(%rip),%r15
  jmp    L3
  nopl   0x0(%rax)
L58:
  add    $0x1,%rbp
  cmp    %r14,%rbp
  je     L117
L3:
  movss  (%r12,%rbp,4),%xmm0
  mov    %ebp,%edx
  ucomiss %xmm1,%xmm0
  jp     L18
  je     L58
L18:
  mov    %r15,%rsi
  mov    %rbx,%rdi
  mov    $0x1,%eax
  add    $0x1,%rbp
  cvtss2sd %xmm0,%xmm0
  call   <fprintf@plt>
  pxor   %xmm1,%xmm1
  cmp    %r14,%rbp
  jne    L3
L117:
  mov    %rbx,%rcx
  mov    $0x2,%edx
  mov    $0x1,%esi
  lea    D22(%rip),%rdi
  call   <fwrite@plt>
  cmpl   $0x1,0x18(%rsp)
  jle    L132
  movslq 0xc(%rsp),%r14
  mov    $0x1,%ebp
  mov    %r14,%rax
  lea    0x0(,%r14,4),%rcx
  sub    $0x2,%eax
  mov    %rcx,0x10(%rsp)
  lea    (%r12,%rcx,1),%r14
  lea    D12(%rip),%r12
  mov    %eax,0x1c(%rsp)
  nopl   0x0(%rax)
L85:
  mov    0x1c(%rsp),%r9d
  cmpl   $0x1,0xc(%rsp)
  mov    $0x1,%r13d
  lea    0x2(%r9),%r15
  jg     L116
  jmp    L107
  nopl   0x0(%rax,%rax,1)
L96:
  add    $0x1,%r13
  cmp    %r15,%r13
  je     L107
L116:
  movss  (%r14,%r13,4),%xmm0
  pxor   %xmm2,%xmm2
  mov    %r13d,%edx
  ucomiss %xmm2,%xmm0
  jp     L79
  je     L96
L79:
  mov    %r12,%rsi
  mov    %rbx,%rdi
  mov    $0x1,%eax
  add    $0x1,%r13
  cvtss2sd %xmm0,%xmm0
  call   <fprintf@plt>
  cmp    %r15,%r13
  jne    L116
L107:
  pxor   %xmm0,%xmm0
  mov    %rbx,%rdi
  mov    $0x1,%eax
  add    $0x1,%ebp
  lea    D16(%rip),%rsi
  cvtss2sd (%r14),%xmm0
  call   <fprintf@plt>
  add    0x10(%rsp),%r14
  cmp    %ebp,0x18(%rsp)
  jne    L85
L132:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: read_data
arguments: label: D12
type_infered: string
name: read_data
arguments: label: D22
type_infered: string
name: read_data
arguments: label: D16
type_infered: string

tool: D12: %+.2f x%d 

tool: D22: ;


tool: D16: <= %+.2f ;


assistant: ```c
void write_lpsolve(FILE *fp, const int m, const int n, const float *lp) {
  for (int j = 1; j < n; j++)
    if (lp[j] != 0)
      fprintf(fp,
              "%+.2"
              "f"
              " x%d ",
              lp[j], j);
  fprintf(fp, ";\n");
  for (int i = 1; i < m; i++) {
    for (int j = 1; j < n; j++) {
      float a = lp[i * n + j];
      if (a != 0)
        fprintf(fp,
                "%+.2"
                "f"
                " x%d ",
                a, j);
    }
    fprintf(fp,
            "<= "
            "%+.2"
            "f"
            " ;\n",
            lp[i * n]);
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<write_lpsolve>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x28,%rsp
  mov    %esi,0x18(%rsp)
  mov    %edx,0xc(%rsp)
  cmp    $0x1,%edx
  jle    L10
  movslq 0xc(%rsp),%r14
  mov    $0x1,%ebp
  pxor   %xmm1,%xmm1
  lea    D21(%rip),%r15
  jmp    L125
  nopl   0x0(%rax)
L64:
  add    $0x1,%rbp
  cmp    %rbp,%r14
  je     L10
L125:
  movss  (%r12,%rbp,4),%xmm0
  mov    %ebp,%edx
  ucomiss %xmm1,%xmm0
  jp     L50
  je     L64
L50:
  mov    %r15,%rsi
  mov    %rbx,%rdi
  mov    $0x1,%eax
  add    $0x1,%rbp
  cvtss2sd %xmm0,%xmm0
  call   <fprintf@plt>
  pxor   %xmm1,%xmm1
  cmp    %rbp,%r14
  jne    L125
L10:
  mov    %rbx,%rcx
  mov    $0x2,%edx
  mov    $0x1,%esi
  lea    D25(%rip),%rdi
  call   <fwrite@plt>
  cmpl   $0x1,0x18(%rsp)
  jle    L54
  movslq 0xc(%rsp),%r14
  mov    $0x1,%ebp
  mov    %r14,%rax
  lea    0x0(,%r14,4),%rcx
  sub    $0x2,%eax
  mov    %rcx,0x10(%rsp)
  lea    (%r12,%rcx,1),%r14
  lea    D21(%rip),%r12
  mov    %eax,0x1c(%rsp)
  nopl   0x0(%rax)
L1:
  mov    0x1c(%rsp),%r9d
  cmpl   $0x1,0xc(%rsp)
  mov    $0x1,%r13d
  lea    0x2(%r9),%r15
  jg     L95
  jmp    L74
  nopl   0x0(%rax,%rax,1)
L105:
  add    $0x1,%r13
  cmp    %r15,%r13
  je     L74
L95:
  movss  (%r14,%r13,4),%xmm0
  pxor   %xmm2,%xmm2
  mov    %r13d,%edx
  ucomiss %xmm2,%xmm0
  jp     L56
  je     L105
L56:
  mov    %r12,%rsi
  mov    %rbx,%rdi
  mov    $0x1,%eax
  add    $0x1,%r13
  cvtss2sd %xmm0,%xmm0
  call   <fprintf@plt>
  cmp    %r15,%r13
  jne    L95
L74:
  pxor   %xmm0,%xmm0
  mov    %rbx,%rdi
  mov    $0x1,%eax
  add    $0x1,%ebp
  lea    D31(%rip),%rsi
  cvtss2sd (%r14),%xmm0
  call   <fprintf@plt>
  add    0x10(%rsp),%r14
  cmp    %ebp,0x18(%rsp)
  jne    L1
L54:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: disassemble_data
arguments: label: D21
type_infered: string
name: disassemble_data
arguments: label: D25
type_infered: string
name: disassemble_data
arguments: label: D31
type_infered: string

tool: D21: %+.2f x%d 

tool: D25: ;


tool: D31: <= %+.2f ;


assistant: ```c
void write_lpsolve(FILE *fp, const int m, const int n, const float *lp) {
  for (int j = 1; j < n; j++)
    if (lp[j] != 0)
      fprintf(fp,
              "%+.2"
              "f"
              " x%d ",
              lp[j], j);
  fprintf(fp, ";\n");
  for (int i = 1; i < m; i++) {
    for (int j = 1; j < n; j++) {
      float a = lp[i * n + j];
      if (a != 0)
        fprintf(fp,
                "%+.2"
                "f"
                " x%d ",
                a, j);
    }
    fprintf(fp,
            "<= "
            "%+.2"
            "f"
            " ;\n",
            lp[i * n]);
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<CheckProprietaryStream>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %esi,-0xc(%rbp)
  cmpl   $0x3,-0xc(%rbp)
  jg     L17
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  jmp    L4
L17:
  mov    -0x8(%rbp),%rax
  mov    $0x74980312,%esi
  mov    %rax,%rdi
  call   <IsMPEG2StartCode@plt>
  test   %rax,%rax
  je     L24
  mov    $0xf1,%eax
  jmp    L4
L24:
  mov    $0x0,%eax
L4:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_tag: D8
type_infered: string

tool: D8: Too few data to detecte private audio stream type

assistant: ```c
int CheckProprietaryStream(const char *pData, int Size) {
  if (Size < 4) {
    printf("Too few data to detecte private audio stream type");
    return 0;
  }
  if (IsMPEG2StartCode((unsigned char *)pData, 0x74980312)) {
    return 0xf1;
  }
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<CheckProprietaryStream>:
  endbr64
  sub    $0x8,%rsp
  cmp    $0x3,%esi
  jle    L0
  mov    $0x74980312,%esi
  call   <IsMPEG2StartCode@plt>
  neg    %rax
  sbb    %eax,%eax
  and    $0xf1,%eax
L10:
  add    $0x8,%rsp
  ret
L0:
  lea    D1(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  jmp    L10
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D1
data_type: string

tool: D1: Too few data to detecte private audio stream type

assistant: ```c
int CheckProprietaryStream(const char *pData, int Size) {
  if (Size < 4) {
    printf("Too few data to detecte private audio stream type");
    return 0;
  }
  if (IsMPEG2StartCode((unsigned char *)pData, 0x74980312)) {
    return 0xf1;
  }
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<CheckProprietaryStream>:
  endbr64
  sub    $0x8,%rsp
  cmp    $0x3,%esi
  jle    L4
  mov    $0x74980312,%esi
  call   <IsMPEG2StartCode@plt>
  neg    %rax
  sbb    %eax,%eax
  add    $0x8,%rsp
  and    $0xf1,%eax
  ret
  cs nopw 0x0(%rax,%rax,1)
L4:
  lea    D9(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D9
data_type: string

tool: D9: Too few data to detecte private audio stream type

assistant: ```c
int CheckProprietaryStream(const char *pData, int Size) {
  if (Size < 4) {
    printf("Too few data to detecte private audio stream type");
    return 0;
  }
  if (IsMPEG2StartCode((unsigned char *)pData, 0x74980312)) {
    return 0xf1;
  }
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<CheckProprietaryStream>:
  endbr64
  sub    $0x8,%rsp
  cmp    $0x3,%esi
  jle    L3
  mov    $0x74980312,%esi
  call   <IsMPEG2StartCode@plt>
  neg    %rax
  sbb    %eax,%eax
  add    $0x8,%rsp
  and    $0xf1,%eax
  ret
  cs nopw 0x0(%rax,%rax,1)
L3:
  lea    D4(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D4
data_type: string

tool: D4: Too few data to detecte private audio stream type

assistant: ```c
int CheckProprietaryStream(const char *pData, int Size) {
  if (Size < 4) {
    printf("Too few data to detecte private audio stream type");
    return 0;
  }
  if (IsMPEG2StartCode((unsigned char *)pData, 0x74980312)) {
    return 0xf1;
  }
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<append_move>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %esi,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x1f,%eax
  sub    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <append_face@plt>
  mov    -0xc(%rbp),%edx
  movslq %edx,%rax
  imul   $0x55555556,%rax,%rax
  shr    $0x20,%rax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  mov    %eax,%ecx
  add    %ecx,%ecx
  add    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    -0x8(%rbp),%rdx
  lea    0x1(%rdx),%rcx
  mov    %rcx,-0x8(%rbp)
  cltq
  lea    D9(%rip),%rcx
  movzbl (%rax,%rcx,1),%eax
  mov    %al,(%rdx)
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  nop
  leave
  ret
```

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

tool: D9: 123

assistant: ```c
void append_move(char *p, int mv) {
  append_face(p, mv / 3);
  *p++ = "123"[mv % 3];
  *p = 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<append_move>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  mov    %esi,%ebx
  movslq %esi,%rbp
  imul   $0x55555556,%rbp,%rbp
  shr    $0x20,%rbp
  mov    %esi,%eax
  sar    $0x1f,%eax
  sub    %eax,%ebp
  mov    %ebp,%esi
  call   <append_face@plt>
  lea    0x0(%rbp,%rbp,2),%eax
  sub    %eax,%ebx
  movslq %ebx,%rbx
  lea    D2(%rip),%rax
  movzbl (%rax,%rbx,1),%eax
  mov    %al,(%r12)
  movb   $0x0,0x1(%r12)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D2
type_guessed: string

tool: D2: 123

assistant: ```c
void append_move(char *p, int mv) {
  append_face(p, mv / 3);
  *p++ = "123"[mv % 3];
  *p = 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<append_move>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  movslq %esi,%rbp
  push   %rbx
  mov    %rbp,%rbx
  imul   $0x55555556,%rbp,%rbp
  mov    %ebx,%eax
  sar    $0x1f,%eax
  shr    $0x20,%rbp
  sub    %eax,%ebp
  mov    %ebp,%esi
  call   <append_face@plt>
  lea    0x0(%rbp,%rbp,2),%eax
  movb   $0x0,0x1(%r12)
  sub    %eax,%ebx
  lea    D4(%rip),%rax
  movslq %ebx,%rbx
  movzbl (%rax,%rbx,1),%eax
  pop    %rbx
  pop    %rbp
  mov    %al,(%r12)
  pop    %r12
  ret
```

tool_calls: name: unpack_data
arguments: tag: D4
type_guessed: string

tool: D4: 123

assistant: ```c
void append_move(char *p, int mv) {
  append_face(p, mv / 3);
  *p++ = "123"[mv % 3];
  *p = 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<append_move>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  movslq %esi,%rbp
  push   %rbx
  mov    %rbp,%rbx
  imul   $0x55555556,%rbp,%rbp
  mov    %ebx,%eax
  sar    $0x1f,%eax
  shr    $0x20,%rbp
  sub    %eax,%ebp
  mov    %ebp,%esi
  call   <append_face@plt>
  lea    0x0(%rbp,%rbp,2),%eax
  movb   $0x0,0x1(%r12)
  sub    %eax,%ebx
  lea    D0(%rip),%rax
  movslq %ebx,%rbx
  movzbl (%rax,%rbx,1),%eax
  pop    %rbx
  pop    %rbp
  mov    %al,(%r12)
  pop    %r12
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D0
data_type: string

tool: D0: 123

assistant: ```c
void append_move(char *p, int mv) {
  append_face(p, mv / 3);
  *p++ = "123"[mv % 3];
  *p = 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<htoi>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x1c(%rbp)
  movw   $0x0,-0x22(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L55
L160:
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x24(%rbp)
  cmpl   $0x0,-0x20(%rbp)
  jne    L134
  addl   $0x1,-0x20(%rbp)
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x23(%rbp)
  cmpb   $0x30,-0x24(%rbp)
  jne    L109
  cmpb   $0x78,-0x23(%rbp)
  je     L90
  cmpb   $0x58,-0x23(%rbp)
  jne    L109
L90:
  movw   $0x1,-0x22(%rbp)
  jmp    L109
L134:
  movsbl -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <isxdigit@plt>
  test   %eax,%eax
  jne    L109
  mov    $0xffffffffffffffff,%rax
  jmp    L129
L109:
  addl   $0x1,-0x20(%rbp)
L55:
  mov    -0x20(%rbp),%eax
  cmp    %eax,-0x1c(%rbp)
  ja     L160
  cmpw   $0x0,-0x22(%rbp)
  je     L8
  addq   $0x2,-0x38(%rbp)
L8:
  movq   $0x0,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x1c(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L104
L113:
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x24(%rbp)
  movsbl -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L150
  movzbl -0x24(%rbp),%eax
  sub    $0x30,%eax
  mov    %al,-0x24(%rbp)
  jmp    L1
L150:
  movsbl -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L1
  movsbl -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L74
  movsbl -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <tolower@plt>
  sub    $0x57,%eax
  jmp    L165
L74:
  movzbl -0x24(%rbp),%eax
  sub    $0x57,%eax
L165:
  mov    %al,-0x24(%rbp)
L1:
  movsbq -0x24(%rbp),%rbx
  mov    -0x20(%rbp),%eax
  mov    %eax,%esi
  mov    $0x10,%edi
  call   <pow@plt>
  imul   %rbx,%rax
  add    %rax,-0x18(%rbp)
  addl   $0x1,-0x20(%rbp)
L104:
  mov    -0x20(%rbp),%eax
  cmp    %eax,-0x1c(%rbp)
  ja     L113
  mov    -0x18(%rbp),%rax
L129:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
unsigned long int htoi(const char *s) {
  unsigned int len = strlen(s);
  unsigned short flag = 0;
  char c, next_char;
  int i = 0;
  while (i < len) {
    c = *(s + i);
    if (i == 0) {
      next_char = *(s + ++i);
      if (c == '0' && (next_char == 'x' || next_char == 'X')) {
        flag = 1;
      }
    } else {
      if (!isxdigit(c)) {
        return -1;
      }
    }
    i++;
  }
  if (flag) {
    s += 2;
  }
  unsigned long int result = 0;
  len = strlen(s);
  i = 0;
  while (i < len) {
    c = *(s + i);
    if (isdigit(c)) {
      c -= '0';
    } else if (isalpha(c)) {
      c = ((isupper(c)) ? tolower(c) : c) - 'a' + 10;
    }
    result += c * ((long int)pow(16, i));
    i++;
  }
  return result;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<htoi>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r12
  call   <strlen@plt>
  test   %eax,%eax
  je     L99
  mov    %eax,%ebp
  mov    $0x0,%ebx
  mov    $0x0,%r13d
  mov    $0x1,%r14d
  jmp    L115
L143:
  movsbl %dil,%edi
  call   <isxdigit@plt>
  test   %eax,%eax
  je     L93
L47:
  add    $0x1,%ebx
  cmp    %ebp,%ebx
  jae    L109
L115:
  movslq %ebx,%rax
  movzbl (%r12,%rax,1),%edi
  test   %ebx,%ebx
  jne    L143
  mov    $0x1,%ebx
  cmp    $0x30,%dil
  jne    L47
  movzbl 0x1(%r12),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  cmove  %r14d,%r13d
  jmp    L47
L109:
  lea    0x2(%r12),%rax
  test   %r13w,%r13w
  cmovne %rax,%r12
L99:
  mov    %r12,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  je     L136
  mov    %eax,%r15d
  mov    $0x0,%ebp
  mov    $0x0,%r14d
  jmp    L105
L24:
  sub    $0x30,%ebx
L108:
  mov    0xc(%rsp),%esi
  mov    $0x10,%edi
  call   <pow@plt>
  movsbq %bl,%rbx
  imul   %rax,%rbx
  add    %rbx,%r14
  add    $0x1,%rbp
  cmp    %rbp,%r15
  je     L66
L105:
  mov    %ebp,0xc(%rsp)
  movzbl (%r12,%rbp,1),%ebx
  movsbl %bl,%r13d
  mov    %r13d,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L24
  mov    %r13d,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L108
  mov    %r13d,%edi
  call   <isupper@plt>
  sub    $0x57,%ebx
  test   %rax,%rax
  je     L108
  mov    %r13d,%edi
  call   <tolower@plt>
  lea    -0x57(%rax),%ebx
  jmp    L108
L93:
  mov    $0xffffffffffffffff,%r14
L66:
  mov    %r14,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L136:
  mov    $0x0,%r14d
  jmp    L66
```

assistant: ```c
unsigned long int htoi(const char *s) {
  unsigned int len = strlen(s);
  unsigned short flag = 0;
  char c, next_char;
  int i = 0;
  while (i < len) {
    c = *(s + i);
    if (i == 0) {
      next_char = *(s + ++i);
      if (c == '0' && (next_char == 'x' || next_char == 'X')) {
        flag = 1;
      }
    } else {
      if (!isxdigit(c)) {
        return -1;
      }
    }
    i++;
  }
  if (flag) {
    s += 2;
  }
  unsigned long int result = 0;
  len = strlen(s);
  i = 0;
  while (i < len) {
    c = *(s + i);
    if (isdigit(c)) {
      c -= '0';
    } else if (isalpha(c)) {
      c = ((isupper(c)) ? tolower(c) : c) - 'a' + 10;
    }
    result += c * ((long int)pow(16, i));
    i++;
  }
  return result;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<htoi>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  call   <strlen@plt>
  test   %eax,%eax
  je     L29
  mov    %eax,%r13d
  xor    %ebx,%ebx
  xor    %ebp,%ebp
  jmp    L84
  nopw   0x0(%rax,%rax,1)
L58:
  mov    $0x2,%eax
  mov    $0x2,%ebx
  cmp    $0x30,%dil
  jne    L100
  movzbl 0x1(%r12),%edx
  and    $0xffffffdf,%edx
  cmp    $0x58,%dl
  mov    $0x1,%edx
  cmove  %edx,%ebp
L100:
  cmp    %eax,%r13d
  jbe    L149
L84:
  movslq %ebx,%rax
  movsbl (%r12,%rax,1),%edi
  test   %ebx,%ebx
  je     L58
  call   <isxdigit@plt>
  test   %eax,%eax
  je     L146
  add    $0x1,%ebx
  mov    %ebx,%eax
  cmp    %eax,%r13d
  ja     L84
L149:
  lea    0x2(%r12),%rax
  test   %bp,%bp
  cmovne %rax,%r12
L29:
  mov    %r12,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  je     L110
  mov    %eax,%eax
  xor    %ebp,%ebp
  xor    %r13d,%r13d
  mov    %rax,0x8(%rsp)
  jmp    L42
  cs nopw 0x0(%rax,%rax,1)
L0:
  sub    $0x30,%ebx
L74:
  mov    %r14d,%esi
  mov    $0x10,%edi
  movsbq %bl,%rbx
  add    $0x1,%rbp
  call   <pow@plt>
  imul   %rax,%rbx
  add    %rbx,%r13
  cmp    %rbp,0x8(%rsp)
  je     L80
L42:
  movsbl (%r12,%rbp,1),%r15d
  mov    %ebp,%r14d
  mov    %r15d,%edi
  mov    %r15d,%ebx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L0
  mov    %r15d,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L74
  mov    %r15d,%edi
  sub    $0x57,%ebx
  call   <isupper@plt>
  test   %rax,%rax
  je     L74
  mov    %r15d,%edi
  call   <tolower@plt>
  lea    -0x57(%rax),%ebx
  jmp    L74
  nopl   0x0(%rax,%rax,1)
L146:
  mov    $0xffffffffffffffff,%r13
L80:
  add    $0x18,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L110:
  xor    %r13d,%r13d
  jmp    L80
```

assistant: ```c
unsigned long int htoi(const char *s) {
  unsigned int len = strlen(s);
  unsigned short flag = 0;
  char c, next_char;
  int i = 0;
  while (i < len) {
    c = *(s + i);
    if (i == 0) {
      next_char = *(s + ++i);
      if (c == '0' && (next_char == 'x' || next_char == 'X')) {
        flag = 1;
      }
    } else {
      if (!isxdigit(c)) {
        return -1;
      }
    }
    i++;
  }
  if (flag) {
    s += 2;
  }
  unsigned long int result = 0;
  len = strlen(s);
  i = 0;
  while (i < len) {
    c = *(s + i);
    if (isdigit(c)) {
      c -= '0';
    } else if (isalpha(c)) {
      c = ((isupper(c)) ? tolower(c) : c) - 'a' + 10;
    }
    result += c * ((long int)pow(16, i));
    i++;
  }
  return result;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<htoi>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  call   <strlen@plt>
  test   %eax,%eax
  je     L14
  mov    %eax,%r13d
  xor    %ebx,%ebx
  xor    %ebp,%ebp
  jmp    L98
  nopw   0x0(%rax,%rax,1)
L149:
  mov    $0x2,%eax
  mov    $0x2,%ebx
  cmp    $0x30,%dil
  jne    L124
  movzbl 0x1(%r12),%edx
  and    $0xffffffdf,%edx
  cmp    $0x58,%dl
  mov    $0x1,%edx
  cmove  %edx,%ebp
L124:
  cmp    %eax,%r13d
  jbe    L8
L98:
  movslq %ebx,%rax
  movsbl (%r12,%rax,1),%edi
  test   %ebx,%ebx
  je     L149
  call   <isxdigit@plt>
  test   %eax,%eax
  je     L22
  add    $0x1,%ebx
  mov    %ebx,%eax
  cmp    %eax,%r13d
  ja     L98
L8:
  lea    0x2(%r12),%rax
  test   %bp,%bp
  cmovne %rax,%r12
L14:
  mov    %r12,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  je     L24
  mov    %eax,%eax
  xor    %ebp,%ebp
  xor    %r13d,%r13d
  mov    %rax,0x8(%rsp)
  jmp    L126
  cs nopw 0x0(%rax,%rax,1)
L70:
  sub    $0x30,%ebx
L107:
  mov    %r14d,%esi
  mov    $0x10,%edi
  movsbq %bl,%rbx
  add    $0x1,%rbp
  call   <pow@plt>
  imul   %rax,%rbx
  add    %rbx,%r13
  cmp    %rbp,0x8(%rsp)
  je     L76
L126:
  movsbl (%r12,%rbp,1),%r15d
  mov    %ebp,%r14d
  mov    %r15d,%edi
  mov    %r15d,%ebx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L70
  mov    %r15d,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L107
  mov    %r15d,%edi
  sub    $0x57,%ebx
  call   <isupper@plt>
  test   %rax,%rax
  je     L107
  mov    %r15d,%edi
  call   <tolower@plt>
  lea    -0x57(%rax),%ebx
  jmp    L107
  nopl   0x0(%rax,%rax,1)
L22:
  mov    $0xffffffffffffffff,%r13
L76:
  add    $0x18,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L24:
  xor    %r13d,%r13d
  jmp    L76
```

assistant: ```c
unsigned long int htoi(const char *s) {
  unsigned int len = strlen(s);
  unsigned short flag = 0;
  char c, next_char;
  int i = 0;
  while (i < len) {
    c = *(s + i);
    if (i == 0) {
      next_char = *(s + ++i);
      if (c == '0' && (next_char == 'x' || next_char == 'X')) {
        flag = 1;
      }
    } else {
      if (!isxdigit(c)) {
        return -1;
      }
    }
    i++;
  }
  if (flag) {
    s += 2;
  }
  unsigned long int result = 0;
  len = strlen(s);
  i = 0;
  while (i < len) {
    c = *(s + i);
    if (isdigit(c)) {
      c -= '0';
    } else if (isalpha(c)) {
      c = ((isupper(c)) ? tolower(c) : c) - 'a' + 10;
    }
    result += c * ((long int)pow(16, i));
    i++;
  }
  return result;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<Act_Sub>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    $0x0,%eax
  call   <ArgNum@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <GetFlag@plt>
  mov    %rax,%rbx
  mov    $0x0,%eax
  call   <ArgNum@plt>
  cltq
  mov    %rbx,%rdx
  sub    %rax,%rdx
  mov    -0x14(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <SetFlag@plt>
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void Act_Sub(void) {
  int a = ArgNum();
  SetFlag(a, GetFlag(a) - ArgNum());
}
```