#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 access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ bin_diff(int, char *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int i = 0, verbose = 0;
  char *oldf, *newf, *outf;
  if (argc == 5 && strcmp(argv[1], "-v") == 0) {
    i++;
    verbose++;
  } else if (argc != 4) {
    printf("usage: %s [-v] old_file new_file out_patch\n", argv[0]);
    return 0;
  }
  oldf = argv[++i];
  newf = argv[++i];
  outf = argv[++i];
  if (access(outf, 0) != -1)
    printf("output file already exists\n");
  else {
    bin_diff(verbose, oldf, newf, outf);
    printf("done!\n");
  }
  return 0;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x8(%rbp)
jne    11a3 <main+0x63>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe83(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a3 <main+0x63>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d3 <main+0x93>
cmpl   $0x4,-0x8(%rbp)
je     11ce <main+0x8e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    126b <main+0x12b>
jmp    11d3 <main+0x93>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1060 <access@plt>
cmp    $0xffffffff,%eax
je     1242 <main+0x102>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1264 <main+0x124>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1050 <bin_diff@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
je     118d <main+0x3d>
cmp    $0x5,%edi
jne    117a <main+0x2a>
mov    0x8(%rbx),%rdi
lea    0xe90(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1192 <main+0x42>
mov    (%rbx),%rsi
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e2 <main+0x92>
xor    %r14d,%r14d
jmp    1198 <main+0x48>
mov    $0x1,%r14d
mov    %r14d,%eax
mov    0x8(%rbx,%rax,8),%r12
mov    0x18(%rbx,%rax,8),%r15
lea    0x2(%r14),%eax
mov    (%rbx,%rax,8),%rbx
mov    %r15,%rdi
xor    %esi,%esi
call   1070 <access@plt>
cmp    $0xffffffff,%eax
je     11c5 <main+0x75>
lea    0xe72(%rip),%rdi
jmp    11dd <main+0x8d>
mov    %r14d,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1060 <bin_diff@plt>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-v\00"
@.str.1 = [44 x i8] c"usage: %s [-v] old_file new_file out_patch\0A\00"
@.str.2 = [28 x i8] c"output file already exists\0A\00"
@.str.3 = [7 x i8] c"done!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 5
br i1 %12, label %13, label %24
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %33
24: ; preds = %13, %2
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 4
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 0, i32* %3
br label %65
32: ; preds = %24
br label %33
33: ; preds = %32, %19
%34 = load i8**, i8*** %5
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %34, i64 %37
%39 = load i8*, i8** %38
store i8* %39, i8** %8
%40 = load i8**, i8*** %5
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %40, i64 %43
%45 = load i8*, i8** %44
store i8* %45, i8** %9
%46 = load i8**, i8*** %5
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %46, i64 %49
%51 = load i8*, i8** %50
store i8* %51, i8** %10
%52 = load i8*, i8** %10
%53 = call i32 @access(i8* %52, i32 0)
%54 = icmp ne i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %33
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %64
57: ; preds = %33
%58 = load i32, i32* %7
%59 = load i8*, i8** %8
%60 = load i8*, i8** %9
%61 = load i8*, i8** %10
%62 = call i32 @bin_diff(i32 %58, i8* %59, i8* %60, i8* %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %57, %55
store i32 0, i32* %3
br label %65
65: ; preds = %64, %27
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [3 x i8] c"-v\00"
@.str.1 = [44 x i8] c"usage: %s [-v] old_file new_file out_patch\0A\00"
@str = [6 x i8] c"done!\00"
@str.4 = [27 x i8] c"output file already exists\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %8 [
i32 5, label %3
i32 4, label %11
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3, %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %32
11: ; preds = %2, %3
%12 = phi i32 [ 1, %3 ], [ 0, %2 ]
%13 = add nuw nsw i32 %12, 1
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = or i32 %12, 2
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = add nuw nsw i32 %12, 3
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = tail call i32 @access(i8* %24, i32 0)
%26 = icmp eq i32 %25, -1
br i1 %26, label %29, label %27
27: ; preds = %11
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0))
br label %32
29: ; preds = %11
%30 = tail call i32 @bin_diff(i32 %12, i8* %16, i8* %20, i8* %24)
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %27, %29, %8
ret i32 0
}