#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 scalar_t__ int32_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ checkResults(void *);
int /*<<< orphan*/ compareResults(void *, void *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ freeResults(void *);
int /*<<< orphan*/ intersectResults(void *, void *);
scalar_t__ loadResults(unsigned char *, void **);
int /*<<< orphan*/ printf(char *, ...);
char *processError(scalar_t__);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  void *oldResults, *newResults;
  int32_t error;
  unsigned char *oldFile = argv[1];
  unsigned char *newFile = argv[2];
  if (argc != 3) {
    printf("[INFO] This program check the correctness of the SW results \n");
    printf("Usage: ./checksum oldFile newFileToCheck\n");
    return (0);
  }
  printf("[INFO] Loading results: %s ...\n", oldFile);
  error = loadResults(oldFile, &oldResults);
  {{if (error){fprintf(stderr, "%s\n", processError(error));
  exit(EXIT_FAILURE);
}
}
}
;
printf("[INFO] Loading results: %s ...\n", newFile);
error = loadResults(newFile, &newResults);
{{if (error){fprintf(stderr, "%s\n", processError(error));
exit(EXIT_FAILURE);
}
}
}
;
printf("[INFO] Checking results ...\n");
checkResults(newResults);
printf("[INFO] Comparing results ...\n");
compareResults(oldResults, newResults);
printf("[INFO] Intersecting results ...\n");
intersectResults(oldResults, newResults);
error = freeResults(oldResults);
{{if (error){fprintf(stderr, "%s\n", processError(error));
exit(EXIT_FAILURE);
}
}
}
;
error = freeResults(newResults);
{{if (error){fprintf(stderr, "%s\n", processError(error));
exit(EXIT_FAILURE);
}
}
}
;
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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11f0 <main+0x60>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13a4 <main+0x214>
mov    -0x30(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <loadResults@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1253 <main+0xc3>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
call   10a0 <processError@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xe48(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x38(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <loadResults@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12b6 <main+0x126>
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   10a0 <processError@plt>
mov    -0x40(%rbp),%edi
mov    %rax,%rdx
lea    0xde5(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1080 <checkResults@plt>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <compareResults@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <intersectResults@plt>
mov    -0x18(%rbp),%rdi
call   1030 <freeResults@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1350 <main+0x1c0>
mov    0x2cbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
call   10a0 <processError@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xd4b(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1030 <freeResults@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     139d <main+0x20d>
mov    0x2c71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
call   10a0 <processError@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rdx
lea    0xcfe(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c42(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    129c <main+0xfc>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r14
lea    0xe41(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <loadResults@plt>
test   %rax,%rax
jne    126c <main+0xcc>
lea    0xe1a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1040 <loadResults@plt>
test   %rax,%rax
jne    126c <main+0xcc>
lea    0xe1b(%rip),%rdi
call   1050 <puts@plt>
mov    0x8(%rsp),%rdi
call   1090 <checkResults@plt>
lea    0xe21(%rip),%rdi
call   1050 <puts@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   10a0 <compareResults@plt>
lea    0xe23(%rip),%rdi
call   1050 <puts@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   1060 <intersectResults@plt>
mov    0x10(%rsp),%rdi
call   1030 <freeResults@plt>
test   %rax,%rax
jne    126c <main+0xcc>
mov    0x8(%rsp),%rdi
call   1030 <freeResults@plt>
test   %rax,%rax
je     12b4 <main+0x114>
mov    0x2d6d(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   10b0 <processError@plt>
lea    0xd9c(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1080 <fprintf@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    0xdda(%rip),%rdi
call   1050 <puts@plt>
lea    0xe0b(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [62 x i8] c"[INFO] This program check the correctness of the SW results \0A\00"
@.str.1 = [42 x i8] c"Usage: ./checksum oldFile newFileToCheck\0A\00"
@.str.2 = [32 x i8] c"[INFO] Loading results: %s ...\0A\00"
@stderr = global i32 0
@.str.3 = [4 x i8] c"%s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [29 x i8] c"[INFO] Checking results ...\0A\00"
@.str.5 = [30 x i8] c"[INFO] Comparing results ...\0A\00"
@.str.6 = [33 x i8] c"[INFO] Intersecting results ...\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 i64
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
store i8* %13, i8** %9
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
store i8* %16, i8** %10
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 3
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %86
22: ; preds = %2
%23 = load i8*, i8** %9
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %9
%26 = call i64 @loadResults(i8* %25, i8** %6)
store i64 %26, i64* %8
%27 = load i64, i64* %8
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = load i64, i64* %8
%32 = call i8* @processError(i64 %31)
%33 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %22
%37 = load i8*, i8** %10
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %10
%40 = call i64 @loadResults(i8* %39, i8** %7)
store i64 %40, i64* %8
%41 = load i64, i64* %8
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %36
%44 = load i32, i32* @stderr
%45 = load i64, i64* %8
%46 = call i8* @processError(i64 %45)
%47 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %46)
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %36
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%52 = load i8*, i8** %7
%53 = call i32 @checkResults(i8* %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%55 = load i8*, i8** %6
%56 = load i8*, i8** %7
%57 = call i32 @compareResults(i8* %55, i8* %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%59 = load i8*, i8** %6
%60 = load i8*, i8** %7
%61 = call i32 @intersectResults(i8* %59, i8* %60)
%62 = load i8*, i8** %6
%63 = call i64 @freeResults(i8* %62)
store i64 %63, i64* %8
%64 = load i64, i64* %8
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %73
66: ; preds = %50
%67 = load i32, i32* @stderr
%68 = load i64, i64* %8
%69 = call i8* @processError(i64 %68)
%70 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %69)
%71 = load i32, i32* @EXIT_FAILURE
%72 = call i32 @exit(i32 %71)
unreachable
73: ; preds = %50
%74 = load i8*, i8** %7
%75 = call i64 @freeResults(i8* %74)
store i64 %75, i64* %8
%76 = load i64, i64* %8
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %85
78: ; preds = %73
%79 = load i32, i32* @stderr
%80 = load i64, i64* %8
%81 = call i8* @processError(i64 %80)
%82 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %81)
%83 = load i32, i32* @EXIT_FAILURE
%84 = call i32 @exit(i32 %83)
unreachable
85: ; preds = %73
store i32 0, i32* %3
br label %86
86: ; preds = %85, %19
%87 = load i32, i32* %3
ret i32 %87
}

LLVM IR (-O2):
@.str.2 = [32 x i8] c"[INFO] Loading results: %s ...\0A\00"
@stderr = global i32 0
@.str.3 = [4 x i8] c"%s\0A\00"
@EXIT_FAILURE = global i32 0
@str = [28 x i8] c"[INFO] Checking results ...\00"
@str.7 = [29 x i8] c"[INFO] Comparing results ...\00"
@str.8 = [32 x i8] c"[INFO] Intersecting results ...\00"
@str.9 = [61 x i8] c"[INFO] This program check the correctness of the SW results \00"
@str.10 = [41 x i8] c"Usage: ./checksum oldFile newFileToCheck\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %3 to i8*
%6 = bitcast i8** %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = icmp eq i32 %0, 3
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.9, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.10, i64 0, i64 0))
br label %66
15: ; preds = %2
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%17 = call i64 @loadResults(i8* %8, i8** %3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = call i8* @processError(i64 %17)
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %15
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%27 = call i64 @loadResults(i8* %10, i8** %4)
%28 = icmp eq i64 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = call i8* @processError(i64 %27)
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %25
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%37 = load i8*, i8** %4
%38 = call i32 @checkResults(i8* %37)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.7, i64 0, i64 0))
%40 = load i8*, i8** %3
%41 = load i8*, i8** %4
%42 = call i32 @compareResults(i8* %40, i8* %41)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
%44 = load i8*, i8** %3
%45 = load i8*, i8** %4
%46 = call i32 @intersectResults(i8* %44, i8* %45)
%47 = load i8*, i8** %3
%48 = call i64 @freeResults(i8* %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %56, label %50
50: ; preds = %35
%51 = load i32, i32* @stderr
%52 = call i8* @processError(i64 %48)
%53 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %35
%57 = load i8*, i8** %4
%58 = call i64 @freeResults(i8* %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %66, label %60
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = call i8* @processError(i64 %58)
%63 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %62)
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %56, %12
ret i32 0
}