#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__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strncmp(char *, char *, int);
int compare_files(char *f1, char *f2) {
  FILE *fp1, *fp2;
  char line1[100 + 1], line2[100 + 1];
  int line_num;
  fp1 = fopen(f1, "r");
  fp2 = fopen(f2, "r");
  if (fp1 == NULL || fp2 == NULL) {
    return 1;
  }
  line_num = 1;
  while (fgets(line1, 100, fp1) && fgets(line2, 100, fp2)) {
    if (strncmp(line1, line2, 100) != 0) {
      printf("%dc%d\n", line_num, line_num);
      printf("< %s", line1);
      printf("---\n");
      printf("> %s", line2);
      break;
    }
    line_num++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<compare_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1191 <compare_files+0x51>
cmpq   $0x0,-0x28(%rbp)
jne    119d <compare_files+0x5d>
movl   $0x1,-0x4(%rbp)
jmp    129a <compare_files+0x15a>
movl   $0x1,-0x104(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x105(%rbp)
je     11f3 <compare_files+0xb3>
lea    -0x100(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x64,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x105(%rbp)
mov    -0x105(%rbp),%al
test   $0x1,%al
jne    1206 <compare_files+0xc6>
jmp    1293 <compare_files+0x153>
lea    -0x90(%rbp),%rdi
lea    -0x100(%rbp),%rsi
mov    $0x64,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     127f <compare_files+0x13f>
mov    -0x104(%rbp),%esi
mov    -0x104(%rbp),%edx
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x100(%rbp),%rsi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1293 <compare_files+0x153>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    11a7 <compare_files+0x67>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_files>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%rbp
lea    0xe95(%rip),%r14
mov    %r14,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r14,%rsi
call   1070 <fopen@plt>
mov    $0x1,%r14d
test   %rbx,%rbx
je     1259 <compare_files+0x109>
mov    %rax,%r15
test   %rax,%rax
je     1259 <compare_files+0x109>
mov    %rsp,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1259 <compare_files+0x109>
mov    $0x1,%ebp
lea    0x70(%rsp),%r12
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    $0x64,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1259 <compare_files+0x109>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x64,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1214 <compare_files+0xc4>
add    $0x1,%ebp
mov    %r13,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11d0 <compare_files+0x80>
jmp    1259 <compare_files+0x109>
lea    0xde7(%rip),%rdi
xor    %r14d,%r14d
mov    %ebp,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdd9(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdd2(%rip),%rdi
call   1040 <puts@plt>
lea    0xdc1(%rip),%rdi
lea    0x70(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"%dc%d\0A\00"
@.str.2 = [5 x i8] c"< %s\00"
@.str.3 = [5 x i8] c"---\0A\00"
@.str.4 = [5 x i8] c"> %s\00"
define i32 @compare_files(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [101 x i8]
%9 = alloca [101 x i8]
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i8*, i8** %5
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
%15 = load i32*, i32** %6
%16 = icmp eq i32* %15, null
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32*, i32** %7
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %21
20: ; preds = %17, %2
store i32 1, i32* %3
br label %52
21: ; preds = %17
store i32 1, i32* %10
br label %22
22: ; preds = %48, %21
%23 = getelementptr inbounds [101 x i8], [101 x i8]* %8, i64 0, i64 0
%24 = load i32*, i32** %6
%25 = call i64 @fgets(i8* %23, i32 100, i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = getelementptr inbounds [101 x i8], [101 x i8]* %9, i64 0, i64 0
%29 = load i32*, i32** %7
%30 = call i64 @fgets(i8* %28, i32 100, i32* %29)
%31 = icmp ne i64 %30, 0
br label %32
32: ; preds = %27, %22
%33 = phi i1 [ false, %22 ], [ %31, %27 ]
br i1 %33, label %34, label %51
34: ; preds = %32
%35 = getelementptr inbounds [101 x i8], [101 x i8]* %8, i64 0, i64 0
%36 = getelementptr inbounds [101 x i8], [101 x i8]* %9, i64 0, i64 0
%37 = call i64 @strncmp(i8* %35, i8* %36, i32 100)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %48
39: ; preds = %34
%40 = load i32, i32* %10
%41 = load i32, i32* %10
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41)
%43 = getelementptr inbounds [101 x i8], [101 x i8]* %8, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%46 = getelementptr inbounds [101 x i8], [101 x i8]* %9, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %46)
br label %51
48: ; preds = %34
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %22
51: ; preds = %39, %32
store i32 0, i32* %3
br label %52
52: ; preds = %51, %20
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"%dc%d\0A\00"
@.str.2 = [5 x i8] c"< %s\00"
@.str.4 = [5 x i8] c"> %s\00"
@str = [4 x i8] c"---\00"
define i32 @compare_files(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [101 x i8]
%4 = alloca [101 x i8]
%5 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %7, null
%10 = icmp eq i32* %8, null
%11 = or i1 %9, %10
br i1 %11, label %31, label %12
12: ; preds = %2
%13 = call i64 @fgets(i8* %5, i32 100, i32* %7)
%14 = icmp eq i64 %13, 0
br i1 %14, label %31, label %15
15: ; preds = %12, %27
%16 = phi i32 [ %28, %27 ], [ 1, %12 ]
%17 = call i64 @fgets(i8* %6, i32 100, i32* %8)
%18 = icmp eq i64 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %15
%20 = call i64 @strncmp(i8* %5, i8* %6, i32 100)
%21 = icmp eq i64 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %16)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %6)
br label %31
27: ; preds = %19
%28 = add nuw nsw i32 %16, 1
%29 = call i64 @fgets(i8* %5, i32 100, i32* %7)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %15
31: ; preds = %27, %15, %12, %22, %2
%32 = phi i32 [ 1, %2 ], [ 0, %22 ], [ 0, %12 ], [ 0, %15 ], [ 0, %27 ]
ret i32 %32
}