user: 请将这段汇编代码片段转换成等效的C代码：

```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     L150
  mov    $0xffffffff,%eax
  jmp    L28
L150:
  cmpl   $0xff,-0x28(%rbp)
  jle    L93
  mov    $0xffffffff,%eax
  jmp    L28
L93:
  cmpl   $0x1,-0x2c(%rbp)
  je     L175
  cmpl   $0x2,-0x2c(%rbp)
  je     L175
  cmpl   $0x4,-0x2c(%rbp)
  je     L175
  cmpl   $0x8,-0x2c(%rbp)
  je     L175
  mov    $0xffffffff,%eax
  jmp    L28
L175:
  mov    -0x2c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jle    L88
  mov    $0xffffffff,%eax
  jmp    L28
L88:
  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     L92
  mov    -0xc(%rbp),%eax
  cltd
  idivl  -0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x10(%rbp)
L92:
  mov    -0x10(%rbp),%eax
  add    %eax,-0xc(%rbp)
  cmpl   $0x0,-0x1c(%rbp)
  je     L44
  mov    -0xc(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jle    L44
  mov    $0xffffffff,%eax
  jmp    L28
L44:
  cmpq   $0x0,-0x18(%rbp)
  je     L128
  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    L134
  mov    D19(%rip),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,(%rax)
  addq   $0x4,-0x8(%rbp)
  jmp    L125
L134:
  cmpl   $0x0,-0x10(%rbp)
  jle    L125
  mov    -0x8(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    D4(%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)
L125:
  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)
L128:
  mov    -0xc(%rbp),%eax
L28:
  leave
  ret
```

assistant: ```c
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);
}
```