#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 */

/* Variables and functions */
unsigned long PRCMHIBRegRead(int);
int /*<<< orphan*/ PRCMHIBRegWrite(int, unsigned long);
void PRCMHibernateWakeUpGPIOSelect(unsigned long ulGPIOBitMap,
                                   unsigned long ulType) {
  unsigned char ucLoop;
  unsigned long ulRegValue;
  ulGPIOBitMap >>= 16;
  for (ucLoop = 0; ucLoop < 7; ucLoop++) {
    if (ulGPIOBitMap & (1 << ucLoop)) {
      ulRegValue = PRCMHIBRegRead(0x4402F800 + 0x00000408);
      ulRegValue =
          (ulRegValue & (~(0x3 << (ucLoop * 2)))) | (ulType << (ucLoop * 2));
      PRCMHIBRegWrite(0x4402F800 + 0x00000408, ulRegValue);
    }
  }
}


x86 assembly (clang, -O0):
<PRCMHibernateWakeUpGPIOSelect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x10,%rax
mov    %rax,-0x8(%rbp)
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x7,%eax
jge    11d3 <PRCMHibernateWakeUpGPIOSelect+0xb3>
mov    -0x8(%rbp),%rax
movzbl -0x11(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     11c1 <PRCMHibernateWakeUpGPIOSelect+0xa1>
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl -0x11(%rbp),%ecx
shl    $0x1,%ecx
mov    $0x3,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
mov    -0x10(%rbp),%rdx
movzbl -0x11(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
shl    %cl,%rdx
mov    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    $0x4402fc08,%edi
call   1030 <PRCMHIBRegWrite@plt>
jmp    11c6 <PRCMHibernateWakeUpGPIOSelect+0xa6>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1140 <PRCMHibernateWakeUpGPIOSelect+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PRCMHibernateWakeUpGPIOSelect>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   $0x10000,%ebx
jne    117e <PRCMHibernateWakeUpGPIOSelect+0x5e>
test   $0x20000,%ebx
jne    11a4 <PRCMHibernateWakeUpGPIOSelect+0x84>
test   $0x40000,%ebx
jne    11d3 <PRCMHibernateWakeUpGPIOSelect+0xb3>
test   $0x80000,%ebx
jne    1201 <PRCMHibernateWakeUpGPIOSelect+0xe1>
test   $0x100000,%ebx
jne    1231 <PRCMHibernateWakeUpGPIOSelect+0x111>
test   $0x200000,%ebx
jne    1261 <PRCMHibernateWakeUpGPIOSelect+0x141>
test   $0x400000,%ebx
jne    1291 <PRCMHibernateWakeUpGPIOSelect+0x171>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
and    $0xfffffffffffffffc,%rax
or     %r14,%rax
mov    $0x4402fc08,%edi
mov    %rax,%rsi
call   1030 <PRCMHIBRegWrite@plt>
test   $0x20000,%ebx
je     113a <PRCMHibernateWakeUpGPIOSelect+0x1a>
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
and    $0xfffffffffffffff3,%rax
lea    0x0(,%r14,4),%rsi
or     %rax,%rsi
mov    $0x4402fc08,%edi
call   1030 <PRCMHIBRegWrite@plt>
test   $0x40000,%ebx
je     1146 <PRCMHibernateWakeUpGPIOSelect+0x26>
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
and    $0xffffffffffffffcf,%rax
mov    %r14,%rsi
shl    $0x4,%rsi
or     %rax,%rsi
mov    $0x4402fc08,%edi
call   1030 <PRCMHIBRegWrite@plt>
test   $0x80000,%ebx
je     1152 <PRCMHibernateWakeUpGPIOSelect+0x32>
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
and    $0xffffffffffffff3f,%rax
mov    %r14,%rsi
shl    $0x6,%rsi
or     %rax,%rsi
mov    $0x4402fc08,%edi
call   1030 <PRCMHIBRegWrite@plt>
test   $0x100000,%ebx
je     115e <PRCMHibernateWakeUpGPIOSelect+0x3e>
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
and    $0xfffffffffffffcff,%rax
mov    %r14,%rsi
shl    $0x8,%rsi
or     %rax,%rsi
mov    $0x4402fc08,%edi
call   1030 <PRCMHIBRegWrite@plt>
test   $0x200000,%ebx
je     116a <PRCMHibernateWakeUpGPIOSelect+0x4a>
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
and    $0xfffffffffffff3ff,%rax
mov    %r14,%rsi
shl    $0xa,%rsi
or     %rax,%rsi
mov    $0x4402fc08,%edi
call   1030 <PRCMHIBRegWrite@plt>
test   $0x400000,%ebx
je     1176 <PRCMHibernateWakeUpGPIOSelect+0x56>
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
and    $0xffffffffffffcfff,%rax
shl    $0xc,%r14
or     %rax,%r14
mov    $0x4402fc08,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <PRCMHIBRegWrite@plt>

LLVM IR (-O0):
define void @PRCMHibernateWakeUpGPIOSelect(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8
%6 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = load i64, i64* %3
%8 = lshr i64 %7, 16
store i64 %8, i64* %3
store i8 0, i8* %5
br label %9
9: ; preds = %41, %2
%10 = load i8, i8* %5
%11 = zext i8 %10 to i32
%12 = icmp slt i32 %11, 7
br i1 %12, label %13, label %44
13: ; preds = %9
%14 = load i64, i64* %3
%15 = load i8, i8* %5
%16 = zext i8 %15 to i32
%17 = shl i32 1, %16
%18 = sext i32 %17 to i64
%19 = and i64 %14, %18
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %40
21: ; preds = %13
%22 = call i64 @PRCMHIBRegRead(i32 1141046280)
store i64 %22, i64* %6
%23 = load i64, i64* %6
%24 = load i8, i8* %5
%25 = zext i8 %24 to i32
%26 = mul nsw i32 %25, 2
%27 = shl i32 3, %26
%28 = xor i32 %27, -1
%29 = sext i32 %28 to i64
%30 = and i64 %23, %29
%31 = load i64, i64* %4
%32 = load i8, i8* %5
%33 = zext i8 %32 to i32
%34 = mul nsw i32 %33, 2
%35 = zext i32 %34 to i64
%36 = shl i64 %31, %35
%37 = or i64 %30, %36
store i64 %37, i64* %6
%38 = load i64, i64* %6
%39 = call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %38)
br label %40
40: ; preds = %21, %13
br label %41
41: ; preds = %40
%42 = load i8, i8* %5
%43 = add i8 %42, 1
store i8 %43, i8* %5
br label %9
44: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @PRCMHibernateWakeUpGPIOSelect(i64 %0, i64 %1) {
%3 = and i64 %0, 65536
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%7 = and i64 %6, -4
%8 = or i64 %7, %1
%9 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %8)
br label %10
10: ; preds = %2, %5
%11 = and i64 %0, 131072
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%15 = and i64 %14, -13
%16 = shl i64 %1, 2
%17 = or i64 %15, %16
%18 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %17)
br label %19
19: ; preds = %13, %10
%20 = and i64 %0, 262144
%21 = icmp eq i64 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%24 = and i64 %23, -49
%25 = shl i64 %1, 4
%26 = or i64 %24, %25
%27 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %26)
br label %28
28: ; preds = %22, %19
%29 = and i64 %0, 524288
%30 = icmp eq i64 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %28
%32 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%33 = and i64 %32, -193
%34 = shl i64 %1, 6
%35 = or i64 %33, %34
%36 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %35)
br label %37
37: ; preds = %31, %28
%38 = and i64 %0, 1048576
%39 = icmp eq i64 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %37
%41 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%42 = and i64 %41, -769
%43 = shl i64 %1, 8
%44 = or i64 %42, %43
%45 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %44)
br label %46
46: ; preds = %40, %37
%47 = and i64 %0, 2097152
%48 = icmp eq i64 %47, 0
br i1 %48, label %55, label %49
49: ; preds = %46
%50 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%51 = and i64 %50, -3073
%52 = shl i64 %1, 10
%53 = or i64 %51, %52
%54 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %53)
br label %55
55: ; preds = %49, %46
%56 = and i64 %0, 4194304
%57 = icmp eq i64 %56, 0
br i1 %57, label %64, label %58
58: ; preds = %55
%59 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%60 = and i64 %59, -12289
%61 = shl i64 %1, 12
%62 = or i64 %60, %61
%63 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %62)
br label %64
64: ; preds = %58, %55
ret void
}