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

```asm
<ThreeAndFiveMultiples>:
  endbr64
  test   %edi,%edi
  jle    L53
  mov    $0x0,%edx
  mov    $0x0,%esi
  jmp    L46
L51:
  add    %edx,%esi
L37:
  add    $0x1,%edx
  cmp    %edx,%edi
  je     L58
L46:
  movslq %edx,%rax
  imul   $0x55555556,%rax,%rax
  shr    $0x20,%rax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  lea    (%rax,%rax,2),%eax
  cmp    %eax,%edx
  je     L51
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x21,%rax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  lea    (%rax,%rax,4),%eax
  cmp    %eax,%edx
  jne    L37
  jmp    L51
L53:
  mov    $0x0,%esi
L58:
  mov    %esi,%eax
  ret
```

assistant: ```c
int ThreeAndFiveMultiples(int n) {
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if ((i % 3 == 0) || (i % 5 == 0)) {
      sum += i;
    }
  }
  return sum;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<ThreeAndFiveMultiples>:
  endbr64
  test   %edi,%edi
  jle    L1
  xor    %eax,%eax
  xor    %r8d,%r8d
  nopl   (%rax)
L30:
  imul   $0xaaaaaaab,%eax,%edx
  cmp    $0x55555555,%edx
  jbe    L13
  imul   $0xcccccccd,%eax,%edx
  cmp    $0x33333333,%edx
  ja     L22
L13:
  add    %eax,%r8d
L22:
  add    $0x1,%eax
  cmp    %eax,%edi
  jne    L30
  mov    %r8d,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L1:
  xor    %r8d,%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
int ThreeAndFiveMultiples(int n) {
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if ((i % 3 == 0) || (i % 5 == 0)) {
      sum += i;
    }
  }
  return sum;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<cm_searching_run_tests>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    $0x0,%eax
  call   <cm_search_array_linear__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_sentinel_linear__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_binary__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_improved_binary__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_interpolation__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_linear__element_does_not_exist__not_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_sentinel_linear__element_does_not_exist__not_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_binary__element_does_not_exist__not_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_improved_binary__element_does_not_exist__not_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_interpolation__element_does_not_exist__not_found@plt>
  nop
  pop    %rbp
  ret
```

assistant: ```c
void cm_searching_run_tests(void) {
  cm_search_array_linear__element_exists__is_found();
  cm_search_array_sentinel_linear__element_exists__is_found();
  cm_search_array_binary__element_exists__is_found();
  cm_search_array_improved_binary__element_exists__is_found();
  cm_search_array_interpolation__element_exists__is_found();
  cm_search_array_linear__element_does_not_exist__not_found();
  cm_search_array_sentinel_linear__element_does_not_exist__not_found();
  cm_search_array_binary__element_does_not_exist__not_found();
  cm_search_array_improved_binary__element_does_not_exist__not_found();
  cm_search_array_interpolation__element_does_not_exist__not_found();
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<cm_searching_run_tests>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%eax
  call   <cm_search_array_linear__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_sentinel_linear__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_binary__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_improved_binary__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_interpolation__element_exists__is_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_linear__element_does_not_exist__not_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_sentinel_linear__element_does_not_exist__not_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_binary__element_does_not_exist__not_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_improved_binary__element_does_not_exist__not_found@plt>
  mov    $0x0,%eax
  call   <cm_search_array_interpolation__element_does_not_exist__not_found@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
void cm_searching_run_tests(void) {
  cm_search_array_linear__element_exists__is_found();
  cm_search_array_sentinel_linear__element_exists__is_found();
  cm_search_array_binary__element_exists__is_found();
  cm_search_array_improved_binary__element_exists__is_found();
  cm_search_array_interpolation__element_exists__is_found();
  cm_search_array_linear__element_does_not_exist__not_found();
  cm_search_array_sentinel_linear__element_does_not_exist__not_found();
  cm_search_array_binary__element_does_not_exist__not_found();
  cm_search_array_improved_binary__element_does_not_exist__not_found();
  cm_search_array_interpolation__element_does_not_exist__not_found();
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<cm_searching_run_tests>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <cm_search_array_linear__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_sentinel_linear__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_binary__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_improved_binary__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_interpolation__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_linear__element_does_not_exist__not_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_sentinel_linear__element_does_not_exist__not_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_binary__element_does_not_exist__not_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_improved_binary__element_does_not_exist__not_found@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  jmp    1120 <cm_search_array_interpolation__element_does_not_exist__not_found@plt>
```

assistant: ```c
void cm_searching_run_tests(void) {
  cm_search_array_linear__element_exists__is_found();
  cm_search_array_sentinel_linear__element_exists__is_found();
  cm_search_array_binary__element_exists__is_found();
  cm_search_array_improved_binary__element_exists__is_found();
  cm_search_array_interpolation__element_exists__is_found();
  cm_search_array_linear__element_does_not_exist__not_found();
  cm_search_array_sentinel_linear__element_does_not_exist__not_found();
  cm_search_array_binary__element_does_not_exist__not_found();
  cm_search_array_improved_binary__element_does_not_exist__not_found();
  cm_search_array_interpolation__element_does_not_exist__not_found();
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<cm_searching_run_tests>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <cm_search_array_linear__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_sentinel_linear__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_binary__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_improved_binary__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_interpolation__element_exists__is_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_linear__element_does_not_exist__not_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_sentinel_linear__element_does_not_exist__not_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_binary__element_does_not_exist__not_found@plt>
  xor    %eax,%eax
  call   <cm_search_array_improved_binary__element_does_not_exist__not_found@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  jmp    1120 <cm_search_array_interpolation__element_does_not_exist__not_found@plt>
```

assistant: ```c
void cm_searching_run_tests(void) {
  cm_search_array_linear__element_exists__is_found();
  cm_search_array_sentinel_linear__element_exists__is_found();
  cm_search_array_binary__element_exists__is_found();
  cm_search_array_improved_binary__element_exists__is_found();
  cm_search_array_interpolation__element_exists__is_found();
  cm_search_array_linear__element_does_not_exist__not_found();
  cm_search_array_sentinel_linear__element_does_not_exist__not_found();
  cm_search_array_binary__element_does_not_exist__not_found();
  cm_search_array_improved_binary__element_does_not_exist__not_found();
  cm_search_array_interpolation__element_does_not_exist__not_found();
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<getter_fd>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x18(%rbp),%rax
  mov    %eax,-0xc(%rbp)
  lea    -0xd(%rbp),%rcx
  mov    -0xc(%rbp),%eax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  cmp    $0x1,%eax
  je     L17
  mov    D4(%rip),%rax
  mov    (%rax),%eax
  jmp    L14
L17:
  movzbl -0xd(%rbp),%eax
  movsbl %al,%eax
L14:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  leave
  ret
```

assistant: ```c
int getter_fd(void *cookie) {
  char ch;
  int fd = (int)cookie;
  if (read(fd, &ch, 1) != 1) {
    return (EOF);
  }
  return (ch);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<getter_fd>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x7(%rsp),%rsi
  mov    $0x1,%edx
  call   <read@plt>
  cmp    $0x1,%eax
  je     L15
  mov    D0(%rip),%rax
  mov    (%rax),%eax
L20:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L22
  add    $0x18,%rsp
  ret
L15:
  movsbl 0x7(%rsp),%eax
  jmp    L20
L22:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int getter_fd(void *cookie) {
  char ch;
  int fd = (int)cookie;
  if (read(fd, &ch, 1) != 1) {
    return (EOF);
  }
  return (ch);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<getter_fd>:
  endbr64
  sub    $0x18,%rsp
  mov    $0x1,%edx
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x7(%rsp),%rsi
  call   <read@plt>
  cmp    $0x1,%eax
  je     L10
  mov    D4(%rip),%rax
  mov    (%rax),%eax
L13:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L29
  add    $0x18,%rsp
  ret
  nopw   0x0(%rax,%rax,1)
L10:
  movsbl 0x7(%rsp),%eax
  jmp    L13
L29:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int getter_fd(void *cookie) {
  char ch;
  int fd = (int)cookie;
  if (read(fd, &ch, 1) != 1) {
    return (EOF);
  }
  return (ch);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<getter_fd>:
  endbr64
  sub    $0x18,%rsp
  mov    $0x1,%edx
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x7(%rsp),%rsi
  call   <read@plt>
  cmp    $0x1,%eax
  je     L20
  mov    D1(%rip),%rax
  mov    (%rax),%eax
L18:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L28
  add    $0x18,%rsp
  ret
  nopw   0x0(%rax,%rax,1)
L20:
  movsbl 0x7(%rsp),%eax
  jmp    L18
L28:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int getter_fd(void *cookie) {
  char ch;
  int fd = (int)cookie;
  if (read(fd, &ch, 1) != 1) {
    return (EOF);
  }
  return (ch);
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<adbuf_printf>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x418,%rsp
  mov    %rdi,%r14
  mov    %rsi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  mov    $0x0,%r12d
  mov    %r12d,%edi
  call   <va_start@plt>
  mov    %rsp,%rdi
  mov    %r12d,%ecx
  mov    %rbp,%rdx
  mov    $0x400,%esi
  call   <vsnprintf@plt>
  mov    %eax,%ebx
  movb   $0x0,0x3ff(%rsp)
  mov    %r12d,%edi
  call   <va_end@plt>
  test   %ebx,%ebx
  js     L43
  cmp    $0x3ff,%ebx
  jle    L7
  lea    0x1(%rbx),%r15d
  mov    %r15d,%edi
  call   <malloc@plt>
  mov    %rax,%r13
  mov    $0x1,%r12d
  test   %rax,%rax
  je     L31
  mov    %rbp,%rsi
  mov    $0x0,%r12d
  mov    %r12d,%edi
  call   <va_start@plt>
  mov    %r12d,%ecx
  mov    %rbp,%rdx
  mov    %r15d,%esi
  mov    %r13,%rdi
  call   <vsnprintf@plt>
  mov    %eax,%ebp
  movslq %ebx,%rax
  movb   $0x0,0x0(%r13,%rax,1)
  mov    %r12d,%edi
  call   <va_end@plt>
  cmp    %ebp,%ebx
  je     L78
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <adbuf_add@plt>
  mov    %eax,%r12d
  mov    %r13,%rdi
  call   <free@plt>
  jmp    L31
L43:
  mov    %rsp,%rbx
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbx,%rsi
  mov    %r14,%rdi
  call   <adbuf_add@plt>
  mov    %eax,%r12d
  jmp    L31
L78:
  mov    %ebx,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <adbuf_add@plt>
  mov    %eax,%r12d
  mov    %r13,%rdi
  call   <free@plt>
  jmp    L31
L7:
  mov    %rsp,%rsi
  mov    %ebx,%edx
  mov    %r14,%rdi
  call   <adbuf_add@plt>
  mov    %eax,%r12d
L31:
  mov    0x408(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L53
  mov    %r12d,%eax
  add    $0x418,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L53:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int adbuf_printf(struct adbuf *dst, const char *fmt, ...) {
  char buf[1024];
  int retval;
  va_list ap;
  va_start(ap, fmt);
  retval = vsnprintf(buf, 1024, fmt, ap);
  buf[1024 - 1] = '\0';
  va_end(ap);
  if (retval <= -1) {
    return adbuf_add(dst, buf, strlen(buf));
  }
  if (retval >= 1024) {
    char *dynbuf;
    int newretval;
    if ((dynbuf = malloc(retval + 1)) == NULL)
      return 1;
    va_start(ap, fmt);
    newretval = vsnprintf(dynbuf, retval + 1, fmt, ap);
    dynbuf[retval] = '\0';
    va_end(ap);
    if (newretval == retval) {
      int rv;
      rv = adbuf_add(dst, dynbuf, retval);
      free(dynbuf);
      return rv;
    } else {
      int rv;
      rv = adbuf_add(dst, dynbuf, strlen(dynbuf));
      free(dynbuf);
      return rv;
    }
  } else {
    return adbuf_add(dst, buf, retval);
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<adbuf_printf>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  mov    %rdi,%rbx
  mov    %ebp,%edi
  sub    $0x428,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x418(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%r14
  call   <va_start@plt>
  mov    %r14,%rdi
  mov    %ebp,%ecx
  mov    %r13,%rdx
  mov    $0x400,%esi
  call   <vsnprintf@plt>
  mov    %ebp,%edi
  movb   $0x0,0x40f(%rsp)
  mov    %eax,%r12d
  call   <va_end@plt>
  test   %r12d,%r12d
  js     L19
  cmp    $0x3ff,%r12d
  jle    L20
  lea    0x1(%r12),%r8d
  mov    $0x1,%r15d
  mov    %r8d,%edi
  mov    %r8d,0xc(%rsp)
  call   <malloc@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L38
  xor    %ebp,%ebp
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <va_start@plt>
  mov    0xc(%rsp),%esi
  mov    %r13,%rdx
  mov    %ebp,%ecx
  mov    %r14,%rdi
  call   <vsnprintf@plt>
  mov    %ebp,%edi
  mov    %eax,%r13d
  movslq %r12d,%rax
  movb   $0x0,(%r14,%rax,1)
  call   <va_end@plt>
  mov    %r12d,%edx
  cmp    %r13d,%r12d
  je     L36
  mov    %r14,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
L36:
  mov    %rbx,%rdi
  mov    %r14,%rsi
  call   <adbuf_add@plt>
  mov    %r14,%rdi
  mov    %eax,%r15d
  call   <free@plt>
L38:
  mov    0x418(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L22
  add    $0x428,%rsp
  mov    %r15d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L20:
  mov    %r12d,%edx
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <adbuf_add@plt>
  mov    %eax,%r15d
  jmp    L38
  nopl   0x0(%rax,%rax,1)
L19:
  mov    %r14,%rdi
  call   <strlen@plt>
  mov    %r14,%rsi
  mov    %rbx,%rdi
  mov    %eax,%edx
  call   <adbuf_add@plt>
  mov    %eax,%r15d
  jmp    L38
L22:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int adbuf_printf(struct adbuf *dst, const char *fmt, ...) {
  char buf[1024];
  int retval;
  va_list ap;
  va_start(ap, fmt);
  retval = vsnprintf(buf, 1024, fmt, ap);
  buf[1024 - 1] = '\0';
  va_end(ap);
  if (retval <= -1) {
    return adbuf_add(dst, buf, strlen(buf));
  }
  if (retval >= 1024) {
    char *dynbuf;
    int newretval;
    if ((dynbuf = malloc(retval + 1)) == NULL)
      return 1;
    va_start(ap, fmt);
    newretval = vsnprintf(dynbuf, retval + 1, fmt, ap);
    dynbuf[retval] = '\0';
    va_end(ap);
    if (newretval == retval) {
      int rv;
      rv = adbuf_add(dst, dynbuf, retval);
      free(dynbuf);
      return rv;
    } else {
      int rv;
      rv = adbuf_add(dst, dynbuf, strlen(dynbuf));
      free(dynbuf);
      return rv;
    }
  } else {
    return adbuf_add(dst, buf, retval);
  }
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<adbuf_printf>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  mov    %rdi,%rbx
  mov    %ebp,%edi
  sub    $0x428,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x418(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%r14
  call   <va_start@plt>
  mov    %r14,%rdi
  mov    %ebp,%ecx
  mov    %r13,%rdx
  mov    $0x400,%esi
  call   <vsnprintf@plt>
  mov    %ebp,%edi
  movb   $0x0,0x40f(%rsp)
  mov    %eax,%r12d
  call   <va_end@plt>
  test   %r12d,%r12d
  js     L39
  cmp    $0x3ff,%r12d
  jle    L4
  lea    0x1(%r12),%r8d
  mov    $0x1,%r15d
  mov    %r8d,%edi
  mov    %r8d,0xc(%rsp)
  call   <malloc@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L68
  xor    %ebp,%ebp
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <va_start@plt>
  mov    0xc(%rsp),%esi
  mov    %r13,%rdx
  mov    %ebp,%ecx
  mov    %r14,%rdi
  call   <vsnprintf@plt>
  mov    %ebp,%edi
  mov    %eax,%r13d
  movslq %r12d,%rax
  movb   $0x0,(%r14,%rax,1)
  call   <va_end@plt>
  mov    %r12d,%edx
  cmp    %r13d,%r12d
  je     L9
  mov    %r14,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
L9:
  mov    %rbx,%rdi
  mov    %r14,%rsi
  call   <adbuf_add@plt>
  mov    %r14,%rdi
  mov    %eax,%r15d
  call   <free@plt>
L68:
  mov    0x418(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L19
  add    $0x428,%rsp
  mov    %r15d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L4:
  mov    %r12d,%edx
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <adbuf_add@plt>
  mov    %eax,%r15d
  jmp    L68
  nopl   0x0(%rax,%rax,1)
L39:
  mov    %r14,%rdi
  call   <strlen@plt>
  mov    %r14,%rsi
  mov    %rbx,%rdi
  mov    %eax,%edx
  call   <adbuf_add@plt>
  mov    %eax,%r15d
  jmp    L68
L19:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int adbuf_printf(struct adbuf *dst, const char *fmt, ...) {
  char buf[1024];
  int retval;
  va_list ap;
  va_start(ap, fmt);
  retval = vsnprintf(buf, 1024, fmt, ap);
  buf[1024 - 1] = '\0';
  va_end(ap);
  if (retval <= -1) {
    return adbuf_add(dst, buf, strlen(buf));
  }
  if (retval >= 1024) {
    char *dynbuf;
    int newretval;
    if ((dynbuf = malloc(retval + 1)) == NULL)
      return 1;
    va_start(ap, fmt);
    newretval = vsnprintf(dynbuf, retval + 1, fmt, ap);
    dynbuf[retval] = '\0';
    va_end(ap);
    if (newretval == retval) {
      int rv;
      rv = adbuf_add(dst, dynbuf, retval);
      free(dynbuf);
      return rv;
    } else {
      int rv;
      rv = adbuf_add(dst, dynbuf, strlen(dynbuf));
      free(dynbuf);
      return rv;
    }
  } else {
    return adbuf_add(dst, buf, retval);
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<get_attr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x20(%rbp),%rsi
  mov    -0x34(%rbp),%eax
  mov    $0x0,%ecx
  mov    $0x18,%edx
  mov    %eax,%edi
  call   <pread@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jg     L1
  mov    -0x40(%rbp),%rax
  movq   $0xffffffffffffffff,(%rax)
  mov    $0xffffffff,%eax
  jmp    L7
L1:
  mov    D8(%rip),%rax
  movq   $0x0,(%rax)
  mov    -0x38(%rbp),%edx
  lea    -0x20(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <strtoll@plt>
  mov    -0x40(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    D8(%rip),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L44
  mov    -0x40(%rbp),%rax
  movq   $0xfffffffffffffffe,(%rax)
  mov    $0xffffffff,%eax
  jmp    L7
L44:
  mov    $0x0,%eax
L7:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L35
  call   <__stack_chk_fail@plt>
L35:
  leave
  ret
```

assistant: ```c
int get_attr(int fd, long long *val, int base) {
  char data[24];
  ssize_t r = pread(fd, data, sizeof(data), 0);
  if (r < 1) {
    *val = -1;
    return -1;
  }
  errno = 0;
  *val = strtoll(data, NULL, base);
  if (errno) {
    *val = -2;
    return -1;
  }
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<get_attr>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %rsi,%rbx
  mov    %edx,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rsi
  mov    $0x0,%ecx
  mov    $0x18,%edx
  call   <pread@plt>
  test   %eax,%eax
  jle    L9
  mov    D2(%rip),%rbp
  movq   $0x0,0x0(%rbp)
  mov    %rsp,%rdi
  mov    %r12d,%edx
  mov    $0x0,%esi
  call   <strtoll@plt>
  mov    %rax,(%rbx)
  cmpq   $0x0,0x0(%rbp)
  jne    L21
  mov    $0x0,%eax
L8:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L42
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L9:
  movq   $0xffffffffffffffff,(%rbx)
  mov    $0xffffffff,%eax
  jmp    L8
L21:
  movq   $0xfffffffffffffffe,(%rbx)
  mov    $0xffffffff,%eax
  jmp    L8
L42:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int get_attr(int fd, long long *val, int base) {
  char data[24];
  ssize_t r = pread(fd, data, sizeof(data), 0);
  if (r < 1) {
    *val = -1;
    return -1;
  }
  errno = 0;
  *val = strtoll(data, NULL, base);
  if (errno) {
    *val = -2;
    return -1;
  }
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<get_attr>:
  endbr64
  push   %r13
  xor    %ecx,%ecx
  push   %r12
  mov    %edx,%r12d
  mov    $0x18,%edx
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbp
  mov    %rbp,%rsi
  call   <pread@plt>
  test   %eax,%eax
  jle    L16
  mov    D3(%rip),%r13
  xor    %esi,%esi
  mov    %r12d,%edx
  mov    %rbp,%rdi
  movq   $0x0,0x0(%r13)
  call   <strtoll@plt>
  cmpq   $0x0,0x0(%r13)
  mov    %rax,(%rbx)
  jne    L4
  xor    %eax,%eax
L10:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L1
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L16:
  movq   $0xffffffffffffffff,(%rbx)
  mov    $0xffffffff,%eax
  jmp    L10
  xchg   %ax,%ax
L4:
  movq   $0xfffffffffffffffe,(%rbx)
  mov    $0xffffffff,%eax
  jmp    L10
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int get_attr(int fd, long long *val, int base) {
  char data[24];
  ssize_t r = pread(fd, data, sizeof(data), 0);
  if (r < 1) {
    *val = -1;
    return -1;
  }
  errno = 0;
  *val = strtoll(data, NULL, base);
  if (errno) {
    *val = -2;
    return -1;
  }
  return 0;
}
```