#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 HibernateTamperIOEnable(uint32_t ui32Input, uint32_t ui32Config) {
  uint32_t ui32Temp, ui32Mask;
  ;
  ui32Temp = (*((volatile unsigned long *)(0x400FC410)));
  ui32Mask = (ui32Temp & (~((0x00000008 | 0x00000004 | 0x00000002 | 0x00000001)
                            << (ui32Input << 3))));
  ui32Temp |= (ui32Mask | ((ui32Config | 0x00000001) << (ui32Input << 3)));
  (*((volatile unsigned long *)(0x400FC360))) = 0xA3359554;
  _HibernateWriteComplete();
  (*((volatile unsigned long *)(0x400FC410))) = ui32Temp;
  _HibernateWriteComplete();
  (*((volatile unsigned long *)(0x400FC360))) = 0;
  _HibernateWriteComplete();
}


x86 assembly (clang, -O0):
<HibernateTamperIOEnable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x400fc410,%eax
mov    (%rax),%rax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x3,%ecx
mov    $0xf,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%edx
or     $0x1,%edx
mov    -0x4(%rbp),%ecx
shl    $0x3,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x400fc360,%eax
mov    $0xa3359554,%ecx
mov    %rcx,(%rax)
mov    $0x0,%al
call   1030 <_HibernateWriteComplete@plt>
movslq -0xc(%rbp),%rcx
mov    $0x400fc410,%eax
mov    %rcx,(%rax)
mov    $0x0,%al
call   1030 <_HibernateWriteComplete@plt>
mov    $0x400fc360,%eax
movq   $0x0,(%rax)
mov    $0x0,%al
call   1030 <_HibernateWriteComplete@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HibernateTamperIOEnable>:
push   %rbx
mov    %esi,%ebx
lea    0x0(,%rdi,8),%ecx
or     $0x1,%ebx
shl    %cl,%ebx
mov    0x400fc410,%rax
40
or     %eax,%ebx
mov    $0xa3359554,%eax
mov    %rax,0x400fc360
40
xor    %eax,%eax
call   1030 <_HibernateWriteComplete@plt>
movslq %ebx,%rax
mov    %rax,0x400fc410
40
xor    %eax,%eax
call   1030 <_HibernateWriteComplete@plt>
movq   $0x0,0x400fc360
xor    %eax,%eax
pop    %rbx
jmp    1030 <_HibernateWriteComplete@plt>

LLVM IR (-O0):
define void @HibernateTamperIOEnable(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load volatile i64, i64* inttoptr (i64 1074775056 to i64*)
%8 = trunc i64 %7 to i32
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = shl i32 %10, 3
%12 = shl i32 15, %11
%13 = xor i32 %12, -1
%14 = and i32 %9, %13
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = or i32 %16, 1
%18 = load i32, i32* %3
%19 = shl i32 %18, 3
%20 = shl i32 %17, %19
%21 = or i32 %15, %20
%22 = load i32, i32* %5
%23 = or i32 %22, %21
store i32 %23, i32* %5
store volatile i64 2738197844, i64* inttoptr (i64 1074774880 to i64*)
%24 = call i32 (...) @_HibernateWriteComplete()
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
store volatile i64 %26, i64* inttoptr (i64 1074775056 to i64*)
%27 = call i32 (...) @_HibernateWriteComplete()
store volatile i64 0, i64* inttoptr (i64 1074774880 to i64*)
%28 = call i32 (...) @_HibernateWriteComplete()
ret void
}

LLVM IR (-O2):
define void @HibernateTamperIOEnable(i32 %0, i32 %1) {
%3 = load volatile i64, i64* inttoptr (i64 1074775056 to i64*)
%4 = trunc i64 %3 to i32
%5 = shl i32 %0, 3
%6 = or i32 %1, 1
%7 = shl i32 %6, %5
%8 = or i32 %7, %4
store volatile i64 2738197844, i64* inttoptr (i64 1074774880 to i64*)
%9 = tail call i32 (...) @_HibernateWriteComplete()
%10 = sext i32 %8 to i64
store volatile i64 %10, i64* inttoptr (i64 1074775056 to i64*)
%11 = tail call i32 (...) @_HibernateWriteComplete()
store volatile i64 0, i64* inttoptr (i64 1074774880 to i64*)
%12 = tail call i32 (...) @_HibernateWriteComplete()
ret void
}