user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  cmp    $0x4,%edi
  jle    L18
  mov    %edi,%r14d
  mov    %rsi,%rbx
  mov    0x8(%rsi),%rdi
  lea    D40(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L38
  mov    0x10(%rbx),%rdi
  lea    D63(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L98
  mov    0x18(%rbx),%rdi
  lea    D63(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L65
  mov    %rax,%rcx
  mov    $0x30,%edx
  mov    $0x1,%esi
  lea    D4(%rip),%r15
  mov    %r15,%rdi
  call   <fwrite@plt>
  mov    %rbp,%rcx
  mov    $0x27,%edx
  mov    $0x1,%esi
  lea    D72(%rip),%rdi
  call   <fwrite@plt>
  mov    0x20(%rbx),%rdx
  lea    D131(%rip),%rsi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    %r13,%rcx
  mov    $0x30,%edx
  mov    $0x1,%esi
  mov    %r15,%rdi
  call   <fwrite@plt>
  cmp    $0x6,%r14d
  jg     L80
  mov    0x18(%rbx),%rdx
  lea    D25(%rip),%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  cmp    $0x6,%r14d
  je     L142
L16:
  mov    0x20(%rbx),%rdx
  lea    D172(%rip),%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %r12,%rdi
  call   <fgetc@plt>
  mov    %eax,%ebx
  mov    $0x0,%ebp
  lea    D150(%rip),%r15
  jmp    L76
L18:
  lea    D65(%rip),%rdi
  call   <puts@plt>
  mov    $0xffffffff,%eax
  jmp    L14
L38:
  mov    0x8(%rbx),%rsi
  lea    D156(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L14
L98:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x10(%rbx),%rsi
  lea    D2(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L14
L65:
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x18(%rbx),%rsi
  lea    D167(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L14
L80:
  mov    0x30(%rbx),%rdx
  lea    D24(%rip),%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    0x18(%rbx),%rdx
  lea    D25(%rip),%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
L142:
  mov    0x28(%rbx),%rdx
  lea    D74(%rip),%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  jmp    L16
L33:
  movzbl %bl,%edx
  mov    %r15,%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x1,%ebp
  mov    %r12,%rdi
  call   <fgetc@plt>
  mov    %eax,%ebx
L76:
  mov    %r12,%rdi
  call   <feof@plt>
  test   %eax,%eax
  jne    L92
  mov    %ebp,%r14d
  and    $0xf,%r14d
  jne    L33
  mov    %r13,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D87(%rip),%rdi
  call   <fwrite@plt>
  mov    %r14d,%ebp
  jmp    L33
L92:
  mov    %r13,%rcx
  mov    $0x9,%edx
  mov    $0x1,%esi
  lea    D53(%rip),%rdi
  call   <fwrite@plt>
  mov    %r13,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D0(%rip),%rdi
  call   <fwrite@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
L14:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: read_data
arguments: label: D40
type_infered: string
name: read_data
arguments: label: D63
type_infered: string
name: read_data
arguments: label: D4
type_infered: string
name: read_data
arguments: label: D72
type_infered: string
name: read_data
arguments: label: D131
type_infered: string
name: read_data
arguments: label: D25
type_infered: string
name: read_data
arguments: label: D172
type_infered: string
name: read_data
arguments: label: D150
type_infered: string
name: read_data
arguments: label: D65
type_infered: string
name: read_data
arguments: label: D156
type_infered: string
name: read_data
arguments: label: D2
type_infered: string
name: read_data
arguments: label: D167
type_infered: string
name: read_data
arguments: label: D24
type_infered: string
name: read_data
arguments: label: D74
type_infered: string
name: read_data
arguments: label: D87
type_infered: string
name: read_data
arguments: label: D53
type_infered: string
name: read_data
arguments: label: D0
type_infered: string

tool: D40: rb

tool: D63: w

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



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



tool: D131: extern CHAR %s[];


tool: D25: #include "%s"



tool: D172: CHAR %s[] =
{

tool: D150:  0x%02x,

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

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


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


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


tool: D24: #include "%s"


tool: D74: %s 

tool: D87: 
   

tool: D53: 
    0x00

tool: D0: 
};


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;
}
```