#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 */

/* Variables and functions */
int check_filenames(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int process_file(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char *in_filename;
  char *out_filename;
  argc--;
  argv++;
  if (argc == 2) {
    in_filename = argv[0];
    out_filename = argv[1];
  } else if (argc == 1) {
    in_filename = NULL;
    out_filename = argv[0];
  } else {
    fprintf(stderr, "Not enough arguments\n\n");
    usage();
    exit(1);
  }
  int ret = check_filenames(in_filename, out_filename);
  if (ret == 1) {
    fprintf(stderr, "Files are the same.\n");
  }
  if (ret > 0) {
    exit(1);
  }
  exit(process_file(in_filename, out_filename));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11a1 <main+0x51>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    11ee <main+0x9e>
cmpl   $0x1,-0x8(%rbp)
jne    11c3 <main+0x73>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    11e9 <main+0x99>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11ee <main+0x9e>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <check_filenames@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    121d <main+0xcd>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
call   1050 <fprintf@plt>
cmpl   $0x0,-0x24(%rbp)
jle    1231 <main+0xe1>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <process_file@plt>
mov    %eax,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
je     1168 <main+0x18>
cmp    $0x3,%edi
jne    1199 <main+0x49>
mov    0x8(%rsi),%r14
add    $0x10,%rsi
jmp    116f <main+0x1f>
add    $0x8,%rsi
xor    %r14d,%r14d
mov    (%rsi),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <check_filenames@plt>
cmp    $0x1,%eax
jne    11bf <main+0x6f>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11c1 <main+0x71>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1060 <usage@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jl     11cb <main+0x7b>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <process_file@plt>
mov    %eax,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"Not enough arguments\0A\0A\00"
@.str.1 = [21 x i8] c"Files are the same.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = add nsw i32 %9, -1
store i32 %10, i32* %4
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i32 1
store i8** %12, i8*** %5
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
store i8* %18, i8** %6
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %7
br label %35
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %29
25: ; preds = %22
store i8* null, i8** %6
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
store i8* %28, i8** %7
br label %34
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%32 = call i32 (...) @usage()
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %25
br label %35
35: ; preds = %34, %15
%36 = load i8*, i8** %6
%37 = load i8*, i8** %7
%38 = call i32 @check_filenames(i8* %36, i8* %37)
store i32 %38, i32* %8
%39 = load i32, i32* %8
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %41, %35
%45 = load i32, i32* %8
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %44
%50 = load i8*, i8** %6
%51 = load i8*, i8** %7
%52 = call i32 @process_file(i8* %50, i8* %51)
%53 = call i32 @exit(i32 %52)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"Not enough arguments\0A\0A\00"
@.str.1 = [21 x i8] c"Files are the same.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
switch i32 %0, label %7 [
i32 3, label %4
i32 2, label %12
]
4: ; preds = %2
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8*, i8** %1, i64 2
br label %12
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 (...) @usage()
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2, %4
%13 = phi i8* [ %5, %4 ], [ null, %2 ]
%14 = phi i8** [ %6, %4 ], [ %3, %2 ]
%15 = load i8*, i8** %14
%16 = tail call i32 @check_filenames(i8* %13, i8* %15)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %23
21: ; preds = %12
%22 = icmp sgt i32 %16, 0
br i1 %22, label %23, label %25
23: ; preds = %18, %21
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %21
%26 = tail call i32 @process_file(i8* %13, i8* %15)
%27 = tail call i32 @exit(i32 %26)
unreachable
}