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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rsi,%r13
  cmp    $0x2,%edi
  jle    L45
  mov    0x8(%rsi),%rdi
  lea    D30(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L110
  mov    0x10(%r13),%rdi
  lea    D30(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L15
  mov    %r14,%rdi
  call   <BE_Cross_FileLengthFromHandle@plt>
  mov    %eax,%ebp
  mov    %r15,%rdi
  call   <BE_Cross_FileLengthFromHandle@plt>
  mov    %eax,%ebx
  mov    %ebp,%edi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  mov    %ebx,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  mov    %r14,%rcx
  mov    $0x1,%edx
  mov    %ebp,%esi
  mov    0x8(%rsp),%rdi
  call   <fread@plt>
  mov    %r15,%rcx
  mov    $0x1,%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <fread@plt>
  mov    %r14,%rdi
  call   <fclose@plt>
  mov    %r15,%rdi
  call   <fclose@plt>
  sub    %ebx,%ebp
  js     L44
  mov    %r12,%rsi
  sub    0x8(%rsp),%rsi
  mov    $0x0,%ecx
  jmp    L119
L45:
  mov    (%rsi),%rsi
  lea    D29(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L78
L110:
  mov    0x8(%r13),%rsi
  lea    D59(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L41
L15:
  mov    $0x0,%edi
  call   <fclose@plt>
  mov    0x10(%r13),%rsi
  lea    D59(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L41
L42:
  cmp    %edx,%ebx
  je     L2
  add    $0x1,%ecx
  sub    $0x1,%rsi
  cmp    %ebp,%ecx
  jg     L44
L119:
  mov    %r12,%rax
  sub    %rsi,%rax
  mov    $0x0,%edx
  test   %ebx,%ebx
  jle    L42
L66:
  movzbl (%rax,%rsi,1),%edi
  cmp    %dil,(%rax)
  jne    L42
  add    $0x1,%edx
  add    $0x1,%rax
  cmp    %edx,%ebx
  jne    L66
L2:
  mov    0x8(%r13),%rdx
  mov    0x10(%r13),%rsi
  mov    %ecx,%r8d
  lea    D31(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L44:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    %r12,%rdi
  call   <free@plt>
L41:
  mov    $0x0,%eax
L78:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D30
type: string
name: retrieve_data
arguments: tag: D29
type: string
name: retrieve_data
arguments: tag: D59
type: string
name: retrieve_data
arguments: tag: D31
type: string

tool: D30: rb

tool: D29: Use command like this: %s <src1> <src2>


tool: D59: Cannot open %s for reading


tool: D31: Match found! %s is in %s at offset %d (0x%x).


assistant: ```c
int main(int argc, char **argv) {
  if (argc < 3) {
    printf("Use command like this: %s <src1> <src2>\n", argv[0]);
    return;
  }
  FILE *fp1 = fopen(argv[1], "rb");
  if (!fp1) {
    printf("Cannot open %s for reading\n", argv[1]);
    return 0;
  }
  FILE *fp2 = fopen(argv[2], "rb");
  if (!fp2) {
    fclose(fp2);
    printf("Cannot open %s for reading\n", argv[2]);
    return 0;
  }
  int32_t fsize1 = BE_Cross_FileLengthFromHandle(fp1), fsize2 = BE_Cross_FileLengthFromHandle(fp2);
  unsigned char *buf1 = (unsigned char *)malloc(fsize1), *buf2 = (unsigned char *)malloc(fsize2);
  fread(buf1, fsize1, 1, fp1);
  fread(buf2, fsize2, 1, fp2);
  fclose(fp1);
  fclose(fp2);
  int buf1loopvar, buf2loopvar;
  for (buf1loopvar = 0; buf1loopvar <= fsize1 - fsize2; ++buf1loopvar) {
    for (buf2loopvar = 0; buf2loopvar < fsize2; ++buf2loopvar) {
      if (buf1[buf1loopvar + buf2loopvar] != buf2[buf2loopvar])
        break;
    }
    if (buf2loopvar == fsize2) {
      printf("Match found! %s is in %s at offset %d (0x%x).\n", argv[2], argv[1], buf1loopvar, buf1loopvar);
      break;
    }
  }
  free(buf1);
  free(buf2);
  return 0;
}
```