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

```asm
<get_dist_conf_name>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x140,%rsp
  mov    %rdi,-0x128(%rbp)
  mov    %rsi,-0x130(%rbp)
  mov    %rdx,-0x138(%rbp)
  mov    %ecx,-0x13c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpq   $0x0,-0x128(%rbp)
  je     L47
  mov    -0x128(%rbp),%rdx
  lea    -0x110(%rbp),%rax
  mov    %rdx,%rcx
  lea    D81(%rip),%rdx
  mov    $0x100,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  lea    -0x110(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  lea    -0x110(%rbp),%rdx
  add    %rdx,%rax
  mov    %rax,-0x118(%rbp)
L0:
  lea    -0x110(%rbp),%rcx
  mov    -0x130(%rbp),%rdx
  mov    -0x13c(%rbp),%esi
  mov    -0x138(%rbp),%rax
  mov    %rcx,%r8
  mov    %rdx,%rcx
  lea    D38(%rip),%rdx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  mov    -0x138(%rbp),%rax
  mov    %rax,%rdi
  call   <stat_file@plt>
  test   %rax,%rax
  je     L55
  mov    $0x0,%eax
  jmp    L49
L41:
  subq   $0x1,-0x118(%rbp)
L55:
  lea    -0x110(%rbp),%rax
  cmp    %rax,-0x118(%rbp)
  jbe    L69
  mov    -0x118(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2d,%al
  jne    L41
L69:
  mov    -0x118(%rbp),%rax
  movb   $0x0,(%rax)
  lea    -0x110(%rbp),%rax
  cmp    %rax,-0x118(%rbp)
  ja     L0
  mov    -0x130(%rbp),%rdx
  mov    -0x13c(%rbp),%esi
  mov    -0x138(%rbp),%rax
  lea    D51(%rip),%r8
  mov    %rdx,%rcx
  lea    D50(%rip),%rdx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  mov    -0x128(%rbp),%rax
  mov    %rax,%rcx
  lea    D22(%rip),%rax
  mov    %rax,%rdx
  mov    $0x0,%esi
  mov    $0xffffffff,%edi
  call   <logger@plt>
  jmp    L75
L47:
  mov    -0x130(%rbp),%rdx
  mov    -0x13c(%rbp),%esi
  mov    -0x138(%rbp),%rax
  lea    D51(%rip),%r8
  mov    %rdx,%rcx
  lea    D50(%rip),%rdx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  mov    -0x138(%rbp),%rax
  mov    %rax,%rcx
  lea    D64(%rip),%rax
  mov    %rax,%rdx
  mov    $0x0,%esi
  mov    $0xffffffff,%edi
  call   <logger@plt>
L75:
  mov    -0x138(%rbp),%rax
  mov    %rax,%rdi
  call   <stat_file@plt>
  test   %rax,%rax
  jne    L72
  mov    -0x138(%rbp),%rax
  mov    %rax,%rcx
  lea    D13(%rip),%rax
  mov    %rax,%rdx
  mov    $0x0,%esi
  mov    $0xffffffff,%edi
  call   <logger@plt>
  mov    $0x6b,%eax
  jmp    L49
L72:
  mov    $0x0,%eax
L49:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L74
  call   <__stack_chk_fail@plt>
L74:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D81
type_infered: string
name: read_data
arguments: tag: D38
type_infered: string
name: read_data
arguments: tag: D51
type_infered: string
name: read_data
arguments: tag: D50
type_infered: string
name: read_data
arguments: tag: D22
type_infered: string
name: read_data
arguments: tag: D64
type_infered: string
name: read_data
arguments: tag: D13
type_infered: string

tool: D81: %s

tool: D38: %s/%s.conf

tool: D51: default

tool: D50: %s/%s

tool: D22: Warning: configuration file for distribution %s not found default used

tool: D64: Warning: distribution not specified default used %s

tool: D13: Distribution configuration not found %s

assistant: ```c
int get_dist_conf_name(char *dist_name, char *dir, char *file, int len) {
  char buf[256];
  char *ep;
  if (dist_name != NULL) {
    snprintf(buf, sizeof(buf), "%s", dist_name);
    ep = buf + strlen(buf);
    do {
      snprintf(file, len, "%s/%s.conf", dir, buf);
      if (stat_file(file))
        return 0;
      while (ep > buf && *ep != '-')
        --ep;
      *ep = 0;
    } while (ep > buf);
    snprintf(file, len, "%s/%s", dir, "default");
    logger(-1, 0,
           "Warning: configuration file"
           " for distribution %s not found default used",
           dist_name);
  } else {
    snprintf(file, len, "%s/%s", dir, "default");
    logger(-1, 0,
           "Warning: distribution not specified"
           " default used %s",
           file);
  }
  if (!stat_file(file)) {
    logger(-1, 0, "Distribution configuration not found %s", file);
    return 107;
  }
  return 0;
}
```