#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 |= (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    11b4 <PRCMHibernateWakeUpGPIOSelect+0x94>
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     11a2 <PRCMHibernateWakeUpGPIOSelect+0x82>
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movzbl -0x11(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
shl    %cl,%rax
or     -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    $0x4402fc08,%edi
call   1030 <PRCMHIBRegWrite@plt>
jmp    11a7 <PRCMHibernateWakeUpGPIOSelect+0x87>
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    11a0 <PRCMHibernateWakeUpGPIOSelect+0x80>
test   $0x40000,%ebx
jne    11cb <PRCMHibernateWakeUpGPIOSelect+0xab>
test   $0x80000,%ebx
jne    11f5 <PRCMHibernateWakeUpGPIOSelect+0xd5>
test   $0x100000,%ebx
jne    121f <PRCMHibernateWakeUpGPIOSelect+0xff>
test   $0x200000,%ebx
jne    1249 <PRCMHibernateWakeUpGPIOSelect+0x129>
test   $0x400000,%ebx
jne    1273 <PRCMHibernateWakeUpGPIOSelect+0x153>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x4402fc08,%edi
call   1040 <PRCMHIBRegRead@plt>
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>
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>
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>
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>
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>
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>
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 = %34, %2
%10 = load i8, i8* %5
%11 = zext i8 %10 to i32
%12 = icmp slt i32 %11, 7
br i1 %12, label %13, label %37
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 %33
21: ; preds = %13
%22 = call i64 @PRCMHIBRegRead(i32 1141046280)
store i64 %22, i64* %6
%23 = load i64, i64* %4
%24 = load i8, i8* %5
%25 = zext i8 %24 to i32
%26 = mul nsw i32 %25, 2
%27 = zext i32 %26 to i64
%28 = shl i64 %23, %27
%29 = load i64, i64* %6
%30 = or i64 %29, %28
store i64 %30, i64* %6
%31 = load i64, i64* %6
%32 = call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %31)
br label %33
33: ; preds = %21, %13
br label %34
34: ; preds = %33
%35 = load i8, i8* %5
%36 = add i8 %35, 1
store i8 %36, i8* %5
br label %9
37: ; 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 %9, label %5
5: ; preds = %2
%6 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%7 = or i64 %6, %1
%8 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %7)
br label %9
9: ; preds = %2, %5
%10 = and i64 %0, 131072
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%14 = shl i64 %1, 2
%15 = or i64 %13, %14
%16 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %15)
br label %17
17: ; preds = %12, %9
%18 = and i64 %0, 262144
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%22 = shl i64 %1, 4
%23 = or i64 %21, %22
%24 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %23)
br label %25
25: ; preds = %20, %17
%26 = and i64 %0, 524288
%27 = icmp eq i64 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %25
%29 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%30 = shl i64 %1, 6
%31 = or i64 %29, %30
%32 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %31)
br label %33
33: ; preds = %28, %25
%34 = and i64 %0, 1048576
%35 = icmp eq i64 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %33
%37 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%38 = shl i64 %1, 8
%39 = or i64 %37, %38
%40 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %39)
br label %41
41: ; preds = %36, %33
%42 = and i64 %0, 2097152
%43 = icmp eq i64 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %41
%45 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%46 = shl i64 %1, 10
%47 = or i64 %45, %46
%48 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %47)
br label %49
49: ; preds = %44, %41
%50 = and i64 %0, 4194304
%51 = icmp eq i64 %50, 0
br i1 %51, label %57, label %52
52: ; preds = %49
%53 = tail call i64 @PRCMHIBRegRead(i32 1141046280)
%54 = shl i64 %1, 12
%55 = or i64 %53, %54
%56 = tail call i32 @PRCMHIBRegWrite(i32 1141046280, i64 %55)
br label %57
57: ; preds = %52, %49
ret void
}