#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 unsigned long *)(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),%rax
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    1171 <HibernateTamperStatusGet+0x71>
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,%rcx
40
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 i64, i64* inttoptr (i64 1074775044 to i64*)
%4 = trunc i64 %3 to i32
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = and i32 %5, 3
store i32 %6, i32* %1
%7 = load i32, i32* %2
%8 = and i32 %7, 2
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i64
%11 = select i1 %9, i32 0, i32 8
%12 = load i32, i32* %1
%13 = or i32 %12, %11
store i32 %13, i32* %1
%14 = load i32, i32* %2
%15 = and i32 %14, 1
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 0, i32 4
%19 = load i32, i32* %1
%20 = or i32 %19, %18
store i32 %20, i32* %1
%21 = load i32, i32* %2
%22 = and i32 %21, 12
%23 = shl i32 %22, 3
%24 = load i32, i32* %1
%25 = or i32 %24, %23
store i32 %25, i32* %1
%26 = load i32, i32* %2
%27 = and i32 %26, 12
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %0
%30 = load i32, i32* %1
%31 = or i32 %30, 16
store i32 %31, i32* %1
br label %32
32: ; preds = %29, %0
%33 = load i32, i32* %1
ret i32 %33
}

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