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

```asm
<locale_charset>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  movq   $0x0,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L121
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L0
L121:
  lea    D42(%rip),%rax
  mov    %rax,%rdi
  call   <getenv@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L52
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L0
L52:
  lea    D46(%rip),%rax
  mov    %rax,%rdi
  call   <getenv@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L32
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L0
L32:
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  call   <getenv@plt>
  mov    %rax,-0x8(%rbp)
L0:
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L132
  lea    D47(%rip),%rax
  mov    %rax,-0x18(%rbp)
L132:
  mov    $0x0,%eax
  call   <get_charset_aliases@plt>
  mov    %rax,-0x10(%rbp)
  jmp    L119
L22:
  mov    -0x10(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L101
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2a,%al
  jne    L134
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L134
L101:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  jmp    L90
L134:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    $0x1,%eax
  cltq
  add    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    $0x1,%eax
  cltq
  add    %rax,-0x10(%rbp)
L119:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L22
L90:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L18
  lea    D38(%rip),%rax
  mov    %rax,-0x18(%rbp)
L18:
  mov    -0x18(%rbp),%rax
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D42
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D46
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D32
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D47
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D38
type_infered: string

tool: D42: LC_ALL

tool: D46: LC_CTYPE

tool: D32: LANG

tool: 

tool: D38: ASCII

assistant: ```c
const char *locale_charset() {
  const char *codeset;
  const char *aliases;
  const char *locale = NULL;
  if (locale == NULL || locale[0] == '\0') {
    locale = getenv("LC_ALL");
    if (locale == NULL || locale[0] == '\0') {
      locale = getenv("LC_CTYPE");
      if (locale == NULL || locale[0] == '\0')
        locale = getenv("LANG");
    }
  }
  codeset = locale;
  if (codeset == NULL)
    codeset = "";
  for (aliases = get_charset_aliases(); *aliases != '\0'; aliases += strlen(aliases) + 1, aliases += strlen(aliases) + 1)
    if (strcmp(codeset, aliases) == 0 || (aliases[0] == '*' && aliases[1] == '\0')) {
      codeset = aliases + strlen(aliases) + 1;
      break;
    }
  if (codeset[0] == '\0')
    codeset = "ASCII";
  return codeset;
}
```