#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *f1 = fopen("cmp1.op3", "rb");
  FILE *f2 = fopen("cmp2.op3", "rb");
  unsigned char byte1 = 0, byte2 = 0;
  int count = 0;
  int insCount = 0;
  int dataPos = 32 + (2 * 4);
  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 == 32) {
      printf("Header\n");
    }
    if (count == 32 + (2 * 4)) {
      printf("Header END\n");
    }
    if (count >= dataPos) {
      if ((count - dataPos) % 24 == 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++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xeaf(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
movb   $0x0,-0x1a(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x28,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x35(%rbp)
je     11b8 <main+0x88>
cmpl   $0x0,-0x30(%rbp)
setne  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    11c8 <main+0x98>
jmp    1324 <main+0x1f4>
mov    -0x10(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rcx
lea    -0x1a(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1227 <main+0xf7>
cmpl   $0x0,-0x30(%rbp)
jne    1227 <main+0xf7>
jmp    1324 <main+0x1f4>
cmpl   $0x20,-0x20(%rbp)
jne    123f <main+0x10f>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x28,-0x20(%rbp)
jne    1257 <main+0x127>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jl     12df <main+0x1af>
mov    -0x20(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    $0x18,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12da <main+0x1aa>
cmpl   $0x0,-0x34(%rbp)
je     12a8 <main+0x178>
mov    -0x24(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
sub    $0x80,%esi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c1 <main+0x191>
mov    -0x24(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x80,-0x24(%rbp)
jne    12d5 <main+0x1a5>
movl   $0x1,-0x34(%rbp)
jmp    12da <main+0x1aa>
jmp    12df <main+0x1af>
mov    -0x20(%rbp),%esi
movzbl -0x19(%rbp),%edx
movzbl -0x1a(%rbp),%ecx
movzbl -0x19(%rbp),%edi
movzbl -0x1a(%rbp),%r9d
lea    0xd69(%rip),%r8
lea    0xd27(%rip),%rax
cmp    %r9d,%edi
cmove  %rax,%r8
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119f <main+0x6f>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%rdi
lea    0xead(%rip),%rbx
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,0x10(%rsp)
lea    0xe9c(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
movb   $0x0,0xf(%rsp)
movb   $0x0,0xe(%rsp)
xor    %r14d,%r14d
xor    %r13d,%r13d
xor    %r15d,%r15d
xchg   %ax,%ax
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rcx
call   1040 <fread@plt>
mov    %rax,%r12
lea    0xe(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rax,%rbp
or     %r12,%rax
je     1294 <main+0x154>
cmp    $0x28,%r13d
je     11f0 <main+0xb0>
cmp    $0x20,%r13d
jne    1210 <main+0xd0>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
jmp    1253 <main+0x113>
nopl   0x0(%rax)
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
test   %r14d,%r14d
je     122e <main+0xee>
lea    -0x80(%r15),%esi
lea    0xe09(%rip),%rdi
jmp    1238 <main+0xf8>
xchg   %ax,%ax
cmp    $0x28,%r13d
jb     1253 <main+0x113>
imul   $0xaaaaaaab,%r13d,%eax
add    $0x7ffffff0,%eax
ror    $0x3,%eax
cmp    $0xaaaaaaa,%eax
ja     1253 <main+0x113>
jmp    11fc <main+0xbc>
lea    0xdec(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15d
cmp    $0x80,%r15d
mov    $0x1,%eax
cmove  %eax,%r14d
movzbl 0xf(%rsp),%edx
movzbl 0xe(%rsp),%ecx
cmp    %cl,%dl
lea    0xde9(%rip),%r8
lea    0xdb3(%rip),%rax
cmove  %rax,%r8
lea    0xdbb(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r12,%r12
je     1294 <main+0x154>
add    $0x1,%r13d
test   %rbp,%rbp
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"cmp1.op3\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [9 x i8] c"cmp2.op3\00"
@.str.3 = [8 x i8] c"Header\0A\00"
@.str.4 = [12 x i8] c"Header END\0A\00"
@.str.5 = [12 x i8] c"DRUM!!! %d\0A\00"
@.str.6 = [18 x i8] c"INSTRUMENT!!! %d\0A\00"
@.str.7 = [28 x i8] c"%03X: {0x%02x == 0x%02x}%s\0A\00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [16 x i8] c" <- NOT SAME!!!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %2
%13 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %3
store i8 0, i8* %4
store i8 0, i8* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 40, i32* %8
store i32 1, i32* %9
store i32 1, i32* %10
store i32 0, i32* %11
br label %14
14: ; preds = %75, %0
%15 = load i32, i32* %9
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %10
%19 = icmp ne i32 %18, 0
br label %20
20: ; preds = %17, %14
%21 = phi i1 [ false, %14 ], [ %19, %17 ]
br i1 %21, label %22, label %91
22: ; preds = %20
%23 = load i32*, i32** %2
%24 = call i64 @fread(i8* %4, i32 1, i32 1, i32* %23)
%25 = icmp ne i64 %24, 0
%26 = zext i1 %25 to i32
store i32 %26, i32* %9
%27 = load i32*, i32** %3
%28 = call i64 @fread(i8* %5, i32 1, i32 1, i32* %27)
%29 = icmp ne i64 %28, 0
%30 = zext i1 %29 to i32
store i32 %30, i32* %10
%31 = load i32, i32* %9
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %22
%34 = load i32, i32* %10
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %33
br label %91
37: ; preds = %33, %22
%38 = load i32, i32* %6
%39 = icmp eq i32 %38, 32
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
%43 = load i32, i32* %6
%44 = icmp eq i32 %43, 40
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %45, %42
%48 = load i32, i32* %6
%49 = load i32, i32* %8
%50 = icmp sge i32 %48, %49
br i1 %50, label %51, label %75
51: ; preds = %47
%52 = load i32, i32* %6
%53 = load i32, i32* %8
%54 = sub nsw i32 %52, %53
%55 = srem i32 %54, 24
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %74
57: ; preds = %51
%58 = load i32, i32* %11
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %57
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
%63 = sub nsw i32 %61, 128
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %63)
br label %69
65: ; preds = %57
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %66)
br label %69
69: ; preds = %65, %60
%70 = load i32, i32* %7
%71 = icmp eq i32 %70, 128
br i1 %71, label %72, label %73
72: ; preds = %69
store i32 1, i32* %11
br label %73
73: ; preds = %72, %69
br label %74
74: ; preds = %73, %51
br label %75
75: ; preds = %74, %47
%76 = load i32, i32* %6
%77 = load i8, i8* %4
%78 = zext i8 %77 to i32
%79 = load i8, i8* %5
%80 = zext i8 %79 to i32
%81 = load i8, i8* %4
%82 = zext i8 %81 to i32
%83 = load i8, i8* %5
%84 = zext i8 %83 to i32
%85 = icmp eq i32 %82, %84
%86 = zext i1 %85 to i64
%87 = select i1 %85, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %76, i32 %78, i32 %80, i8* %87)
%89 = load i32, i32* %6
%90 = add nsw i32 %89, 1
store i32 %90, i32* %6
br label %14
91: ; preds = %36, %20
%92 = load i32, i32* %1
ret i32 %92
}

LLVM IR (-O2):
@.str = [9 x i8] c"cmp1.op3\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [9 x i8] c"cmp2.op3\00"
@.str.5 = [12 x i8] c"DRUM!!! %d\0A\00"
@.str.6 = [18 x i8] c"INSTRUMENT!!! %d\0A\00"
@.str.7 = [28 x i8] c"%03X: {0x%02x == 0x%02x}%s\0A\00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [16 x i8] c" <- NOT SAME!!!\00"
@str = [11 x i8] c"Header END\00"
@str.10 = [7 x i8] c"Header\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8 0, i8* %1
store i8 0, i8* %2
br label %5
5: ; preds = %0, %37
%6 = phi i32 [ 0, %0 ], [ %39, %37 ]
%7 = phi i32 [ 0, %0 ], [ %47, %37 ]
%8 = phi i32 [ 0, %0 ], [ %38, %37 ]
%9 = call i64 @fread(i8* %1, i32 1, i32 1, i32* %3)
%10 = icmp ne i64 %9, 0
%11 = call i64 @fread(i8* %2, i32 1, i32 1, i32* %4)
%12 = icmp ne i64 %11, 0
%13 = or i64 %11, %9
%14 = icmp eq i64 %13, 0
br i1 %14, label %49, label %15
15: ; preds = %5
switch i32 %7, label %20 [
i32 32, label %16
i32 40, label %18
]
16: ; preds = %15
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.10, i64 0, i64 0))
br label %37
18: ; preds = %15
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %26
20: ; preds = %15
%21 = icmp ugt i32 %7, 39
br i1 %21, label %22, label %37
22: ; preds = %20
%23 = add nsw i32 %7, -40
%24 = srem i32 %23, 24
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %18, %22
%27 = icmp eq i32 %6, 0
br i1 %27, label %31, label %28
28: ; preds = %26
%29 = add nsw i32 %8, -128
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %29)
br label %33
31: ; preds = %26
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %8)
br label %33
33: ; preds = %31, %28
%34 = add nsw i32 %8, 1
%35 = icmp eq i32 %34, 128
%36 = select i1 %35, i32 1, i32 %6
br label %37
37: ; preds = %16, %33, %22, %20
%38 = phi i32 [ %8, %22 ], [ %8, %20 ], [ %34, %33 ], [ %8, %16 ]
%39 = phi i32 [ %6, %22 ], [ %6, %20 ], [ %36, %33 ], [ %6, %16 ]
%40 = load i8, i8* %1
%41 = zext i8 %40 to i32
%42 = load i8, i8* %2
%43 = zext i8 %42 to i32
%44 = icmp eq i8 %40, %42
%45 = select i1 %44, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %7, i32 %41, i32 %43, i8* %45)
%47 = add nuw nsw i32 %7, 1
%48 = and i1 %10, %12
br i1 %48, label %5, label %49
49: ; preds = %5, %37
ret i32 0
}