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

```asm
<main>:
  endbr64
  push   %r15
  lea    D114(%rip),%rsi
  lea    D171(%rip),%rdi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x6a8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x698(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  mov    $0x2b,%edx
  mov    $0x1,%esi
  lea    D61(%rip),%rdi
  mov    %rax,%rcx
  mov    %rax,%rbp
  call   <fwrite@plt>
  lea    0x410(%rsp),%rdi
  xor    %eax,%eax
  mov    %rdi,0x8(%rsp)
  cs nopw 0x0(%rax,%rax,1)
L75:
  mov    %eax,%ecx
  lea    0x0(,%rax,8),%edx
  mov    0x8(%rsp),%rsi
  sar    $0x2,%ecx
  or     %ecx,%edx
  mov    %dl,(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    $0x20,%rax
  jne    L75
  xor    %eax,%eax
  lea    0x430(%rsp),%r14
  nopw   0x0(%rax,%rax,1)
L81:
  mov    %eax,%ecx
  lea    0x0(,%rax,4),%edx
  sar    $0x4,%ecx
  or     %ecx,%edx
  mov    %dl,(%r14,%rax,1)
  add    $0x1,%rax
  cmp    $0x40,%rax
  jne    L81
  xor    %ebx,%ebx
  lea    0x470(%rsp),%r13
  lea    0x580(%rsp),%r12
  xchg   %ax,%ax
L23:
  lea    -0x8(%rbx),%r15d
  mov    $0xff,%eax
  mov    $0x1f,%esi
  cmp    %eax,%r15d
  cmovg  %eax,%r15d
  xor    %eax,%eax
  test   %r15d,%r15d
  cmovs  %eax,%r15d
  mov    %r15d,%edi
  call   <mul8bit@plt>
  mov    $0x3f,%esi
  mov    %r15d,%edi
  movzbl 0x410(%rsp,%rax,1),%eax
  mov    %al,0x0(%r13,%rbx,1)
  call   <mul8bit@plt>
  movzbl 0x430(%rsp,%rax,1),%eax
  mov    %al,(%r12,%rbx,1)
  add    $0x1,%rbx
  cmp    $0x110,%rbx
  jne    L23
  mov    %rbp,%rcx
  mov    $0x30,%edx
  mov    $0x1,%esi
  xor    %r15d,%r15d
  lea    D13(%rip),%rdi
  lea    D19(%rip),%rbx
  call   <fwrite@plt>
  jmp    L176
  xchg   %ax,%ax
L3:
  movzbl 0x0(%r13,%r15,1),%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  xor    %eax,%eax
  add    $0x1,%r15
  call   <fprintf@plt>
  cmp    $0x110,%r15
  je     L21
L176:
  test   $0x7,%r15b
  jne    L3
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D45(%rip),%rdi
  call   <fwrite@plt>
  jmp    L3
L21:
  mov    %rbp,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  xor    %r15d,%r15d
  lea    D77(%rip),%rdi
  lea    D45(%rip),%r13
  call   <fwrite@plt>
  mov    %rbp,%rcx
  mov    $0x2f,%edx
  mov    $0x1,%esi
  lea    D82(%rip),%rdi
  call   <fwrite@plt>
  jmp    L12
  nop
L39:
  movzbl (%r12,%r15,1),%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  xor    %eax,%eax
  add    $0x1,%r15
  call   <fprintf@plt>
  cmp    $0x110,%r15
  je     L65
L12:
  test   $0x7,%r15b
  jne    L39
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r13,%rdi
  call   <fwrite@plt>
  jmp    L39
L65:
  mov    %rbp,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  xor    %r15d,%r15d
  lea    D77(%rip),%rdi
  lea    0x10(%rsp),%rbx
  call   <fwrite@plt>
  mov    0x8(%rsp),%rsi
  mov    $0x20,%edx
  mov    %rbx,%rdi
  lea    0x210(%rsp),%r12
  lea    D153(%rip),%r13
  call   <prepare_opt_table@plt>
  mov    %r14,%rsi
  mov    $0x40,%edx
  mov    %r12,%rdi
  call   <prepare_opt_table@plt>
  mov    %rbp,%rcx
  mov    $0x2e,%edx
  mov    $0x1,%esi
  lea    D116(%rip),%rdi
  lea    D45(%rip),%r14
  call   <fwrite@plt>
  jmp    L114
L109:
  movzbl 0x1(%rbx,%r15,2),%ecx
  movzbl (%rbx,%r15,2),%edx
  mov    %r13,%rsi
  xor    %eax,%eax
  mov    %rbp,%rdi
  add    $0x1,%r15
  call   <fprintf@plt>
  cmp    $0x100,%r15
  je     L35
L114:
  test   $0x3,%r15b
  jne    L109
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r14,%rdi
  call   <fwrite@plt>
  jmp    L109
L35:
  mov    %rbp,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  xor    %ebx,%ebx
  lea    D77(%rip),%rdi
  lea    D45(%rip),%r14
  call   <fwrite@plt>
  mov    %rbp,%rcx
  mov    $0x2e,%edx
  mov    $0x1,%esi
  lea    D4(%rip),%rdi
  call   <fwrite@plt>
  jmp    L76
  nop
L195:
  movzbl 0x1(%r12,%rbx,2),%ecx
  movzbl (%r12,%rbx,2),%edx
  mov    %r13,%rsi
  xor    %eax,%eax
  mov    %rbp,%rdi
  add    $0x1,%rbx
  call   <fprintf@plt>
  cmp    $0x100,%rbx
  je     L197
L76:
  test   $0x3,%bl
  jne    L195
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r14,%rdi
  call   <fwrite@plt>
  jmp    L195
L197:
  mov    %rbp,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  lea    D77(%rip),%rdi
  call   <fwrite@plt>
  lea    D136(%rip),%rdi
  mov    %rbp,%rcx
  mov    $0x7,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    0x698(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L68
  add    $0x6a8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L68:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D114
data_type: string
name: disassemble_data
arguments: data_tag: D171
data_type: string
name: disassemble_data
arguments: data_tag: D61
data_type: string
name: disassemble_data
arguments: data_tag: D13
data_type: string
name: disassemble_data
arguments: data_tag: D19
data_type: string
name: disassemble_data
arguments: data_tag: D45
data_type: string
name: disassemble_data
arguments: data_tag: D77
data_type: string
name: disassemble_data
arguments: data_tag: D82
data_type: string
name: disassemble_data
arguments: data_tag: D153
data_type: string
name: disassemble_data
arguments: data_tag: D116
data_type: string
name: disassemble_data
arguments: data_tag: D4
data_type: string
name: disassemble_data
arguments: data_tag: D136
data_type: string

tool: D114: w

tool: D171: dxt_tables.h

tool: D61: #ifndef DXT_TABLES_H
#define DXT_TABLES_H



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

tool: D19: 0x%02x, 

tool: D45: 
   

tool: D77: 
};



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

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

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

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

tool: D136: #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);
}
```