#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int compareFiles(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int main(int argc, char *argv[]) {
  int res, prec = sizeof(double);
  char pSrc1Fn[64], pSrc2Fn[64];
  if (argc == 4) {
    sprintf(pSrc1Fn, "%s", argv[1]);
    sprintf(pSrc2Fn, "%s", argv[2]);
    prec = atoi(argv[3]);
    if ((prec != 32) && (prec != 64)) {
      printf("Precision needs to be equal to 32 or 64\n");
      return EXIT_FAILURE;
    }
    prec = prec / 8;
  } else {
    printf("Usage: \n");
    printf("   ./compare filename1 filename2 precision(32 or 64)\n");
    return EXIT_FAILURE;
  }
  printf("Files %s and %s in %d bits precision.\n", pSrc1Fn, pSrc2Fn, prec * 8);
  res = compareFiles(pSrc1Fn, pSrc2Fn, prec);
  if (res == EXIT_FAILURE)
    return EXIT_FAILURE;
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x8,-0x18(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    11f3 <main+0xb3>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe83(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe68(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
je     11e0 <main+0xa0>
cmpl   $0x40,-0x18(%rbp)
je     11e0 <main+0xa0>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1284 <main+0x144>
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    1220 <main+0xe0>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1284 <main+0x144>
lea    -0x60(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
mov    -0x18(%rbp),%ecx
shl    $0x3,%ecx
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <compareFiles@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2d81(%rip),%rcx
cmp    (%rcx),%eax
jne    1278 <main+0x138>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1284 <main+0x144>
mov    0x2d59(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
cmp    $0x4,%edi
jne    11dc <main+0x8c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x40(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    0x18(%rbx),%rdi
call   1070 <atoi@plt>
cmp    $0x20,%eax
je     1191 <main+0x41>
cmp    $0x40,%eax
jne    11f1 <main+0xa1>
mov    %eax,%ebx
shr    $0x3,%ebx
and    $0xfffffff8,%eax
lea    0xe60(%rip),%rdi
lea    0x40(%rsp),%r14
mov    %rsp,%r15
mov    %r14,%rsi
mov    %r15,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1060 <compareFiles@plt>
mov    %eax,%ecx
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%ecx
je     1206 <main+0xb6>
mov    0x2dfe(%rip),%rax
jmp    1204 <main+0xb4>
lea    0xe44(%rip),%rdi
call   1040 <puts@plt>
lea    0xe40(%rip),%rdi
jmp    11f8 <main+0xa8>
lea    0xe6c(%rip),%rdi
call   1040 <puts@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [41 x i8] c"Precision needs to be equal to 32 or 64\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [9 x i8] c"Usage: \0A\00"
@.str.3 = [54 x i8] c" ./compare filename1 filename2 precision(32 or 64)\0A\00"
@.str.4 = [39 x i8] c"Files %s and %s in %d bits precision.\0A\00"
@EXIT_SUCCESS = 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 [64 x i8]
%9 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 8, i32* %7
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %38
12: ; preds = %2
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 32
br i1 %28, label %29, label %35
29: ; preds = %12
%30 = load i32, i32* %7
%31 = icmp ne i32 %30, 64
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
store i32 %34, i32* %3
br label %59
35: ; preds = %29, %12
%36 = load i32, i32* %7
%37 = sdiv i32 %36, 8
store i32 %37, i32* %7
br label %42
38: ; preds = %2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
store i32 %41, i32* %3
br label %59
42: ; preds = %35
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%44 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%45 = load i32, i32* %7
%46 = mul nsw i32 %45, 8
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %43, i8* %44, i32 %46)
%48 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%49 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%50 = load i32, i32* %7
%51 = call i32 @compareFiles(i8* %48, i8* %49, i32 %50)
store i32 %51, i32* %6
%52 = load i32, i32* %6
%53 = load i32, i32* @EXIT_FAILURE
%54 = icmp eq i32 %52, %53
br i1 %54, label %55, label %57
55: ; preds = %42
%56 = load i32, i32* @EXIT_FAILURE
store i32 %56, i32* %3
br label %59
57: ; preds = %42
%58 = load i32, i32* @EXIT_SUCCESS
store i32 %58, i32* %3
br label %59
59: ; preds = %57, %55, %38, %32
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.4 = [39 x i8] c"Files %s and %s in %d bits precision.\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [8 x i8] c"Usage: \00"
@str.5 = [53 x i8] c" ./compare filename1 filename2 precision(32 or 64)\00"
@str.6 = [40 x i8] c"Precision needs to be equal to 32 or 64\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 4
br i1 %7, label %8, label %30
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i8* @strcpy(i8* %5, i8* dereferenceable(1) %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = call i8* @strcpy(i8* %6, i8* dereferenceable(1) %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
switch i32 %17, label %18 [
i32 64, label %21
i32 32, label %21
]
18: ; preds = %8
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.6, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
br label %34
21: ; preds = %8, %8
%22 = lshr i32 %17, 3
%23 = and i32 %17, -8
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* %6, i32 %23)
%25 = call i32 @compareFiles(i8* %5, i8* %6, i32 %22)
%26 = load i32, i32* @EXIT_FAILURE
%27 = icmp eq i32 %25, %26
%28 = load i32, i32* @EXIT_SUCCESS
%29 = select i1 %27, i32 %26, i32 %28
br label %34
30: ; preds = %2
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.5, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
br label %34
34: ; preds = %21, %30, %18
%35 = phi i32 [ %20, %18 ], [ %33, %30 ], [ %29, %21 ]
ret i32 %35
}