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

```asm
<main>:
  endbr64
  push   %r15
  xor    %esi,%esi
  mov    $0x400,%edx
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x828,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x818(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%r15
  lea    0x410(%rsp),%r13
  mov    %r15,%rdi
  call   <memset@plt>
  xor    %esi,%esi
  mov    $0x400,%edx
  mov    %r13,%rdi
  call   <memset@plt>
  lea    D81(%rip),%rdi
  call   <getenv@plt>
  lea    D144(%rip),%rdi
  mov    %rax,%rbp
  call   <getenv@plt>
  test   %rbp,%rbp
  je     L155
  mov    %rax,%r12
  test   %rax,%rax
  je     L88
  mov    %rbp,%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
  mov    $0x4,%edx
  lea    D249(%rip),%rsi
  mov    %r12,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L57
L145:
  lea    D98(%rip),%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
L211:
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <strcat@plt>
  lea    D50(%rip),%rsi
  mov    %r13,%rdi
  call   <strcat@plt>
  lea    D186(%rip),%rsi
  mov    %r15,%rdi
  call   <fopen@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L38
  lea    D256(%rip),%rsi
  mov    %r13,%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L195
  mov    %rax,%rcx
  mov    $0x28,%edx
  mov    $0x1,%esi
  xor    %r13d,%r13d
  lea    D180(%rip),%r12
  lea    D28(%rip),%r15
  mov    %r12,%rdi
  call   <fwrite@plt>
  mov    %rbp,%rcx
  mov    $0x28,%edx
  mov    %r12,%rdi
  mov    $0x1,%esi
  lea    0xe(%rsp),%r12
  call   <fwrite@plt>
  mov    %rbp,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  mov    %rbp,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  mov    %rbp,%rcx
  mov    $0x1c,%edx
  mov    $0x1,%esi
  lea    D182(%rip),%rdi
  call   <fwrite@plt>
  jmp    L138
  nop
L69:
  add    $0x1,%r13d
L35:
  mov    %rbp,%rcx
  mov    $0x2,%edx
  mov    $0x1,%esi
  mov    %r15,%rdi
  call   <fwrite@plt>
  movzbl %bl,%edx
  lea    D91(%rip),%rsi
  mov    %r12,%rdi
  call   <sprintf@plt>
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <fputs@plt>
  mov    %rbp,%rcx
  mov    $0x2,%edx
  mov    $0x1,%esi
  lea    D196(%rip),%rdi
  call   <fwrite@plt>
L138:
  mov    %r14,%rdi
  call   <getc@plt>
  mov    %r14,%rdi
  mov    %eax,%ebx
  call   <feof@plt>
  test   %rax,%rax
  jne    L74
  xor    %esi,%esi
  mov    $0x2,%edx
  mov    %r12,%rdi
  call   <memset@plt>
  cmp    $0x10,%r13d
  jne    L69
  mov    %rbp,%rsi
  mov    $0xa,%edi
  mov    $0x1,%r13d
  call   <fputc@plt>
  jmp    L35
  nopl   0x0(%rax,%rax,1)
L74:
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D78(%rip),%rdi
  call   <fwrite@plt>
  mov    %r14,%rdi
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  xor    %edi,%edi
  call   <exit@plt>
  xor    %eax,%eax
L142:
  mov    0x818(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L97
  add    $0x828,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L57:
  mov    $0x4,%edx
  lea    D219(%rip),%rsi
  mov    %r12,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L216
  mov    $0x4,%edx
  lea    D164(%rip),%rsi
  mov    %r12,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L145
  mov    $0x4,%edx
  lea    D63(%rip),%rsi
  mov    %r12,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L145
  mov    $0x4,%edx
  lea    D6(%rip),%rsi
  mov    %r12,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L216
  mov    $0x4,%edx
  lea    D46(%rip),%rsi
  mov    %r12,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L216
  mov    $0x4,%edx
  lea    D255(%rip),%rsi
  mov    %r12,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L216
  mov    $0x4,%edx
  lea    D65(%rip),%rsi
  mov    %r12,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L216
  mov    $0x9,%edx
  lea    D95(%rip),%rsi
  mov    %r12,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L145
L216:
  lea    D40(%rip),%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
  jmp    L211
L88:
  lea    D56(%rip),%rdi
  call   <puts@plt>
L7:
  or     $0xffffffff,%eax
  jmp    L142
L155:
  lea    D220(%rip),%rdi
  call   <puts@plt>
  jmp    L7
L195:
  mov    %r13,%rsi
  lea    D191(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L7
L38:
  mov    %r15,%rsi
  lea    D127(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L7
L97:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D81
type_guessed: string
name: extract_symbolic_data
arguments: tag: D144
type_guessed: string
name: extract_symbolic_data
arguments: tag: D249
type_guessed: string
name: extract_symbolic_data
arguments: tag: D98
type_guessed: string
name: extract_symbolic_data
arguments: tag: D50
type_guessed: string
name: extract_symbolic_data
arguments: tag: D186
type_guessed: string
name: extract_symbolic_data
arguments: tag: D256
type_guessed: string
name: extract_symbolic_data
arguments: tag: D180
type_guessed: string
name: extract_symbolic_data
arguments: tag: D28
type_guessed: string
name: extract_symbolic_data
arguments: tag: D182
type_guessed: string
name: extract_symbolic_data
arguments: tag: D91
type_guessed: string
name: extract_symbolic_data
arguments: tag: D196
type_guessed: string
name: extract_symbolic_data
arguments: tag: D78
type_guessed: string
name: extract_symbolic_data
arguments: tag: D219
type_guessed: string
name: extract_symbolic_data
arguments: tag: D164
type_guessed: string
name: extract_symbolic_data
arguments: tag: D63
type_guessed: string
name: extract_symbolic_data
arguments: tag: D6
type_guessed: string
name: extract_symbolic_data
arguments: tag: D46
type_guessed: string
name: extract_symbolic_data
arguments: tag: D255
type_guessed: string
name: extract_symbolic_data
arguments: tag: D65
type_guessed: string
name: extract_symbolic_data
arguments: tag: D95
type_guessed: string
name: extract_symbolic_data
arguments: tag: D40
type_guessed: string
name: extract_symbolic_data
arguments: tag: D56
type_guessed: string
name: extract_symbolic_data
arguments: tag: D220
type_guessed: string
name: extract_symbolic_data
arguments: tag: D191
type_guessed: string
name: extract_symbolic_data
arguments: tag: D127
type_guessed: string

tool: D81: RT28xx_DIR

tool: D144: CHIPSET

tool: D249: 2860

tool: D98: /common/rt2860.bin

tool: D50: /include/firmware.h

tool: D186: r

tool: D256: w

tool: D180: /* AUTO GEN PLEASE DO NOT MODIFY IT */ 


tool: D28: 0x

tool: D182: UCHAR FirmwareImage [] = { 


tool: D91: %02x

tool: D196: , 

tool: D78: } ;


tool: D219: 2870

tool: D164: 3090

tool: D63: 3390

tool: D6: 2070

tool: D46: 3070

tool: D255: 3572

tool: D65: 3370

tool: D95: USB_COMBO

tool: D40: /common/rt2870.bin

tool: D56: Environment value "CHIPSET" not export 

tool: D220: Environment value "RT28xx_DIR" not export 

tool: D191: Can't open write file %s 


tool: D127: Can't read file %s 


assistant: ```c
int main(int argc, char *argv[]) {
  FILE *infile, *outfile;
  char infname[1024];
  char outfname[1024];
  char *rt28xxdir;
  char *chipset;
  int i = 0;
  unsigned char c;
  memset(infname, 0, 1024);
  memset(outfname, 0, 1024);
  rt28xxdir = (char *)getenv("RT28xx_DIR");
  chipset = (char *)getenv("CHIPSET");
  if (!rt28xxdir) {
    printf("Environment value \"RT28xx_DIR\" not export \n");
    return -1;
  }
  if (!chipset) {
    printf("Environment value \"CHIPSET\" not export \n");
    return -1;
  }
  strcat(infname, rt28xxdir);
  if (strncmp(chipset, "2860", 4) == 0)
    strcat(infname, "/common/rt2860.bin");
  else if (strncmp(chipset, "2870", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "3090", 4) == 0)
    strcat(infname, "/common/rt2860.bin");
  else if (strncmp(chipset, "3390", 4) == 0)
    strcat(infname, "/common/rt2860.bin");
  else if (strncmp(chipset, "2070", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "3070", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "3572", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "3370", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "USB_COMBO", 9) == 0)
    strcat(infname, "/common/rt2870.bin");
  else
    strcat(infname, "/common/rt2860.bin");
  strcat(outfname, rt28xxdir);
  strcat(outfname, "/include/firmware.h");
  infile = fopen(infname, "r");
  if (infile == (FILE *)NULL) {
    printf("Can't read file %s \n", infname);
    return -1;
  }
  outfile = fopen(outfname, "w");
  if (outfile == (FILE *)NULL) {
    printf("Can't open write file %s \n", outfname);
    return -1;
  }
  fputs("/* AUTO GEN PLEASE DO NOT MODIFY IT */ \n", outfile);
  fputs("/* AUTO GEN PLEASE DO NOT MODIFY IT */ \n", outfile);
  fputs("\n", outfile);
  fputs("\n", outfile);
  fputs("UCHAR FirmwareImage [] = { \n", outfile);
  while (1) {
    char cc[2];
    c = getc(infile);
    if (feof(infile))
      break;
    memset(cc, 0, 2);
    if (i >= 16) {
      fputs("\n", outfile);
      i = 0;
    }
    fputs("0x", outfile);
    sprintf(cc, "%02x", c);
    fputs(cc, outfile);
    fputs(", ", outfile);
    i++;
  }
  fputs("} ;\n", outfile);
  fclose(infile);
  fclose(outfile);
  exit(0);
}
```