#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*/ diff_line(char *, char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *fp1, *fp2;
  char fp1_line[1000], fp2_line[1000];
  int i;
  if (argc != 3) {
    printf("differ fileone filetwo\n");
    exit(0);
  }
  fp1 = fopen(argv[1], "r");
  if (!fp1) {
    printf("Error opening file %s\n", argv[1]);
  }
  fp2 = fopen(argv[2], "r");
  if (!fp2) {
    printf("Error opening file %s\n", argv[2]);
  }
  i = 0;
  while ((fgets(fp1_line, 1000, fp1) != NULL) &&
         (fgets(fp2_line, 1000, fp2) != NULL)) {
    diff_line(fp1_line, fp2_line, i);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1188 <main+0x38>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c1 <main+0x71>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe48(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11fa <main+0xaa>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x804(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x805(%rbp)
je     1250 <main+0x100>
lea    -0x800(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x805(%rbp)
mov    -0x805(%rbp),%al
test   $0x1,%al
jne    1263 <main+0x113>
jmp    1290 <main+0x140>
lea    -0x410(%rbp),%rdi
lea    -0x800(%rbp),%rsi
mov    -0x804(%rbp),%edx
call   1030 <diff_line@plt>
mov    -0x804(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x804(%rbp)
jmp    1204 <main+0xb4>
xor    %eax,%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7e0,%rsp
cmp    $0x3,%edi
jne    124c <main+0xec>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11a5 <main+0x45>
mov    0x8(%r15),%rsi
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%r15),%rdi
lea    0xe50(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11cf <main+0x6f>
mov    0x10(%r15),%rsi
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     123a <main+0xda>
xor    %ebp,%ebp
lea    0x3f0(%rsp),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     123a <main+0xda>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <diff_line@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1200 <main+0xa0>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdc6(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"differ fileone filetwo\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"Error opening file %s\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 [1000 x i8]
%9 = alloca [1000 x i8]
%10 = alloca i32
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 %16
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %28, label %23
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %23, %16
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %7
%33 = load i32*, i32** %7
%34 = icmp ne i32* %33, null
br i1 %34, label %40, label %35
35: ; preds = %28
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %35, %28
store i32 0, i32* %10
br label %41
41: ; preds = %53, %40
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%43 = load i32*, i32** %6
%44 = call i32* @fgets(i8* %42, i32 1000, i32* %43)
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %51
46: ; preds = %41
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%48 = load i32*, i32** %7
%49 = call i32* @fgets(i8* %47, i32 1000, i32* %48)
%50 = icmp ne i32* %49, null
br label %51
51: ; preds = %46, %41
%52 = phi i1 [ false, %41 ], [ %50, %46 ]
br i1 %52, label %53, label %60
53: ; preds = %51
%54 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%55 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%56 = load i32, i32* %10
%57 = call i32 @diff_line(i8* %54, i8* %55, i32 %56)
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %41
60: ; preds = %51
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"Error opening file %s\0A\00"
@str = [23 x i8] c"differ fileone filetwo\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %11
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i8*, i8** %20
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %19
%28 = call i32* @fgets(i8* %5, i32 1000, i32* %14)
%29 = icmp eq i32* %28, null
br i1 %29, label %39, label %30
30: ; preds = %27, %34
%31 = phi i32 [ %36, %34 ], [ 0, %27 ]
%32 = call i32* @fgets(i8* %6, i32 1000, i32* %22)
%33 = icmp eq i32* %32, null
br i1 %33, label %39, label %34
34: ; preds = %30
%35 = call i32 @diff_line(i8* %5, i8* %6, i32 %31)
%36 = add nuw nsw i32 %31, 1
%37 = call i32* @fgets(i8* %5, i32 1000, i32* %14)
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %30
39: ; preds = %30, %34, %27
ret i32 0
}