#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*/ ASSERT(int);
int /*<<< orphan*/ _HibernateWriteComplete();
void HibernateWakeSet(uint32_t ui32WakeFlags) {
  ASSERT(!(ui32WakeFlags &
           ~(0x00000010 | 0x00000008 | 0x00000010 | 0x00100010 | 0x00000200)));
  (*((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),%eax
and    $0xffeffde7,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
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    11f7 <HibernateWakeSet+0xd7>
mov    -0x4(%rbp),%eax
and    $0x100010,%eax
cmp    $0x0,%eax
je     11bc <HibernateWakeSet+0x9c>
mov    $0x400fc010,%eax
mov    (%rax),%eax
and    $0x100,%eax
cmp    $0x0,%eax
jne    11bc <HibernateWakeSet+0x9c>
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    11e6 <HibernateWakeSet+0xc6>
jmp    11cc <HibernateWakeSet+0xac>
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
xor    %edi,%edi
test   $0xffeffde7,%ebx
sete   %dil
call   1040 <ASSERT@plt>
mov    $0xfffffde7,%eax
and    0x400fc010,%eax
or     %ebx,%eax
mov    %eax,0x400fc010
xor    %eax,%eax
call   1030 <_HibernateWriteComplete@plt>
mov    $0x70ff0000,%eax
and    0x400fe000,%eax
cmp    $0x100a0000,%eax
jne    11b2 <HibernateWakeSet+0x92>
test   $0x100010,%ebx
je     118a <HibernateWakeSet+0x6a>
testl  $0x100,0x400fc010
jne    118a <HibernateWakeSet+0x6a>
orl    $0x100,0x400fc010
xor    %eax,%eax
call   1030 <_HibernateWriteComplete@plt>
sar    $0x10,%ebx
or     $0x1,%ebx
mov    %ebx,0x400fc02c
nopw   0x0(%rax,%rax,1)
cmpl   $0x0,0x400fc02c
jns    11a0 <HibernateWakeSet+0x80>
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 = and i32 %3, -1049113
%5 = icmp ne i32 %4, 0
%6 = xor i1 %5, true
%7 = zext i1 %6 to i32
%8 = call i32 @ASSERT(i32 %7)
%9 = load i32, i32* %2
%10 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
%11 = and i32 %10, -537
%12 = or i32 %9, %11
store volatile i32 %12, i32* inttoptr (i64 1074774032 to i32*)
%13 = call i32 (...) @_HibernateWriteComplete()
%14 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%15 = and i32 %14, 1895759872
%16 = icmp eq i32 %15, 269090816
br i1 %16, label %17, label %41
17: ; preds = %1
%18 = load i32, i32* %2
%19 = and i32 %18, 1048592
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
%23 = and i32 %22, 256
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
%27 = or i32 %26, 256
store volatile i32 %27, i32* inttoptr (i64 1074774032 to i32*)
%28 = call i32 (...) @_HibernateWriteComplete()
br label %29
29: ; preds = %25, %21, %17
%30 = load i32, i32* %2
%31 = ashr i32 %30, 16
%32 = or i32 %31, 1
store volatile i32 %32, i32* inttoptr (i64 1074774060 to i32*)
br label %33
33: ; preds = %37, %29
%34 = load volatile i32, i32* inttoptr (i64 1074774060 to i32*)
%35 = and i32 %34, -2147483648
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
br label %33
38: ; preds = %33
%39 = load volatile i32, i32* inttoptr (i64 1074774060 to i32*)
%40 = and i32 %39, -2
store volatile i32 %40, i32* inttoptr (i64 1074774060 to i32*)
br label %41
41: ; preds = %38, %1
ret void
}

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