user: Converte this assembly snippet into its equivalent C code:

```asm
<local_ns_initparse>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdx,%r12
  movslq %esi,%rsi
  lea    (%rdi,%rsi,1),%r13
  mov    %rdi,(%rdx)
  mov    %r13,0x8(%rdx)
  mov    D41(%rip),%rax
  movslq (%rax),%rax
  add    %rdi,%rax
  cmp    %rax,%r13
  jb     L128
  mov    %rdi,%rbp
  mov    0x10(%rdx),%rdi
  mov    %rbp,%rsi
  call   <NS_GET16@plt>
  mov    D41(%rip),%rax
  movslq (%rax),%rax
  add    %rbp,%rax
  cmp    %rax,%r13
  jb     L22
  mov    0x18(%r12),%rdi
  mov    %rbp,%rsi
  call   <NS_GET16@plt>
  mov    D78(%rip),%rax
  mov    (%rax),%esi
  test   %esi,%esi
  jle    L35
  mov    $0x0,%ebx
  mov    D41(%rip),%r14
L114:
  movslq (%r14),%rax
  add    %rbp,%rax
  cmp    %rax,%r13
  jb     L106
  mov    0x20(%r12),%rax
  mov    (%rax,%rbx,8),%rdi
  mov    %rbp,%rsi
  call   <NS_GET16@plt>
  mov    D78(%rip),%rax
  mov    (%rax),%esi
  add    $0x1,%rbx
  cmp    %ebx,%esi
  jg     L114
  test   %esi,%esi
  jle    L35
  mov    $0x0,%ebx
  jmp    L103
L128:
  mov    D124(%rip),%rax
  mov    (%rax),%edx
  mov    D26(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L39
L22:
  mov    D124(%rip),%rax
  mov    (%rax),%edx
  mov    D26(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L39
L106:
  mov    D124(%rip),%rax
  mov    (%rax),%edx
  mov    D26(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
L39:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L21:
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <local_ns_skiprr@plt>
  test   %eax,%eax
  js     L159
  mov    0x28(%r12),%rdx
  mov    %rbp,(%rdx,%r14,1)
  cltq
  add    %rax,%rbp
L163:
  mov    D78(%rip),%rax
  mov    (%rax),%esi
  add    $0x1,%rbx
  cmp    %ebx,%esi
  jle    L35
L103:
  mov    %ebx,%edx
  lea    0x0(,%rbx,8),%r14
  mov    0x20(%r12),%rax
  mov    (%rax,%rbx,8),%rcx
  test   %rcx,%rcx
  jne    L21
  mov    0x28(%r12),%rax
  movq   $0x0,(%rax,%rbx,8)
  jmp    L163
L35:
  cmp    %rbp,%r13
  jne    L164
  mov    %r12,%rdi
  call   <local_ns_setsection@plt>
  mov    $0x0,%eax
  jmp    L39
L164:
  mov    D124(%rip),%rax
  mov    (%rax),%edx
  mov    D26(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L39
L159:
  mov    $0xffffffff,%eax
  jmp    L39
```

assistant: ```c
int local_ns_initparse(const unsigned char *msg, int msglen, ns_msg *handle) {
  const unsigned char *eom = msg + msglen;
  int i;
  handle->_msg = msg;
  handle->_eom = eom;
  if (msg + NS_INT16SZ > eom) {
    errno = EMSGSIZE;
    return -1;
  }
  NS_GET16(handle->_id, msg);
  if (msg + NS_INT16SZ > eom) {
    errno = EMSGSIZE;
    return -1;
  }
  NS_GET16(handle->_flags, msg);
  for (i = 0; i < ns_s_max; i++) {
    if (msg + NS_INT16SZ > eom) {
      errno = EMSGSIZE;
      return -1;
    }
    NS_GET16(handle->_counts[i], msg);
  }
  for (i = 0; i < ns_s_max; i++)
    if (handle->_counts[i] == 0)
      handle->_sections[i] = NULL;
    else {
      int b = local_ns_skiprr(msg, eom, (ns_sect)i, handle->_counts[i]);
      if (b < 0)
        return -1;
      handle->_sections[i] = msg;
      msg += b;
    }
  if (msg != eom) {
    errno = EMSGSIZE;
    return -1;
  }
  local_ns_setsection(handle, ns_s_max);
  return 0;
}
```