#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 */
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
void filecomp(FILE *fp1, FILE *fp2) {
  char line1[10000];
  char line2[10000];
  char *lp1;
  char *lp2;
  do {
    lp1 = fgets(line1, 10000, fp1);
    lp2 = fgets(line2, 10000, fp2);
    if (lp1 == line1 && lp2 == line2) {
      if (strcmp(line1, line2) != 0) {
        printf("First difference is:\n\n%s\n", line1);
        lp1 = NULL;
        lp2 = NULL;
      }
    } else if (lp1 != line1 && lp2 == line2)
      printf("End of first file reached at the following line:\n\n%s\n", line2);
    else
      printf("End of second file reached at the following line:\n\n%s\n",
             line2);
  } while (lp1 == line1 && lp2 == line2);
}


x86 assembly (clang, -O0):
<filecomp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x2720(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x2710,%esi
call   1040 <fgets@plt>
mov    %rax,-0x4e38(%rbp)
lea    -0x4e30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2710,%esi
call   1040 <fgets@plt>
mov    %rax,-0x4e40(%rbp)
mov    -0x4e38(%rbp),%rax
lea    -0x2720(%rbp),%rcx
cmp    %rcx,%rax
jne    11f4 <filecomp+0xc4>
mov    -0x4e40(%rbp),%rax
lea    -0x4e30(%rbp),%rcx
cmp    %rcx,%rax
jne    11f4 <filecomp+0xc4>
lea    -0x2720(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11ef <filecomp+0xbf>
lea    -0x2720(%rbp),%rsi
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x4e38(%rbp)
movq   $0x0,-0x4e40(%rbp)
jmp    1252 <filecomp+0x122>
mov    -0x4e38(%rbp),%rax
lea    -0x2720(%rbp),%rcx
cmp    %rcx,%rax
je     123a <filecomp+0x10a>
mov    -0x4e40(%rbp),%rax
lea    -0x4e30(%rbp),%rcx
cmp    %rcx,%rax
jne    123a <filecomp+0x10a>
lea    -0x4e30(%rbp),%rsi
lea    0xdea(%rip),%rdi
call   1030 <printf@plt>
jmp    124d <filecomp+0x11d>
lea    -0x4e30(%rbp),%rsi
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
jmp    1252 <filecomp+0x122>
jmp    1257 <filecomp+0x127>
mov    -0x4e38(%rbp),%rcx
lea    -0x2720(%rbp),%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x4e41(%rbp)
jne    1290 <filecomp+0x160>
mov    -0x4e40(%rbp),%rax
lea    -0x4e30(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
mov    %al,-0x4e41(%rbp)
mov    -0x4e41(%rbp),%al
test   $0x1,%al
jne    1143 <filecomp+0x13>
add    $0x4e50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filecomp>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4e20,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0x2710(%rsp),%r13
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x2710,%esi
mov    %r12,%rdx
call   1040 <fgets@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x2710,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
cmp    %r13,%rbx
jne    11ae <filecomp+0x7e>
cmp    %r15,%rax
jne    11ae <filecomp+0x7e>
mov    %r13,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1160 <filecomp+0x30>
lea    0xe5c(%rip),%rdi
lea    0x2710(%rsp),%rsi
jmp    11cb <filecomp+0x9b>
cmp    %r13,%rbx
je     11c1 <filecomp+0x91>
cmp    %r15,%rax
jne    11c1 <filecomp+0x91>
lea    0xe5b(%rip),%rdi
jmp    11c8 <filecomp+0x98>
lea    0xe88(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
add    $0x4e20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"First difference is:\0A\0A%s\0A\00"
@.str.1 = [54 x i8] c"End of first file reached at the following line:\0A\0A%s\0A\00"
@.str.2 = [55 x i8] c"End of second file reached at the following line:\0A\0A%s\0A\00"
define void @filecomp(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [10000 x i8]
%6 = alloca [10000 x i8]
%7 = alloca i8*
%8 = alloca i8*
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %9
9: ; preds = %56, %2
%10 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%11 = load i32*, i32** %3
%12 = call i8* @fgets(i8* %10, i32 10000, i32* %11)
store i8* %12, i8** %7
%13 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%14 = load i32*, i32** %4
%15 = call i8* @fgets(i8* %13, i32 10000, i32* %14)
store i8* %15, i8** %8
%16 = load i8*, i8** %7
%17 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%18 = icmp eq i8* %16, %17
br i1 %18, label %19, label %32
19: ; preds = %9
%20 = load i8*, i8** %8
%21 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%22 = icmp eq i8* %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%25 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%26 = call i64 @strcmp(i8* %24, i8* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %29)
store i8* null, i8** %7
store i8* null, i8** %8
br label %31
31: ; preds = %28, %23
br label %47
32: ; preds = %19, %9
%33 = load i8*, i8** %7
%34 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%35 = icmp ne i8* %33, %34
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i8*, i8** %8
%38 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%39 = icmp eq i8* %37, %38
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%42 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %41)
br label %46
43: ; preds = %36, %32
%44 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%45 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %43, %40
br label %47
47: ; preds = %46, %31
br label %48
48: ; preds = %47
%49 = load i8*, i8** %7
%50 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%51 = icmp eq i8* %49, %50
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i8*, i8** %8
%54 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%55 = icmp eq i8* %53, %54
br label %56
56: ; preds = %52, %48
%57 = phi i1 [ false, %48 ], [ %55, %52 ]
br i1 %57, label %9, label %58
58: ; preds = %56
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"First difference is:\0A\0A%s\0A\00"
@.str.1 = [54 x i8] c"End of first file reached at the following line:\0A\0A%s\0A\00"
@.str.2 = [55 x i8] c"End of second file reached at the following line:\0A\0A%s\0A\00"
define void @filecomp(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [10000 x i8]
%4 = alloca [10000 x i8]
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %13, %2
%8 = call i8* @fgets(i8* %5, i32 10000, i32* %0)
%9 = call i8* @fgets(i8* %6, i32 10000, i32* %1)
%10 = icmp eq i8* %8, %5
%11 = icmp eq i8* %9, %6
%12 = and i1 %10, %11
br i1 %12, label %13, label %18
13: ; preds = %7
%14 = call i64 @strcmp(i8* %5, i8* %6)
%15 = icmp eq i64 %14, 0
br i1 %15, label %7, label %16
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %25
18: ; preds = %7
%19 = icmp ne i8* %8, %5
%20 = and i1 %19, %11
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %25
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %25
25: ; preds = %21, %23, %16
ret void
}