#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ *output;
  scalar_t__ *input;
  int /*<<< orphan*/ cmd_select;
  int /*<<< orphan*/ cmd_class;
};
struct dell_wmi_smbios_buffer {
  TYPE_1__ std;
};
typedef scalar_t__ __u16;

/* Variables and functions */
int /*<<< orphan*/ CLASS_TOKEN_READ;
int /*<<< orphan*/ SELECT_TOKEN_STD;
int run_wmi_smbios_cmd(struct dell_wmi_smbios_buffer *);
int token_is_active(__u16 *location, __u16 *cmpvalue,
                    struct dell_wmi_smbios_buffer *buffer) {
  int ret;
  buffer->std.cmd_class = CLASS_TOKEN_READ;
  buffer->std.cmd_select = SELECT_TOKEN_STD;
  buffer->std.input[0] = *location;
  ret = run_wmi_smbios_cmd(buffer);
  if (ret != 0 || buffer->std.output[0] != 0)
    return ret;
  ret = (buffer->std.output[1] == *cmpvalue);
  return ret;
}


x86 assembly (clang, -O0):
<token_is_active>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    0x2eb5(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <run_wmi_smbios_cmd@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    117d <token_is_active+0x6d>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
cmpq   $0x0,(%rax)
je     1188 <token_is_active+0x78>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ab <token_is_active+0x9b>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<token_is_active>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    0x2eb7(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rdx)
mov    0x2ec3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rdx)
mov    (%rdi),%rax
mov    0x8(%rdx),%rcx
mov    %rax,(%rcx)
mov    %rdx,%rdi
call   1030 <run_wmi_smbios_cmd@plt>
test   %eax,%eax
jne    115f <token_is_active+0x4f>
mov    (%rbx),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
jne    115f <token_is_active+0x4f>
mov    0x8(%rcx),%rcx
xor    %eax,%eax
cmp    (%r14),%rcx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dell_wmi_smbios_buffer = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64*, i64*, i32, i32 }
@CLASS_TOKEN_READ = global i32 0
@SELECT_TOKEN_STD = global i32 0
define i32 @token_is_active(i64* %0, i64* %1, %struct.dell_wmi_smbios_buffer* %2) {
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca %struct.dell_wmi_smbios_buffer*
%8 = alloca i32
store i64* %0, i64** %5
store i64* %1, i64** %6
store %struct.dell_wmi_smbios_buffer* %2, %struct.dell_wmi_smbios_buffer** %7
%9 = load i32, i32* @CLASS_TOKEN_READ
%10 = load %struct.dell_wmi_smbios_buffer*, %struct.dell_wmi_smbios_buffer** %7
%11 = getelementptr inbounds %struct.dell_wmi_smbios_buffer, %struct.dell_wmi_smbios_buffer* %10, i32 0, i32 0
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 3
store i32 %9, i32* %12
%13 = load i32, i32* @SELECT_TOKEN_STD
%14 = load %struct.dell_wmi_smbios_buffer*, %struct.dell_wmi_smbios_buffer** %7
%15 = getelementptr inbounds %struct.dell_wmi_smbios_buffer, %struct.dell_wmi_smbios_buffer* %14, i32 0, i32 0
%16 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %15, i32 0, i32 2
store i32 %13, i32* %16
%17 = load i64*, i64** %5
%18 = load i64, i64* %17
%19 = load %struct.dell_wmi_smbios_buffer*, %struct.dell_wmi_smbios_buffer** %7
%20 = getelementptr inbounds %struct.dell_wmi_smbios_buffer, %struct.dell_wmi_smbios_buffer* %19, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 1
%22 = load i64*, i64** %21
%23 = getelementptr inbounds i64, i64* %22, i64 0
store i64 %18, i64* %23
%24 = load %struct.dell_wmi_smbios_buffer*, %struct.dell_wmi_smbios_buffer** %7
%25 = call i32 @run_wmi_smbios_cmd(%struct.dell_wmi_smbios_buffer* %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp ne i32 %26, 0
br i1 %27, label %36, label %28
28: ; preds = %3
%29 = load %struct.dell_wmi_smbios_buffer*, %struct.dell_wmi_smbios_buffer** %7
%30 = getelementptr inbounds %struct.dell_wmi_smbios_buffer, %struct.dell_wmi_smbios_buffer* %29, i32 0, i32 0
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i32 0, i32 0
%32 = load i64*, i64** %31
%33 = getelementptr inbounds i64, i64* %32, i64 0
%34 = load i64, i64* %33
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %28, %3
%37 = load i32, i32* %8
store i32 %37, i32* %4
br label %50
38: ; preds = %28
%39 = load %struct.dell_wmi_smbios_buffer*, %struct.dell_wmi_smbios_buffer** %7
%40 = getelementptr inbounds %struct.dell_wmi_smbios_buffer, %struct.dell_wmi_smbios_buffer* %39, i32 0, i32 0
%41 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %40, i32 0, i32 0
%42 = load i64*, i64** %41
%43 = getelementptr inbounds i64, i64* %42, i64 1
%44 = load i64, i64* %43
%45 = load i64*, i64** %6
%46 = load i64, i64* %45
%47 = icmp eq i64 %44, %46
%48 = zext i1 %47 to i32
store i32 %48, i32* %8
%49 = load i32, i32* %8
store i32 %49, i32* %4
br label %50
50: ; preds = %38, %36
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
%struct.dell_wmi_smbios_buffer = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64*, i64*, i32, i32 }
@CLASS_TOKEN_READ = global i32 0
@SELECT_TOKEN_STD = global i32 0
define i32 @token_is_active(i64* nocapture %0, i64* nocapture %1, %struct.dell_wmi_smbios_buffer* %2) {
%4 = load i32, i32* @CLASS_TOKEN_READ
%5 = getelementptr inbounds %struct.dell_wmi_smbios_buffer, %struct.dell_wmi_smbios_buffer* %2, i64 0, i32 0, i32 3
store i32 %4, i32* %5
%6 = load i32, i32* @SELECT_TOKEN_STD
%7 = getelementptr inbounds %struct.dell_wmi_smbios_buffer, %struct.dell_wmi_smbios_buffer* %2, i64 0, i32 0, i32 2
store i32 %6, i32* %7
%8 = load i64, i64* %0
%9 = getelementptr inbounds %struct.dell_wmi_smbios_buffer, %struct.dell_wmi_smbios_buffer* %2, i64 0, i32 0, i32 1
%10 = load i64*, i64** %9
store i64 %8, i64* %10
%11 = tail call i32 @run_wmi_smbios_cmd(%struct.dell_wmi_smbios_buffer* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %3
%14 = getelementptr inbounds %struct.dell_wmi_smbios_buffer, %struct.dell_wmi_smbios_buffer* %2, i64 0, i32 0, i32 0
%15 = load i64*, i64** %14
%16 = load i64, i64* %15
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = getelementptr inbounds i64, i64* %15, i64 1
%20 = load i64, i64* %19
%21 = load i64, i64* %1
%22 = icmp eq i64 %20, %21
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %3, %13, %18
%25 = phi i32 [ %23, %18 ], [ 0, %13 ], [ %11, %3 ]
ret i32 %25
}