#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ _HibernateWriteComplete();
void HibernateWakeSet(uint32_t ui32WakeFlags) {

  ;
  (*((volatile uint32_t *)(0x400FC010))) =
      (ui32WakeFlags | ((*((volatile uint32_t *)(0x400FC010))) &
                        ~(0x00000010 | 0x00000008 | 0x00000200)));
  _HibernateWriteComplete();
  if ((((*((volatile uint32_t *)(0x400FE000))) & (0x70000000 | 0x00FF0000)) ==
       (0x10000000 | 0x000A0000))) {
    if ((ui32WakeFlags & (0x00100010 | 0x00000010)) &&
        (((*((volatile uint32_t *)(0x400FC010))) & 0x00000100) == 0)) {
      (*((volatile uint32_t *)(0x400FC010))) |= 0x00000100;
      _HibernateWriteComplete();
    }
    (*((volatile uint32_t *)(0x400FC02C))) = (ui32WakeFlags >> 16) | 0x00000001;
    while (((*((volatile uint32_t *)(0x400FC02C))) & 0x80000000) == 0) {
    }
    (*((volatile uint32_t *)(0x400FC02C))) &= ~0x00000001;
  }
}


x86 assembly (clang, -O0):
<HibernateWakeSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x400fc010,%eax
mov    (%rax),%eax
and    $0xfffffde7,%eax
or     %eax,%ecx
mov    $0x400fc010,%eax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1030 <_HibernateWriteComplete@plt>
mov    $0x400fe000,%eax
mov    (%rax),%eax
and    $0x70ff0000,%eax
cmp    $0x100a0000,%eax
jne    11cd <HibernateWakeSet+0xbd>
mov    -0x4(%rbp),%eax
and    $0x100010,%eax
cmp    $0x0,%eax
je     1192 <HibernateWakeSet+0x82>
mov    $0x400fc010,%eax
mov    (%rax),%eax
and    $0x100,%eax
cmp    $0x0,%eax
jne    1192 <HibernateWakeSet+0x82>
mov    $0x400fc010,%eax
mov    (%rax),%ecx
or     $0x100,%ecx
mov    $0x400fc010,%eax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1030 <_HibernateWriteComplete@plt>
mov    -0x4(%rbp),%ecx
sar    $0x10,%ecx
or     $0x1,%ecx
mov    $0x400fc02c,%eax
mov    %ecx,(%rax)
mov    $0x400fc02c,%eax
mov    (%rax),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
jne    11bc <HibernateWakeSet+0xac>
jmp    11a2 <HibernateWakeSet+0x92>
mov    $0x400fc02c,%eax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    $0x400fc02c,%eax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HibernateWakeSet>:
push   %rbx
mov    %edi,%ebx
mov    $0xfffffde7,%eax
and    0x400fc010,%eax
or     %edi,%eax
mov    %eax,0x400fc010
xor    %eax,%eax
call   1030 <_HibernateWriteComplete@plt>
mov    $0x70ff0000,%eax
and    0x400fe000,%eax
cmp    $0x100a0000,%eax
jne    1192 <HibernateWakeSet+0x82>
test   $0x100010,%ebx
je     1169 <HibernateWakeSet+0x59>
testl  $0x100,0x400fc010
jne    1169 <HibernateWakeSet+0x59>
orl    $0x100,0x400fc010
xor    %eax,%eax
call   1030 <_HibernateWriteComplete@plt>
sar    $0x10,%ebx
or     $0x1,%ebx
mov    %ebx,0x400fc02c
cs nopw 0x0(%rax,%rax,1)
cmpl   $0x0,0x400fc02c
jns    1180 <HibernateWakeSet+0x70>
andl   $0xfffffffe,0x400fc02c
fe
pop    %rbx
ret

LLVM IR (-O0):
define void @HibernateWakeSet(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
%5 = and i32 %4, -537
%6 = or i32 %3, %5
store volatile i32 %6, i32* inttoptr (i64 1074774032 to i32*)
%7 = call i32 (...) @_HibernateWriteComplete()
%8 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%9 = and i32 %8, 1895759872
%10 = icmp eq i32 %9, 269090816
br i1 %10, label %11, label %35
11: ; preds = %1
%12 = load i32, i32* %2
%13 = and i32 %12, 1048592
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
%17 = and i32 %16, 256
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
%21 = or i32 %20, 256
store volatile i32 %21, i32* inttoptr (i64 1074774032 to i32*)
%22 = call i32 (...) @_HibernateWriteComplete()
br label %23
23: ; preds = %19, %15, %11
%24 = load i32, i32* %2
%25 = ashr i32 %24, 16
%26 = or i32 %25, 1
store volatile i32 %26, i32* inttoptr (i64 1074774060 to i32*)
br label %27
27: ; preds = %31, %23
%28 = load volatile i32, i32* inttoptr (i64 1074774060 to i32*)
%29 = and i32 %28, -2147483648
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
br label %27
32: ; preds = %27
%33 = load volatile i32, i32* inttoptr (i64 1074774060 to i32*)
%34 = and i32 %33, -2
store volatile i32 %34, i32* inttoptr (i64 1074774060 to i32*)
br label %35
35: ; preds = %32, %1
ret void
}

LLVM IR (-O2):
define void @HibernateWakeSet(i32 %0) {
%2 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
%3 = and i32 %2, -537
%4 = or i32 %3, %0
store volatile i32 %4, i32* inttoptr (i64 1074774032 to i32*)
%5 = tail call i32 (...) @_HibernateWriteComplete()
%6 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%7 = and i32 %6, 1895759872
%8 = icmp eq i32 %7, 269090816
br i1 %8, label %9, label %29
9: ; preds = %1
%10 = and i32 %0, 1048592
%11 = icmp eq i32 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
%14 = and i32 %13, 256
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
%18 = or i32 %17, 256
store volatile i32 %18, i32* inttoptr (i64 1074774032 to i32*)
%19 = tail call i32 (...) @_HibernateWriteComplete()
br label %20
20: ; preds = %16, %12, %9
%21 = ashr i32 %0, 16
%22 = or i32 %21, 1
store volatile i32 %22, i32* inttoptr (i64 1074774060 to i32*)
br label %23
23: ; preds = %23, %20
%24 = load volatile i32, i32* inttoptr (i64 1074774060 to i32*)
%25 = icmp sgt i32 %24, -1
br i1 %25, label %23, label %26
26: ; preds = %23
%27 = load volatile i32, i32* inttoptr (i64 1074774060 to i32*)
%28 = and i32 %27, -2
store volatile i32 %28, i32* inttoptr (i64 1074774060 to i32*)
br label %29
29: ; preds = %26, %1
ret void
}