#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 */
uint32_t HibernateTamperStatusGet(void) {
  uint32_t ui32Status, ui32Reg;
  ui32Reg = (*((volatile uint32_t *)(0x400FC404)));
  ui32Status = (ui32Reg & (0x00000002 | 0x00000001));
  ui32Status |= ((ui32Reg & 0x00000002) ? 0 : 0x00000008);
  ui32Status |= ((ui32Reg & 0x00000001) ? 0 : 0x00000004);
  ui32Status |= ((ui32Reg & 0x0000000C) << 3);
  if ((ui32Reg & 0x0000000C) == 0) {
    ui32Status |= 0x00000010;
  }
  return (ui32Status);
}


x86 assembly (clang, -O0):
<HibernateTamperStatusGet>:
push   %rbp
mov    %rsp,%rbp
mov    $0x400fc404,%eax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edx
and    $0x2,%edx
mov    $0x8,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edx
and    $0x1,%edx
mov    $0x4,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
and    $0xc,%eax
shl    $0x3,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
and    $0xc,%eax
cmp    $0x0,%eax
jne    1170 <HibernateTamperStatusGet+0x70>
mov    -0x4(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<HibernateTamperStatusGet>:
mov    0x400fc404,%ecx
mov    %ecx,%eax
and    $0x3,%eax
lea    0x0(,%rcx,4),%edx
mov    %edx,%esi
and    $0x8,%esi
or     %eax,%esi
and    $0x4,%edx
or     %esi,%edx
and    $0xc,%ecx
lea    (%rdx,%rcx,8),%edx
xor    $0xc,%edx
lea    0x10(%rdx),%eax
test   %ecx,%ecx
cmovne %edx,%eax
ret

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

LLVM IR (-O2):
define i32 @HibernateTamperStatusGet() {
%1 = load volatile i32, i32* inttoptr (i64 1074775044 to i32*)
%2 = and i32 %1, 3
%3 = shl i32 %1, 2
%4 = and i32 %3, 8
%5 = and i32 %3, 4
%6 = and i32 %1, 12
%7 = shl nuw nsw i32 %6, 3
%8 = or i32 %4, %2
%9 = or i32 %8, %5
%10 = or i32 %9, %7
%11 = xor i32 %10, 12
%12 = icmp eq i32 %6, 0
%13 = or i32 %11, 16
%14 = select i1 %12, i32 %13, i32 %11
ret i32 %14
}