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

```asm
<get_val_struct_part>:
  endbr64
  sub    $0x68,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L129
  movzbl (%rdi),%edx
  movb   $0x0,(%rsp)
  test   %dl,%dl
  je     L129
  test   %esi,%esi
  je     L61
  mov    $0x1,%eax
  xor    %ecx,%ecx
  nop
L122:
  cmp    $0x3b,%dl
  movslq %eax,%r8
  sete   %dl
  movzbl %dl,%edx
  add    %edx,%ecx
  movzbl (%rdi,%rax,1),%edx
  test   %dl,%dl
  je     L129
  add    $0x1,%rax
  cmp    %esi,%ecx
  jne    L122
  cmp    $0x4e,%r8d
  setle  %al
L9:
  cmp    $0x3b,%dl
  je     L76
  test   %al,%al
  je     L76
  lea    0x1(%r8),%eax
  mov    %rsp,%r9
  xor    %ecx,%ecx
  cltq
  sub    %r8,%r9
  nopl   0x0(%rax)
L100:
  mov    %dl,-0x1(%r9,%rax,1)
  movzbl (%rdi,%rax,1),%edx
  add    $0x1,%ecx
  cmp    $0x3b,%dl
  setne  %r8b
  cmp    $0x4e,%eax
  setle  %sil
  add    $0x1,%rax
  test   %sil,%r8b
  jne    L100
L126:
  movslq %ecx,%rcx
  movb   $0x0,(%rsp,%rcx,1)
  cmpb   $0x0,(%rsp)
  je     L129
  mov    %rsp,%rdi
  call   <strdup@plt>
L81:
  mov    0x58(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L74
  add    $0x68,%rsp
  ret
  nopl   (%rax)
L129:
  xor    %eax,%eax
  jmp    L81
  nopl   0x0(%rax)
L61:
  xor    %r8d,%r8d
  mov    $0x1,%eax
  jmp    L9
  nopw   0x0(%rax,%rax,1)
L76:
  xor    %ecx,%ecx
  jmp    L126
L74:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *get_val_struct_part(const char *str, int part_index) {
  char buf[80];
  int i = 0;
  int j = 0;
  int part_counter = 0;
  int done = 0;
  char *result = NULL;
  if (NULL != str) {
    buf[0] = '\0';
    while ('\0' != str[i] && 1 != done) {
      if (part_index == part_counter) {
        while (str[i] != ';' && i < 80 - 1) {
          buf[j] = str[i];
          j++;
          i++;
        }
        buf[j] = '\0';
        done = 1;
      } else {
        if (';' == str[i]) {
          part_counter++;
        }
        i++;
      }
    }
    if ('\0' != buf[0]) {
      result = strdup(buf);
    }
  }
  return result;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<sfree>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  sub    $0x4,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x8(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <munlock@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  leave
  ret
```

assistant: ```c
void sfree(void *p) {
  int *q = (int *)p - 1;
  memset(p, 0, *q);
  munlock(p, *q);
  free(q);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<sfree>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  mov    -0x4(%rdi),%edx
  mov    $0x0,%esi
  call   <memset@plt>
  mov    -0x4(%rbx),%esi
  mov    %rbx,%rdi
  call   <munlock@plt>
  lea    -0x4(%rbx),%rdi
  call   <free@plt>
  pop    %rbx
  ret
```

assistant: ```c
void sfree(void *p) {
  int *q = (int *)p - 1;
  memset(p, 0, *q);
  munlock(p, *q);
  free(q);
}
```
user: Translate the below assembly code into C programming language:

```asm
<sfree>:
  endbr64
  push   %rbx
  mov    -0x4(%rdi),%edx
  mov    %rdi,%rbx
  xor    %esi,%esi
  call   <memset@plt>
  mov    -0x4(%rbx),%esi
  mov    %rbx,%rdi
  call   <munlock@plt>
  lea    -0x4(%rbx),%rdi
  pop    %rbx
  jmp    1080 <free@plt>
```

assistant: ```c
void sfree(void *p) {
  int *q = (int *)p - 1;
  memset(p, 0, *q);
  munlock(p, *q);
  free(q);
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<sfree>:
  endbr64
  push   %rbx
  mov    -0x4(%rdi),%edx
  mov    %rdi,%rbx
  xor    %esi,%esi
  call   <memset@plt>
  mov    -0x4(%rbx),%esi
  mov    %rbx,%rdi
  call   <munlock@plt>
  lea    -0x4(%rbx),%rdi
  pop    %rbx
  jmp    1080 <free@plt>
```

assistant: ```c
void sfree(void *p) {
  int *q = (int *)p - 1;
  memset(p, 0, *q);
  munlock(p, *q);
  free(q);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x730,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  jmp    L87
L67:
  lea    -0x2720(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x2724(%rbp)
  movl   $0xffffffff,-0x2728(%rbp)
  movl   $0x0,-0x2730(%rbp)
  jmp    L44
L76:
  mov    -0x2730(%rbp),%eax
  cltq
  movzbl -0x2720(%rbp,%rax,1),%eax
  cmp    $0x20,%al
  je     L19
  mov    -0x2730(%rbp),%eax
  cltq
  movzbl -0x2720(%rbp,%rax,1),%eax
  test   %al,%al
  jne    L10
L19:
  mov    -0x2730(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x272c(%rbp)
  jmp    L41
L9:
  mov    -0x272c(%rbp),%eax
  cltq
  movzbl -0x2720(%rbp,%rax,1),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <putchar@plt>
  subl   $0x1,-0x272c(%rbp)
L41:
  mov    -0x272c(%rbp),%eax
  cmp    -0x2728(%rbp),%eax
  jg     L9
  mov    -0x2730(%rbp),%eax
  cltq
  movzbl -0x2720(%rbp,%rax,1),%eax
  test   %al,%al
  je     L23
  mov    $0x20,%edi
  call   <putchar@plt>
  jmp    L92
L23:
  mov    $0xa,%edi
  call   <putchar@plt>
L92:
  mov    -0x2730(%rbp),%eax
  mov    %eax,-0x2728(%rbp)
L10:
  addl   $0x1,-0x2730(%rbp)
L44:
  mov    -0x2730(%rbp),%eax
  cmp    -0x2724(%rbp),%eax
  jle    L76
L87:
  lea    -0x2720(%rbp),%rax
  mov    %rax,%rdi
  call   <gets@plt>
  test   %rax,%rax
  jne    L67
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L3
  call   <__stack_chk_fail@plt>
L3:
  leave
  ret
```

assistant: ```c
int main() {
  int len, i, j, b, k;
  char a[10000];
  while (gets(a)) {
    len = strlen(a);
    b = -1;
    for (i = 0; i <= len; i++) {
      if (a[i] == ' ' || a[i] == '\0') {
        for (j = i - 1; j > b; j--)
          printf("%c", a[j]);
        if (a[i] != '\0')
          printf(" ");
        else
          printf("\n");
        b = i;
      }
    }
  }
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x738,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x2728(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rax
  mov    %rax,0x8(%rsp)
L39:
  mov    0x8(%rsp),%rdi
  call   <gets@plt>
  test   %rax,%rax
  je     L21
  mov    0x8(%rsp),%rdi
  call   <strlen@plt>
  mov    %eax,%r14d
  test   %eax,%eax
  js     L39
  lea    0x10(%rsp),%rbp
  mov    $0xffffffff,%eax
  mov    $0x0,%r12d
  jmp    L69
L98:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    %r12d,%eax
L23:
  add    $0x1,%r12d
  add    $0x1,%rbp
  cmp    %r12d,%r14d
  jl     L39
L69:
  mov    %rbp,%r15
  testb  $0xdf,0x0(%rbp)
  jne    L23
  lea    -0x1(%r12),%edx
  cmp    %edx,%eax
  jge    L95
  lea    -0x1(%rbp),%r13
  mov    %r12d,%edx
  sub    %eax,%edx
  lea    -0x2(%rdx),%eax
  sub    %rax,%r13
  mov    %rbp,%rbx
L4:
  movsbl -0x1(%rbx),%edi
  call   <putchar@plt>
  sub    $0x1,%rbx
  cmp    %r13,%rbx
  jne    L4
L95:
  cmpb   $0x0,(%r15)
  je     L98
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %r12d,%eax
  jmp    L23
L21:
  mov    0x2728(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L8
  mov    $0x0,%eax
  add    $0x2738,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L8:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  int len, i, j, b, k;
  char a[10000];
  while (gets(a)) {
    len = strlen(a);
    b = -1;
    for (i = 0; i <= len; i++) {
      if (a[i] == ' ' || a[i] == '\0') {
        for (j = i - 1; j > b; j--)
          printf("%c", a[j]);
        if (a[i] != '\0')
          printf(" ");
        else
          printf("\n");
        b = i;
      }
    }
  }
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x728,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x2718(%rsp)
  xor    %eax,%eax
  mov    %rsp,%r15
  nopl   0x0(%rax,%rax,1)
L67:
  mov    %r15,%rdi
  call   <gets@plt>
  test   %rax,%rax
  je     L85
  mov    %r15,%rdi
  mov    %r15,%r12
  xor    %ebp,%ebp
  call   <strlen@plt>
  mov    $0xffffffff,%edx
  mov    %eax,%r14d
  test   %eax,%eax
  jns    L68
  jmp    L67
  nopl   0x0(%rax)
L29:
  add    $0x1,%ebp
  add    $0x1,%r12
  cmp    %ebp,%r14d
  jl     L67
L68:
  movzbl (%r12),%eax
  test   $0xdf,%al
  jne    L29
  lea    -0x1(%rbp),%ecx
  cmp    %ecx,%edx
  jge    L43
  mov    %ebp,%eax
  lea    -0x1(%r12),%r13
  mov    %r12,%rbx
  sub    %edx,%eax
  sub    $0x2,%eax
  sub    %rax,%r13
  cs nopw 0x0(%rax,%rax,1)
L105:
  movsbl -0x1(%rbx),%edi
  sub    $0x1,%rbx
  call   <putchar@plt>
  cmp    %r13,%rbx
  jne    L105
  movzbl (%r12),%eax
L43:
  test   %al,%al
  je     L41
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %ebp,%edx
  jmp    L29
  nopl   0x0(%rax)
L41:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    %ebp,%edx
  jmp    L29
L85:
  mov    0x2718(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L33
  add    $0x2728,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L33:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  int len, i, j, b, k;
  char a[10000];
  while (gets(a)) {
    len = strlen(a);
    b = -1;
    for (i = 0; i <= len; i++) {
      if (a[i] == ' ' || a[i] == '\0') {
        for (j = i - 1; j > b; j--)
          printf("%c", a[j]);
        if (a[i] != '\0')
          printf(" ");
        else
          printf("\n");
        b = i;
      }
    }
  }
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x728,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x2718(%rsp)
  xor    %eax,%eax
  mov    %rsp,%r15
  nopl   0x0(%rax,%rax,1)
L85:
  mov    %r15,%rdi
  call   <gets@plt>
  test   %rax,%rax
  je     L107
  mov    %r15,%rdi
  mov    %r15,%r12
  xor    %ebp,%ebp
  call   <strlen@plt>
  mov    $0xffffffff,%edx
  mov    %eax,%r14d
  test   %eax,%eax
  jns    L49
  jmp    L85
  nopl   0x0(%rax)
L66:
  add    $0x1,%ebp
  add    $0x1,%r12
  cmp    %ebp,%r14d
  jl     L85
L49:
  movzbl (%r12),%eax
  test   $0xdf,%al
  jne    L66
  lea    -0x1(%rbp),%ecx
  cmp    %ecx,%edx
  jge    L76
  mov    %ebp,%eax
  lea    -0x1(%r12),%r13
  mov    %r12,%rbx
  sub    %edx,%eax
  sub    $0x2,%eax
  sub    %rax,%r13
  cs nopw 0x0(%rax,%rax,1)
L99:
  movsbl -0x1(%rbx),%edi
  sub    $0x1,%rbx
  call   <putchar@plt>
  cmp    %r13,%rbx
  jne    L99
  movzbl (%r12),%eax
L76:
  test   %al,%al
  je     L27
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %ebp,%edx
  jmp    L66
  nopl   0x0(%rax)
L27:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    %ebp,%edx
  jmp    L66
L107:
  mov    0x2718(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L40
  add    $0x2728,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L40:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  int len, i, j, b, k;
  char a[10000];
  while (gets(a)) {
    len = strlen(a);
    b = -1;
    for (i = 0; i <= len; i++) {
      if (a[i] == ' ' || a[i] == '\0') {
        for (j = i - 1; j > b; j--)
          printf("%c", a[j]);
        if (a[i] != '\0')
          printf(" ");
        else
          printf("\n");
        b = i;
      }
    }
  }
  return 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<play_sound>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <init_timer@plt>
  mov    $0x61,%edi
  call   <inb@plt>
  mov    %al,-0x1(%rbp)
  movzbl -0x1(%rbp),%eax
  or     $0x3,%eax
  movzbl %al,%eax
  mov    %eax,%esi
  mov    $0x61,%edi
  call   <outb@plt>
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <usleep@plt>
  movzbl -0x1(%rbp),%eax
  and    $0xfc,%eax
  mov    %eax,%esi
  mov    $0x61,%edi
  call   <outb@plt>
  nop
  leave
  ret
```

assistant: ```c
void play_sound(int freq, int period) {
  unsigned char b;
  init_timer(freq);
  b = inb(0x61);
  outb(0x61, b | 0x2 | 0x1);
  usleep(period);
  outb(0x61, b & ~(0x2 | 0x1));
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<play_sound>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %esi,%ebp
  call   <init_timer@plt>
  mov    $0x61,%edi
  call   <inb@plt>
  mov    %eax,%ebx
  mov    %eax,%esi
  or     $0x3,%esi
  movzbl %sil,%esi
  mov    $0x61,%edi
  call   <outb@plt>
  mov    %ebp,%edi
  call   <usleep@plt>
  mov    %ebx,%esi
  and    $0xfc,%esi
  mov    $0x61,%edi
  call   <outb@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void play_sound(int freq, int period) {
  unsigned char b;
  init_timer(freq);
  b = inb(0x61);
  outb(0x61, b | 0x2 | 0x1);
  usleep(period);
  outb(0x61, b & ~(0x2 | 0x1));
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<play_sound>:
  endbr64
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  sub    $0x8,%rsp
  call   <init_timer@plt>
  mov    $0x61,%edi
  call   <inb@plt>
  mov    $0x61,%edi
  mov    %eax,%esi
  mov    %eax,%ebx
  or     $0x3,%esi
  movzbl %sil,%esi
  call   <outb@plt>
  mov    %ebp,%edi
  call   <usleep@plt>
  mov    %ebx,%esi
  add    $0x8,%rsp
  mov    $0x61,%edi
  pop    %rbx
  and    $0xfc,%esi
  pop    %rbp
  jmp    1080 <outb@plt>
```

assistant: ```c
void play_sound(int freq, int period) {
  unsigned char b;
  init_timer(freq);
  b = inb(0x61);
  outb(0x61, b | 0x2 | 0x1);
  usleep(period);
  outb(0x61, b & ~(0x2 | 0x1));
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<play_sound>:
  endbr64
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  sub    $0x8,%rsp
  call   <init_timer@plt>
  mov    $0x61,%edi
  call   <inb@plt>
  mov    $0x61,%edi
  mov    %eax,%esi
  mov    %eax,%ebx
  or     $0x3,%esi
  movzbl %sil,%esi
  call   <outb@plt>
  mov    %ebp,%edi
  call   <usleep@plt>
  mov    %ebx,%esi
  add    $0x8,%rsp
  mov    $0x61,%edi
  pop    %rbx
  and    $0xfc,%esi
  pop    %rbp
  jmp    1080 <outb@plt>
```

assistant: ```c
void play_sound(int freq, int period) {
  unsigned char b;
  init_timer(freq);
  b = inb(0x61);
  outb(0x61, b | 0x2 | 0x1);
  usleep(period);
  outb(0x61, b & ~(0x2 | 0x1));
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<sprintbuf>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x160,%rsp
  mov    %rdi,-0x158(%rbp)
  mov    %rsi,-0x160(%rbp)
  mov    %rdx,-0xa0(%rbp)
  mov    %rcx,-0x98(%rbp)
  mov    %r8,-0x90(%rbp)
  mov    %r9,-0x88(%rbp)
  test   %al,%al
  je     L35
  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)
L35:
  mov    %fs:0x28,%rax
  mov    %rax,-0xb8(%rbp)
  xor    %eax,%eax
  mov    -0x160(%rbp),%rdx
  mov    -0x150(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <va_start@plt>
  mov    -0x150(%rbp),%ecx
  mov    -0x160(%rbp),%rdx
  lea    -0x140(%rbp),%rax
  mov    $0x80,%esi
  mov    %rax,%rdi
  call   <vsnprintf@plt>
  mov    %eax,-0x14c(%rbp)
  mov    -0x150(%rbp),%eax
  mov    %eax,%edi
  call   <va_end@plt>
  cmpl   $0xffffffff,-0x14c(%rbp)
  je     L45
  cmpl   $0x7f,-0x14c(%rbp)
  jle    L12
L45:
  mov    -0x160(%rbp),%rdx
  mov    -0x150(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <va_start@plt>
  mov    -0x150(%rbp),%edx
  mov    -0x160(%rbp),%rcx
  lea    -0x148(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <vasprintf@plt>
  mov    %eax,-0x14c(%rbp)
  cmpl   $0xffffffff,-0x14c(%rbp)
  jne    L44
  mov    -0x150(%rbp),%eax
  mov    %eax,%edi
  call   <va_end@plt>
  mov    $0xffffffff,%eax
  jmp    L42
L44:
  mov    -0x150(%rbp),%eax
  mov    %eax,%edi
  call   <va_end@plt>
  mov    -0x148(%rbp),%rcx
  mov    -0x14c(%rbp),%edx
  mov    -0x158(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <printbuf_memappend@plt>
  mov    -0x148(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x14c(%rbp),%eax
  jmp    L42
L12:
  mov    -0x14c(%rbp),%edx
  lea    -0x140(%rbp),%rcx
  mov    -0x158(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <printbuf_memappend@plt>
  mov    -0x14c(%rbp),%eax
L42:
  mov    -0xb8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L66
  call   <__stack_chk_fail@plt>
L66:
  leave
  ret
```

assistant: ```c
int sprintbuf(struct printbuf *p, const char *msg, ...) {
  va_list ap;
  char *t;
  int size;
  char buf[128];
  va_start(ap, msg);
  size = vsnprintf(buf, 128, msg, ap);
  va_end(ap);
  if (size == -1 || size > 127) {
    va_start(ap, msg);
    if ((size = vasprintf(&t, msg, ap)) == -1) {
      va_end(ap);
      return -1;
    }
    va_end(ap);
    printbuf_memappend(p, t, size);
    free(t);
    return size;
  } else {
    printbuf_memappend(p, buf, size);
    return size;
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<sprintbuf>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xa8,%rsp
  mov    %rdi,%r13
  mov    %rsi,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  mov    $0x0,%ebp
  mov    %ebp,%edi
  call   <va_start@plt>
  lea    0x10(%rsp),%rdi
  mov    %ebp,%ecx
  mov    %r12,%rdx
  mov    $0x80,%esi
  call   <vsnprintf@plt>
  mov    %eax,%ebx
  mov    %ebp,%edi
  call   <va_end@plt>
  cmp    $0xffffffff,%ebx
  je     L29
  cmp    $0x7f,%ebx
  jg     L29
  lea    0x10(%rsp),%rsi
  mov    %ebx,%edx
  mov    %r13,%rdi
  call   <printbuf_memappend@plt>
  jmp    L57
L29:
  mov    %r12,%rsi
  mov    $0x0,%ebp
  mov    %ebp,%edi
  call   <va_start@plt>
  lea    0x8(%rsp),%rdi
  mov    %ebp,%edx
  mov    %r12,%rsi
  call   <vasprintf@plt>
  mov    %eax,%ebx
  cmp    $0xffffffff,%eax
  je     L38
  mov    $0x0,%ebp
  mov    %ebp,%edi
  call   <va_end@plt>
  mov    %ebx,%edx
  mov    0x8(%rsp),%rsi
  mov    %r13,%rdi
  call   <printbuf_memappend@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
L57:
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L12
  mov    %ebx,%eax
  add    $0xa8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L38:
  mov    %ebp,%edi
  call   <va_end@plt>
  jmp    L57
L12:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int sprintbuf(struct printbuf *p, const char *msg, ...) {
  va_list ap;
  char *t;
  int size;
  char buf[128];
  va_start(ap, msg);
  size = vsnprintf(buf, 128, msg, ap);
  va_end(ap);
  if (size == -1 || size > 127) {
    va_start(ap, msg);
    if ((size = vasprintf(&t, msg, ap)) == -1) {
      va_end(ap);
      return -1;
    }
    va_end(ap);
    printbuf_memappend(p, t, size);
    free(t);
    return size;
  } else {
    printbuf_memappend(p, buf, size);
    return size;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<sprintbuf>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  mov    %ebp,%edi
  sub    $0xa0,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%r15
  call   <va_start@plt>
  mov    %r15,%rdi
  mov    %ebp,%ecx
  mov    %r13,%rdx
  mov    $0x80,%esi
  call   <vsnprintf@plt>
  mov    %ebp,%edi
  mov    %eax,%r12d
  call   <va_end@plt>
  cmp    $0xffffffff,%r12d
  je     L8
  cmp    $0x7f,%r12d
  jg     L8
  mov    %r12d,%edx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <printbuf_memappend@plt>
  jmp    L23
  nopl   0x0(%rax,%rax,1)
L8:
  xor    %ebp,%ebp
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <va_start@plt>
  lea    0x8(%rsp),%rdi
  mov    %ebp,%edx
  mov    %r13,%rsi
  call   <vasprintf@plt>
  mov    %eax,%r12d
  cmp    $0xffffffff,%eax
  je     L27
  xor    %edi,%edi
  call   <va_end@plt>
  mov    0x8(%rsp),%rsi
  mov    %r14,%rdi
  mov    %r12d,%edx
  call   <printbuf_memappend@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
L23:
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L9
  add    $0xa0,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L27:
  mov    %ebp,%edi
  call   <va_end@plt>
  jmp    L23
L9:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int sprintbuf(struct printbuf *p, const char *msg, ...) {
  va_list ap;
  char *t;
  int size;
  char buf[128];
  va_start(ap, msg);
  size = vsnprintf(buf, 128, msg, ap);
  va_end(ap);
  if (size == -1 || size > 127) {
    va_start(ap, msg);
    if ((size = vasprintf(&t, msg, ap)) == -1) {
      va_end(ap);
      return -1;
    }
    va_end(ap);
    printbuf_memappend(p, t, size);
    free(t);
    return size;
  } else {
    printbuf_memappend(p, buf, size);
    return size;
  }
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<sprintbuf>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  mov    %ebp,%edi
  sub    $0xa0,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%r15
  call   <va_start@plt>
  mov    %r15,%rdi
  mov    %ebp,%ecx
  mov    %r13,%rdx
  mov    $0x80,%esi
  call   <vsnprintf@plt>
  mov    %ebp,%edi
  mov    %eax,%r12d
  call   <va_end@plt>
  cmp    $0xffffffff,%r12d
  je     L9
  cmp    $0x7f,%r12d
  jg     L9
  mov    %r12d,%edx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <printbuf_memappend@plt>
  jmp    L8
  nopl   0x0(%rax,%rax,1)
L9:
  xor    %ebp,%ebp
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <va_start@plt>
  lea    0x8(%rsp),%rdi
  mov    %ebp,%edx
  mov    %r13,%rsi
  call   <vasprintf@plt>
  mov    %eax,%r12d
  cmp    $0xffffffff,%eax
  je     L41
  xor    %edi,%edi
  call   <va_end@plt>
  mov    0x8(%rsp),%rsi
  mov    %r14,%rdi
  mov    %r12d,%edx
  call   <printbuf_memappend@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
L8:
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L20
  add    $0xa0,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L41:
  mov    %ebp,%edi
  call   <va_end@plt>
  jmp    L8
L20:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int sprintbuf(struct printbuf *p, const char *msg, ...) {
  va_list ap;
  char *t;
  int size;
  char buf[128];
  va_start(ap, msg);
  size = vsnprintf(buf, 128, msg, ap);
  va_end(ap);
  if (size == -1 || size > 127) {
    va_start(ap, msg);
    if ((size = vasprintf(&t, msg, ap)) == -1) {
      va_end(ap);
      return -1;
    }
    va_end(ap);
    printbuf_memappend(p, t, size);
    free(t);
    return size;
  } else {
    printbuf_memappend(p, buf, size);
    return size;
  }
}
```