user: Translate the below assembly code into C programming language:

```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    $0x0,%esi
  mov    %rax,%rdi
  call   <IsResourceInFile@plt>
  test   %eax,%eax
  je     L73
  mov    $0x1,%eax
  jmp    L101
L73:
  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    L6
  lea    -0x580(%rbp),%rax
  mov    %rax,-0x5a0(%rbp)
  mov    -0x5a8(%rbp),%rax
  mov    %rax,-0x598(%rbp)
  jmp    L100
L6:
  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)
L100:
  mov    -0x5a0(%rbp),%rax
  lea    D2(%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    $0x0,%esi
  mov    %rax,%rdi
  call   <IsResourceInFile@plt>
  test   %eax,%eax
  je     L24
  mov    $0x1,%eax
  jmp    L101
L24:
  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    L111
L103:
  mov    -0x598(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L87
  mov    -0x598(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    -0x598(%rbp),%rdx
  mov    %al,(%rdx)
L87:
  addq   $0x1,-0x598(%rbp)
L111:
  mov    -0x598(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L103
  mov    -0x5a0(%rbp),%rax
  mov    $0x2e,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x590(%rbp)
  cmpq   $0x0,-0x590(%rbp)
  jne    L129
  mov    -0x5a0(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  movslq %eax,%rdx
  mov    -0x5a0(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x590(%rbp)
L129:
  mov    -0x590(%rbp),%rax
  sub    -0x5a0(%rbp),%rax
  cmp    $0x8,%rax
  jg     L29
  mov    -0x590(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    $0x4,%eax
  jle    L35
L29:
  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    L83
  mov    -0x5a0(%rbp),%rax
  add    $0x6,%rax
  mov    %rax,-0x590(%rbp)
L83:
  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>
L35:
  lea    -0x580(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <IsResourceInFile@plt>
L101:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L115
  call   <__stack_chk_fail@plt>
L115:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D2
type: string

tool: D2: resource.frk/

assistant: ```c
int FindResourceFile(char *filename) {
  char *spt, *pt, *dpt;
  char buffer[1400];
  if (IsResourceInFile(filename, NULL))
    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, NULL))
    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, NULL));
}
```