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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    D28(%rip),%rbx
  mov    %rbx,%rsi
  lea    D58(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r14
  mov    %rbx,%rsi
  lea    D21(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,(%rsp)
  movb   $0x0,0x16(%rsp)
  movb   $0x0,0x17(%rsp)
  mov    $0x0,%r15d
  movl   $0x0,0xc(%rsp)
  mov    $0x0,%ebx
  jmp    L54
L74:
  lea    D52(%rip),%rdi
  call   <puts@plt>
L17:
  movzbl 0x16(%rsp),%edx
  movzbl 0x17(%rsp),%ecx
  cmp    %cl,%dl
  movzbl %cl,%ecx
  movzbl %dl,%edx
  lea    D60(%rip),%r8
  lea    D40(%rip),%rax
  cmovne %rax,%r8
  mov    %ebx,%esi
  lea    D62(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x1,%ebx
  test   %r12b,%r12b
  je     L96
  test   %r13b,%r13b
  je     L96
L54:
  lea    0x16(%rsp),%rdi
  mov    %r14,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  call   <fread@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  setne  %r12b
  lea    0x17(%rsp),%rdi
  mov    (%rsp),%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  call   <fread@plt>
  test   %rax,%rax
  setne  %r13b
  or     %rbp,%rax
  je     L96
  test   %ebx,%ebx
  je     L74
  cmp    $0x8,%ebx
  je     L104
  cmp    $0x7,%ebx
  jle    L17
  lea    -0x8(%rbx),%edx
  movslq %edx,%rax
  imul   $0x38e38e39,%rax,%rax
  sar    $0x23,%rax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  lea    (%rax,%rax,8),%eax
  shl    $0x2,%eax
  cmp    %eax,%edx
  jne    L17
  jmp    L7
L104:
  lea    D86(%rip),%rdi
  call   <puts@plt>
L7:
  test   %r15d,%r15d
  je     L35
  mov    0xc(%rsp),%eax
  lea    0x1(%rax),%ebp
  lea    -0x80(%rax),%esi
  lea    D59(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %ebp,0xc(%rsp)
L76:
  cmpl   $0x80,0xc(%rsp)
  mov    $0x1,%eax
  cmove  %eax,%r15d
  jmp    L17
L35:
  mov    0xc(%rsp),%esi
  lea    0x1(%rsi),%ebp
  lea    D30(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %ebp,0xc(%rsp)
  jmp    L76
L96:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L30
  mov    $0x0,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L30:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D28
type_guessed: string
name: parse_data
arguments: tag: D58
type_guessed: string
name: parse_data
arguments: tag: D21
type_guessed: string
name: parse_data
arguments: tag: D52
type_guessed: string
name: parse_data
arguments: tag: D60
type_guessed: string
name: parse_data
arguments: tag: D40
type_guessed: string
name: parse_data
arguments: tag: D62
type_guessed: string
name: parse_data
arguments: tag: D86
type_guessed: string
name: parse_data
arguments: tag: D59
type_guessed: string
name: parse_data
arguments: tag: D30
type_guessed: string

tool: D28: rb

tool: D58: dmx_doom2.op2

tool: D21: dmx_doom2_modded.op2

tool: D52: Header

tool: 

tool: D40:  <- NOT SAME!!!

tool: D62: %03X: {0x%02x == 0x%02x}%s


tool: D86: Header END

tool: D59: DRUM!!! %d


tool: D30: INSTRUMENT!!! %d


assistant: ```c
int main() {
  FILE *f1 = fopen("dmx_doom2.op2", "rb");
  FILE *f2 = fopen("dmx_doom2_modded.op2", "rb");
  unsigned char byte1 = 0, byte2 = 0;
  int count = 0;
  int insCount = 0;
  int dataPos = 8;
  int valid1 = 1;
  int valid2 = 1;
  int drumMode = 0;
  while (valid1 && valid2) {
    valid1 = (fread(&byte1, 1, 1, f1) != 0);
    valid2 = (fread(&byte2, 1, 1, f2) != 0);
    if (!valid1 && !valid2)
      break;
    if (count == 0) {
      printf("Header\n");
    }
    if (count == 8) {
      printf("Header END\n");
    }
    if (count >= dataPos) {
      if ((count - dataPos) % 36 == 0) {
        if (drumMode)
          printf("DRUM!!! %d\n", (insCount++) - 128);
        else
          printf("INSTRUMENT!!! %d\n", insCount++);
        if (insCount == 128)
          drumMode = 1;
      }
    }
    printf("%03X: {0x%02x == 0x%02x}%s\n", count, byte1, byte2, (byte1 == byte2) ? "" : " <- NOT SAME!!!");
    count++;
  }
}
```