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

```asm
<FindResourceFile>:
  endbr64
  push   %r14
  xor    %esi,%esi
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x590,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x588(%rsp)
  xor    %eax,%eax
  call   <IsResourceInFile@plt>
  test   %eax,%eax
  je     L149
L82:
  mov    $0x1,%eax
L151:
  mov    0x588(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L61
  add    $0x590,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L149:
  lea    0x10(%rsp),%r12
  mov    %rbp,%rsi
  mov    %r12,%rdi
  mov    %r12,%r13
  call   <strcpy@plt>
  mov    $0x2f,%esi
  mov    %r12,%rdi
  call   <strrchr@plt>
  test   %rax,%rax
  je     L113
  lea    0x1(%rax),%r13
  mov    %r13,%rax
  sub    %r12,%rax
  add    %rax,%rbp
L113:
  lea    D1(%rip),%rsi
  mov    %r13,%rdi
  call   <strcpy@plt>
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <strcat@plt>
  xor    %esi,%esi
  mov    %r12,%rdi
  call   <IsResourceInFile@plt>
  test   %eax,%eax
  jne    L82
  mov    %r12,%rdi
  mov    $0x2f,%esi
  call   <strrchr@plt>
  movsbl 0x1(%rax),%edi
  mov    %rax,%rbp
  lea    0x1(%rax),%r13
  test   %dil,%dil
  je     L77
  mov    %r13,%rbx
  xchg   %ax,%ax
L35:
  call   <isupper@plt>
  test   %rax,%rax
  jne    L86
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  jne    L35
L77:
  mov    $0x2e,%esi
  mov    %r13,%rdi
  call   <strchr@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L3
L64:
  mov    %r14,%rbx
  sub    %r13,%rbx
  cmp    $0x8,%rbx
  jg     L20
  mov    %r14,%rdi
  call   <strlen@plt>
  cmp    $0x4,%eax
  jle    L146
  lea    0x8(%rsp),%r13
  mov    $0x7,%edx
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <strncpy@plt>
  movb   $0x0,0xc(%rsp)
  cmp    $0x6,%rbx
  jg     L147
L44:
  mov    $0x317e,%eax
  lea    0x2(%r14),%rdi
  mov    %r13,%rsi
  mov    %ax,(%r14)
  call   <strcpy@plt>
L146:
  xor    %esi,%esi
  mov    %r12,%rdi
  call   <IsResourceInFile@plt>
  jmp    L151
  nopl   (%rax)
L86:
  movsbl (%rbx),%edi
  add    $0x1,%rbx
  call   <tolower@plt>
  mov    %al,-0x1(%rbx)
  movsbl (%rbx),%edi
  test   %dil,%dil
  jne    L35
  jmp    L77
  nopl   0x0(%rax,%rax,1)
L20:
  lea    0x8(%rsp),%r13
  mov    $0x7,%edx
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <strncpy@plt>
  movb   $0x0,0xc(%rsp)
L147:
  lea    0x7(%rbp),%r14
  jmp    L44
L3:
  mov    %r13,%rdi
  call   <strlen@plt>
  movslq %eax,%r14
  add    %r13,%r14
  jmp    L64
L61:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D1
type_infered: string

tool: D1: 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));
}
```