user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %rsi,-0x40(%rbp)
  cmpl   $0x2,-0x34(%rbp)
  jg     L31
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D15(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  nop
  jmp    L40
L31:
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  lea    D41(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L55
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D40(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  jmp    L40
L55:
  mov    -0x40(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  lea    D41(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L46
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x40(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D40(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  jmp    L40
L46:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <BE_Cross_FileLengthFromHandle@plt>
  mov    %eax,-0x28(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <BE_Cross_FileLengthFromHandle@plt>
  mov    %eax,-0x24(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x28(%rbp),%esi
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %rax,%rdi
  call   <fread@plt>
  mov    -0x18(%rbp),%rdx
  mov    -0x24(%rbp),%esi
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %rax,%rdi
  call   <fread@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  movl   $0x0,-0x30(%rbp)
  jmp    L4
L120:
  movl   $0x0,-0x2c(%rbp)
  jmp    L116
L72:
  mov    -0x30(%rbp),%edx
  mov    -0x2c(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L118
  addl   $0x1,-0x2c(%rbp)
L116:
  mov    -0x2c(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L72
  jmp    L12
L118:
  nop
L12:
  mov    -0x2c(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jne    L127
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  mov    -0x30(%rbp),%esi
  mov    -0x30(%rbp),%ecx
  mov    %esi,%r8d
  mov    %rax,%rsi
  lea    D42(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L78
L127:
  addl   $0x1,-0x30(%rbp)
L4:
  mov    -0x28(%rbp),%eax
  sub    -0x24(%rbp),%eax
  cmp    %eax,-0x30(%rbp)
  jle    L120
L78:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
L40:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D15
datatype: string
name: unpack_data
arguments: label: D41
datatype: string
name: unpack_data
arguments: label: D40
datatype: string
name: unpack_data
arguments: label: D42
datatype: string

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


tool: D41: rb

tool: D40: Cannot open %s for reading


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