#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*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  FILE *fp1, *fp2;
  char *prog, *filename1, *filename2, *l1, *l2;
  char line1[1000], line2[1000];
  int linenum;
  linenum = 0;
  prog = argv[0];
  filename1 = argv[1];
  filename2 = argv[2];
  if (argc == 3 && (fp1 = fopen(filename1, "r")) != NULL &&
      (fp2 = fopen(filename2, "r")) != NULL) {
    while ((l1 = fgets(line1, 1000, fp1)) != NULL &&
           (l2 = fgets(line2, 1000, fp2)) != NULL) {
      ++linenum;
      if (strcmp(l1, l2) != 0) {
        printf("%s and %s are diff from line %d\n", filename1, filename2,
               linenum);
        printf("%s:", filename1);
        fputs(l1, stdout);
        printf("%s:", filename2);
        fputs(l2, stdout);
        break;
      }
    }
    ++linenum;
    if (l1 == NULL && (l2 = fgets(line2, 1000, fp2)) != NULL) {
      printf("%s and %s are diff from line %d\n", filename1, filename2,
             linenum);
      printf("%s:", filename2);
      fputs(l2, stdout);
    } else if (l1 != NULL && l2 == NULL) {
      printf("%s and %s are diff from line %d\n", filename1, filename2,
             linenum);
      printf("%s:", filename1);
      fputs(l1, stdout);
    }
    fclose(fp1);
    fclose(fp2);
  } else {
    printf("Usage:%s file1 file2\n", prog);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x824(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    13e0 <main+0x280>
mov    -0x30(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     13e0 <main+0x280>
mov    -0x38(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     13e0 <main+0x280>
jmp    11f1 <main+0x91>
lea    -0x430(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
mov    %rax,%rcx
mov    %rcx,-0x40(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x825(%rbp)
je     1245 <main+0xe5>
lea    -0x820(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x825(%rbp)
mov    -0x825(%rbp),%al
test   $0x1,%al
jne    1258 <main+0xf8>
jmp    12ec <main+0x18c>
mov    -0x824(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x824(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12e7 <main+0x187>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x824(%rbp),%ecx
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    0x2d29(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rsi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    0x2d05(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
jmp    12ec <main+0x18c>
jmp    11f1 <main+0x91>
mov    -0x824(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x824(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    136e <main+0x20e>
lea    -0x820(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     136e <main+0x20e>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x824(%rbp),%ecx
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    0x2c7e(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
jmp    13c9 <main+0x269>
cmpq   $0x0,-0x40(%rbp)
je     13c4 <main+0x264>
cmpq   $0x0,-0x48(%rbp)
jne    13c4 <main+0x264>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x824(%rbp),%ecx
lea    0xc69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xc78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    0x2c23(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
jmp    13c9 <main+0x269>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    13f2 <main+0x292>
mov    -0x28(%rbp),%rsi
lea    0xc3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7e8,%rsp
mov    (%rsi),%rbx
cmp    $0x3,%edi
jne    1264 <main+0x104>
mov    0x8(%rsi),%rbp
mov    0x10(%rsi),%r15
lea    0xe74(%rip),%rsi
mov    %rbp,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1264 <main+0x104>
mov    %rax,%r13
lea    0xe59(%rip),%rsi
mov    %r15,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1264 <main+0x104>
mov    %rax,%r14
mov    %rbp,(%rsp)
mov    %r15,0x8(%rsp)
mov    $0x1,%ebp
lea    0x10(%rsp),%r12
xchg   %ax,%ax
lea    0x400(%rsp),%rdi
mov    $0x3e8,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %rax,%r15
test   %rbx,%rbx
je     1289 <main+0x129>
test   %r15,%r15
je     12ac <main+0x14c>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
add    $0x1,%ebp
test   %rax,%rax
je     11d0 <main+0x70>
add    $0xffffffff,%ebp
lea    0xdd8(%rip),%rdi
mov    (%rsp),%rsi
mov    0x8(%rsp),%r12
mov    %r12,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xddd(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
jmp    12cb <main+0x16b>
lea    0xdbc(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x7e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r15,%r15
je     12ed <main+0x18d>
lea    0xd6d(%rip),%rdi
mov    (%rsp),%rsi
mov    0x8(%rsp),%r12
mov    %r12,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12cb <main+0x16b>
lea    0xd4f(%rip),%rdi
mov    (%rsp),%r12
mov    %r12,%rsi
mov    0x8(%rsp),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%r15
lea    0xd51(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1050 <fputs@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
jmp    1275 <main+0x115>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [33 x i8] c"%s and %s are diff from line %d\0A\00"
@.str.2 = [4 x i8] c"%s:\00"
@stdout = global i32 0
@.str.3 = [22 x i8] c"Usage:%s file1 file2\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 i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [1000 x i8]
%14 = alloca [1000 x i8]
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %15
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
store i8* %18, i8** %8
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %9
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
store i8* %24, i8** %10
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %113
27: ; preds = %2
%28 = load i8*, i8** %9
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %29, i32** %6
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %113
31: ; preds = %27
%32 = load i8*, i8** %10
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %33, i32** %7
%34 = icmp ne i32* %33, null
br i1 %34, label %35, label %113
35: ; preds = %31
br label %36
36: ; preds = %70, %35
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%38 = load i32*, i32** %6
%39 = call i8* @fgets(i8* %37, i32 1000, i32* %38)
store i8* %39, i8** %11
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %14, i64 0, i64 0
%43 = load i32*, i32** %7
%44 = call i8* @fgets(i8* %42, i32 1000, i32* %43)
store i8* %44, i8** %12
%45 = icmp ne i8* %44, null
br label %46
46: ; preds = %41, %36
%47 = phi i1 [ false, %36 ], [ %45, %41 ]
br i1 %47, label %48, label %71
48: ; preds = %46
%49 = load i32, i32* %15
%50 = add nsw i32 %49, 1
store i32 %50, i32* %15
%51 = load i8*, i8** %11
%52 = load i8*, i8** %12
%53 = call i64 @strcmp(i8* %51, i8* %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %70
55: ; preds = %48
%56 = load i8*, i8** %9
%57 = load i8*, i8** %10
%58 = load i32, i32* %15
%59 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %56, i8* %57, i32 %58)
%60 = load i8*, i8** %9
%61 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %60)
%62 = load i8*, i8** %11
%63 = load i32, i32* @stdout
%64 = call i32 @fputs(i8* %62, i32 %63)
%65 = load i8*, i8** %10
%66 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %65)
%67 = load i8*, i8** %12
%68 = load i32, i32* @stdout
%69 = call i32 @fputs(i8* %67, i32 %68)
br label %71
70: ; preds = %48
br label %36
71: ; preds = %55, %46
%72 = load i32, i32* %15
%73 = add nsw i32 %72, 1
store i32 %73, i32* %15
%74 = load i8*, i8** %11
%75 = icmp eq i8* %74, null
br i1 %75, label %76, label %91
76: ; preds = %71
%77 = getelementptr inbounds [1000 x i8], [1000 x i8]* %14, i64 0, i64 0
%78 = load i32*, i32** %7
%79 = call i8* @fgets(i8* %77, i32 1000, i32* %78)
store i8* %79, i8** %12
%80 = icmp ne i8* %79, null
br i1 %80, label %81, label %91
81: ; preds = %76
%82 = load i8*, i8** %9
%83 = load i8*, i8** %10
%84 = load i32, i32* %15
%85 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %82, i8* %83, i32 %84)
%86 = load i8*, i8** %10
%87 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %86)
%88 = load i8*, i8** %12
%89 = load i32, i32* @stdout
%90 = call i32 @fputs(i8* %88, i32 %89)
br label %108
91: ; preds = %76, %71
%92 = load i8*, i8** %11
%93 = icmp ne i8* %92, null
br i1 %93, label %94, label %107
94: ; preds = %91
%95 = load i8*, i8** %12
%96 = icmp eq i8* %95, null
br i1 %96, label %97, label %107
97: ; preds = %94
%98 = load i8*, i8** %9
%99 = load i8*, i8** %10
%100 = load i32, i32* %15
%101 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %98, i8* %99, i32 %100)
%102 = load i8*, i8** %9
%103 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %102)
%104 = load i8*, i8** %11
%105 = load i32, i32* @stdout
%106 = call i32 @fputs(i8* %104, i32 %105)
br label %107
107: ; preds = %97, %94, %91
br label %108
108: ; preds = %107, %81
%109 = load i32*, i32** %6
%110 = call i32 @fclose(i32* %109)
%111 = load i32*, i32** %7
%112 = call i32 @fclose(i32* %111)
br label %116
113: ; preds = %31, %27, %2
%114 = load i8*, i8** %8
%115 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %114)
br label %116
116: ; preds = %113, %108
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [33 x i8] c"%s and %s are diff from line %d\0A\00"
@.str.2 = [4 x i8] c"%s:\00"
@stdout = global i32 0
@.str.3 = [22 x i8] c"Usage:%s file1 file2\0A\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 = load i8*, i8** %1
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = icmp eq i32 %0, 3
br i1 %12, label %13, label %50
13: ; preds = %2
%14 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %50, label %16
16: ; preds = %13
%17 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %50, label %19
19: ; preds = %16, %27
%20 = phi i32 [ %26, %27 ], [ 0, %16 ]
%21 = call i8* @fgets(i8* %5, i32 1000, i32* %14)
%22 = icmp eq i8* %21, null
%23 = call i8* @fgets(i8* %6, i32 1000, i32* %17)
%24 = icmp eq i8* %23, null
br i1 %22, label %35, label %25
25: ; preds = %19
%26 = add nuw nsw i32 %20, 1
br i1 %24, label %39, label %27
27: ; preds = %25
%28 = call i64 @strcmp(i8* %21, i8* %23)
%29 = icmp eq i64 %28, 0
br i1 %29, label %19, label %30
30: ; preds = %27
%31 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %11, i32 %26)
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%33 = load i32, i32* @stdout
%34 = call i32 @fputs(i8* %21, i32 %33)
br label %41
35: ; preds = %19
br i1 %24, label %47, label %36
36: ; preds = %35
%37 = add nuw nsw i32 %20, 1
%38 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %11, i32 %37)
br label %41
39: ; preds = %25
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %11, i32 %26)
br label %41
41: ; preds = %36, %39, %30
%42 = phi i8* [ %11, %30 ], [ %9, %39 ], [ %11, %36 ]
%43 = phi i8* [ %23, %30 ], [ %21, %39 ], [ %23, %36 ]
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%45 = load i32, i32* @stdout
%46 = call i32 @fputs(i8* %43, i32 %45)
br label %47
47: ; preds = %41, %35
%48 = call i32 @fclose(i32* %14)
%49 = call i32 @fclose(i32* %17)
br label %52
50: ; preds = %16, %13, %2
%51 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %7)
br label %52
52: ; preds = %50, %47
ret i32 0
}