ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<dos2unix>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  lea    -0x30000(%rsp),%r11
L6:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L6
  sub    $0xd50,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x30d48(%rsp)
  xor    %eax,%eax
  mov    %rdi,%rbp
  call   <is_ascii@plt>
  cmp    $0x1,%eax
  je     L31
L40:
  mov    $0x1,%eax
L11:
  mov    0x30d48(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L32
  add    $0x30d50,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L31:
  mov    %rbp,%rdi
  call   <is_dos_eol@plt>
  cmp    $0x1,%eax
  jne    L40
  mov    %rbp,%rdi
  lea    D16(%rip),%rsi
  mov    %rsp,%r13
  call   <fopen@plt>
  mov    $0x186a0,%edx
  mov    $0x1,%esi
  mov    %r13,%rdi
  mov    %rax,%rcx
  mov    %rax,%r12
  call   <fread@plt>
  mov    %r12,%rdi
  lea    0x186a0(%rsp),%r12
  call   <fclose@plt>
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <to_unix_line_endings@plt>
  lea    D14(%rip),%rsi
  mov    %rbp,%rdi
  call   <fopen@plt>
  mov    %r12,%rdi
  mov    %rax,%rbp
  call   <strlen@plt>
  mov    %rbp,%rcx
  mov    $0x1,%esi
  mov    %r12,%rdi
  mov    %eax,%edx
  call   <fwrite@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
  jmp    L11
L32:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D16
type_infered: string
name: disassemble_data
arguments: label: D14
type_infered: string

tool: D16: rb

tool: D14: wb

assistant: ```c
int dos2unix(char *filename) {
  if (is_ascii(filename) == 1 && is_dos_eol(filename) == 1) {
    char contents[100000];
    char out[100000];
    FILE *f;
    f = fopen(filename, "rb");
    fread(contents, 1, 100000, f);
    fclose(f);
    to_unix_line_endings(contents, out);
    f = fopen(filename, "wb");
    fwrite(out, 1, strlen(out), f);
    fclose(f);
    return 0;
  }
  return 1;
}
```
user: Translate the below assembly code into C programming language:

```asm
<DataMapReadString>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x20(%rbp)
  movl   $0x100,-0x28(%rbp)
  movl   $0x100,-0x1c(%rbp)
  movl   $0x0,-0x24(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  jmp    L30
L79:
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  movzbl -0x29(%rbp),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L106
  mov    -0x1c(%rbp),%eax
  add    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L77
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L77:
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x18(%rbp)
L106:
  cmpq   $0x0,-0x18(%rbp)
  jne    L30
  mov    $0x0,%eax
  jmp    L58
L30:
  lea    -0x29(%rbp),%rcx
  mov    -0x34(%rbp),%eax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    %eax,-0x20(%rbp)
  cmpl   $0x1,-0x20(%rbp)
  jne    L75
  movzbl -0x29(%rbp),%eax
  test   %al,%al
  jne    L79
L75:
  cmpl   $0x1,-0x20(%rbp)
  je     L98
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L58
L98:
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  addl   $0x1,-0x24(%rbp)
  mov    -0x24(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L39
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L39:
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
L58:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L99
  call   <__stack_chk_fail@plt>
L99:
  leave
  ret
```

assistant: ```c
char *DataMapReadString(int fid) {
  char *ptr, *tmp;
  char t;
  int st = 0;
  int blk = 256;
  int stp = 256;
  int sze = 0;
  ptr = malloc(sizeof(char) * blk);
  while (((st = read(fid, &t, 1)) == 1) && (t != 0)) {
    ptr[sze] = t;
    sze++;
    if (sze >= blk) {
      blk += stp;
      tmp = realloc(ptr, blk);
      if (tmp == NULL)
        free(ptr);
      ptr = tmp;
    }
    if (ptr == NULL)
      return NULL;
  }
  if (st != 1) {
    free(ptr);
    return NULL;
  }
  ptr[sze] = 0;
  sze++;
  tmp = realloc(ptr, sze);
  if (tmp == NULL)
    free(ptr);
  ptr = tmp;
  return ptr;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<DataMapReadString>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,%r14d
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    $0x100,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  mov    $0x0,%ebx
  mov    $0x100,%r13d
  lea    0x17(%rsp),%r15
  jmp    L46
L56:
  mov    %r12,%rdi
  call   <free@plt>
L66:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L70
  mov    %rbp,%rax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L118:
  test   %r12,%r12
  je     L80
L45:
  add    $0x1,%rbx
L46:
  mov    %ebx,%ebp
  mov    %ebx,0xc(%rsp)
  mov    $0x1,%edx
  mov    %r15,%rsi
  mov    %r14d,%edi
  call   <read@plt>
  cmp    $0x1,%eax
  jne    L47
  movzbl 0x17(%rsp),%eax
  test   %al,%al
  je     L27
  mov    %al,(%r12,%rbx,1)
  add    $0x1,%ebp
  cmp    %ebp,%r13d
  jg     L118
  add    $0x100,%r13d
  mov    %r13d,%esi
  mov    %r12,%rdi
  call   <realloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L56
  mov    %rax,%r12
  jmp    L45
L47:
  mov    %r12,%rdi
  call   <free@plt>
  mov    $0x0,%ebp
  jmp    L66
L27:
  mov    0xc(%rsp),%ecx
  movslq %ecx,%rax
  movb   $0x0,(%r12,%rax,1)
  lea    0x1(%rcx),%esi
  mov    %r12,%rdi
  call   <realloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  jne    L66
  mov    %r12,%rdi
  call   <free@plt>
  jmp    L66
L80:
  mov    %r12,%rbp
  jmp    L66
L70:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *DataMapReadString(int fid) {
  char *ptr, *tmp;
  char t;
  int st = 0;
  int blk = 256;
  int stp = 256;
  int sze = 0;
  ptr = malloc(sizeof(char) * blk);
  while (((st = read(fid, &t, 1)) == 1) && (t != 0)) {
    ptr[sze] = t;
    sze++;
    if (sze >= blk) {
      blk += stp;
      tmp = realloc(ptr, blk);
      if (tmp == NULL)
        free(ptr);
      ptr = tmp;
    }
    if (ptr == NULL)
      return NULL;
  }
  if (st != 1) {
    free(ptr);
    return NULL;
  }
  ptr[sze] = 0;
  sze++;
  tmp = realloc(ptr, sze);
  if (tmp == NULL)
    free(ptr);
  ptr = tmp;
  return ptr;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<DataMapReadString>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %edi,%r13d
  mov    $0x100,%edi
  push   %r12
  mov    $0x100,%r12d
  push   %rbp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x7(%rsp),%r14
  call   <malloc@plt>
  mov    %rax,%rbp
  jmp    L19
  nopl   0x0(%rax)
L66:
  test   %rbp,%rbp
  je     L79
L84:
  add    $0x1,%rbx
L19:
  mov    $0x1,%edx
  mov    %r14,%rsi
  mov    %r13d,%edi
  call   <read@plt>
  cmp    $0x1,%eax
  jne    L93
  movzbl 0x7(%rsp),%eax
  lea    0x0(%rbp,%rbx,1),%rdx
  lea    0x1(%rbx),%esi
  test   %al,%al
  je     L21
  mov    %al,(%rdx)
  cmp    %esi,%r12d
  jg     L66
  add    $0x100,%r12d
  mov    %rbp,%rdi
  mov    %r12d,%esi
  call   <realloc@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L94
  mov    %rax,%rbp
  jmp    L84
  nopl   (%rax)
L21:
  movb   $0x0,(%rdx)
  mov    %rbp,%rdi
  call   <realloc@plt>
  mov    %rax,%r15
  test   %rax,%rax
  jne    L86
  nopl   0x0(%rax,%rax,1)
L94:
  mov    %rbp,%rdi
  call   <free@plt>
L86:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L45
  add    $0x18,%rsp
  mov    %r15,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L93:
  mov    %rbp,%rdi
  call   <free@plt>
L79:
  xor    %r15d,%r15d
  jmp    L86
L45:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *DataMapReadString(int fid) {
  char *ptr, *tmp;
  char t;
  int st = 0;
  int blk = 256;
  int stp = 256;
  int sze = 0;
  ptr = malloc(sizeof(char) * blk);
  while (((st = read(fid, &t, 1)) == 1) && (t != 0)) {
    ptr[sze] = t;
    sze++;
    if (sze >= blk) {
      blk += stp;
      tmp = realloc(ptr, blk);
      if (tmp == NULL)
        free(ptr);
      ptr = tmp;
    }
    if (ptr == NULL)
      return NULL;
  }
  if (st != 1) {
    free(ptr);
    return NULL;
  }
  ptr[sze] = 0;
  sze++;
  tmp = realloc(ptr, sze);
  if (tmp == NULL)
    free(ptr);
  ptr = tmp;
  return ptr;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<DataMapReadString>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %edi,%r13d
  mov    $0x100,%edi
  push   %r12
  mov    $0x100,%r12d
  push   %rbp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x7(%rsp),%r14
  call   <malloc@plt>
  mov    %rax,%rbp
  jmp    L58
  nopl   0x0(%rax)
L19:
  test   %rbp,%rbp
  je     L2
L3:
  add    $0x1,%rbx
L58:
  mov    $0x1,%edx
  mov    %r14,%rsi
  mov    %r13d,%edi
  call   <read@plt>
  cmp    $0x1,%eax
  jne    L56
  movzbl 0x7(%rsp),%eax
  lea    0x0(%rbp,%rbx,1),%rdx
  lea    0x1(%rbx),%esi
  test   %al,%al
  je     L11
  mov    %al,(%rdx)
  cmp    %esi,%r12d
  jg     L19
  add    $0x100,%r12d
  mov    %rbp,%rdi
  mov    %r12d,%esi
  call   <realloc@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L50
  mov    %rax,%rbp
  jmp    L3
  nopl   (%rax)
L11:
  movb   $0x0,(%rdx)
  mov    %rbp,%rdi
  call   <realloc@plt>
  mov    %rax,%r15
  test   %rax,%rax
  jne    L75
  nopl   0x0(%rax,%rax,1)
L50:
  mov    %rbp,%rdi
  call   <free@plt>
L75:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L61
  add    $0x18,%rsp
  mov    %r15,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L56:
  mov    %rbp,%rdi
  call   <free@plt>
L2:
  xor    %r15d,%r15d
  jmp    L75
L61:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *DataMapReadString(int fid) {
  char *ptr, *tmp;
  char t;
  int st = 0;
  int blk = 256;
  int stp = 256;
  int sze = 0;
  ptr = malloc(sizeof(char) * blk);
  while (((st = read(fid, &t, 1)) == 1) && (t != 0)) {
    ptr[sze] = t;
    sze++;
    if (sze >= blk) {
      blk += stp;
      tmp = realloc(ptr, blk);
      if (tmp == NULL)
        free(ptr);
      ptr = tmp;
    }
    if (ptr == NULL)
      return NULL;
  }
  if (st != 1) {
    free(ptr);
    return NULL;
  }
  ptr[sze] = 0;
  sze++;
  tmp = realloc(ptr, sze);
  if (tmp == NULL)
    free(ptr);
  ptr = tmp;
  return ptr;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<_strpos>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L4
  mov    -0x8(%rbp),%rax
  sub    -0x18(%rbp),%rax
  jmp    L10
L4:
  mov    $0xffffffff,%eax
L10:
  leave
  ret
```

assistant: ```c
int _strpos(char *haystack, char *needle) {
  char *p = strstr(haystack, needle);
  if (p) {
    return p - haystack;
  }
  return -1;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<_strpos>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  call   <strstr@plt>
  test   %rax,%rax
  je     L4
  sub    %ebx,%eax
L10:
  pop    %rbx
  ret
L4:
  mov    $0xffffffff,%eax
  jmp    L10
```

assistant: ```c
int _strpos(char *haystack, char *needle) {
  char *p = strstr(haystack, needle);
  if (p) {
    return p - haystack;
  }
  return -1;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<_strpos>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  call   <strstr@plt>
  test   %rax,%rax
  je     L6
  sub    %ebx,%eax
  pop    %rbx
  ret
  cs nopw 0x0(%rax,%rax,1)
L6:
  mov    $0xffffffff,%eax
  pop    %rbx
  ret
```

assistant: ```c
int _strpos(char *haystack, char *needle) {
  char *p = strstr(haystack, needle);
  if (p) {
    return p - haystack;
  }
  return -1;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<_strpos>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  call   <strstr@plt>
  test   %rax,%rax
  je     L9
  sub    %ebx,%eax
  pop    %rbx
  ret
  cs nopw 0x0(%rax,%rax,1)
L9:
  mov    $0xffffffff,%eax
  pop    %rbx
  ret
```

assistant: ```c
int _strpos(char *haystack, char *needle) {
  char *p = strstr(haystack, needle);
  if (p) {
    return p - haystack;
  }
  return -1;
}
```
user: Translate the below assembly code into C programming language:

```asm
<lcd_printf>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xd0,%rsp
  mov    %rdi,-0xc8(%rbp)
  mov    %rsi,-0xa8(%rbp)
  mov    %rdx,-0xa0(%rbp)
  mov    %rcx,-0x98(%rbp)
  mov    %r8,-0x90(%rbp)
  mov    %r9,-0x88(%rbp)
  test   %al,%al
  je     L30
  movaps %xmm0,-0x80(%rbp)
  movaps %xmm1,-0x70(%rbp)
  movaps %xmm2,-0x60(%rbp)
  movaps %xmm3,-0x50(%rbp)
  movaps %xmm4,-0x40(%rbp)
  movaps %xmm5,-0x30(%rbp)
  movaps %xmm6,-0x20(%rbp)
  movaps %xmm7,-0x10(%rbp)
L30:
  mov    -0xc8(%rbp),%rdx
  mov    -0xbc(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <va_start@plt>
  mov    -0xbc(%rbp),%edx
  mov    -0xc8(%rbp),%rax
  mov    %rax,%rsi
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  call   <vsprintf@plt>
  mov    %eax,-0xb8(%rbp)
  movl   $0x0,-0xc0(%rbp)
  jmp    L62
L52:
  mov    -0xc0(%rbp),%eax
  cltq
  lea    D8(%rip),%rdx
  movzbl (%rax,%rdx,1),%eax
  movsbl %al,%eax
  mov    %eax,-0xb4(%rbp)
  cmpl   $0xa,-0xb4(%rbp)
  je     L44
  cmpl   $0x1f,-0xb4(%rbp)
  jle    L33
  cmpl   $0x7f,-0xb4(%rbp)
  jg     L33
  mov    -0xb4(%rbp),%eax
  mov    %eax,%edi
  call   <lcd_print_char@plt>
L33:
  addl   $0x1,-0xc0(%rbp)
L62:
  mov    -0xc0(%rbp),%eax
  cmp    -0xb8(%rbp),%eax
  jl     L52
  jmp    L67
L44:
  nop
L67:
  nop
  leave
  ret
```

assistant: ```c
void lcd_printf(const char *fmt, ...) {
  int i;
  uint32_t text_size, letter;
  static char text_buffer[32];
  va_list args;
  va_start(args, fmt);
  text_size = vsprintf(text_buffer, fmt, args);
  for (i = 0; i < text_size; i++) {
    letter = text_buffer[i];
    if (letter == 10)
      break;
    else {
      if ((letter > 0x1F) && (letter < 0x80))
        lcd_print_char(letter);
    }
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<lcd_printf>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rdi,%rsi
  mov    $0x0,%ebp
  mov    %ebp,%edi
  call   <va_start@plt>
  mov    %ebp,%edx
  mov    %rbx,%rsi
  lea    D3(%rip),%rdi
  call   <vsprintf@plt>
  test   %eax,%eax
  jle    L4
  lea    D3(%rip),%rbx
  lea    -0x1(%rax),%ebp
  lea    0x1(%rbx),%rax
  add    %rax,%rbp
  jmp    L56
L9:
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  je     L4
L56:
  movzbl (%rbx),%eax
  movsbl %al,%edi
  cmp    $0xa,%al
  je     L4
  mov    %edi,%eax
  sub    $0x20,%eax
  cmp    $0x5f,%eax
  ja     L9
  call   <lcd_print_char@plt>
  jmp    L9
L4:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void lcd_printf(const char *fmt, ...) {
  int i;
  uint32_t text_size, letter;
  static char text_buffer[32];
  va_list args;
  va_start(args, fmt);
  text_size = vsprintf(text_buffer, fmt, args);
  for (i = 0; i < text_size; i++) {
    letter = text_buffer[i];
    if (letter == 10)
      break;
    else {
      if ((letter > 0x1F) && (letter < 0x80))
        lcd_print_char(letter);
    }
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<lcd_printf>:
  endbr64
  push   %r12
  xor    %r12d,%r12d
  mov    %rdi,%rsi
  push   %rbp
  mov    %rdi,%rbp
  mov    %r12d,%edi
  push   %rbx
  lea    D6(%rip),%rbx
  call   <va_start@plt>
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <vsprintf@plt>
  test   %eax,%eax
  jle    L29
  lea    -0x1(%rax),%ebp
  lea    0x1(%rbx),%rax
  add    %rax,%rbp
  jmp    L13
  xchg   %ax,%ax
L11:
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  je     L29
L13:
  movsbl (%rbx),%edi
  cmp    $0xa,%edi
  je     L29
  lea    -0x20(%rdi),%eax
  cmp    $0x5f,%eax
  ja     L11
  call   <lcd_print_char@plt>
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L13
L29:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void lcd_printf(const char *fmt, ...) {
  int i;
  uint32_t text_size, letter;
  static char text_buffer[32];
  va_list args;
  va_start(args, fmt);
  text_size = vsprintf(text_buffer, fmt, args);
  for (i = 0; i < text_size; i++) {
    letter = text_buffer[i];
    if (letter == 10)
      break;
    else {
      if ((letter > 0x1F) && (letter < 0x80))
        lcd_print_char(letter);
    }
  }
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<lcd_printf>:
  endbr64
  push   %r12
  xor    %r12d,%r12d
  mov    %rdi,%rsi
  push   %rbp
  mov    %rdi,%rbp
  mov    %r12d,%edi
  push   %rbx
  lea    D1(%rip),%rbx
  call   <va_start@plt>
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <vsprintf@plt>
  test   %eax,%eax
  jle    L47
  lea    -0x1(%rax),%ebp
  lea    0x1(%rbx),%rax
  add    %rax,%rbp
  jmp    L18
  xchg   %ax,%ax
L43:
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  je     L47
L18:
  movsbl (%rbx),%edi
  cmp    $0xa,%edi
  je     L47
  lea    -0x20(%rdi),%eax
  cmp    $0x5f,%eax
  ja     L43
  call   <lcd_print_char@plt>
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L18
L47:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void lcd_printf(const char *fmt, ...) {
  int i;
  uint32_t text_size, letter;
  static char text_buffer[32];
  va_list args;
  va_start(args, fmt);
  text_size = vsprintf(text_buffer, fmt, args);
  for (i = 0; i < text_size; i++) {
    letter = text_buffer[i];
    if (letter == 10)
      break;
    else {
      if ((letter > 0x1F) && (letter < 0x80))
        lcd_print_char(letter);
    }
  }
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<__strxspn>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x140,%rsp
  mov    %rdi,-0x128(%rbp)
  mov    %rsi,-0x130(%rbp)
  mov    %edx,-0x134(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x118(%rbp)
  lea    -0x110(%rbp),%rax
  mov    $0x100,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  jmp    L8
L35:
  mov    -0x130(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x130(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  cltq
  movb   $0x1,-0x110(%rbp,%rax,1)
L8:
  mov    -0x130(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L35
  mov    -0x134(%rbp),%eax
  mov    %al,-0x110(%rbp)
  jmp    L32
L5:
  addq   $0x1,-0x118(%rbp)
L32:
  mov    -0x128(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x128(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  cltq
  movzbl -0x110(%rbp,%rax,1),%eax
  movsbl %al,%eax
  cmp    %eax,-0x134(%rbp)
  jne    L5
  mov    -0x118(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L40
  call   <__stack_chk_fail@plt>
L40:
  leave
  ret
```

assistant: ```c
size_t __strxspn(const char *s, const char *map, int parity) {
  char matchmap[255U + 1];
  size_t n = 0;
  memset(matchmap, 0, sizeof matchmap);
  while (*map)
    matchmap[(unsigned char)*map++] = 1;
  matchmap[0] = parity;
  while (matchmap[(unsigned char)*s++] ^ parity)
    n++;
  return n;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<__strxspn>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x110,%rsp
  mov    %rdi,%r12
  mov    %rsi,%rbx
  mov    %edx,%ebp
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rdi
  mov    $0x100,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  movzbl (%rbx),%eax
  test   %al,%al
  je     L38
L3:
  add    $0x1,%rbx
  movzbl %al,%eax
  movb   $0x1,(%rsp,%rax,1)
  movzbl (%rbx),%eax
  test   %al,%al
  jne    L3
L38:
  mov    %bpl,(%rsp)
  movzbl (%r12),%eax
  movsbl (%rsp,%rax,1),%eax
  cmp    %eax,%ebp
  je     L42
  mov    $0x0,%eax
L51:
  add    $0x1,%rax
  movzbl (%r12,%rax,1),%edx
  movsbl (%rsp,%rdx,1),%edx
  cmp    %ebp,%edx
  jne    L51
L56:
  mov    0x108(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L40
  add    $0x110,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L42:
  mov    $0x0,%eax
  jmp    L56
L40:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t __strxspn(const char *s, const char *map, int parity) {
  char matchmap[255U + 1];
  size_t n = 0;
  memset(matchmap, 0, sizeof matchmap);
  while (*map)
    matchmap[(unsigned char)*map++] = 1;
  matchmap[0] = parity;
  while (matchmap[(unsigned char)*s++] ^ parity)
    n++;
  return n;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<__strxspn>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %edx,%ebp
  mov    $0x100,%edx
  push   %rbx
  mov    %rsi,%rbx
  xor    %esi,%esi
  sub    $0x110,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rdi
  call   <memset@plt>
  movzbl (%rbx),%eax
  test   %al,%al
  je     L26
L13:
  add    $0x1,%rbx
  movb   $0x1,(%rsp,%rax,1)
  movzbl (%rbx),%eax
  test   %al,%al
  jne    L13
L26:
  movzbl (%r12),%eax
  mov    %bpl,(%rsp)
  movsbl (%rsp,%rax,1),%eax
  cmp    %eax,%ebp
  mov    $0x0,%eax
  je     L42
  nopl   (%rax)
L18:
  add    $0x1,%rax
  movzbl (%r12,%rax,1),%edx
  movsbl (%rsp,%rdx,1),%edx
  cmp    %ebp,%edx
  jne    L18
L42:
  mov    0x108(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L36
  add    $0x110,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L36:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t __strxspn(const char *s, const char *map, int parity) {
  char matchmap[255U + 1];
  size_t n = 0;
  memset(matchmap, 0, sizeof matchmap);
  while (*map)
    matchmap[(unsigned char)*map++] = 1;
  matchmap[0] = parity;
  while (matchmap[(unsigned char)*s++] ^ parity)
    n++;
  return n;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<__strxspn>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %edx,%ebp
  mov    $0x100,%edx
  push   %rbx
  mov    %rsi,%rbx
  xor    %esi,%esi
  sub    $0x110,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rdi
  call   <memset@plt>
  movzbl (%rbx),%eax
  test   %al,%al
  je     L4
L2:
  add    $0x1,%rbx
  movb   $0x1,(%rsp,%rax,1)
  movzbl (%rbx),%eax
  test   %al,%al
  jne    L2
L4:
  movzbl (%r12),%eax
  mov    %bpl,(%rsp)
  movsbl (%rsp,%rax,1),%eax
  cmp    %eax,%ebp
  mov    $0x0,%eax
  je     L9
  nopl   (%rax)
L27:
  add    $0x1,%rax
  movzbl (%r12,%rax,1),%edx
  movsbl (%rsp,%rdx,1),%edx
  cmp    %ebp,%edx
  jne    L27
L9:
  mov    0x108(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L31
  add    $0x110,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L31:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t __strxspn(const char *s, const char *map, int parity) {
  char matchmap[255U + 1];
  size_t n = 0;
  memset(matchmap, 0, sizeof matchmap);
  while (*map)
    matchmap[(unsigned char)*map++] = 1;
  matchmap[0] = parity;
  while (matchmap[(unsigned char)*s++] ^ parity)
    n++;
  return n;
}
```