user: Translate the below assembly code into C programming language:

```asm
<copy_request_header_to_buffer>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x28(%rbp)
  mov    %rcx,-0x38(%rbp)
  movl   $0x0,-0x14(%rbp)
  cmpl   $0x8,-0x28(%rbp)
  jne    L77
  mov    $0x9,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  lea    D10(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  jmp    L50
L77:
  cmpl   $0x9,-0x28(%rbp)
  jne    L50
  mov    $0x6,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  lea    D1(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
L50:
  movl   $0x0,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0x38(%rbp),%rax
  movb   $0x0,(%rax)
  cmpl   $0x1,-0x24(%rbp)
  jne    L94
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  movb   $0x1,(%rax)
  jmp    L61
L94:
  cmpl   $0x2,-0x24(%rbp)
  jne    L61
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  movb   $0x2,(%rax)
L61:
  movl   $0x0,-0x10(%rbp)
  jmp    L62
L54:
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    -0x10(%rbp),%edx
  add    $0x2,%edx
  movslq %edx,%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x10(%rbp)
L62:
  mov    -0x10(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jl     L54
  mov    -0xc(%rbp),%eax
  add    $0x2,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  addl   $0x1,-0x14(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0xc(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L85
L87:
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x14(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x14(%rbp)
  addl   $0x1,-0x10(%rbp)
L85:
  mov    -0x10(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jl     L87
  mov    -0x14(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x14(%rbp)
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D10
type: string
name: disassemble_data
arguments: label: D1
type: string

tool: D10: netascii

tool: D1: octet

assistant: ```c
void *copy_request_header_to_buffer(int opcode, char *filename, int mode, char *buffer) {
  int cur_size = 0;
  char *mode_s;
  if (mode == 8) {
    mode_s = (char *)malloc(sizeof(char) * 9);
    strcpy(mode_s, "netascii");
  } else if (mode == 9) {
    mode_s = (char *)malloc(sizeof(char) * 6);
    strcpy(mode_s, "octet");
  }
  int i = 0, len = strlen(filename);
  buffer[0] = '\0';
  if (opcode == 1)
    buffer[1] = '\1';
  else if (opcode == 2)
    buffer[1] = '\2';
  for (i = 0; i < len; i++) {
    buffer[2 + i] = filename[i];
  }
  cur_size = len + 2;
  buffer[cur_size] = '\0';
  cur_size++;
  len = strlen(mode_s);
  for (i = 0; i < len; i++) {
    buffer[cur_size] = mode_s[i];
    cur_size++;
  }
  buffer[cur_size++] = '\0';
}
```