#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 HibernateClockConfig(uint32_t ui32Config) {
  uint32_t ui32HIBCtl;
  ASSERT((ui32Config & ~(0x00020000 | 0x00000000 | 0x00010000)) == 0);
  ui32HIBCtl = (*((volatile uint32_t *)(0x400FC010)));
  ui32HIBCtl &= ~(0x00020000 | 0x00000000 | 0x00080000 | 0x00010000);
  ui32HIBCtl |=
      ui32Config & (0x00020000 | 0x00000000 | 0x00080000 | 0x00010000);
  if (ui32Config & 0x00080000) {
    ui32HIBCtl |= 0x00000040;
  }
  (*((volatile uint32_t *)(0x400FC010))) = ui32HIBCtl;
  _HibernateWriteComplete();
  if ((((*((volatile uint32_t *)(0x400FE000))) & (0x70000000 | 0x00FF0000)) ==
       (0x10000000 | 0x000A0000))) {
    (*((volatile uint32_t *)(0x400FCFC8))) =
        ui32Config & (0x00000001 | 0x00000002);
  }
}


x86 assembly (clang, -O0):
<HibernateClockConfig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffcffff,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
mov    $0x400fc010,%eax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xfff4ffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xb0000,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80000,%eax
cmp    $0x0,%eax
je     1180 <HibernateClockConfig+0x60>
mov    -0x8(%rbp),%eax
or     $0x40,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%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    11b5 <HibernateClockConfig+0x95>
mov    -0x4(%rbp),%ecx
and    $0x3,%ecx
mov    $0x400fcfc8,%eax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HibernateClockConfig>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
test   $0xfffcffff,%ebx
sete   %dil
call   1040 <ASSERT@plt>
mov    $0xfff4ffff,%eax
and    0x400fc010,%eax
mov    %ebx,%ecx
and    $0xb0000,%ecx
mov    %ebx,%edx
shr    $0xd,%edx
and    $0x40,%edx
or     %ecx,%edx
or     %eax,%edx
mov    %edx,0x400fc010
xor    %eax,%eax
call   1030 <_HibernateWriteComplete@plt>
mov    $0x70ff0000,%eax
and    0x400fe000,%eax
cmp    $0x100a0000,%eax
jne    117f <HibernateClockConfig+0x5f>
and    $0x3,%ebx
mov    %ebx,0x400fcfc8
pop    %rbx
ret

LLVM IR (-O0):
define void @HibernateClockConfig(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, -196609
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @ASSERT(i32 %7)
%9 = load volatile i32, i32* inttoptr (i64 1074774032 to i32*)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = and i32 %10, -720897
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = and i32 %12, 720896
%14 = load i32, i32* %3
%15 = or i32 %14, %13
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = and i32 %16, 524288
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %1
%20 = load i32, i32* %3
%21 = or i32 %20, 64
store i32 %21, i32* %3
br label %22
22: ; preds = %19, %1
%23 = load i32, i32* %3
store volatile i32 %23, i32* inttoptr (i64 1074774032 to i32*)
%24 = call i32 (...) @_HibernateWriteComplete()
%25 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%26 = and i32 %25, 1895759872
%27 = icmp eq i32 %26, 269090816
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32, i32* %2
%30 = and i32 %29, 3
store volatile i32 %30, i32* inttoptr (i64 1074778056 to i32*)
br label %31
31: ; preds = %28, %22
ret void
}

LLVM IR (-O2):
define void @HibernateClockConfig(i32 %0) {
%2 = and i32 %0, -196609
%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, -720897
%8 = and i32 %0, 720896
%9 = lshr i32 %0, 13
%10 = and i32 %9, 64
%11 = or i32 %10, %8
%12 = or i32 %11, %7
store volatile i32 %12, i32* inttoptr (i64 1074774032 to i32*)
%13 = tail 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 %19
17: ; preds = %1
%18 = and i32 %0, 3
store volatile i32 %18, i32* inttoptr (i64 1074778056 to i32*)
br label %19
19: ; preds = %17, %1
ret void
}