#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*/ oldbuf;
typedef int /*<<< orphan*/ newbuf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int compare_file(FILE *old_f, FILE *new_f) {
  char oldbuf[2048], newbuf[2048], *oldcp, *newcp;
  int retval;
  while (1) {
    oldcp = fgets(oldbuf, sizeof(oldbuf), old_f);
    newcp = fgets(newbuf, sizeof(newbuf), new_f);
    if (!oldcp && !newcp) {
      retval = 1;
      break;
    }
    if (!oldcp || !newcp || strcmp(oldbuf, newbuf)) {
      retval = 0;
      break;
    }
  }
  return retval;
}


x86 assembly (clang, -O0):
<compare_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x800,%esi
call   1030 <fgets@plt>
mov    %rax,-0x1018(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x800,%esi
call   1030 <fgets@plt>
mov    %rax,-0x1020(%rbp)
cmpq   $0x0,-0x1018(%rbp)
jne    1196 <compare_file+0x76>
cmpq   $0x0,-0x1020(%rbp)
jne    1196 <compare_file+0x76>
movl   $0x1,-0x1024(%rbp)
jmp    11e3 <compare_file+0xc3>
cmpq   $0x0,-0x1018(%rbp)
je     11cf <compare_file+0xaf>
cmpq   $0x0,-0x1020(%rbp)
je     11cf <compare_file+0xaf>
lea    -0x810(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11de <compare_file+0xbe>
movl   $0x0,-0x1024(%rbp)
jmp    11e3 <compare_file+0xc3>
jmp    1133 <compare_file+0x13>
mov    -0x1024(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rsi,%r14
mov    %rdi,%r13
lea    0x800(%rsp),%r15
mov    %rsp,%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0x800,%esi
mov    %r13,%rdx
call   1030 <fgets@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x800,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
mov    %rbx,%rcx
or     %rax,%rcx
je     1197 <compare_file+0x77>
test   %rbx,%rbx
je     119c <compare_file+0x7c>
test   %rax,%rax
je     119c <compare_file+0x7c>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1150 <compare_file+0x30>
jmp    119c <compare_file+0x7c>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @compare_file(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [2048 x i8]
%6 = alloca [2048 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %10
10: ; preds = %2, %35
%11 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i8* @fgets(i8* %11, i32 2048, i32* %12)
store i8* %13, i8** %7
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i8* @fgets(i8* %14, i32 2048, i32* %15)
store i8* %16, i8** %8
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %23, label %19
19: ; preds = %10
%20 = load i8*, i8** %8
%21 = icmp ne i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %19
store i32 1, i32* %9
br label %36
23: ; preds = %19, %10
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = load i8*, i8** %8
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%32 = call i64 @strcmp(i8* %30, i8* %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %29, %26, %23
store i32 0, i32* %9
br label %36
35: ; preds = %29
br label %10
36: ; preds = %34, %22
%37 = load i32, i32* %9
ret i32 %37
}

LLVM IR (-O2):
define i32 @compare_file(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [2048 x i8]
%4 = alloca [2048 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %15, %2
%8 = call i8* @fgets(i8* %5, i32 2048, i32* %0)
%9 = call i8* @fgets(i8* %6, i32 2048, i32* %1)
%10 = icmp ne i8* %8, null
%11 = icmp ne i8* %9, null
%12 = or i1 %10, %11
br i1 %12, label %13, label %18
13: ; preds = %7
%14 = and i1 %10, %11
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = call i64 @strcmp(i8* %5, i8* %6)
%17 = icmp eq i64 %16, 0
br i1 %17, label %7, label %18
18: ; preds = %13, %15, %7
%19 = phi i32 [ 1, %7 ], [ 0, %15 ], [ 0, %13 ]
ret i32 %19
}