#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 */
char *MD5File(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcasecmp(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char *md5sum = NULL, buf[65];
  if (argc < 3) {
    fprintf(stderr, "USAGE: %s <correct MD5 sum> <file>\n", argv[0]);
    return -1;
  }
  if (strlen(argv[1]) != 32)
    fprintf(stderr, "WARNING: MD5 hash size is wrong.\n");
  md5sum = MD5File(argv[2], buf);
  if (!md5sum) {
    perror("Could not obtain MD5 sum");
    return -1;
  }
  if (!strcasecmp(md5sum, argv[1])) {
    fprintf(stderr, "%s: OK\n", argv[2]);
    return 0;
  } else {
    fprintf(stderr, "%s: FAILED.  Checksum is %s\n", argv[2], md5sum);
    return -1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11a2 <main+0x52>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1276 <main+0x126>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x20,%eax
je     11cf <main+0x7f>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x60(%rbp),%rsi
call   1070 <MD5File@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1207 <main+0xb7>
lea    0xe50(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1276 <main+0x126>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    124c <main+0xfc>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1276 <main+0x126>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     117b <main+0x2b>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe8e(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11e2 <main+0x92>
mov    0x8(%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x20,%eax
je     11a0 <main+0x50>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x10(%rbx),%rdi
mov    %rsp,%rsi
call   1070 <MD5File@plt>
test   %rax,%rax
je     1203 <main+0xb3>
mov    %rax,%r14
mov    0x8(%rbx),%rsi
mov    %rax,%rdi
call   1030 <strcasecmp@plt>
mov    0x2e19(%rip),%rcx
mov    (%rcx),%edi
mov    0x10(%rbx),%rdx
test   %eax,%eax
je     11f1 <main+0xa1>
lea    0xe8f(%rip),%rsi
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe67(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11e7 <main+0x97>
lea    0xe3c(%rip),%rdi
call   1060 <perror@plt>
jmp    11e2 <main+0x92>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"USAGE: %s <correct MD5 sum> <file>\0A\00"
@.str.1 = [34 x i8] c"WARNING: MD5 hash size is wrong.\0A\00"
@.str.2 = [25 x i8] c"Could not obtain MD5 sum\00"
@.str.3 = [8 x i8] c"%s: OK\0A\00"
@.str.4 = [29 x i8] c"%s: FAILED. Checksum is %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [65 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 -1, i32* %3
br label %55
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
%21 = icmp ne i32 %20, 32
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %22, %16
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = getelementptr inbounds [65 x i8], [65 x i8]* %7, i64 0, i64 0
%30 = call i8* @MD5File(i8* %28, i8* %29)
store i8* %30, i8** %6
%31 = load i8*, i8** %6
%32 = icmp ne i8* %31, null
br i1 %32, label %35, label %33
33: ; preds = %25
%34 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %55
35: ; preds = %25
%36 = load i8*, i8** %6
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 @strcasecmp(i8* %36, i8* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %35
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %46)
store i32 0, i32* %3
br label %55
48: ; preds = %35
%49 = load i32, i32* @stderr
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = load i8*, i8** %6
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %52, i8* %53)
store i32 -1, i32* %3
br label %55
55: ; preds = %48, %42, %33, %10
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"USAGE: %s <correct MD5 sum> <file>\0A\00"
@.str.1 = [34 x i8] c"WARNING: MD5 hash size is wrong.\0A\00"
@.str.2 = [25 x i8] c"Could not obtain MD5 sum\00"
@.str.3 = [8 x i8] c"%s: OK\0A\00"
@.str.4 = [29 x i8] c"%s: FAILED. Checksum is %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65 x i8]
%4 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %35
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @strlen(i8* %12)
%14 = icmp eq i32 %13, 32
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %10
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = call i8* @MD5File(i8* %20, i8* %4)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %35
25: ; preds = %18
%26 = load i8*, i8** %11
%27 = call i32 @strcasecmp(i8* %21, i8* %26)
%28 = icmp eq i32 %27, 0
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %19
br i1 %28, label %31, label %33
31: ; preds = %25
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %35
33: ; preds = %25
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %30, i8* %21)
br label %35
35: ; preds = %33, %31, %23, %6
%36 = phi i32 [ -1, %6 ], [ -1, %33 ], [ 0, %31 ], [ -1, %23 ]
ret i32 %36
}