user: Please show me the C implementation that matches the assembly code listed below:

```asm
<get_basename>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r12
  push   %rbx
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%r12
  mov    D37(%rip),%rax
  mov    (%rax),%ebx
  movslq %ebx,%rax
  sub    $0x1,%rax
  mov    %rax,-0x28(%rbp)
  movslq %ebx,%rax
  mov    %rax,%r10
  mov    $0x0,%r11d
  movslq %ebx,%rax
  mov    %rax,%r8
  mov    $0x0,%r9d
  movslq %ebx,%rax
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L66:
  cmp    %rdx,%rsp
  je     L104
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L66
L104:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L127
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L127:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x48(%rbp)
  jne    L41
  mov    D14(%rip),%rax
  mov    (%rax),%eax
  jmp    L7
L41:
  cmpq   $0x0,-0x38(%rbp)
  je     L100
  cmpq   $0x0,-0x40(%rbp)
  jne    L116
L100:
  mov    D11(%rip),%rax
  mov    (%rax),%eax
  jmp    L7
L116:
  movslq %ebx,%rdx
  mov    -0x48(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  movslq %ebx,%rax
  lea    -0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  movzbl (%rax,%rdx,1),%eax
  test   %al,%al
  je     L72
  mov    D11(%rip),%rax
  mov    (%rax),%eax
  jmp    L7
L72:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <basename@plt>
  mov    %rax,%rcx
  mov    -0x40(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x40(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L89
  mov    D11(%rip),%rax
  mov    (%rax),%eax
  jmp    L7
L89:
  mov    -0x40(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <dot_to_absolute@plt>
  mov    %eax,-0x2c(%rbp)
  cmpl   $0x0,-0x2c(%rbp)
  je     L8
  mov    -0x2c(%rbp),%eax
  jmp    L7
L8:
  mov    $0x0,%eax
L7:
  mov    %r12,%rsp
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L112
  call   <__stack_chk_fail@plt>
L112:
  lea    -0x10(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %rbp
  ret
```

assistant: ```c
int get_basename(char *base_name, size_t base_name_size, const char *path) {
  char tmp_path[PATH_MAX];
  int ret;
  if (!path)
    return EINVAL;
  if (!base_name || base_name_size < 1)
    return ENOBUFS;
  strncpy(tmp_path, path, sizeof(tmp_path));
  if (tmp_path[sizeof(tmp_path) - 1] != '\0')
    return ENOBUFS;
  strncpy(base_name, basename(tmp_path), base_name_size);
  if (base_name[base_name_size - 1] != '\0')
    return ENOBUFS;
  ret = dot_to_absolute(base_name, base_name_size);
  if (ret != 0) {
    return ret;
  }
  return 0;
}
```