#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 */
long compare_blocks(short *, short *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fread(short *, int, int, int /*<<< orphan*/ *);
short *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *f1, *f2;
  short *buf1, *buf2;
  if (argc != 3) {
    printf("Usage: %s FILE1 FILE2\n", argv[0]);
  }
  f1 = fopen(argv[1], "r");
  f2 = fopen(argv[2], "r");
  if (f1 == NULL || f2 == NULL) {
    fprintf(stderr, "Error: cannot open file\n");
    exit(1);
  }
  buf1 = malloc(48000 * 2 * 100 * sizeof(short));
  buf2 = malloc(48000 * 2 * 100 * sizeof(short));
  fread(buf1, sizeof(short), 48000 * 2 * 100, f1);
  fread(buf2, sizeof(short), 48000 * 2 * 100, f2);
  long offset = compare_blocks(buf1, buf2, 48000 * 2 * 100);
  printf("%ld\n", offset);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a5 <main+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe63(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11eb <main+0x7b>
cmpq   $0x0,-0x20(%rbp)
jne    120a <main+0x9a>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    $0x124f800,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x124f800,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x2,%esi
mov    $0x927c00,%edx
call   1030 <fread@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x2,%esi
mov    $0x927c00,%edx
call   1030 <fread@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x927c00,%edx
call   1050 <compare_blocks@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1191 <main+0x21>
mov    (%rbx),%rsi
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xe7b(%rip),%r14
mov    %r14,%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
mov    %r14,%rsi
call   1080 <fopen@plt>
test   %r15,%r15
je     122c <main+0xbc>
mov    %rax,%r14
test   %rax,%rax
je     122c <main+0xbc>
mov    $0x124f800,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    $0x124f800,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x2,%esi
mov    $0x927c00,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x927c00,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x927c00,%edx
call   1050 <compare_blocks@plt>
lea    0xe17(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: %s FILE1 FILE2\0A\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c"Error: cannot open file\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i16*
%9 = alloca i16*
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %13, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %7
%27 = load i32*, i32** %6
%28 = icmp eq i32* %27, null
br i1 %28, label %32, label %29
29: ; preds = %18
%30 = load i32*, i32** %7
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %36
32: ; preds = %29, %18
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %29
%37 = call i16* @malloc(i32 19200000)
store i16* %37, i16** %8
%38 = call i16* @malloc(i32 19200000)
store i16* %38, i16** %9
%39 = load i16*, i16** %8
%40 = load i32*, i32** %6
%41 = call i32 @fread(i16* %39, i32 2, i32 9600000, i32* %40)
%42 = load i16*, i16** %9
%43 = load i32*, i32** %7
%44 = call i32 @fread(i16* %42, i32 2, i32 9600000, i32* %43)
%45 = load i16*, i16** %8
%46 = load i16*, i16** %9
%47 = call i64 @compare_blocks(i16* %45, i16* %46, i32 9600000)
store i64 %47, i64* %10
%48 = load i64, i64* %10
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %48)
%50 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: %s FILE1 FILE2\0A\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c"Error: cannot open file\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %10, null
%15 = icmp eq i32* %13, null
%16 = or i1 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %7
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %7
%22 = tail call i16* @malloc(i32 19200000)
%23 = tail call i16* @malloc(i32 19200000)
%24 = tail call i32 @fread(i16* %22, i32 2, i32 9600000, i32* %10)
%25 = tail call i32 @fread(i16* %23, i32 2, i32 9600000, i32* %13)
%26 = tail call i64 @compare_blocks(i16* %22, i16* %23, i32 9600000)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %26)
%28 = tail call i32 @exit(i32 0)
unreachable
}