#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 PRCMOCRRegisterWrite(unsigned char ucIndex, unsigned long ulRegValue) {
  unsigned long ulVal;
  ucIndex = ucIndex << 2;
  if (((*((volatile unsigned long *)(0x4402E000 + 0x00000188))) &
       (0x00000080)) &&
      (ucIndex == 0)) {
    ulVal = PRCMHIBRegRead(0x4402F800 + 0x00000420 + ucIndex);
    ulRegValue = ((ulRegValue << 0x1) | (ulVal & (0x1)));
  }
  PRCMHIBRegWrite(0x4402F800 + 0x00000420 + ucIndex, ulRegValue);
}


x86 assembly (clang, -O0):
<PRCMOCRRegisterWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movzbl -0x1(%rbp),%eax
shl    $0x2,%eax
mov    %al,-0x1(%rbp)
mov    $0x4402e188,%eax
mov    (%rax),%rax
and    $0x80,%rax
cmp    $0x0,%rax
je     118b <PRCMOCRRegisterWrite+0x6b>
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    118b <PRCMOCRRegisterWrite+0x6b>
movzbl -0x1(%rbp),%edi
add    $0x4402fc20,%edi
call   1040 <PRCMHIBRegRead@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    -0x18(%rbp),%rcx
and    $0x1,%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
movzbl -0x1(%rbp),%edi
add    $0x4402fc20,%edi
mov    -0x10(%rbp),%rsi
call   1030 <PRCMHIBRegWrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PRCMOCRRegisterWrite>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
shl    $0x2,%bpl
mov    0x4402e188,%rax
44
test   %bpl,%bpl
jne    1154 <PRCMOCRRegisterWrite+0x34>
and    $0x80,%eax
test   %rax,%rax
je     1154 <PRCMOCRRegisterWrite+0x34>
mov    $0x4402fc20,%edi
call   1040 <PRCMHIBRegRead@plt>
and    $0x1,%eax
lea    (%rax,%rbx,2),%rbx
movzbl %bpl,%edi
add    $0x4402fc20,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <PRCMHIBRegWrite@plt>

LLVM IR (-O0):
define void @PRCMOCRRegisterWrite(i8 zeroext %0, i64 %1) {
%3 = alloca i8
%4 = alloca i64
%5 = alloca i64
store i8 %0, i8* %3
store i64 %1, i64* %4
%6 = load i8, i8* %3
%7 = zext i8 %6 to i32
%8 = shl i32 %7, 2
%9 = trunc i32 %8 to i8
store i8 %9, i8* %3
%10 = load volatile i64, i64* inttoptr (i64 1141039496 to i64*)
%11 = and i64 %10, 128
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %2
%14 = load i8, i8* %3
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i8, i8* %3
%19 = zext i8 %18 to i32
%20 = add nsw i32 1141046304, %19
%21 = call i64 @PRCMHIBRegRead(i32 %20)
store i64 %21, i64* %5
%22 = load i64, i64* %4
%23 = shl i64 %22, 1
%24 = load i64, i64* %5
%25 = and i64 %24, 1
%26 = or i64 %23, %25
store i64 %26, i64* %4
br label %27
27: ; preds = %17, %13, %2
%28 = load i8, i8* %3
%29 = zext i8 %28 to i32
%30 = add nsw i32 1141046304, %29
%31 = load i64, i64* %4
%32 = call i32 @PRCMHIBRegWrite(i32 %30, i64 %31)
ret void
}

LLVM IR (-O2):
define void @PRCMOCRRegisterWrite(i8 zeroext %0, i64 %1) {
%3 = shl i8 %0, 2
%4 = load volatile i64, i64* inttoptr (i64 1141039496 to i64*)
%5 = and i64 %4, 128
%6 = icmp ne i64 %5, 0
%7 = icmp eq i8 %3, 0
%8 = and i1 %7, %6
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = tail call i64 @PRCMHIBRegRead(i32 1141046304)
%11 = shl i64 %1, 1
%12 = and i64 %10, 1
%13 = or i64 %12, %11
br label %14
14: ; preds = %9, %2
%15 = phi i64 [ %13, %9 ], [ %1, %2 ]
%16 = zext i8 %3 to i32
%17 = add nuw nsw i32 %16, 1141046304
%18 = tail call i32 @PRCMHIBRegWrite(i32 %17, i64 %15)
ret void
}