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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int readKeyFile(uint8_t key[8]) {
  FILE *f;
  int retval = 1;
  f = fopen("iclass_key.bin", "rb");
  if (f) {
    if (fread(key, sizeof(uint8_t), 8, f) == 1) {
      retval = 0;
    }
    fclose(f);
  }
  return retval;
}


x86 assembly (clang, -O0):
<readKeyFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xeb6(%rip),%rdi
lea    0xebe(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1195 <readKeyFile+0x65>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    118c <readKeyFile+0x5c>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readKeyFile>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     117a <readKeyFile+0x4a>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x8,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
setne  %bpl
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    117f <readKeyFile+0x4f>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"iclass_key.bin\00"
@.str.1 = [3 x i8] c"rb\00"
define i32 @readKeyFile(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %2
store i32 1, i32* %4
%5 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %17
8: ; preds = %1
%9 = load i32*, i32** %2
%10 = load i32*, i32** %3
%11 = call i32 @fread(i32* %9, i32 4, i32 8, i32* %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %8
store i32 0, i32* %4
br label %14
14: ; preds = %13, %8
%15 = load i32*, i32** %3
%16 = call i32 @fclose(i32* %15)
br label %17
17: ; preds = %14, %1
%18 = load i32, i32* %4
ret i32 %18
}

LLVM IR (-O2):
@.str = [15 x i8] c"iclass_key.bin\00"
@.str.1 = [3 x i8] c"rb\00"
define i32 @readKeyFile(i32* nocapture %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i32 @fread(i32* %0, i32 4, i32 8, i32* %2)
%6 = icmp ne i32 %5, 1
%7 = zext i1 %6 to i32
%8 = tail call i32 @fclose(i32* %2)
br label %9
9: ; preds = %4, %1
%10 = phi i32 [ %7, %4 ], [ 1, %1 ]
ret i32 %10
}