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    $0x8,%rsp
  cmp    $0x4,%edi
  jle    L124
  mov    %edi,%r14d
  mov    0x8(%rsi),%rdi
  mov    %rsi,%rbx
  lea    D90(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L71
  mov    0x10(%rbx),%rdi
  lea    D173(%rip),%r12
  mov    %r12,%rsi
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L65
  mov    0x18(%rbx),%rdi
  mov    %r12,%rsi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L4
  lea    D68(%rip),%r15
  mov    %rax,%rcx
  mov    $0x30,%edx
  mov    $0x1,%esi
  mov    %r15,%rdi
  call   <fwrite@plt>
  mov    %r12,%rcx
  mov    $0x27,%edx
  mov    $0x1,%esi
  lea    D41(%rip),%rdi
  call   <fwrite@plt>
  mov    0x20(%rbx),%rdx
  mov    %r12,%rdi
  xor    %eax,%eax
  lea    D48(%rip),%rsi
  call   <fprintf@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    %r13,%rcx
  mov    $0x30,%edx
  mov    %r15,%rdi
  mov    $0x1,%esi
  call   <fwrite@plt>
  cmp    $0x6,%r14d
  jg     L84
  mov    0x18(%rbx),%rdx
  xor    %eax,%eax
  lea    D113(%rip),%rsi
  mov    %r13,%rdi
  call   <fprintf@plt>
  cmp    $0x5,%r14d
  jne    L35
L143:
  mov    0x20(%rbx),%rdx
  lea    D102(%rip),%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  xor    %r12d,%r12d
  lea    D118(%rip),%r15
  lea    D55(%rip),%r14
  call   <fprintf@plt>
  mov    %rbp,%rdi
  call   <fgetc@plt>
  mov    %eax,%ebx
  jmp    L59
  cs nopw 0x0(%rax,%rax,1)
L9:
  add    $0x1,%r12d
L14:
  movzbl %bl,%edx
  mov    %r14,%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    %rbp,%rdi
  call   <fgetc@plt>
  mov    %eax,%ebx
L59:
  mov    %rbp,%rdi
  call   <feof@plt>
  test   %eax,%eax
  jne    L27
  test   $0xf,%r12b
  jne    L9
  mov    %r13,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r15,%rdi
  call   <fwrite@plt>
  mov    $0x1,%r12d
  jmp    L14
  nopl   (%rax)
L27:
  mov    %r13,%rcx
  mov    $0x9,%edx
  mov    $0x1,%esi
  lea    D27(%rip),%rdi
  call   <fwrite@plt>
  mov    %r13,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D32(%rip),%rdi
  call   <fwrite@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L64:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L84:
  mov    0x30(%rbx),%rdx
  lea    D125(%rip),%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    0x18(%rbx),%rdx
  mov    %r13,%rdi
  xor    %eax,%eax
  lea    D113(%rip),%rsi
  call   <fprintf@plt>
L35:
  mov    0x28(%rbx),%rdx
  lea    D155(%rip),%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  jmp    L143
L124:
  lea    D17(%rip),%rdi
  call   <puts@plt>
  or     $0xffffffff,%eax
  jmp    L64
L71:
  mov    0x8(%rbx),%rsi
  lea    D16(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  or     $0xffffffff,%eax
  jmp    L64
L4:
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    0x18(%rbx),%rsi
  lea    D156(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  or     $0xffffffff,%eax
  jmp    L64
L65:
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    0x10(%rbx),%rsi
  lea    D168(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  or     $0xffffffff,%eax
  jmp    L64
```

tool_calls: name: disassemble_data
arguments: label: D90
type_infered: string
name: disassemble_data
arguments: label: D173
type_infered: string
name: disassemble_data
arguments: label: D68
type_infered: string
name: disassemble_data
arguments: label: D41
type_infered: string
name: disassemble_data
arguments: label: D48
type_infered: string
name: disassemble_data
arguments: label: D113
type_infered: string
name: disassemble_data
arguments: label: D102
type_infered: string
name: disassemble_data
arguments: label: D118
type_infered: string
name: disassemble_data
arguments: label: D55
type_infered: string
name: disassemble_data
arguments: label: D27
type_infered: string
name: disassemble_data
arguments: label: D32
type_infered: string
name: disassemble_data
arguments: label: D125
type_infered: string
name: disassemble_data
arguments: label: D155
type_infered: string
name: disassemble_data
arguments: label: D17
type_infered: string
name: disassemble_data
arguments: label: D16
type_infered: string
name: disassemble_data
arguments: label: D156
type_infered: string
name: disassemble_data
arguments: label: D168
type_infered: string

tool: D90: rb

tool: D173: w

tool: D68: /* This file is autogenerated, do not edit. */



tool: D41: #ifndef CHAR
#define CHAR char
#endif



tool: D48: extern CHAR %s[];


tool: D113: #include "%s"



tool: D102: CHAR %s[] =
{

tool: D118: 
   

tool: D55:  0x%02x,

tool: D27: 
    0x00

tool: D32: 
};


tool: D125: #include "%s"


tool: D155: %s 

tool: D17: Usage: bin2c infile.bin outfile.c outfile.h array_name [array_attribute [header_for_attribute]]

tool: D16: ERROR: Couldn't open data file '%s'.


tool: D156: ERROR: Couldn't create output header file '%s'.


tool: D168: ERROR: Couldn't create output source file '%s'.


assistant: ```c
int main(int argc, char *argv[]) {
  FILE *inFile;
  FILE *outCFile;
  FILE *outHFile;
  unsigned char ch;
  unsigned char cnt;
  if (argc < 5) {
    printf("Usage: bin2c infile.bin outfile.c outfile.h array_name [array_attribute [header_for_attribute]]\n");
    return -1;
  }
  inFile = fopen(argv[1], "rb");
  if (!inFile) {
    printf("ERROR: Couldn't open data file '%s'.\n", argv[1]);
    return -1;
  }
  outCFile = fopen(argv[2], "w");
  if (!outCFile) {
    fclose(inFile);
    printf("ERROR: Couldn't create output source file '%s'.\n", argv[2]);
    return -1;
  }
  outHFile = fopen(argv[3], "w");
  if (!outHFile) {
    fclose(outCFile);
    fclose(inFile);
    printf("ERROR: Couldn't create output header file '%s'.\n", argv[3]);
    return -1;
  }
  fprintf(outHFile, "/* This file is autogenerated, do not edit. */\n\n");
  fprintf(outHFile, "#ifndef CHAR\n"
                    "#define CHAR char\n"
                    "#endif\n\n");
  fprintf(outHFile, "extern CHAR %s[];\n", argv[4]);
  fclose(outHFile);
  fprintf(outCFile, "/* This file is autogenerated, do not edit. */\n\n");
  if (argc >= 7) {
    fprintf(outCFile, "#include \"%s\"\n", argv[6]);
  }
  fprintf(outCFile, "#include \"%s\"\n\n", argv[3]);
  if (argc >= 6) {
    fprintf(outCFile, "%s ", argv[5]);
  }
  fprintf(outCFile, "CHAR %s[] =\n{", argv[4]);
  cnt = 0;
  ch = fgetc(inFile);
  while (!feof(inFile)) {
    if ((cnt % 16) == 0) {
      fprintf(outCFile, "\n   ");
      cnt = 0;
    }
    fprintf(outCFile, " 0x%02x,", (unsigned int)ch);
    ++cnt;
    ch = fgetc(inFile);
  }
  fprintf(outCFile, "\n    0x00");
  fprintf(outCFile, "\n};\n");
  fclose(outCFile);
  fclose(inFile);
  return 0;
}
```