#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "\n DIFF File1 File2 \n");
    return (-1);
  }
  FILE *fp1 = fopen(argv[1], "r");
  if (fp1 == NULL) {
    fprintf(stderr, "\n Unable to open file1:%s \n", argv[1]);
    return (-2);
  }
  FILE *fp2 = fopen(argv[2], "r");
  if (fp2 == NULL) {
    fprintf(stderr, "\n Unable to open file2:%s \n", argv[2]);
    return (-3);
  }
  int ok1 = fseek(fp1, 0L, SEEK_END);
  long size1 = ftell(fp1);
  int ok2 = fseek(fp2, 0L, SEEK_END);
  long size2 = ftell(fp2);
  if (size2 > size1) {
    fseek(fp2, size1, SEEK_SET);
    while (!feof(fp2)) {
      int c = fgetc(fp2);
      if (c != -1) {
        fputc(c, stdout);
      }
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11b3 <main+0x43>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1315 <main+0x1a5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1201 <main+0x91>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1315 <main+0x1a5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe05(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    124f <main+0xdf>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1315 <main+0x1a5>
mov    -0x18(%rbp),%rdi
mov    0x2d8e(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <fseek@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d68(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <fseek@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jle    130e <main+0x19e>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x2d18(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12dd <main+0x16d>
jmp    1309 <main+0x199>
mov    -0x20(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
je     1304 <main+0x194>
mov    -0x44(%rbp),%edi
mov    0x2ccb(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
jmp    12bf <main+0x14f>
jmp    130e <main+0x19e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    $0x3,%edi
jne    1254 <main+0xe4>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe85(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1273 <main+0x103>
mov    %rax,%r12
mov    0x10(%rbx),%rdi
lea    0xe69(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1296 <main+0x126>
mov    %rax,%r15
mov    0x2e24(%rip),%r13
mov    0x0(%r13),%edx
xor    %r14d,%r14d
mov    %r12,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r12,%rdi
call   1060 <ftell@plt>
mov    %rax,%rbx
mov    0x0(%r13),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r15,%rdi
call   1060 <ftell@plt>
cmp    %rbx,%rax
jle    12b7 <main+0x147>
mov    0x2dca(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <fseek@plt>
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    12b7 <main+0x147>
mov    0x2d9e(%rip),%rbx
jmp    123c <main+0xcc>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    12b7 <main+0x147>
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    $0xffffffff,%eax
je     1230 <main+0xc0>
mov    (%rbx),%esi
mov    %eax,%edi
call   1040 <fputc@plt>
jmp    1230 <main+0xc0>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%r14d
jmp    12b7 <main+0x147>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xd90(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xfffffffe,%r14d
jmp    12b7 <main+0x147>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xd89(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xfffffffd,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"\0A DIFF File1 File2 \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"\0A Unable to open file1:%s \0A\00"
@.str.3 = [28 x i8] c"\0A Unable to open file2:%s \0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %80
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %29)
store i32 -2, i32* %3
br label %80
31: ; preds = %18
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %35, i32** %7
%36 = load i32*, i32** %7
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %44
38: ; preds = %31
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %42)
store i32 -3, i32* %3
br label %80
44: ; preds = %31
%45 = load i32*, i32** %6
%46 = load i32, i32* @SEEK_END
%47 = call i32 @fseek(i32* %45, i64 0, i32 %46)
store i32 %47, i32* %8
%48 = load i32*, i32** %6
%49 = call i64 @ftell(i32* %48)
store i64 %49, i64* %9
%50 = load i32*, i32** %7
%51 = load i32, i32* @SEEK_END
%52 = call i32 @fseek(i32* %50, i64 0, i32 %51)
store i32 %52, i32* %10
%53 = load i32*, i32** %7
%54 = call i64 @ftell(i32* %53)
store i64 %54, i64* %11
%55 = load i64, i64* %11
%56 = load i64, i64* %9
%57 = icmp sgt i64 %55, %56
br i1 %57, label %58, label %79
58: ; preds = %44
%59 = load i32*, i32** %7
%60 = load i64, i64* %9
%61 = load i32, i32* @SEEK_SET
%62 = call i32 @fseek(i32* %59, i64 %60, i32 %61)
br label %63
63: ; preds = %77, %58
%64 = load i32*, i32** %7
%65 = call i32 @feof(i32* %64)
%66 = icmp ne i32 %65, 0
%67 = xor i1 %66, true
br i1 %67, label %68, label %78
68: ; preds = %63
%69 = load i32*, i32** %7
%70 = call i32 @fgetc(i32* %69)
store i32 %70, i32* %12
%71 = load i32, i32* %12
%72 = icmp ne i32 %71, -1
br i1 %72, label %73, label %77
73: ; preds = %68
%74 = load i32, i32* %12
%75 = load i32, i32* @stdout
%76 = call i32 @fputc(i32 %74, i32 %75)
br label %77
77: ; preds = %73, %68
br label %63
78: ; preds = %63
br label %79
79: ; preds = %78, %44
store i32 0, i32* %3
br label %80
80: ; preds = %79, %38, %25, %15
%81 = load i32, i32* %3
ret i32 %81
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"\0A DIFF File1 File2 \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"\0A Unable to open file1:%s \0A\00"
@.str.3 = [28 x i8] c"\0A Unable to open file2:%s \0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %47
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %8
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %47
16: ; preds = %7
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %17
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %23)
br label %47
25: ; preds = %16
%26 = load i32, i32* @SEEK_END
%27 = tail call i32 @fseek(i32* %10, i64 0, i32 %26)
%28 = tail call i64 @ftell(i32* %10)
%29 = load i32, i32* @SEEK_END
%30 = tail call i32 @fseek(i32* %19, i64 0, i32 %29)
%31 = tail call i64 @ftell(i32* %19)
%32 = icmp sgt i64 %31, %28
br i1 %32, label %33, label %47
33: ; preds = %25
%34 = load i32, i32* @SEEK_SET
%35 = tail call i32 @fseek(i32* %19, i64 %28, i32 %34)
%36 = tail call i32 @feof(i32* %19)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %33, %44
%39 = tail call i32 @fgetc(i32* %19)
%40 = icmp eq i32 %39, -1
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load i32, i32* @stdout
%43 = tail call i32 @fputc(i32 %39, i32 %42)
br label %44
44: ; preds = %41, %38
%45 = tail call i32 @feof(i32* %19)
%46 = icmp eq i32 %45, 0
br i1 %46, label %38, label %47
47: ; preds = %44, %33, %12, %25, %21, %4
%48 = phi i32 [ -1, %4 ], [ -2, %12 ], [ -3, %21 ], [ 0, %25 ], [ 0, %33 ], [ 0, %44 ]
ret i32 %48
}