ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What is the c source code of the assembly code below:

```asm
<Sfile_fgets_n>:
  endbr64
  push   %r12
  push   %rbp
  mov    %ecx,%ebp
  push   %rbx
  mov    %rdi,%rbx
  call   <fgets@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L90
  mov    %rbx,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jle    L90
  movslq %eax,%rsi
  and    $0x1,%ebp
  lea    -0x1(%rbx,%rsi,1),%rdx
  movzbl (%rdx),%ecx
  jne    L103
  cmp    $0xd,%cl
  je     L57
  cmp    $0xa,%cl
  jne    L90
L58:
  movb   $0x0,(%rdx)
  sub    $0x1,%eax
  je     L90
  cltq
  lea    -0x1(%rbx,%rax,1),%rdx
  movzbl (%rdx),%ecx
L41:
  cmp    $0xd,%cl
  jne    L90
L84:
  movb   $0x0,(%rdx)
L90:
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L103:
  cmp    $0xa,%cl
  je     L84
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   (%rax)
L57:
  movb   $0x0,(%rdx)
  sub    $0x1,%eax
  je     L90
  lea    -0x2(%rbx,%rsi,1),%rdx
  movzbl (%rdx),%ecx
  cmp    $0xa,%cl
  jne    L41
  jmp    L58
```

assistant: ```c
char *Sfile_fgets_n(char *line, int maxl, FILE *fp, int flag) {
  int l;
  char *ret;
  ret = fgets(line, maxl, fp);
  if (ret == NULL)
    return (NULL);
  l = strlen(line);
  if (l > 0 && !(flag & 1))
    if (line[l - 1] == '\r')
      line[--l] = 0;
  if (l > 0)
    if (line[l - 1] == '\n')
      line[--l] = 0;
  if (l > 0 && !(flag & 1))
    if (line[l - 1] == '\r')
      line[--l] = 0;
  return (ret);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<lfr_getcpuflags>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    $0x1,%eax
  cpuid
  mov    %ebx,%esi
  mov    %eax,-0x20(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %ecx,-0x18(%rbp)
  mov    %edx,-0x14(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <lfr_getcpuflags_x86@plt>
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
unsigned lfr_getcpuflags(void) {
  unsigned a, b, c, d;
  __asm__("cpuid" : "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(1));
  return lfr_getcpuflags_x86(d, c);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<lfr_getcpuflags>:
  endbr64
  push   %rbx
  mov    $0x1,%eax
  cpuid
  mov    %edx,%edi
  mov    %ecx,%esi
  mov    $0x0,%eax
  call   <lfr_getcpuflags_x86@plt>
  pop    %rbx
  ret
```

assistant: ```c
unsigned lfr_getcpuflags(void) {
  unsigned a, b, c, d;
  __asm__("cpuid" : "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(1));
  return lfr_getcpuflags_x86(d, c);
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<lfr_getcpuflags>:
  endbr64
  push   %rbx
  mov    $0x1,%eax
  cpuid
  xor    %eax,%eax
  mov    %edx,%edi
  mov    %ecx,%esi
  pop    %rbx
  jmp    1050 <lfr_getcpuflags_x86@plt>
```

assistant: ```c
unsigned lfr_getcpuflags(void) {
  unsigned a, b, c, d;
  __asm__("cpuid" : "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(1));
  return lfr_getcpuflags_x86(d, c);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<lfr_getcpuflags>:
  endbr64
  push   %rbx
  mov    $0x1,%eax
  cpuid
  xor    %eax,%eax
  mov    %edx,%edi
  mov    %ecx,%esi
  pop    %rbx
  jmp    1050 <lfr_getcpuflags_x86@plt>
```

assistant: ```c
unsigned lfr_getcpuflags(void) {
  unsigned a, b, c, d;
  __asm__("cpuid" : "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(1));
  return lfr_getcpuflags_x86(d, c);
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<to_p_string>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  movl   $0x1,-0x4(%rbp)
  jmp    L2
L1:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  movzbl -0x5(%rbp),%eax
  mov    %al,(%rdx)
  movzbl -0x6(%rbp),%eax
  add    $0x1,%eax
  mov    %al,-0x6(%rbp)
L2:
  mov    -0x4(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x4(%rbp)
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x5(%rbp)
  cmpb   $0x0,-0x5(%rbp)
  jne    L1
  mov    -0x20(%rbp),%rax
  movzbl -0x6(%rbp),%edx
  mov    %dl,(%rax)
  mov    $0x0,%eax
  pop    %rbp
  ret
```

assistant: ```c
int to_p_string(char *cstr, char *new_pstr) {
  char c;
  char size;
  int index = 1;
  while (c = cstr[(index++) - 1], c != 0) {
    new_pstr[index] = c;
    size += 1;
  }
  new_pstr[0] = size;
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<to_p_string>:
  endbr64
  movzbl (%rdi),%edx
  test   %dl,%dl
  je     L3
  mov    $0x2,%eax
L17:
  mov    %dl,(%rsi,%rax,1)
  lea    -0x1(%rcx,%rax,1),%ecx
  add    $0x1,%rax
  movzbl -0x2(%rdi,%rax,1),%edx
  test   %dl,%dl
  jne    L17
L3:
  mov    %cl,(%rsi)
  mov    $0x0,%eax
  ret
```

assistant: ```c
int to_p_string(char *cstr, char *new_pstr) {
  char c;
  char size;
  int index = 1;
  while (c = cstr[(index++) - 1], c != 0) {
    new_pstr[index] = c;
    size += 1;
  }
  new_pstr[0] = size;
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<to_p_string>:
  endbr64
  movzbl (%rdi),%edx
  test   %dl,%dl
  je     L13
  mov    $0x2,%eax
L0:
  mov    %dl,(%rsi,%rax,1)
  lea    -0x1(%rcx,%rax,1),%ecx
  add    $0x1,%rax
  movzbl -0x2(%rdi,%rax,1),%edx
  test   %dl,%dl
  jne    L0
L13:
  mov    %cl,(%rsi)
  xor    %eax,%eax
  ret
```

assistant: ```c
int to_p_string(char *cstr, char *new_pstr) {
  char c;
  char size;
  int index = 1;
  while (c = cstr[(index++) - 1], c != 0) {
    new_pstr[index] = c;
    size += 1;
  }
  new_pstr[0] = size;
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<to_p_string>:
  endbr64
  movzbl (%rdi),%edx
  test   %dl,%dl
  je     L10
  mov    $0x2,%eax
L13:
  mov    %dl,(%rsi,%rax,1)
  lea    -0x1(%rcx,%rax,1),%ecx
  add    $0x1,%rax
  movzbl -0x2(%rdi,%rax,1),%edx
  test   %dl,%dl
  jne    L13
L10:
  mov    %cl,(%rsi)
  xor    %eax,%eax
  ret
```

assistant: ```c
int to_p_string(char *cstr, char *new_pstr) {
  char c;
  char size;
  int index = 1;
  while (c = cstr[(index++) - 1], c != 0) {
    new_pstr[index] = c;
    size += 1;
  }
  new_pstr[0] = size;
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<verify_benchmark>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  movl   $0xf4240,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  je     L19
  mov    $0x0,%eax
  jmp    L1
L19:
  mov    $0x1,%eax
L1:
  pop    %rbp
  ret
```

assistant: ```c
int verify_benchmark(int r) {
  int expected = 1000000;
  if (r != expected)
    return 0;
  return 1;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<verify_benchmark>:
  endbr64
  cmp    $0xf4240,%edi
  sete   %al
  movzbl %al,%eax
  ret
```

assistant: ```c
int verify_benchmark(int r) {
  int expected = 1000000;
  if (r != expected)
    return 0;
  return 1;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<verify_benchmark>:
  endbr64
  xor    %eax,%eax
  cmp    $0xf4240,%edi
  sete   %al
  ret
```

assistant: ```c
int verify_benchmark(int r) {
  int expected = 1000000;
  if (r != expected)
    return 0;
  return 1;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<verify_benchmark>:
  endbr64
  xor    %eax,%eax
  cmp    $0xf4240,%edi
  sete   %al
  ret
```

assistant: ```c
int verify_benchmark(int r) {
  int expected = 1000000;
  if (r != expected)
    return 0;
  return 1;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<sizer>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    %rdx,-0x18(%rbp)
  mov    %rcx,-0x20(%rbp)
  cmpq   $0x8,-0x18(%rbp)
  je     L21
  cmpq   $0x8,-0x18(%rbp)
  ja     L26
  cmpq   $0x2,-0x18(%rbp)
  je     L74
  cmpq   $0x4,-0x18(%rbp)
  je     L68
  jmp    L26
L74:
  mov    -0x20(%rbp),%rax
  movzwl (%rax),%eax
  movzwl %ax,%edx
  mov    -0x10(%rbp),%rsi
  mov    -0x8(%rbp),%rax
  mov    %edx,%ecx
  lea    D35(%rip),%rdx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  jmp    L79
L68:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rsi
  mov    -0x8(%rbp),%rax
  mov    %edx,%ecx
  lea    D10(%rip),%rdx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  jmp    L79
L21:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%rsi
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rcx
  lea    D24(%rip),%rdx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  jmp    L79
L26:
  mov    -0x10(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  lea    D1(%rip),%rdx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  nop
L79:
  mov    -0x8(%rbp),%rax
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D35
type: string
name: read_data
arguments: data_label: D10
type: string
name: read_data
arguments: data_label: D24
type: string
name: read_data
arguments: data_label: D1
type: string

tool: D35: %hu

tool: D10: %u

tool: D24: %lu

tool: D1: unknown

assistant: ```c
char *sizer(char *buffer, size_t capacity, size_t vsize, const void *value) {
  switch (vsize) {
  case 2:
    snprintf(buffer, capacity, "%hu", *((const short unsigned *)value));
    break;
  case 4:
    if (sizeof(long) == 4) {
      snprintf(buffer, capacity, "%lu", *((const long unsigned *)value));
    } else {
      snprintf(buffer, capacity, "%u", *((const unsigned *)value));
    }
    break;
  case 8:
    if (sizeof(long) == 4) {
      snprintf(buffer, capacity, "%llu", *((const long long unsigned *)value));
    } else {
      snprintf(buffer, capacity, "%lu", *((const long unsigned *)value));
    }
    break;
  default:
    snprintf(buffer, capacity, "unknown");
    break;
  }
  return buffer;
}
```
user: What is the c source code of the assembly code below:

```asm
<sizer>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  cmp    $0x4,%rdx
  je     L2
  cmp    $0x8,%rdx
  je     L40
  cmp    $0x2,%rdx
  je     L18
  lea    D28(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  jmp    L41
L18:
  movzwl (%rcx),%ecx
  lea    D14(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
L41:
  mov    %rbx,%rax
  pop    %rbx
  ret
L2:
  mov    (%rcx),%ecx
  lea    D2(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  jmp    L41
L40:
  mov    (%rcx),%rcx
  lea    D1(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  jmp    L41
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D28
type_guessed: string
name: extract_symbolic_data
arguments: data_label: D14
type_guessed: string
name: extract_symbolic_data
arguments: data_label: D2
type_guessed: string
name: extract_symbolic_data
arguments: data_label: D1
type_guessed: string

tool: D28: unknown

tool: D14: %hu

tool: D2: %u

tool: D1: %lu

assistant: ```c
char *sizer(char *buffer, size_t capacity, size_t vsize, const void *value) {
  switch (vsize) {
  case 2:
    snprintf(buffer, capacity, "%hu", *((const short unsigned *)value));
    break;
  case 4:
    if (sizeof(long) == 4) {
      snprintf(buffer, capacity, "%lu", *((const long unsigned *)value));
    } else {
      snprintf(buffer, capacity, "%u", *((const unsigned *)value));
    }
    break;
  case 8:
    if (sizeof(long) == 4) {
      snprintf(buffer, capacity, "%llu", *((const long long unsigned *)value));
    } else {
      snprintf(buffer, capacity, "%lu", *((const long unsigned *)value));
    }
    break;
  default:
    snprintf(buffer, capacity, "unknown");
    break;
  }
  return buffer;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<sizer>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  cmp    $0x4,%rdx
  je     L2
  cmp    $0x8,%rdx
  je     L11
  cmp    $0x2,%rdx
  je     L12
  lea    D31(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
  nop
L2:
  mov    (%rcx),%ecx
  lea    D26(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
  cs nopw 0x0(%rax,%rax,1)
L12:
  movzwl (%rcx),%ecx
  lea    D38(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L11:
  mov    (%rcx),%rcx
  lea    D22(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
```

tool_calls: name: retrieve_data
arguments: label: D31
type_infered: string
name: retrieve_data
arguments: label: D26
type_infered: string
name: retrieve_data
arguments: label: D38
type_infered: string
name: retrieve_data
arguments: label: D22
type_infered: string

tool: D31: unknown

tool: D26: %u

tool: D38: %hu

tool: D22: %lu

assistant: ```c
char *sizer(char *buffer, size_t capacity, size_t vsize, const void *value) {
  switch (vsize) {
  case 2:
    snprintf(buffer, capacity, "%hu", *((const short unsigned *)value));
    break;
  case 4:
    if (sizeof(long) == 4) {
      snprintf(buffer, capacity, "%lu", *((const long unsigned *)value));
    } else {
      snprintf(buffer, capacity, "%u", *((const unsigned *)value));
    }
    break;
  case 8:
    if (sizeof(long) == 4) {
      snprintf(buffer, capacity, "%llu", *((const long long unsigned *)value));
    } else {
      snprintf(buffer, capacity, "%lu", *((const long unsigned *)value));
    }
    break;
  default:
    snprintf(buffer, capacity, "unknown");
    break;
  }
  return buffer;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<sizer>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  cmp    $0x4,%rdx
  je     L17
  cmp    $0x8,%rdx
  je     L13
  cmp    $0x2,%rdx
  je     L22
  lea    D29(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
  nop
L17:
  mov    (%rcx),%ecx
  lea    D19(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
  cs nopw 0x0(%rax,%rax,1)
L22:
  movzwl (%rcx),%ecx
  lea    D37(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L13:
  mov    (%rcx),%rcx
  lea    D35(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D29
type_infered: string
name: unpack_data
arguments: data_label: D19
type_infered: string
name: unpack_data
arguments: data_label: D37
type_infered: string
name: unpack_data
arguments: data_label: D35
type_infered: string

tool: D29: unknown

tool: D19: %u

tool: D37: %hu

tool: D35: %lu

assistant: ```c
char *sizer(char *buffer, size_t capacity, size_t vsize, const void *value) {
  switch (vsize) {
  case 2:
    snprintf(buffer, capacity, "%hu", *((const short unsigned *)value));
    break;
  case 4:
    if (sizeof(long) == 4) {
      snprintf(buffer, capacity, "%lu", *((const long unsigned *)value));
    } else {
      snprintf(buffer, capacity, "%u", *((const unsigned *)value));
    }
    break;
  case 8:
    if (sizeof(long) == 4) {
      snprintf(buffer, capacity, "%llu", *((const long long unsigned *)value));
    } else {
      snprintf(buffer, capacity, "%lu", *((const long unsigned *)value));
    }
    break;
  default:
    snprintf(buffer, capacity, "unknown");
    break;
  }
  return buffer;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<ui_cmd_remove_trailing_ws>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L45
  mov    $0x0,%eax
  jmp    L10
L45:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  jmp    L22
L49:
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  subq   $0x1,-0x8(%rbp)
L22:
  cmpq   $0x0,-0x8(%rbp)
  je     L40
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L49
L40:
  mov    -0x18(%rbp),%rax
L10:
  leave
  ret
```

assistant: ```c
char *ui_cmd_remove_trailing_ws(char *input) {
  if (!input)
    return NULL;
  char *input_end = input + strlen(input) - 1;
  while (input_end && isspace(*input_end)) {
    *input_end = '\0';
    input_end--;
  }
  return input;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<ui_cmd_remove_trailing_ws>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  test   %rdi,%rdi
  je     L9
  call   <strlen@plt>
  cltq
  lea    -0x1(%rbp,%rax,1),%rbx
  jmp    L23
L16:
  movb   $0x0,(%rbx)
  sub    $0x1,%rbx
L23:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L16
L9:
  mov    %rbp,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
char *ui_cmd_remove_trailing_ws(char *input) {
  if (!input)
    return NULL;
  char *input_end = input + strlen(input) - 1;
  while (input_end && isspace(*input_end)) {
    *input_end = '\0';
    input_end--;
  }
  return input;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<ui_cmd_remove_trailing_ws>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbx
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L24
  call   <strlen@plt>
  cltq
  lea    -0x1(%r12,%rax,1),%rbx
  jmp    L6
  nopl   0x0(%rax)
L25:
  movb   $0x0,(%rbx)
  sub    $0x1,%rbx
L6:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L25
L24:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %r12
  ret
```

assistant: ```c
char *ui_cmd_remove_trailing_ws(char *input) {
  if (!input)
    return NULL;
  char *input_end = input + strlen(input) - 1;
  while (input_end && isspace(*input_end)) {
    *input_end = '\0';
    input_end--;
  }
  return input;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<ui_cmd_remove_trailing_ws>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbx
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L13
  call   <strlen@plt>
  cltq
  lea    -0x1(%r12,%rax,1),%rbx
  jmp    L23
  nopl   0x0(%rax)
L19:
  movb   $0x0,(%rbx)
  sub    $0x1,%rbx
L23:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L19
L13:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %r12
  ret
```

assistant: ```c
char *ui_cmd_remove_trailing_ws(char *input) {
  if (!input)
    return NULL;
  char *input_end = input + strlen(input) - 1;
  while (input_end && isspace(*input_end)) {
    *input_end = '\0';
    input_end--;
  }
  return input;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<vTwoOne>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L6
L15:
  mov    -0x4(%rbp),%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x5(%rbp)
  cmpb   $0x39,-0x5(%rbp)
  jbe    L17
  movzbl -0x5(%rbp),%eax
  mov    %eax,%edi
  call   <toupper@plt>
  sub    $0x37,%eax
  mov    %al,-0x5(%rbp)
  jmp    L50
L17:
  andb   $0xf,-0x5(%rbp)
L50:
  mov    -0x4(%rbp),%eax
  shr    %eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl -0x5(%rbp),%edx
  shl    $0x4,%edx
  mov    %dl,(%rax)
  mov    -0x4(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x5(%rbp)
  cmpb   $0x39,-0x5(%rbp)
  jbe    L0
  movzbl -0x5(%rbp),%eax
  mov    %eax,%edi
  call   <toupper@plt>
  sub    $0x37,%eax
  mov    %al,-0x5(%rbp)
  jmp    L42
L0:
  andb   $0xf,-0x5(%rbp)
L42:
  mov    -0x4(%rbp),%eax
  shr    %eax
  mov    %eax,%edx
  mov    %edx,%ecx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%ecx
  mov    %edx,%edx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl -0x5(%rbp),%edx
  add    %ecx,%edx
  mov    %dl,(%rax)
  addl   $0x2,-0x4(%rbp)
L6:
  mov    -0x4(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jb     L15
  nop
  nop
  leave
  ret
```

assistant: ```c
void vTwoOne(unsigned char *psIn, unsigned int uiLength, unsigned char *psOut) {
  unsigned char ucTmp;
  unsigned int i;
  for (i = 0; i < uiLength; i += 2) {
    ucTmp = psIn[i];
    if (ucTmp > '9')
      ucTmp = toupper(ucTmp) - 'A' + 0x0a;
    else
      ucTmp &= 0x0f;
    psOut[i / 2] = ucTmp << 4;
    ucTmp = psIn[i + 1];
    if (ucTmp > '9')
      ucTmp = toupper(ucTmp) - 'A' + 0x0a;
    else
      ucTmp &= 0x0f;
    psOut[i / 2] += ucTmp;
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<vTwoOne>:
  endbr64
  test   %esi,%esi
  je     L46
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  mov    %esi,%r13d
  mov    %rdx,%r14
  mov    $0x0,%ebp
  jmp    L14
L19:
  movzbl %dil,%edi
  call   <toupper@plt>
  sub    $0x37,%eax
  jmp    L40
L27:
  add    %al,(%rbx)
  add    $0x2,%ebp
  cmp    %ebp,%r13d
  jbe    L67
L14:
  mov    %ebp,%eax
  movzbl (%r12,%rax,1),%edi
  mov    %edi,%eax
  and    $0xf,%eax
  cmp    $0x39,%dil
  ja     L19
L40:
  mov    %ebp,%ebx
  shr    %ebx
  mov    %ebx,%ebx
  add    %r14,%rbx
  shl    $0x4,%eax
  mov    %al,(%rbx)
  lea    0x1(%rbp),%eax
  movzbl (%r12,%rax,1),%edi
  mov    %edi,%eax
  and    $0xf,%eax
  cmp    $0x39,%dil
  jbe    L27
  movzbl %dil,%edi
  call   <toupper@plt>
  sub    $0x37,%eax
  jmp    L27
L67:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L46:
  ret
```

assistant: ```c
void vTwoOne(unsigned char *psIn, unsigned int uiLength, unsigned char *psOut) {
  unsigned char ucTmp;
  unsigned int i;
  for (i = 0; i < uiLength; i += 2) {
    ucTmp = psIn[i];
    if (ucTmp > '9')
      ucTmp = toupper(ucTmp) - 'A' + 0x0a;
    else
      ucTmp &= 0x0f;
    psOut[i / 2] = ucTmp << 4;
    ucTmp = psIn[i + 1];
    if (ucTmp > '9')
      ucTmp = toupper(ucTmp) - 'A' + 0x0a;
    else
      ucTmp &= 0x0f;
    psOut[i / 2] += ucTmp;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<vTwoOne>:
  endbr64
  test   %esi,%esi
  je     L21
  push   %r14
  mov    %rdi,%r14
  push   %r13
  xor    %r13d,%r13d
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  jmp    L18
  nopl   0x0(%rax)
L8:
  mov    %r13d,%ebx
  lea    0x1(%r13),%edx
  shl    $0x4,%eax
  shr    %ebx
  add    %r12,%rbx
  mov    %al,(%rbx)
  movzbl (%r14,%rdx,1),%edi
  mov    %edi,%edx
  and    $0xf,%edx
  cmp    $0x39,%dil
  ja     L28
  add    %eax,%edx
  add    $0x2,%r13d
  mov    %dl,(%rbx)
  cmp    %r13d,%ebp
  jbe    L54
L18:
  mov    %r13d,%eax
  movzbl (%r14,%rax,1),%edi
  mov    %edi,%eax
  and    $0xf,%eax
  cmp    $0x39,%dil
  jbe    L8
  call   <toupper@plt>
  sub    $0x37,%eax
  jmp    L8
  nopl   0x0(%rax,%rax,1)
L28:
  call   <toupper@plt>
  add    $0x2,%r13d
  lea    -0x37(%rax),%edx
  movzbl (%rbx),%eax
  add    %eax,%edx
  mov    %dl,(%rbx)
  cmp    %r13d,%ebp
  ja     L18
L54:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L21:
  ret
```

assistant: ```c
void vTwoOne(unsigned char *psIn, unsigned int uiLength, unsigned char *psOut) {
  unsigned char ucTmp;
  unsigned int i;
  for (i = 0; i < uiLength; i += 2) {
    ucTmp = psIn[i];
    if (ucTmp > '9')
      ucTmp = toupper(ucTmp) - 'A' + 0x0a;
    else
      ucTmp &= 0x0f;
    psOut[i / 2] = ucTmp << 4;
    ucTmp = psIn[i + 1];
    if (ucTmp > '9')
      ucTmp = toupper(ucTmp) - 'A' + 0x0a;
    else
      ucTmp &= 0x0f;
    psOut[i / 2] += ucTmp;
  }
}
```