#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 */
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main() {
  int i = 1;
  FILE *f1 = fopen("file1.txt", "r");
  FILE *f2 = fopen("file2.txt", "r");
  char line1[1000];
  char line2[1000];
  while (feof(f1) == 0 && feof(f2) == 0) {
    fgets(line1, 1000, f1);
    fgets(line2, 1000, f2);
    if (strcmp(line1, line2) != 0) {
      printf("file1 %d: %s", i, line1);
      printf("file2 %d: %s", i, line2);
      return 0;
    }
    ++i;
  }
  printf("each line in file1 is the same as the one in file2.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xe90(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe85(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x7f1(%rbp)
jne    11cb <main+0x7b>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x7f1(%rbp)
mov    -0x7f1(%rbp),%al
test   $0x1,%al
jne    11de <main+0x8e>
jmp    126f <main+0x11f>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
lea    -0x7f0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
lea    -0x400(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1261 <main+0x111>
mov    -0x8(%rbp),%esi
lea    -0x400(%rbp),%rdx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    -0x7f0(%rbp),%rdx
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1284 <main+0x134>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1197 <main+0x47>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7e0,%rsp
lea    0xe8a(%rip),%rdi
lea    0xe8d(%rip),%rbx
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     11c5 <main+0x65>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
lea    0x3f0(%rsp),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %rax,%rax
jne    11a7 <main+0x47>
mov    %r15,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1232 <main+0xd2>
add    $0x1,%ebp
mov    %r14,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     11e0 <main+0x80>
jmp    11a7 <main+0x47>
lea    0xddd(%rip),%rdi
lea    0x3f0(%rsp),%rdx
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdd2(%rip),%rdi
mov    %rsp,%rdx
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b3 <main+0x53>

LLVM IR (-O0):
@.str = [10 x i8] c"file1.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"file2.txt\00"
@.str.3 = [13 x i8] c"file1 %d: %s\00"
@.str.4 = [13 x i8] c"file2 %d: %s\00"
@.str.5 = [53 x i8] c"each line in file1 is the same as the one in file2.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [1000 x i8]
%6 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 1, i32* %2
%7 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %3
%8 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %4
br label %9
9: ; preds = %37, %0
%10 = load i32*, i32** %3
%11 = call i64 @feof(i32* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32*, i32** %4
%15 = call i64 @feof(i32* %14)
%16 = icmp eq i64 %15, 0
br label %17
17: ; preds = %13, %9
%18 = phi i1 [ false, %9 ], [ %16, %13 ]
br i1 %18, label %19, label %40
19: ; preds = %17
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%21 = load i32*, i32** %3
%22 = call i32 @fgets(i8* %20, i32 1000, i32* %21)
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%24 = load i32*, i32** %4
%25 = call i32 @fgets(i8* %23, i32 1000, i32* %24)
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%28 = call i64 @strcmp(i8* %26, i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %19
%31 = load i32, i32* %2
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %31, i8* %32)
%34 = load i32, i32* %2
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %34, i8* %35)
store i32 0, i32* %1
br label %42
37: ; preds = %19
%38 = load i32, i32* %2
%39 = add nsw i32 %38, 1
store i32 %39, i32* %2
br label %9
40: ; preds = %17
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %42
42: ; preds = %40, %30
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [10 x i8] c"file1.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"file2.txt\00"
@.str.3 = [13 x i8] c"file1 %d: %s\00"
@.str.4 = [13 x i8] c"file2 %d: %s\00"
@str = [52 x i8] c"each line in file1 is the same as the one in file2.\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%7 = call i64 @feof(i32* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %0, %21
%10 = phi i32 [ %22, %21 ], [ 1, %0 ]
%11 = call i64 @feof(i32* %4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = call i32 @fgets(i8* %5, i32 1000, i32* %3)
%15 = call i32 @fgets(i8* %6, i32 1000, i32* %4)
%16 = call i64 @strcmp(i8* %5, i8* %6)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %10, i8* %5)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %10, i8* %6)
br label %27
21: ; preds = %13
%22 = add nuw nsw i32 %10, 1
%23 = call i64 @feof(i32* %3)
%24 = icmp eq i64 %23, 0
br i1 %24, label %9, label %25
25: ; preds = %9, %21, %0
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %25, %18
ret i32 0
}