#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*/ compare(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "usage: ex0706 file1 file2\n");
    return 0;
  }
  FILE *fp1, *fp2;
  if ((fp1 = fopen(*++argv, "r")) != NULL &&
      (fp2 = fopen(*++argv, "r")) != NULL) {
    compare(fp1, fp2);
  } else {
    fprintf(stderr, "error opening files\n");
  }
  fclose(fp1);
  fclose(fp2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1181 <main+0x41>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    121b <main+0xdb>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe80(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11ed <main+0xad>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11ed <main+0xad>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <compare@plt>
jmp    1202 <main+0xc2>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1189 <main+0x49>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xec4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     11a0 <main+0x60>
mov    0x10(%rbx),%rdi
lea    0xeac(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a0 <main+0x60>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <compare@plt>
jmp    11b7 <main+0x77>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11c7 <main+0x87>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"usage: ex0706 file1 file2\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"error opening files\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %37
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i32 1
store i8** %15, i8*** %5
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %6
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %29
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i32 1
store i8** %21, i8*** %5
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %7
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load i32*, i32** %6
%27 = load i32*, i32** %7
%28 = call i32 @compare(i32* %26, i32* %27)
br label %32
29: ; preds = %19, %13
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %29, %25
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
%35 = load i32*, i32** %7
%36 = call i32 @fclose(i32* %35)
store i32 0, i32* %3
br label %37
37: ; preds = %32, %10
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"usage: ex0706 file1 file2\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"error opening files\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 i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %26
7: ; preds = %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 = icmp eq i32* %10, null
br i1 %11, label %19, label %12
12: ; preds = %7
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = tail call i32 @compare(i32* %10, i32* %15)
br label %22
19: ; preds = %12, %7
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %19, %17
%23 = phi i32* [ %15, %17 ], [ null, %19 ]
%24 = tail call i32 @fclose(i32* %10)
%25 = tail call i32 @fclose(i32* %23)
br label %26
26: ; preds = %22, %4
ret i32 0
}