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

```asm
<payload_insert_host>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  movl   $0x0,-0xc(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x8(%rbp)
  movl   $0x0,-0x4(%rbp)
  nop
L39:
  mov    -0xc(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jae    L56
  addl   $0x1,-0xc(%rbp)
  mov    -0xc(%rbp),%edx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x1,%al
  jne    L39
L56:
  cmpl   $0x7,-0xc(%rbp)
  je     L42
  mov    $0xffffffff,%eax
  jmp    L76
L42:
  mov    -0x24(%rbp),%edx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  call   <payload_get_offset_by_name@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0xffffffff,-0x4(%rbp)
  jne    L69
  mov    $0x1,%eax
  jmp    L76
L69:
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x4(%rbp),%edx
  add    %edx,%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%rax
  mov    $0x6,%edx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memmove@plt>
  mov    -0x24(%rbp),%edx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  call   <payload_get_offset_by_name@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0xffffffff,-0x4(%rbp)
  jne    L47
  mov    $0x1,%eax
  jmp    L76
L47:
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x4(%rbp),%edx
  add    %edx,%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%rax
  mov    $0x6,%edx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memmove@plt>
  mov    -0x24(%rbp),%edx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  lea    D48(%rip),%rax
  mov    %rax,%rdi
  call   <payload_get_offset_by_name@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0xffffffff,-0x4(%rbp)
  je     L17
  mov    -0x4(%rbp),%edx
  mov    -0x8(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x24(%rbp)
  ja     L23
L17:
  mov    $0x1,%eax
  jmp    L76
L23:
  lea    D48(%rip),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x4(%rbp),%edx
  add    %edx,%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memmove@plt>
  mov    $0x0,%eax
L76:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D32
type_guessed: string
name: unpack_data
arguments: data_tag: D5
type_guessed: string
name: unpack_data
arguments: data_tag: D48
type_guessed: string

tool: D32: UName

tool: D5: PWD

tool: D48: Domain0

assistant: ```c
int payload_insert_host(const char *host, const char *buf, const unsigned int n_buf) {
  unsigned int i = 0;
  unsigned int n_host = strlen(host);
  int offset = 0;
  while (i < n_host && (buf[++i] != 0x1)) {
  }
  if (i != (6 + 1))
    return -1;
  if ((offset = payload_get_offset_by_name("UName", buf, n_buf)) == -1)
    return 1;
  memmove((void *)&buf[offset + strlen("UName") + 1], (const void *)host, 6);
  if ((offset = payload_get_offset_by_name("PWD", buf, n_buf)) == -1)
    return 1;
  memmove((void *)&buf[offset + strlen("PWD") + 1], (const void *)host, 6);
  if ((offset = payload_get_offset_by_name("Domain0", buf, n_buf)) == -1 || (offset + n_host) >= n_buf)
    return 1;
  memmove((void *)&buf[offset + strlen("Domain0") + 1], (const void *)host, n_host);
  return 0;
}
```