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

```asm
<fdt_get_path>:
  endbr64
  push   %r15
  mov    %ecx,%r15d
  push   %r14
  mov    %rdx,%r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x28,%rsp
  mov    %ecx,0x4(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <fdt_check_header@plt>
  mov    %eax,(%rsp)
  test   %eax,%eax
  jne    L160
  cmp    $0x1,%r15d
  jle    L206
  movl   $0x0,0x10(%rsp)
  test   %ebx,%ebx
  js     L145
  lea    0x14(%rsp),%rax
  xor    %r13d,%r13d
  xor    %edx,%edx
  xor    %r15d,%r15d
  mov    %rax,0x8(%rsp)
  xor    %r12d,%r12d
L14:
  cmp    %r12d,%edx
  jle    L202
  nopl   (%rax)
L180:
  cmp    %ebx,%r13d
  je     L108
L199:
  mov    %r13d,%esi
  lea    0x10(%rsp),%rdx
  mov    %rbp,%rdi
  call   <fdt_next_node@plt>
  mov    %eax,%r13d
  test   %eax,%eax
  js     L135
  cmp    %eax,%ebx
  jl     L135
  mov    0x10(%rsp),%edx
  cmp    %edx,%r12d
  jle    L14
  nopl   (%rax)
L105:
  lea    -0x1(%r15),%eax
  cltq
  cs nopw 0x0(%rax,%rax,1)
L21:
  mov    %eax,%r15d
  sub    $0x1,%rax
  cmpb   $0x2f,(%r14,%rax,1)
  jne    L21
  sub    $0x1,%r12d
  cmp    %edx,%r12d
  jne    L105
  cmp    %r12d,%edx
  jg     L180
L202:
  mov    0x8(%rsp),%rdx
  mov    %r13d,%esi
  mov    %rbp,%rdi
  call   <fdt_get_name@plt>
  mov    %rax,%rsi
  test   %rax,%rax
  je     L89
  mov    0x14(%rsp),%edx
  lea    (%rdx,%r15,1),%eax
  cmp    0x4(%rsp),%eax
  jge    L180
  movslq %r15d,%rdi
  add    $0x1,%r12d
  add    %r14,%rdi
  call   <memcpy@plt>
  mov    0x14(%rsp),%eax
  add    %r15d,%eax
  lea    0x1(%rax),%r15d
  cltq
  movb   $0x2f,(%r14,%rax,1)
  cmp    %ebx,%r13d
  jne    L199
L108:
  cmp    %r12d,0x10(%rsp)
  jge    L206
  xor    %eax,%eax
  cmp    $0x1,%r15d
  setg   %al
  sub    %eax,%r15d
  movslq %r15d,%r15
  movb   $0x0,(%r14,%r15,1)
L160:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L177
  mov    (%rsp),%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L135:
  cmp    $0xffffffff,%r13d
  jge    L145
  cmp    $0xfffffffc,%r13d
  mov    $0xfffffff5,%r12d
  cmovne %r13d,%r12d
  mov    %r12d,(%rsp)
  jmp    L160
L89:
  mov    0x14(%rsp),%eax
  mov    %eax,(%rsp)
  jmp    L160
L177:
  call   <__stack_chk_fail@plt>
  nopl   0x0(%rax)
L145:
  movl   $0xfffffffc,(%rsp)
  jmp    L160
L206:
  movl   $0xfffffffd,(%rsp)
  jmp    L160
```

assistant: ```c
int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) {
  int pdepth = 0, p = 0;
  int offset, depth, namelen;
  const char *name;
  {
    int err_;
    if ((err_ = fdt_check_header(fdt)) != 0)
      return err_;
  };
  if (buflen < 2)
    return -3;
  for (offset = 0, depth = 0; (offset >= 0) && (offset <= nodeoffset); offset = fdt_next_node(fdt, offset, &depth)) {
    while (pdepth > depth) {
      do {
        p--;
      } while (buf[p - 1] != '/');
      pdepth--;
    }
    if (pdepth >= depth) {
      name = fdt_get_name(fdt, offset, &namelen);
      if (!name)
        return namelen;
      if ((p + namelen + 1) <= buflen) {
        memcpy(buf + p, name, namelen);
        p += namelen;
        buf[p++] = '/';
        pdepth++;
      }
    }
    if (offset == nodeoffset) {
      if (pdepth < (depth + 1))
        return -3;
      if (p > 1)
        p--;
      buf[p] = '\0';
      return 0;
    }
  }
  if ((offset == -1) || (offset >= 0))
    return -4;
  else if (offset == -4)
    return -11;
  return offset;
}
```