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

```asm
<make_hack_name>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  mov    %rsi,%rdi
  push   %rbx
  sub    $0x118,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  call   <strdup@plt>
  movsbl (%rax),%edi
  mov    %rax,%r12
  test   %dil,%dil
  je     L102
  mov    %rax,%rbx
  jmp    L50
  nop
L81:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  je     L102
L50:
  call   <isspace@plt>
  test   %rax,%rax
  je     L81
  movb   $0x0,(%rbx)
L102:
  mov    $0x2f,%esi
  mov    %r12,%rdi
  call   <strrchr@plt>
  test   %rax,%rax
  je     L14
  lea    0x1(%rax),%rdi
  call   <strdup@plt>
  mov    %r12,%rdi
  mov    %rax,%rbx
  call   <free@plt>
  mov    %rbx,%r12
L14:
  mov    %r12,%rdi
  call   <strlen@plt>
  cmp    $0x32,%eax
  jle    L179
  movb   $0x0,0x32(%r12)
L179:
  mov    %rsp,%r13
  mov    %r12,%rdx
  lea    D0(%rip),%rsi
  mov    %r13,%rdi
  call   <sprintf@plt>
  mov    %r13,%rdx
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <get_string_resource@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  jne    L49
  movzbl (%r12),%ecx
  mov    %r12,%rdx
  mov    %ecx,%eax
  test   %cl,%cl
  jne    L117
  jmp    L97
  nopl   0x0(%rax)
L203:
  movzbl 0x1(%rdx),%eax
  add    $0x1,%rdx
  test   %al,%al
  je     L151
L117:
  sub    $0x41,%eax
  cmp    $0x19,%al
  ja     L203
L97:
  mov    0x108(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L140
  add    $0x118,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
L49:
  mov    %r12,%rdi
  mov    %rbx,%r12
  call   <free@plt>
  jmp    L97
  nopl   (%rax)
L151:
  lea    -0x61(%rcx),%eax
  cmp    $0x19,%al
  ja     L3
  sub    $0x20,%ecx
  mov    %cl,(%r12)
L3:
  cmp    $0x58,%cl
  je     L188
  cmp    $0x47,%cl
  jne    L97
  cmpb   $0x6c,0x1(%r12)
  jne    L97
  movzbl 0x2(%r12),%eax
  lea    -0x61(%rax),%edx
  cmp    $0x19,%dl
  ja     L97
  sub    $0x20,%eax
  movb   $0x4c,0x1(%r12)
  mov    %al,0x2(%r12)
  jmp    L97
  cs nopw 0x0(%rax,%rax,1)
L188:
  movzbl 0x1(%r12),%eax
  lea    -0x61(%rax),%edx
  cmp    $0x19,%dl
  ja     L97
  sub    $0x20,%eax
  mov    %al,0x1(%r12)
  jmp    L97
L140:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D0
type: string

tool: D0: hacks.%s.name

assistant: ```c
char *make_hack_name(Display *dpy, const char *shell_command) {
  char *s = strdup(shell_command);
  char *s2;
  char res_name[255];
  for (s2 = s; *s2; s2++)
    if (isspace(*s2)) {
      *s2 = 0;
      break;
    }
  s2 = strrchr(s, '/');
  if (s2) {
    s2 = strdup(s2 + 1);
    free(s);
    s = s2;
  }
  if (strlen(s) > 50)
    s[50] = 0;
  sprintf(res_name, "hacks.%s.name", s);
  s2 = get_string_resource(dpy, res_name, res_name);
  if (s2) {
    free(s);
    return s2;
  }
  for (s2 = s; *s2; s2++)
    if (*s2 >= 'A' && *s2 <= 'Z')
      return s;
  if (s[0] >= 'a' && s[0] <= 'z')
    s[0] -= 'a' - 'A';
  if (s[0] == 'X' && s[1] >= 'a' && s[1] <= 'z')
    s[1] -= 'a' - 'A';
  if (s[0] == 'G' && s[1] == 'l' && s[2] >= 'a' && s[2] <= 'z')
    s[1] -= 'a' - 'A', s[2] -= 'a' - 'A';
  return s;
}
```