#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 */
unsigned long Read_Key();
int /*<<< orphan*/ pgWaitV();
int Confirm_Control(void) {
  unsigned long key;
  while (1) {
    while (1) {
      key = Read_Key();
      if (key != 0)
        break;
      pgWaitV();
    }
    if (key & 0x2000) {
      return 1;
    }
    if (key & 0x4000) {
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<Confirm_Control>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
jmp    112d <Confirm_Control+0xd>
mov    $0x0,%al
call   1030 <Read_Key@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1148 <Confirm_Control+0x28>
jmp    1154 <Confirm_Control+0x34>
mov    $0x0,%al
call   1040 <pgWaitV@plt>
jmp    112d <Confirm_Control+0xd>
mov    -0x10(%rbp),%rax
and    $0x2000,%rax
cmp    $0x0,%rax
je     1174 <Confirm_Control+0x54>
movl   $0x1,-0x4(%rbp)
jmp    1199 <Confirm_Control+0x79>
mov    -0x10(%rbp),%rax
and    $0x4000,%rax
cmp    $0x0,%rax
je     1194 <Confirm_Control+0x74>
movl   $0x0,-0x4(%rbp)
jmp    1199 <Confirm_Control+0x79>
jmp    1128 <Confirm_Control+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Confirm_Control>:
push   %rax
jmp    1137 <Confirm_Control+0x17>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <pgWaitV@plt>
xor    %eax,%eax
call   1030 <Read_Key@plt>
test   %rax,%rax
je     1130 <Confirm_Control+0x10>
test   $0x2000,%eax
jne    1155 <Confirm_Control+0x35>
test   $0x4000,%eax
je     1137 <Confirm_Control+0x17>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @Confirm_Control() {
%1 = alloca i32
%2 = alloca i64
br label %3
3: ; preds = %0, %21
br label %4
4: ; preds = %3, %9
%5 = call i64 (...) @Read_Key()
store i64 %5, i64* %2
%6 = load i64, i64* %2
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %4
br label %11
9: ; preds = %4
%10 = call i32 (...) @pgWaitV()
br label %4
11: ; preds = %8
%12 = load i64, i64* %2
%13 = and i64 %12, 8192
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 1, i32* %1
br label %22
16: ; preds = %11
%17 = load i64, i64* %2
%18 = and i64 %17, 16384
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 0, i32* %1
br label %22
21: ; preds = %16
br label %3
22: ; preds = %20, %15
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @Confirm_Control() {
br label %1
1: ; preds = %12, %0
%2 = tail call i64 (...) @Read_Key()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1, %4
%5 = tail call i32 (...) @pgWaitV()
%6 = tail call i64 (...) @Read_Key()
%7 = icmp eq i64 %6, 0
br i1 %7, label %4, label %8
8: ; preds = %4, %1
%9 = phi i64 [ %2, %1 ], [ %6, %4 ]
%10 = and i64 %9, 8192
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = and i64 %9, 16384
%14 = icmp eq i64 %13, 0
br i1 %14, label %1, label %15
15: ; preds = %12, %8
%16 = phi i32 [ 1, %8 ], [ 0, %12 ]
ret i32 %16
}