user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```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     L159
L75:
  mov    $0x1,%eax
L39:
  mov    0x588(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L24
  add    $0x590,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L159:
  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     L104
  lea    0x1(%rax),%r13
  mov    %r13,%rax
  sub    %r12,%rax
  add    %rax,%rbp
L104:
  lea    D0(%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    L75
  mov    %r12,%rdi
  mov    $0x2f,%esi
  call   <strrchr@plt>
  movsbl 0x1(%rax),%edi
  mov    %rax,%rbp
  lea    0x1(%rax),%r13
  test   %dil,%dil
  je     L71
  mov    %r13,%rbx
  jmp    L139
L32:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  je     L71
L139:
  call   <isupper@plt>
  test   %rax,%rax
  je     L32
  movsbl (%rbx),%edi
  add    $0x1,%rbx
  call   <tolower@plt>
  mov    %al,-0x1(%rbx)
  movsbl (%rbx),%edi
  test   %dil,%dil
  jne    L139
L71:
  mov    $0x2e,%esi
  mov    %r13,%rdi
  call   <strchr@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L55
L42:
  mov    %r14,%rbx
  sub    %r13,%rbx
  cmp    $0x8,%rbx
  jg     L28
  mov    %r14,%rdi
  call   <strlen@plt>
  cmp    $0x4,%eax
  jle    L57
  lea    0x8(%rsp),%r13
  mov    $0x7,%edx
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <strncpy@plt>
  movb   $0x0,0xc(%rsp)
  cmp    $0x6,%rbx
  jg     L135
L7:
  mov    $0x317e,%eax
  lea    0x2(%r14),%rdi
  mov    %r13,%rsi
  mov    %ax,(%r14)
  call   <strcpy@plt>
L57:
  xor    %esi,%esi
  mov    %r12,%rdi
  call   <IsResourceInFile@plt>
  jmp    L39
L28:
  lea    0x8(%rsp),%r13
  mov    $0x7,%edx
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <strncpy@plt>
  movb   $0x0,0xc(%rsp)
L135:
  lea    0x7(%rbp),%r14
  jmp    L7
L55:
  mov    %r13,%rdi
  call   <strlen@plt>
  movslq %eax,%r14
  add    %r13,%r14
  jmp    L42
L24:
  call   <__stack_chk_fail@plt>
```

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

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