#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 /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ md5(unsigned char *, int, unsigned char *);
scalar_t__ memcmp(unsigned char *, char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  unsigned char md5sum[16];
  unsigned char buffer[4];
  int fd;
  if (argc != 2) {
    printf("Usage: %s <file>\n", argv[0]);
    exit(-1);
  }
  do {
    if (!((fd = open(argv[1], O_RDONLY)) != -1)) {
      perror("open");
      exit(-1);
    }
  } while (0);
  do {
    if (!(read(fd, buffer, 4) == 4)) {
      perror("read");
      exit(-1);
    }
  } while (0);
  md5(buffer, 4, md5sum);
  if (memcmp(md5sum,
             "\x88\x71\x75\xe5\x15\xcd\x3b\x47\x9f\x6a\xe6\xfb\x1a\x76\x13\x8e",
             16) == 0) {
    printf("ok\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)
cmpl   $0x2,-0x8(%rbp)
je     11af <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    11b4 <main+0x44>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
jne    11ec <main+0x7c>
lea    0xe35(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    11f1 <main+0x81>
jmp    11f6 <main+0x86>
mov    -0x28(%rbp),%edi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0x4,%eax
je     1226 <main+0xb6>
lea    0xe00(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    122b <main+0xbb>
lea    -0x24(%rbp),%rdi
lea    -0x20(%rbp),%rdx
mov    $0x4,%esi
call   1090 <md5@plt>
lea    -0x20(%rbp),%rdi
lea    0xdd4(%rip),%rsi
mov    $0x10,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    126a <main+0xfa>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
cmp    $0x2,%edi
jne    11fb <main+0x7b>
mov    0x8(%rsi),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     1216 <main+0x96>
lea    0xc(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1050 <read@plt>
cmp    $0x4,%eax
jne    121f <main+0x9f>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    $0x4,%esi
mov    %rbx,%rdx
call   10a0 <md5@plt>
lea    0xe47(%rip),%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
jne    11f3 <main+0x73>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
mov    (%rsi),%rsi
lea    0xdfb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
lea    0xdf5(%rip),%rdi
jmp    1226 <main+0xa6>
lea    0xdf1(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Usage: %s <file>\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"read\00"
@.str.3 = [17 x i8] c"\88qu\E5\15\CD;G\9Fj\E6\FB\1Av\13\8E\00"
@.str.4 = [4 x i8] c"ok\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [16 x i8]
%7 = alloca [4 x 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 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %2
br label %18
18: ; preds = %17
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i32, i32* @O_RDONLY
%23 = call i32 @open(i8* %21, i32 %22)
store i32 %23, i32* %8
%24 = icmp ne i32 %23, -1
br i1 %24, label %28, label %25
25: ; preds = %18
%26 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %18
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
%31 = load i32, i32* %8
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%33 = call i32 @read(i32 %31, i8* %32, i32 4)
%34 = icmp eq i32 %33, 4
br i1 %34, label %38, label %35
35: ; preds = %30
%36 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @exit(i32 -1)
unreachable
38: ; preds = %30
br label %39
39: ; preds = %38
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%41 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%42 = call i32 @md5(i8* %40, i32 4, i8* %41)
%43 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%44 = call i64 @memcmp(i8* %43, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 16)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %39
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %46, %39
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Usage: %s <file>\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"read\00"
@.str.3 = [17 x i8] c"\88qu\E5\15\CD;G\9Fj\E6\FB\1Av\13\8E\00"
@str = [3 x i8] c"ok\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_RDONLY
%16 = tail call i32 @open(i8* %14, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %12
%22 = call i32 @read(i32 %16, i8* %6, i32 4)
%23 = icmp eq i32 %22, 4
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = tail call i32 @exit(i32 -1)
unreachable
27: ; preds = %21
%28 = call i32 @md5(i8* %6, i32 4, i8* %5)
%29 = call i64 @memcmp(i8* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 16)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
ret i32 0
}