#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*/ uint8_t;

/* Variables and functions */
int EOF;
scalar_t__ feof(int /*<<< orphan*/);
int fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
size_t fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int read_key(uint8_t key[64]) {
  size_t rc = fread(key, 1, 64, stdin);
  int end = fgetc(stdin);
  if (rc == 64 && end == EOF && feof(stdin)) {
    return 0;
  }
  fprintf(stderr, "error: input key must be %d bytes\n", 64);
  return -1;
}


x86 assembly (clang, -O0):
<read_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x40,%edx
call   1030 <fread@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
cmpq   $0x40,-0x18(%rbp)
jne    11be <read_key+0x7e>
mov    -0x1c(%rbp),%eax
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%eax
jne    11be <read_key+0x7e>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11be <read_key+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11df <read_key+0x9f>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
mov    $0x40,%edx
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_key>:
push   %r14
push   %rbx
push   %rax
mov    0x2e9d(%rip),%r14
mov    (%r14),%ecx
mov    $0x1,%esi
mov    $0x40,%edx
call   1030 <fread@plt>
mov    %rax,%rbx
mov    (%r14),%edi
call   1040 <fgetc@plt>
cmp    $0x40,%rbx
jne    118b <read_key+0x4b>
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%eax
jne    118b <read_key+0x4b>
mov    (%r14),%edi
call   1060 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11aa <read_key+0x6a>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
mov    $0x40,%edx
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"error: input key must be %d bytes\0A\00"
define i32 @read_key(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = load i32, i32* @stdin
%8 = call i64 @fread(i32* %6, i32 1, i32 64, i32 %7)
store i64 %8, i64* %4
%9 = load i32, i32* @stdin
%10 = call i32 @fgetc(i32 %9)
store i32 %10, i32* %5
%11 = load i64, i64* %4
%12 = icmp eq i64 %11, 64
br i1 %12, label %13, label %22
13: ; preds = %1
%14 = load i32, i32* %5
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i32, i32* @stdin
%19 = call i64 @feof(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 0, i32* %2
br label %25
22: ; preds = %17, %13, %1
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 64)
store i32 -1, i32* %2
br label %25
25: ; preds = %22, %21
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"error: input key must be %d bytes\0A\00"
define i32 @read_key(i32* %0) {
%2 = load i32, i32* @stdin
%3 = tail call i64 @fread(i32* %0, i32 1, i32 64, i32 %2)
%4 = load i32, i32* @stdin
%5 = tail call i32 @fgetc(i32 %4)
%6 = icmp eq i64 %3, 64
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %5, %7
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @stdin
%12 = tail call i64 @feof(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10, %1
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 64)
br label %17
17: ; preds = %10, %14
%18 = phi i32 [ -1, %14 ], [ 0, %10 ]
ret i32 %18
}