ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<print_help>:
  endbr64
  sub    $0x8,%rsp
  mov    %rdi,%rsi
  lea    D18(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D51(%rip),%rdi
  call   <puts@plt>
  lea    D2(%rip),%rdi
  call   <puts@plt>
  lea    D29(%rip),%rdi
  call   <puts@plt>
  lea    D30(%rip),%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D80(%rip),%rdi
  call   <puts@plt>
  lea    D45(%rip),%rdi
  call   <puts@plt>
  lea    D69(%rip),%rdi
  call   <puts@plt>
  lea    D72(%rip),%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  add    $0x8,%rsp
  jmp    1070 <putchar@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D18
type_guessed: string
name: retrieve_data
arguments: data_label: D51
type_guessed: string
name: retrieve_data
arguments: data_label: D2
type_guessed: string
name: retrieve_data
arguments: data_label: D29
type_guessed: string
name: retrieve_data
arguments: data_label: D30
type_guessed: string
name: retrieve_data
arguments: data_label: D80
type_guessed: string
name: retrieve_data
arguments: data_label: D45
type_guessed: string
name: retrieve_data
arguments: data_label: D69
type_guessed: string
name: retrieve_data
arguments: data_label: D72
type_guessed: string

tool: D18: Uso: %s <c/asm1/asm2> <fitro> <parametros...>


tool: D51: Opcion C o ASM

tool: D2:          c : ejecuta el codigo C

tool: D29:       asm1 : ejecuta el codigo ASM version 1

tool: D30:       asm2 : ejecuta el codigo ASM version 2

tool: D80: Filtro:

tool: D45:       <c/asm1/asm2> blur <src> <dst>

tool: D69:       <c/asm1/asm2> merge <src1> <src2> <dst> <value>

tool: D72:       <c/asm1/asm2> hsl <src> <dst> <h> 
 <l>

assistant: ```c
void print_help(char *name) {
  printf("Uso: %s <c/asm1/asm2> <fitro> <parametros...>\n", name);
  printf("\n");
  printf("Opcion C o ASM\n");
  printf("         c : ejecuta el codigo C\n");
  printf("      asm1 : ejecuta el codigo ASM version 1\n");
  printf("      asm2 : ejecuta el codigo ASM version 2\n");
  printf("\n");
  printf("Filtro:\n");
  printf("      <c/asm1/asm2> blur <src> <dst>\n");
  printf("      <c/asm1/asm2> merge <src1> <src2> <dst> <value>\n");
  printf("      <c/asm1/asm2> hsl <src> <dst> <h> 
 <l>\n");
  printf("\n");
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<print_help>:
  endbr64
  sub    $0x8,%rsp
  mov    %rdi,%rsi
  lea    D75(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D48(%rip),%rdi
  call   <puts@plt>
  lea    D81(%rip),%rdi
  call   <puts@plt>
  lea    D32(%rip),%rdi
  call   <puts@plt>
  lea    D57(%rip),%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D55(%rip),%rdi
  call   <puts@plt>
  lea    D76(%rip),%rdi
  call   <puts@plt>
  lea    D84(%rip),%rdi
  call   <puts@plt>
  lea    D19(%rip),%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  add    $0x8,%rsp
  jmp    1070 <putchar@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D75
datatype: string
name: extract_symbolic_data
arguments: label: D48
datatype: string
name: extract_symbolic_data
arguments: label: D81
datatype: string
name: extract_symbolic_data
arguments: label: D32
datatype: string
name: extract_symbolic_data
arguments: label: D57
datatype: string
name: extract_symbolic_data
arguments: label: D55
datatype: string
name: extract_symbolic_data
arguments: label: D76
datatype: string
name: extract_symbolic_data
arguments: label: D84
datatype: string
name: extract_symbolic_data
arguments: label: D19
datatype: string

tool: D75: Uso: %s <c/asm1/asm2> <fitro> <parametros...>


tool: D48: Opcion C o ASM

tool: D81:          c : ejecuta el codigo C

tool: D32:       asm1 : ejecuta el codigo ASM version 1

tool: D57:       asm2 : ejecuta el codigo ASM version 2

tool: D55: Filtro:

tool: D76:       <c/asm1/asm2> blur <src> <dst>

tool: D84:       <c/asm1/asm2> merge <src1> <src2> <dst> <value>

tool: D19:       <c/asm1/asm2> hsl <src> <dst> <h> 
 <l>

assistant: ```c
void print_help(char *name) {
  printf("Uso: %s <c/asm1/asm2> <fitro> <parametros...>\n", name);
  printf("\n");
  printf("Opcion C o ASM\n");
  printf("         c : ejecuta el codigo C\n");
  printf("      asm1 : ejecuta el codigo ASM version 1\n");
  printf("      asm2 : ejecuta el codigo ASM version 2\n");
  printf("\n");
  printf("Filtro:\n");
  printf("      <c/asm1/asm2> blur <src> <dst>\n");
  printf("      <c/asm1/asm2> merge <src1> <src2> <dst> <value>\n");
  printf("      <c/asm1/asm2> hsl <src> <dst> <h> 
 <l>\n");
  printf("\n");
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<print_data_send_error>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%esi
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D5
type_infered: string

tool: D5: Unable to send data packet with block_number %d


assistant: ```c
print_data_send_error(int block_number) {
  printf("Unable to send data packet with block_number %d\n", block_number);
  exit(1);
}
```
user: Translate the below assembly code into C programming language:

```asm
<print_data_send_error>:
  endbr64
  sub    $0x8,%rsp
  mov    %edi,%esi
  lea    D2(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  add    $0x8,%rsp
  ret
```

tool_calls: name: read_data
arguments: tag: D2
datatype: string

tool: D2: Unable to send data packet with block_number %d


assistant: ```c
print_data_send_error(int block_number) {
  printf("Unable to send data packet with block_number %d\n", block_number);
  exit(1);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<print_data_send_error>:
  endbr64
  sub    $0x8,%rsp
  mov    %edi,%esi
  lea    D2(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  add    $0x8,%rsp
  jmp    1070 <exit@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D2
type_guessed: string

tool: D2: Unable to send data packet with block_number %d


assistant: ```c
print_data_send_error(int block_number) {
  printf("Unable to send data packet with block_number %d\n", block_number);
  exit(1);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<print_data_send_error>:
  endbr64
  sub    $0x8,%rsp
  mov    %edi,%esi
  lea    D5(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  add    $0x8,%rsp
  jmp    1070 <exit@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D5
datatype: string

tool: D5: Unable to send data packet with block_number %d


assistant: ```c
print_data_send_error(int block_number) {
  printf("Unable to send data packet with block_number %d\n", block_number);
  exit(1);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<check_line_continuation>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x130,%rsp
  mov    %rdi,-0x128(%rbp)
  mov    %rsi,-0x130(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x118(%rbp)
  jmp    L83
L117:
  lea    -0x110(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x114(%rbp)
  addl   $0x1,-0x118(%rbp)
  cmpl   $0x1,-0x114(%rbp)
  jle    L83
  mov    -0x114(%rbp),%eax
  sub    $0x1,%eax
  cltq
  movzbl -0x110(%rbp,%rax,1),%eax
  cmp    $0xa,%al
  jne    L83
  mov    -0x114(%rbp),%eax
  sub    $0x2,%eax
  cltq
  movzbl -0x110(%rbp,%rax,1),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isblank@plt>
  test   %rax,%rax
  jne    L33
  jmp    L83
L33:
  subl   $0x3,-0x114(%rbp)
  jmp    L66
L25:
  subl   $0x1,-0x114(%rbp)
L66:
  cmpl   $0x0,-0x114(%rbp)
  js     L81
  mov    -0x114(%rbp),%eax
  cltq
  movzbl -0x110(%rbp,%rax,1),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isblank@plt>
  test   %rax,%rax
  jne    L25
L81:
  cmpl   $0x0,-0x114(%rbp)
  js     L83
  mov    -0x114(%rbp),%eax
  cltq
  movzbl -0x110(%rbp,%rax,1),%eax
  cmp    $0x5c,%al
  jne    L83
  mov    -0x130(%rbp),%rax
  mov    %rax,%rsi
  lea    D10(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x118(%rbp),%eax
  mov    %eax,%esi
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  nop
L83:
  mov    -0x128(%rbp),%rdx
  lea    -0x110(%rbp),%rax
  mov    $0x100,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L117
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L34
  call   <__stack_chk_fail@plt>
L34:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D10
type: string
name: retrieve_data
arguments: tag: D9
type: string

tool: D10: [%s]


tool: D9: Warning: "backslash + space" detected at the end of line %d.
         This will not work as line continuation.


assistant: ```c
int check_line_continuation(FILE *ftmpl, char *node_name) {
  char buf[256];
  int line = 0;
  while (fgets(buf, 256, ftmpl) != NULL) {
    int len = strlen(buf);
    ++line;
    if (len < 2 || buf[len - 1] != '\n' || !isblank(buf[len - 2])) {
      continue;
    }
    len -= 3;
    while (len >= 0 && isblank(buf[len])) {
      --len;
    }
    if (len >= 0 && buf[len] == '\\') {
      printf("[%s]\n", node_name);
      printf("Warning: \"backslash + space\" detected at the end of line %d.\n"
             "         This will not work as line continuation.\n",
             line);
      continue;
    }
  }
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<check_line_continuation>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x128,%rsp
  mov    %rdi,%r13
  mov    %rsi,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x118(%rsp)
  xor    %eax,%eax
  mov    $0x0,%r12d
  lea    0x10(%rsp),%rbp
  lea    D3(%rip),%r15
L105:
  mov    %r13,%rdx
  mov    $0x100,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L39
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  add    $0x1,%r12d
  cmp    $0x1,%eax
  jle    L105
  lea    -0x1(%rax),%eax
  cltq
  cmpb   $0xa,0x10(%rsp,%rax,1)
  jne    L105
  lea    -0x2(%rbx),%eax
  cltq
  movsbl 0x10(%rsp,%rax,1),%edi
  call   <isblank@plt>
  test   %rax,%rax
  je     L105
  sub    $0x3,%ebx
  js     L105
  movslq %ebx,%rbx
L28:
  movsbl (%rbx,%rbp,1),%edi
  call   <isblank@plt>
  test   %rax,%rax
  je     L40
  sub    $0x1,%rbx
  test   %ebx,%ebx
  jns    L28
  jmp    L105
L40:
  test   %ebx,%ebx
  js     L105
  movslq %ebx,%r14
  cmpb   $0x5c,0x10(%rsp,%r14,1)
  jne    L105
  mov    0x8(%rsp),%rsi
  mov    %r15,%rdi
  call   <printf@plt>
  mov    %r12d,%esi
  lea    D0(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L105
L39:
  mov    0x118(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L11
  mov    $0x0,%eax
  add    $0x128,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L11:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D3
type: string
name: read_data
arguments: tag: D0
type: string

tool: D3: [%s]


tool: D0: Warning: "backslash + space" detected at the end of line %d.
         This will not work as line continuation.


assistant: ```c
int check_line_continuation(FILE *ftmpl, char *node_name) {
  char buf[256];
  int line = 0;
  while (fgets(buf, 256, ftmpl) != NULL) {
    int len = strlen(buf);
    ++line;
    if (len < 2 || buf[len - 1] != '\n' || !isblank(buf[len - 2])) {
      continue;
    }
    len -= 3;
    while (len >= 0 && isblank(buf[len])) {
      --len;
    }
    if (len >= 0 && buf[len] == '\\') {
      printf("[%s]\n", node_name);
      printf("Warning: \"backslash + space\" detected at the end of line %d.\n"
             "         This will not work as line continuation.\n",
             line);
      continue;
    }
  }
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<check_line_continuation>:
  endbr64
  push   %r15
  lea    D18(%rip),%r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  sub    $0x128,%rsp
  mov    %rsi,0x8(%rsp)
  lea    0x10(%rsp),%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x118(%rsp)
  xor    %eax,%eax
  xchg   %ax,%ax
L80:
  mov    %r12,%rdx
  mov    $0x100,%esi
  mov    %rbx,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L55
  mov    %rbx,%rdi
  add    $0x1,%ebp
  call   <strlen@plt>
  mov    %eax,%r13d
  cmp    $0x1,%eax
  jle    L80
  lea    -0x1(%rax),%eax
  cltq
  cmpb   $0xa,0x10(%rsp,%rax,1)
  jne    L80
  lea    -0x2(%r13),%eax
  cltq
  movsbl 0x10(%rsp,%rax,1),%edi
  call   <isblank@plt>
  test   %rax,%rax
  je     L80
  lea    -0x3(%r13),%edx
  cmp    $0x2,%r13d
  je     L80
  movslq %edx,%r14
  jmp    L48
  nopl   0x0(%rax)
L61:
  sub    $0x1,%r14
  cmp    $0xffffffff,%r14d
  je     L80
L48:
  movsbl (%rbx,%r14,1),%edi
  movslq %r14d,%r13
  call   <isblank@plt>
  test   %rax,%rax
  jne    L61
  cmpb   $0x5c,0x10(%rsp,%r13,1)
  jne    L80
  mov    0x8(%rsp),%rsi
  mov    %r15,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %ebp,%esi
  lea    D12(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L80
  nopl   0x0(%rax)
L55:
  mov    0x118(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L51
  add    $0x128,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L51:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D18
type: string
name: extract_symbolic_data
arguments: data_label: D12
type: string

tool: D18: [%s]


tool: D12: Warning: "backslash + space" detected at the end of line %d.
         This will not work as line continuation.


assistant: ```c
int check_line_continuation(FILE *ftmpl, char *node_name) {
  char buf[256];
  int line = 0;
  while (fgets(buf, 256, ftmpl) != NULL) {
    int len = strlen(buf);
    ++line;
    if (len < 2 || buf[len - 1] != '\n' || !isblank(buf[len - 2])) {
      continue;
    }
    len -= 3;
    while (len >= 0 && isblank(buf[len])) {
      --len;
    }
    if (len >= 0 && buf[len] == '\\') {
      printf("[%s]\n", node_name);
      printf("Warning: \"backslash + space\" detected at the end of line %d.\n"
             "         This will not work as line continuation.\n",
             line);
      continue;
    }
  }
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<check_line_continuation>:
  endbr64
  push   %r15
  lea    D1(%rip),%r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  sub    $0x128,%rsp
  mov    %rsi,0x8(%rsp)
  lea    0x10(%rsp),%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x118(%rsp)
  xor    %eax,%eax
  xchg   %ax,%ax
L84:
  mov    %r12,%rdx
  mov    $0x100,%esi
  mov    %rbx,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L76
  mov    %rbx,%rdi
  add    $0x1,%ebp
  call   <strlen@plt>
  mov    %eax,%r13d
  cmp    $0x1,%eax
  jle    L84
  lea    -0x1(%rax),%eax
  cltq
  cmpb   $0xa,0x10(%rsp,%rax,1)
  jne    L84
  lea    -0x2(%r13),%eax
  cltq
  movsbl 0x10(%rsp,%rax,1),%edi
  call   <isblank@plt>
  test   %rax,%rax
  je     L84
  lea    -0x3(%r13),%edx
  cmp    $0x2,%r13d
  je     L84
  movslq %edx,%r14
  jmp    L74
  nopl   0x0(%rax)
L95:
  sub    $0x1,%r14
  cmp    $0xffffffff,%r14d
  je     L84
L74:
  movsbl (%rbx,%r14,1),%edi
  movslq %r14d,%r13
  call   <isblank@plt>
  test   %rax,%rax
  jne    L95
  cmpb   $0x5c,0x10(%rsp,%r13,1)
  jne    L84
  mov    0x8(%rsp),%rsi
  mov    %r15,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %ebp,%esi
  lea    D10(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L84
  nopl   0x0(%rax)
L76:
  mov    0x118(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L46
  add    $0x128,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L46:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D1
datatype: string
name: retrieve_data
arguments: data_tag: D10
datatype: string

tool: D1: [%s]


tool: D10: Warning: "backslash + space" detected at the end of line %d.
         This will not work as line continuation.


assistant: ```c
int check_line_continuation(FILE *ftmpl, char *node_name) {
  char buf[256];
  int line = 0;
  while (fgets(buf, 256, ftmpl) != NULL) {
    int len = strlen(buf);
    ++line;
    if (len < 2 || buf[len - 1] != '\n' || !isblank(buf[len - 2])) {
      continue;
    }
    len -= 3;
    while (len >= 0 && isblank(buf[len])) {
      --len;
    }
    if (len >= 0 && buf[len] == '\\') {
      printf("[%s]\n", node_name);
      printf("Warning: \"backslash + space\" detected at the end of line %d.\n"
             "         This will not work as line continuation.\n",
             line);
      continue;
    }
  }
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<str_append_n>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jbe    L8
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x20,(%rax)
L8:
  mov    -0x34(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  sub    -0x28(%rbp),%rax
  mov    %rax,%rcx
  mov    %rdx,%rax
  sub    %rcx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x10(%rbp),%rdx
  mov    -0x30(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x34(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x10(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  cmp    %rax,%rdx
  cmovbe %rdx,%rax
  leave
  ret
```

assistant: ```c
int str_append_n(char *buf, const char *src, int buf_len) {
  size_t l1, l2;
  char *p = buf;
  p = buf + strlen(buf);
  if (p > buf)
    *p++ = ' ';
  l1 = buf_len - (p - buf);
  l2 = strlen(src);
  strncpy(p, src, l1);
  buf[buf_len - 1] = '\0';
  return (l2 < l1 ? l2 : l1);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<str_append_n>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%r15
  mov    %edx,%r12d
  call   <strlen@plt>
  lea    (%rbx,%rax,1),%rbp
  cmp    %rbp,%rbx
  jae    L3
  movb   $0x20,0x0(%rbp)
  lea    0x1(%rbp),%rbp
L3:
  movslq %r12d,%r12
  mov    %rbp,%rax
  sub    %rbx,%rax
  mov    %r12,%r13
  sub    %rax,%r13
  mov    %r15,%rdi
  call   <strlen@plt>
  mov    %rax,%r14
  mov    %r13,%rdx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <strncpy@plt>
  movb   $0x0,-0x1(%rbx,%r12,1)
  cmp    %r14,%r13
  cmovbe %r13,%r14
  mov    %r14,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int str_append_n(char *buf, const char *src, int buf_len) {
  size_t l1, l2;
  char *p = buf;
  p = buf + strlen(buf);
  if (p > buf)
    *p++ = ' ';
  l1 = buf_len - (p - buf);
  l2 = strlen(src);
  strncpy(p, src, l1);
  buf[buf_len - 1] = '\0';
  return (l2 < l1 ? l2 : l1);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<str_append_n>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  push   %r13
  push   %r12
  movslq %edx,%r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  call   <strlen@plt>
  lea    (%rbx,%rax,1),%rbp
  cmp    %rbp,%rbx
  jae    L6
  movb   $0x20,0x0(%rbp)
  add    $0x1,%rbp
L6:
  mov    %rbp,%rax
  mov    %r15,%rdi
  mov    %r12,%r13
  sub    %rbx,%rax
  sub    %rax,%r13
  call   <strlen@plt>
  mov    %r13,%rdx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  mov    %rax,%r14
  call   <strncpy@plt>
  cmp    %r14,%r13
  movb   $0x0,-0x1(%rbx,%r12,1)
  cmovbe %r13,%r14
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  mov    %r14,%rax
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int str_append_n(char *buf, const char *src, int buf_len) {
  size_t l1, l2;
  char *p = buf;
  p = buf + strlen(buf);
  if (p > buf)
    *p++ = ' ';
  l1 = buf_len - (p - buf);
  l2 = strlen(src);
  strncpy(p, src, l1);
  buf[buf_len - 1] = '\0';
  return (l2 < l1 ? l2 : l1);
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<str_append_n>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  push   %r13
  push   %r12
  movslq %edx,%r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  call   <strlen@plt>
  lea    (%rbx,%rax,1),%rbp
  cmp    %rbp,%rbx
  jae    L3
  movb   $0x20,0x0(%rbp)
  add    $0x1,%rbp
L3:
  mov    %rbp,%rax
  mov    %r15,%rdi
  mov    %r12,%r13
  sub    %rbx,%rax
  sub    %rax,%r13
  call   <strlen@plt>
  mov    %r13,%rdx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  mov    %rax,%r14
  call   <strncpy@plt>
  cmp    %r14,%r13
  movb   $0x0,-0x1(%rbx,%r12,1)
  cmovbe %r13,%r14
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  mov    %r14,%rax
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int str_append_n(char *buf, const char *src, int buf_len) {
  size_t l1, l2;
  char *p = buf;
  p = buf + strlen(buf);
  if (p > buf)
    *p++ = ' ';
  l1 = buf_len - (p - buf);
  l2 = strlen(src);
  strncpy(p, src, l1);
  buf[buf_len - 1] = '\0';
  return (l2 < l1 ? l2 : l1);
}
```