#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 */
int /*<<< orphan*/ ca5_writeR(unsigned long, unsigned int);
void pinWrite(int pin, int value) {
  unsigned int bank = pin >> 5;
  unsigned int index = pin - (bank << 5);
  unsigned int phyaddr = 0;
  unsigned int base_address = 0;
  if (bank == 0)
    base_address = 0x20930000;
  else if (bank == 1)
    base_address = 0x20931000;
  else if (bank == 2)
    base_address = 0x11A08000;
  else if (bank == 3)
    base_address = 0x20932000;
  else {
    return;
  }
  if (value)
    phyaddr = base_address + (0x10);
  else
    phyaddr = base_address + (0x14);
  ca5_writeR((1UL << (index)), phyaddr);
}


x86 assembly (clang, -O0):
<pinWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x5,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x5,%ecx
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1159 <pinWrite+0x49>
movl   $0x20930000,-0x18(%rbp)
jmp    11af <pinWrite+0x9f>
cmpl   $0x1,-0xc(%rbp)
jne    116f <pinWrite+0x5f>
movl   $0x20931000,-0x18(%rbp)
jmp    11aa <pinWrite+0x9a>
cmpl   $0x2,-0xc(%rbp)
jne    1185 <pinWrite+0x75>
movl   $0x11a08000,-0x18(%rbp)
jmp    11a5 <pinWrite+0x95>
cmpl   $0x3,-0xc(%rbp)
jne    119b <pinWrite+0x8b>
movl   $0x20932000,-0x18(%rbp)
jmp    11a0 <pinWrite+0x90>
jmp    11e5 <pinWrite+0xd5>
jmp    11a5 <pinWrite+0x95>
jmp    11aa <pinWrite+0x9a>
jmp    11af <pinWrite+0x9f>
cmpl   $0x0,-0x8(%rbp)
je     11c7 <pinWrite+0xb7>
mov    -0x18(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x14(%rbp)
jmp    11d0 <pinWrite+0xc0>
mov    -0x18(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
mov    $0x1,%edi
shl    %cl,%rdi
mov    -0x14(%rbp),%esi
call   1030 <ca5_writeR@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pinWrite>:
mov    $0x20930000,%ecx
cmp    $0x20,%edi
jb     1133 <pinWrite+0x23>
mov    %edi,%eax
sar    $0x5,%eax
add    $0xffffffff,%eax
cmp    $0x2,%eax
ja     1159 <pinWrite+0x49>
cltq
lea    0xed0(%rip),%rcx
mov    (%rcx,%rax,4),%ecx
and    $0x1f,%edi
xor    %eax,%eax
test   %esi,%esi
sete   %al
shl    $0x2,%eax
or     %ecx,%eax
or     $0x10,%eax
mov    $0x1,%edx
mov    %edi,%ecx
shl    %cl,%rdx
mov    %rdx,%rdi
mov    %eax,%esi
jmp    1030 <ca5_writeR@plt>
ret

LLVM IR (-O0):
define void @pinWrite(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = ashr i32 %9, 5
store i32 %10, i32* %5
%11 = load i32, i32* %3
%12 = load i32, i32* %5
%13 = shl i32 %12, 5
%14 = sub i32 %11, %13
store i32 %14, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 546504704, i32* %8
br label %34
18: ; preds = %2
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 546508800, i32* %8
br label %33
22: ; preds = %18
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 295731200, i32* %8
br label %32
26: ; preds = %22
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 3
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 546512896, i32* %8
br label %31
30: ; preds = %26
br label %49
31: ; preds = %29
br label %32
32: ; preds = %31, %25
br label %33
33: ; preds = %32, %21
br label %34
34: ; preds = %33, %17
%35 = load i32, i32* %4
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %8
%39 = add i32 %38, 16
store i32 %39, i32* %7
br label %43
40: ; preds = %34
%41 = load i32, i32* %8
%42 = add i32 %41, 20
store i32 %42, i32* %7
br label %43
43: ; preds = %40, %37
%44 = load i32, i32* %6
%45 = zext i32 %44 to i64
%46 = shl i64 1, %45
%47 = load i32, i32* %7
%48 = call i32 @ca5_writeR(i64 %46, i32 %47)
br label %49
49: ; preds = %43, %30
ret void
}

LLVM IR (-O2):
@switch.table.pinWrite = [3 x i32] [i32 546508800, i32 295731200, i32 546512896]
define void @pinWrite(i32 %0, i32 %1) {
%3 = and i32 %0, 31
%4 = icmp ult i32 %0, 32
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = ashr i32 %0, 5
%7 = add nsw i32 %6, -1
%8 = icmp ult i32 %7, 3
br i1 %8, label %9, label %21
9: ; preds = %5
%10 = sext i32 %7 to i64
%11 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.pinWrite, i64 0, i64 %10
%12 = load i32, i32* %11
br label %13
13: ; preds = %9, %2
%14 = phi i32 [ 546504704, %2 ], [ %12, %9 ]
%15 = icmp eq i32 %1, 0
%16 = select i1 %15, i32 20, i32 16
%17 = or i32 %14, %16
%18 = zext i32 %3 to i64
%19 = shl nuw nsw i64 1, %18
%20 = tail call i32 @ca5_writeR(i64 %19, i32 %17)
br label %21
21: ; preds = %5, %13
ret void
}