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

```asm
<main>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x690,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x688(%rsp)
  xor    %eax,%eax
  lea    D13(%rip),%rsi
  lea    D54(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  mov    %rax,%rcx
  mov    $0x2b,%edx
  mov    $0x1,%esi
  lea    D144(%rip),%rdi
  call   <fwrite@plt>
  mov    $0x0,%eax
L86:
  mov    %eax,%ecx
  sar    $0x2,%ecx
  lea    0x0(,%rax,8),%edx
  or     %ecx,%edx
  mov    %dl,0x400(%rsp,%rax,1)
  add    $0x1,%rax
  cmp    $0x20,%rax
  jne    L86
  mov    $0x0,%eax
L92:
  mov    %eax,%ecx
  sar    $0x4,%ecx
  lea    0x0(,%rax,4),%edx
  or     %ecx,%edx
  mov    %dl,0x420(%rsp,%rax,1)
  add    $0x1,%rax
  cmp    $0x40,%rax
  jne    L92
  mov    $0x0,%ebp
L147:
  lea    -0x8(%rbp),%ebx
  mov    $0xff,%eax
  cmp    %eax,%ebx
  cmovg  %eax,%ebx
  test   %ebx,%ebx
  mov    $0x0,%eax
  cmovs  %eax,%ebx
  mov    $0x1f,%esi
  mov    %ebx,%edi
  call   <mul8bit@plt>
  movzbl 0x400(%rsp,%rax,1),%eax
  mov    %al,0x460(%rsp,%rbp,1)
  mov    $0x3f,%esi
  mov    %ebx,%edi
  call   <mul8bit@plt>
  movzbl 0x420(%rsp,%rax,1),%eax
  mov    %al,0x570(%rsp,%rbp,1)
  add    $0x1,%rbp
  cmp    $0x110,%rbp
  jne    L147
  mov    %r12,%rcx
  mov    $0x30,%edx
  mov    $0x1,%esi
  lea    D160(%rip),%rdi
  call   <fwrite@plt>
  mov    $0x0,%ebx
  lea    D86(%rip),%r14
  lea    0x460(%rsp),%r13
  lea    D79(%rip),%rbp
  jmp    L78
L60:
  movzbl (%rbx,%r13,1),%edx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x1,%rbx
  cmp    $0x110,%rbx
  je     L29
L78:
  test   $0x7,%bl
  jne    L60
  mov    %r12,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r14,%rdi
  call   <fwrite@plt>
  jmp    L60
L29:
  mov    %r12,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  lea    D132(%rip),%rdi
  call   <fwrite@plt>
  mov    %r12,%rcx
  mov    $0x2f,%edx
  mov    $0x1,%esi
  lea    D172(%rip),%rdi
  call   <fwrite@plt>
  mov    $0x0,%ebx
  lea    D86(%rip),%r14
  lea    0x570(%rsp),%r13
  lea    D79(%rip),%rbp
  jmp    L142
L169:
  movzbl (%rbx,%r13,1),%edx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x1,%rbx
  cmp    $0x110,%rbx
  je     L160
L142:
  test   $0x7,%bl
  jne    L169
  mov    %r12,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r14,%rdi
  call   <fwrite@plt>
  jmp    L169
L160:
  mov    %r12,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  lea    D132(%rip),%rdi
  call   <fwrite@plt>
  lea    0x400(%rsp),%rsi
  mov    %rsp,%rdi
  mov    $0x20,%edx
  call   <prepare_opt_table@plt>
  lea    0x420(%rsp),%rsi
  lea    0x200(%rsp),%rdi
  mov    $0x40,%edx
  call   <prepare_opt_table@plt>
  mov    %r12,%rcx
  mov    $0x2e,%edx
  mov    $0x1,%esi
  lea    D143(%rip),%rdi
  call   <fwrite@plt>
  mov    $0x0,%ebx
  lea    D86(%rip),%r14
  mov    %rsp,%rbp
  lea    D8(%rip),%r13
  jmp    L51
L54:
  movzbl 0x1(%rbp,%rbx,2),%ecx
  movzbl 0x0(%rbp,%rbx,2),%edx
  mov    %r13,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x1,%rbx
  cmp    $0x100,%rbx
  je     L65
L51:
  test   $0x3,%bl
  jne    L54
  mov    %r12,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r14,%rdi
  call   <fwrite@plt>
  jmp    L54
L65:
  mov    %r12,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  lea    D132(%rip),%rdi
  call   <fwrite@plt>
  mov    %r12,%rcx
  mov    $0x2e,%edx
  mov    $0x1,%esi
  lea    D71(%rip),%rdi
  call   <fwrite@plt>
  mov    $0x0,%ebx
  lea    D86(%rip),%r14
  lea    0x200(%rsp),%rbp
  lea    D8(%rip),%r13
  jmp    L131
L74:
  movzbl 0x1(%rbp,%rbx,2),%ecx
  movzbl 0x0(%rbp,%rbx,2),%edx
  mov    %r13,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x1,%rbx
  cmp    $0x100,%rbx
  je     L85
L131:
  test   $0x3,%bl
  jne    L74
  mov    %r12,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r14,%rdi
  call   <fwrite@plt>
  jmp    L74
L85:
  mov    %r12,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  lea    D132(%rip),%rdi
  call   <fwrite@plt>
  mov    %r12,%rcx
  mov    $0x7,%edx
  mov    $0x1,%esi
  lea    D193(%rip),%rdi
  call   <fwrite@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x688(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L77
  mov    $0x0,%eax
  add    $0x690,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L77:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D13
data_type: string
name: read_data
arguments: label: D54
data_type: string
name: read_data
arguments: label: D144
data_type: string
name: read_data
arguments: label: D160
data_type: string
name: read_data
arguments: label: D86
data_type: string
name: read_data
arguments: label: D79
data_type: string
name: read_data
arguments: label: D132
data_type: string
name: read_data
arguments: label: D172
data_type: string
name: read_data
arguments: label: D143
data_type: string
name: read_data
arguments: label: D8
data_type: string
name: read_data
arguments: label: D71
data_type: string
name: read_data
arguments: label: D193
data_type: string

tool: D13: w

tool: D54: dxt_tables.h

tool: D144: #ifndef DXT_TABLES_H
#define DXT_TABLES_H



tool: D160: static const unsigned char quantRB[256 + 16] =
{

tool: D86: 
   

tool: D79: 0x%02x, 

tool: D132: 
};



tool: D172: static const unsigned char quantG[256 + 16] =
{

tool: D143: static const unsigned char omatch5[256][2] =
{

tool: D8: {0x%02x, 0x%02x}, 

tool: D71: static const unsigned char omatch6[256][2] =
{

tool: D193: #endif


assistant: ```c
int main(void) {
  FILE *fp;
  int i, v;
  unsigned char expand5[32];
  unsigned char expand6[64];
  unsigned char quantRB[256 + 16];
  unsigned char quantG[256 + 16];
  unsigned char omatch5[256][2];
  unsigned char omatch6[256][2];
  fp = fopen("dxt_tables.h", "w");
  fprintf(fp, "#ifndef DXT_TABLES_H\n"
              "#define DXT_TABLES_H\n\n");
  for (i = 0; i < 32; ++i)
    expand5[i] = (i << 3) | (i >> 2);
  for (i = 0; i < 64; ++i)
    expand6[i] = (i << 2) | (i >> 4);
  for (i = 0; i < 256 + 16; ++i) {
    v = i - 8;
    if (v < 0)
      v = 0;
    if (v > 255)
      v = 255;
    quantRB[i] = expand5[mul8bit(v, 31)];
    quantG[i] = expand6[mul8bit(v, 63)];
  }
  fprintf(fp, "static const unsigned char quantRB[256 + 16] =\n"
              "{");
  for (i = 0; i < 256 + 16; ++i) {
    if (i % 8 == 0)
      fprintf(fp, "\n   ");
    fprintf(fp, "0x%02x, ", quantRB[i]);
  }
  fprintf(fp, "\n};\n\n");
  fprintf(fp, "static const unsigned char quantG[256 + 16] =\n"
              "{");
  for (i = 0; i < 256 + 16; ++i) {
    if (i % 8 == 0)
      fprintf(fp, "\n   ");
    fprintf(fp, "0x%02x, ", quantG[i]);
  }
  fprintf(fp, "\n};\n\n");
  prepare_opt_table(&omatch5[0][0], expand5, 32);
  prepare_opt_table(&omatch6[0][0], expand6, 64);
  fprintf(fp, "static const unsigned char omatch5[256][2] =\n"
              "{");
  for (i = 0; i < 256; ++i) {
    if (i % 4 == 0)
      fprintf(fp, "\n   ");
    fprintf(fp, "{0x%02x, 0x%02x}, ", omatch5[i][0], omatch5[i][1]);
  }
  fprintf(fp, "\n};\n\n");
  fprintf(fp, "static const unsigned char omatch6[256][2] =\n"
              "{");
  for (i = 0; i < 256; ++i) {
    if (i % 4 == 0)
      fprintf(fp, "\n   ");
    fprintf(fp, "{0x%02x, 0x%02x}, ", omatch6[i][0], omatch6[i][1]);
  }
  fprintf(fp, "\n};\n\n");
  fprintf(fp, "#endif\n");
  fclose(fp);
  return (0);
}
```