#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 uint32_t *)(0x400FC410)));
  ui32Mask = (ui32Temp & (~((0x00000008 | 0x00000004 | 0x00000002 | 0x00000001)
                            << (ui32Input << 3))));
  ui32Temp = (ui32Mask | ((ui32Config | 0x00000001) << (ui32Input << 3)));
  (*((volatile uint32_t *)(0x400FC360))) = 0xA3359554;
  _HibernateWriteComplete();
  (*((volatile uint32_t *)(0x400FC410))) = ui32Temp;
  _HibernateWriteComplete();
  (*((volatile uint32_t *)(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),%eax
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
mov    %eax,-0xc(%rbp)
mov    $0x400fc360,%eax
movl   $0xa3359554,(%rax)
mov    $0x0,%al
call   1030 <_HibernateWriteComplete@plt>
mov    -0xc(%rbp),%ecx
mov    $0x400fc410,%eax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1030 <_HibernateWriteComplete@plt>
mov    $0x400fc360,%eax
movl   $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
mov    $0xf,%eax
shl    %cl,%eax
not    %eax
or     $0x1,%ebx
shl    %cl,%ebx
and    0x400fc410,%eax
or     %eax,%ebx
movl   $0xa3359554,0x400fc360
54 95 35 a3
xor    %eax,%eax
call   1030 <_HibernateWriteComplete@plt>
mov    %ebx,0x400fc410
xor    %eax,%eax
call   1030 <_HibernateWriteComplete@plt>
movl   $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 i32, i32* inttoptr (i64 1074775056 to i32*)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = shl i32 %9, 3
%11 = shl i32 15, %10
%12 = xor i32 %11, -1
%13 = and i32 %8, %12
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = or i32 %15, 1
%17 = load i32, i32* %3
%18 = shl i32 %17, 3
%19 = shl i32 %16, %18
%20 = or i32 %14, %19
store i32 %20, i32* %5
store volatile i32 -1556769452, i32* inttoptr (i64 1074774880 to i32*)
%21 = call i32 (...) @_HibernateWriteComplete()
%22 = load i32, i32* %5
store volatile i32 %22, i32* inttoptr (i64 1074775056 to i32*)
%23 = call i32 (...) @_HibernateWriteComplete()
store volatile i32 0, i32* inttoptr (i64 1074774880 to i32*)
%24 = call i32 (...) @_HibernateWriteComplete()
ret void
}

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