#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*/ TIOCLINUX;
scalar_t__ ioctl(int /*<<< orphan*/, int /*<<< orphan*/, char *);
int WpeLinuxBioskey(void) {
  char c;
  int status;
  c = 6;
  status = 0;
  if (ioctl(0, TIOCLINUX, &c) == 0) {
    if (c & 0x01) {
      status |= 0x03;
    }
    if (c & 0x04) {
      status |= 0x04;
    }
    if (c & 0x0A) {
      status |= 0x08;
    }
  }
  return (status);
}


x86 assembly (clang, -O0):
<WpeLinuxBioskey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x6,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x1(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jne    1191 <WpeLinuxBioskey+0x81>
movsbl -0x1(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     115a <WpeLinuxBioskey+0x4a>
mov    -0x8(%rbp),%eax
or     $0x3,%eax
mov    %eax,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1173 <WpeLinuxBioskey+0x63>
mov    -0x8(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
and    $0xa,%eax
cmp    $0x0,%eax
je     118c <WpeLinuxBioskey+0x7c>
mov    -0x8(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x8(%rbp)
jmp    1191 <WpeLinuxBioskey+0x81>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WpeLinuxBioskey>:
push   %rbx
sub    $0x10,%rsp
movb   $0x6,0xf(%rsp)
mov    0x2ebf(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
lea    0xf(%rsp),%rdx
xor    %edi,%edi
call   1030 <ioctl@plt>
test   %rax,%rax
jne    1154 <WpeLinuxBioskey+0x44>
movzbl 0xf(%rsp),%eax
mov    %eax,%ecx
and    $0x1,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %eax,%edx
and    $0x4,%edx
or     %ecx,%edx
mov    %edx,%ebx
or     $0x8,%ebx
test   $0xa,%al
cmove  %edx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@TIOCLINUX = global i32 0
define i32 @WpeLinuxBioskey() {
%1 = alloca i8
%2 = alloca i32
store i8 6, i8* %1
store i32 0, i32* %2
%3 = load i32, i32* @TIOCLINUX
%4 = call i64 @ioctl(i32 0, i32 %3, i8* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %31
6: ; preds = %0
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
%9 = and i32 %8, 1
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* %2
%13 = or i32 %12, 3
store i32 %13, i32* %2
br label %14
14: ; preds = %11, %6
%15 = load i8, i8* %1
%16 = sext i8 %15 to i32
%17 = and i32 %16, 4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* %2
%21 = or i32 %20, 4
store i32 %21, i32* %2
br label %22
22: ; preds = %19, %14
%23 = load i8, i8* %1
%24 = sext i8 %23 to i32
%25 = and i32 %24, 10
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* %2
%29 = or i32 %28, 8
store i32 %29, i32* %2
br label %30
30: ; preds = %27, %22
br label %31
31: ; preds = %30, %0
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@TIOCLINUX = global i32 0
define i32 @WpeLinuxBioskey() {
%1 = alloca i8
store i8 6, i8* %1
%2 = load i32, i32* @TIOCLINUX
%3 = call i64 @ioctl(i32 0, i32 %2, i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %17
5: ; preds = %0
%6 = load i8, i8* %1
%7 = and i8 %6, 1
%8 = icmp eq i8 %7, 0
%9 = select i1 %8, i32 0, i32 3
%10 = and i8 %6, 4
%11 = zext i8 %10 to i32
%12 = or i32 %9, %11
%13 = and i8 %6, 10
%14 = icmp eq i8 %13, 0
%15 = or i32 %12, 8
%16 = select i1 %14, i32 %12, i32 %15
br label %17
17: ; preds = %5, %0
%18 = phi i32 [ 0, %0 ], [ %16, %5 ]
ret i32 %18
}