#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*/ generatekey(char *, char const *);
scalar_t__ getcpuid();
int /*<<< orphan*/ isFileExists(char *);
int memcmp(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ serialread(char *);
int validatekey() {
  if (!isFileExists("/boot/license.img"))
    return -1;
  return memcmp(serialread("/boot/license.img"),
                generatekey("1234567890", (const char *)getcpuid()), 64);
}


x86 assembly (clang, -O0):
<validatekey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1070 <isFileExists@plt>
cmp    $0x0,%eax
jne    1179 <validatekey+0x29>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <validatekey+0x60>
lea    0xe80(%rip),%rdi
call   1060 <serialread@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getcpuid@plt>
mov    %rax,%rsi
lea    0xe79(%rip),%rdi
call   1040 <generatekey@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%esi
mov    $0x40,%edx
call   1030 <memcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validatekey>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1070 <isFileExists@plt>
test   %eax,%eax
je     1194 <validatekey+0x44>
lea    0xe98(%rip),%rdi
call   1060 <serialread@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <getcpuid@plt>
lea    0xe95(%rip),%rdi
mov    %rax,%rsi
call   1040 <generatekey@plt>
mov    %ebx,%edi
mov    %eax,%esi
mov    $0x40,%edx
pop    %rbx
jmp    1030 <memcmp@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"/boot/license.img\00"
@.str.1 = [11 x i8] c"1234567890\00"
define i32 @validatekey() {
%1 = alloca i32
%2 = call i32 @isFileExists(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i32 %2, 0
br i1 %3, label %5, label %4
4: ; preds = %0
store i32 -1, i32* %1
br label %11
5: ; preds = %0
%6 = call i32 @serialread(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i64 (...) @getcpuid()
%8 = inttoptr i64 %7 to i8*
%9 = call i32 @generatekey(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 @memcmp(i32 %6, i32 %9, i32 64)
store i32 %10, i32* %1
br label %11
11: ; preds = %5, %4
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@.str = [18 x i8] c"/boot/license.img\00"
@.str.1 = [11 x i8] c"1234567890\00"
define i32 @validatekey() {
%1 = tail call i32 @isFileExists(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = tail call i32 @serialread(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = tail call i64 (...) @getcpuid()
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @generatekey(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = tail call i32 @memcmp(i32 %4, i32 %7, i32 64)
br label %9
9: ; preds = %0, %3
%10 = phi i32 [ %8, %3 ], [ -1, %0 ]
ret i32 %10
}