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

```asm
<inet6_opt_append>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    %ecx,-0x24(%rbp)
  mov    %r8d,-0x28(%rbp)
  mov    %r9d,-0x2c(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  movl   $0x0,-0x10(%rbp)
  cmpl   $0x1,-0x24(%rbp)
  jg     L127
  mov    $0xffffffff,%eax
  jmp    L121
L127:
  cmpl   $0xff,-0x28(%rbp)
  jle    L163
  mov    $0xffffffff,%eax
  jmp    L121
L163:
  cmpl   $0x1,-0x2c(%rbp)
  je     L158
  cmpl   $0x2,-0x2c(%rbp)
  je     L158
  cmpl   $0x4,-0x2c(%rbp)
  je     L158
  cmpl   $0x8,-0x2c(%rbp)
  je     L158
  mov    $0xffffffff,%eax
  jmp    L121
L158:
  mov    -0x2c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jle    L118
  mov    $0xffffffff,%eax
  jmp    L121
L118:
  mov    -0x28(%rbp),%eax
  add    $0x2,%eax
  add    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  cltd
  idivl  -0x2c(%rbp)
  mov    %edx,%eax
  test   %eax,%eax
  je     L182
  mov    -0xc(%rbp),%eax
  cltd
  idivl  -0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x10(%rbp)
L182:
  mov    -0x10(%rbp),%eax
  add    %eax,-0xc(%rbp)
  cmpl   $0x0,-0x1c(%rbp)
  je     L15
  mov    -0xc(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jle    L15
  mov    $0xffffffff,%eax
  jmp    L121
L15:
  cmpq   $0x0,-0x18(%rbp)
  je     L90
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  cmpl   $0x1,-0x10(%rbp)
  jne    L87
  mov    D4(%rip),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,(%rax)
  addq   $0x4,-0x8(%rbp)
  jmp    L56
L87:
  cmpl   $0x0,-0x10(%rbp)
  jle    L56
  mov    -0x8(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    D18(%rip),%rdx
  mov    (%rdx),%edx
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x10(%rbp),%edx
  sub    $0x2,%edx
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%eax
  lea    -0x2(%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  sub    $0x8,%rax
  add    %rax,-0x8(%rbp)
L56:
  mov    -0x8(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x24(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x28(%rbp),%edx
  mov    %edx,(%rax)
  mov    0x10(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
L90:
  mov    -0xc(%rbp),%eax
L121:
  leave
  ret
```

assistant: ```c
__attribute__((visibility("default"))) int inet6_opt_append(void *extbuf, socklen_t extlen, int offset, u_int8_t type, socklen_t len, u_int8_t align, void **databufp) {
  int currentlen = offset, padlen = 0;
  if (type < 2)
    return (-1);
  if (len > 255) {
    return (-1);
  }
  if (align != 1 && align != 2 && align != 4 && align != 8)
    return (-1);
  if (align > len)
    return (-1);
  currentlen += 2 + len;
  if (currentlen % align)
    padlen = align - (currentlen % align);
  currentlen += padlen;
  if (extlen && currentlen > extlen)
    return (-1);
  if (extbuf) {
    u_int8_t *optp = (u_int8_t *)extbuf + offset;
    if (padlen == 1) {
      *optp = IP6OPT_PAD1;
      optp++;
    } else if (padlen > 0) {
      *optp++ = IP6OPT_PADN;
      *optp++ = padlen - 2;
      memset(optp, 0, padlen - 2);
      optp += (padlen - 2);
    }
    *optp++ = type;
    *optp++ = len;
    *databufp = optp;
  }
  return (currentlen);
}
```