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

```asm
<FindResourceFile>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x5b0,%rsp
  mov    %rdi,-0x5a8(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x5a8(%rbp),%rax
  mov    %rax,%rdi
  call   <IsResourceInFile@plt>
  test   %eax,%eax
  je     L86
  mov    $0x1,%eax
  jmp    L111
L86:
  mov    -0x5a8(%rbp),%rdx
  lea    -0x580(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    -0x580(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0x5a0(%rbp)
  cmpq   $0x0,-0x5a0(%rbp)
  jne    L38
  lea    -0x580(%rbp),%rax
  mov    %rax,-0x5a0(%rbp)
  mov    -0x5a8(%rbp),%rax
  mov    %rax,-0x598(%rbp)
  jmp    L73
L38:
  addq   $0x1,-0x5a0(%rbp)
  lea    -0x580(%rbp),%rdx
  mov    -0x5a0(%rbp),%rax
  sub    %rdx,%rax
  mov    %rax,%rdx
  mov    -0x5a8(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x598(%rbp)
L73:
  mov    -0x5a0(%rbp),%rax
  lea    D6(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x598(%rbp),%rdx
  mov    -0x5a0(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  lea    -0x580(%rbp),%rax
  mov    %rax,%rdi
  call   <IsResourceInFile@plt>
  test   %eax,%eax
  je     L11
  mov    $0x1,%eax
  jmp    L111
L11:
  lea    -0x580(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  add    $0x1,%rax
  mov    %rax,-0x5a0(%rbp)
  mov    -0x5a0(%rbp),%rax
  mov    %rax,-0x598(%rbp)
  jmp    L139
L129:
  mov    -0x598(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L60
  mov    -0x598(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    -0x598(%rbp),%rdx
  mov    %al,(%rdx)
L60:
  addq   $0x1,-0x598(%rbp)
L139:
  mov    -0x598(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L129
  mov    -0x5a0(%rbp),%rax
  mov    $0x2e,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x590(%rbp)
  cmpq   $0x0,-0x590(%rbp)
  jne    L64
  mov    -0x5a0(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  movslq %eax,%rdx
  mov    -0x5a0(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x590(%rbp)
L64:
  mov    -0x590(%rbp),%rax
  sub    -0x5a0(%rbp),%rax
  cmp    $0x8,%rax
  jg     L90
  mov    -0x590(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    $0x4,%eax
  jle    L88
L90:
  mov    -0x590(%rbp),%rcx
  lea    -0x588(%rbp),%rax
  mov    $0x7,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  movb   $0x0,-0x584(%rbp)
  mov    -0x590(%rbp),%rax
  sub    -0x5a0(%rbp),%rax
  cmp    $0x6,%rax
  jle    L95
  mov    -0x5a0(%rbp),%rax
  add    $0x6,%rax
  mov    %rax,-0x590(%rbp)
L95:
  mov    -0x590(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x590(%rbp)
  movb   $0x7e,(%rax)
  mov    -0x590(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x590(%rbp)
  movb   $0x31,(%rax)
  lea    -0x588(%rbp),%rdx
  mov    -0x590(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
L88:
  lea    -0x580(%rbp),%rax
  mov    %rax,%rdi
  call   <IsResourceInFile@plt>
L111:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L99
  call   <__stack_chk_fail@plt>
L99:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D6
data_type: string

tool: D6: resource.frk/

assistant: ```c
int FindResourceFile(char *filename) {
  char *spt, *pt, *dpt;
  char buffer[1400];
  if (IsResourceInFile(filename))
    return (1);
  strcpy(buffer, filename);
  spt = strrchr(buffer, '/');
  if (spt == NULL) {
    spt = buffer;
    pt = filename;
  } else {
    ++spt;
    pt = filename + (spt - buffer);
  }
  strcpy(spt, "resource.frk/");
  strcat(spt, pt);
  if (IsResourceInFile(buffer))
    return (1);
  spt = strrchr(buffer, '/') + 1;
  for (pt = spt; *pt; ++pt)
    if (isupper(*pt))
      *pt = tolower(*pt);
  dpt = strchr(spt, '.');
  if (dpt == NULL)
    dpt = spt + strlen(spt);
  if (dpt - spt > 8 || strlen(dpt) > 4) {
    char exten[8];
    strncpy(exten, dpt, 7);
    exten[4] = '\0';
    if (dpt - spt > 6)
      dpt = spt + 6;
    *dpt++ = '~';
    *dpt++ = '1';
    strcpy(dpt, exten);
  }
  return (IsResourceInFile(buffer));
}
```