#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
unsigned int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ x11_hash(char *, char *);
int main(int argc, char **argv) {
  {
    char in[80];
    char hash[32];
    char res[32];
    FILE *f = fopen("hashlist.data", "rb");
    if (f) {
      char buf[128];
      while (1) {
        unsigned r = fread(buf, 1, 6, f);
        if (!r)
          break;
        r = fread(in, 1, 80, f);
        if (!r)
          break;
        r = fread(buf, 1, 7, f);
        if (!r)
          break;
        r = fread(hash, 1, 32, f);
        if (!r)
          break;
        r = fread(buf, 1, 2, f);
        if (!r)
          break;
        x11_hash(in, res);
        if (memcmp(res, hash, 32) != 0) {
          printf("ERROR, incorrect hash\n");
        } else {
          printf("Correct hash\n");
        }
      }
      fclose(f);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
je     1306 <main+0x1a6>
jmp    11a6 <main+0x46>
lea    -0x130(%rbp),%rdi
mov    -0xa8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x6,%edx
call   1030 <fread@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
jne    11db <main+0x7b>
jmp    12fa <main+0x19a>
lea    -0x60(%rbp),%rdi
mov    -0xa8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x50,%edx
call   1030 <fread@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
jne    120d <main+0xad>
jmp    12fa <main+0x19a>
lea    -0x130(%rbp),%rdi
mov    -0xa8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x7,%edx
call   1030 <fread@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
jne    1242 <main+0xe2>
jmp    12fa <main+0x19a>
lea    -0x80(%rbp),%rdi
mov    -0xa8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x20,%edx
call   1030 <fread@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
jne    1274 <main+0x114>
jmp    12fa <main+0x19a>
lea    -0x130(%rbp),%rdi
mov    -0xa8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
jne    12a9 <main+0x149>
jmp    12fa <main+0x19a>
lea    -0x60(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1070 <x11_hash@plt>
lea    -0xa0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x20,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     12e9 <main+0x189>
lea    0xd32(%rip),%rdi
call   1050 <printf@plt>
jmp    12f5 <main+0x195>
lea    0xd38(%rip),%rdi
call   1050 <printf@plt>
jmp    11a6 <main+0x46>
mov    -0xa8(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
lea    0xe88(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1292 <main+0x132>
mov    %rax,%rbx
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     128a <main+0x12a>
lea    0xc0(%rsp),%r14
lea    0x40(%rsp),%r15
lea    0x20(%rsp),%r12
mov    %rsp,%r13
lea    0xe53(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x50,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     128a <main+0x12a>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x7,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     128a <main+0x12a>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x20,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     128a <main+0x12a>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     128a <main+0x12a>
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <x11_hash@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x20,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
mov    %rbp,%rdi
lea    0xdad(%rip),%rax
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %eax,%eax
jne    11d0 <main+0x70>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"hashlist.data\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [23 x i8] c"ERROR, incorrect hash\0A\00"
@.str.3 = [14 x i8] c"Correct hash\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
%9 = alloca i32*
%10 = alloca [128 x i8]
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %9
%13 = load i32*, i32** %9
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %67
15: ; preds = %2
br label %16
16: ; preds = %15, %63
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%18 = load i32*, i32** %9
%19 = call i32 @fread(i8* %17, i32 1, i32 6, i32* %18)
store i32 %19, i32* %11
%20 = load i32, i32* %11
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %16
br label %64
23: ; preds = %16
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%25 = load i32*, i32** %9
%26 = call i32 @fread(i8* %24, i32 1, i32 80, i32* %25)
store i32 %26, i32* %11
%27 = load i32, i32* %11
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %23
br label %64
30: ; preds = %23
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%32 = load i32*, i32** %9
%33 = call i32 @fread(i8* %31, i32 1, i32 7, i32* %32)
store i32 %33, i32* %11
%34 = load i32, i32* %11
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %30
br label %64
37: ; preds = %30
%38 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%39 = load i32*, i32** %9
%40 = call i32 @fread(i8* %38, i32 1, i32 32, i32* %39)
store i32 %40, i32* %11
%41 = load i32, i32* %11
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %37
br label %64
44: ; preds = %37
%45 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%46 = load i32*, i32** %9
%47 = call i32 @fread(i8* %45, i32 1, i32 2, i32* %46)
store i32 %47, i32* %11
%48 = load i32, i32* %11
%49 = icmp ne i32 %48, 0
br i1 %49, label %51, label %50
50: ; preds = %44
br label %64
51: ; preds = %44
%52 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%53 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%54 = call i32 @x11_hash(i8* %52, i8* %53)
%55 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%56 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%57 = call i64 @memcmp(i8* %55, i8* %56, i32 32)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %51
%60 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %63
61: ; preds = %51
%62 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %63
63: ; preds = %61, %59
br label %16
64: ; preds = %50, %43, %36, %29, %22
%65 = load i32*, i32** %9
%66 = call i32 @fclose(i32* %65)
br label %67
67: ; preds = %64, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"hashlist.data\00"
@.str.1 = [3 x i8] c"rb\00"
@str = [13 x i8] c"Correct hash\00"
@str.4 = [22 x i8] c"ERROR, incorrect hash\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [80 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [128 x i8]
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %38, label %12
12: ; preds = %2
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%14 = call i32 @fread(i8* %13, i32 1, i32 6, i32* %10)
%15 = icmp eq i32 %14, 0
br i1 %15, label %36, label %16
16: ; preds = %12, %28
%17 = call i32 @fread(i8* %7, i32 1, i32 80, i32* %10)
%18 = icmp eq i32 %17, 0
br i1 %18, label %36, label %19
19: ; preds = %16
%20 = call i32 @fread(i8* %13, i32 1, i32 7, i32* %10)
%21 = icmp eq i32 %20, 0
br i1 %21, label %36, label %22
22: ; preds = %19
%23 = call i32 @fread(i8* %8, i32 1, i32 32, i32* %10)
%24 = icmp eq i32 %23, 0
br i1 %24, label %36, label %25
25: ; preds = %22
%26 = call i32 @fread(i8* %13, i32 1, i32 2, i32* %10)
%27 = icmp eq i32 %26, 0
br i1 %27, label %36, label %28
28: ; preds = %25
%29 = call i32 @x11_hash(i8* %7, i8* %9)
%30 = call i64 @memcmp(i8* %9, i8* %8, i32 32)
%31 = icmp eq i64 %30, 0
%32 = select i1 %31, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0)
%33 = call i32 @puts(i8* dereferenceable(1) %32)
%34 = call i32 @fread(i8* %13, i32 1, i32 6, i32* %10)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %16
36: ; preds = %25, %22, %19, %16, %28, %12
%37 = call i32 @fclose(i32* %10)
br label %38
38: ; preds = %36, %2
ret i32 0
}