#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 pinModeIn(int pin) {
  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;
  }
  phyaddr = base_address + (0x08);
  ca5_writeR((1UL << (index)), phyaddr);
}


x86 assembly (clang, -O0):
<pinModeIn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x5,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x5,%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1156 <pinModeIn+0x46>
movl   $0x20930000,-0x14(%rbp)
jmp    11ac <pinModeIn+0x9c>
cmpl   $0x1,-0x8(%rbp)
jne    116c <pinModeIn+0x5c>
movl   $0x20931000,-0x14(%rbp)
jmp    11a7 <pinModeIn+0x97>
cmpl   $0x2,-0x8(%rbp)
jne    1182 <pinModeIn+0x72>
movl   $0x11a08000,-0x14(%rbp)
jmp    11a2 <pinModeIn+0x92>
cmpl   $0x3,-0x8(%rbp)
jne    1198 <pinModeIn+0x88>
movl   $0x20932000,-0x14(%rbp)
jmp    119d <pinModeIn+0x8d>
jmp    11ca <pinModeIn+0xba>
jmp    11a2 <pinModeIn+0x92>
jmp    11a7 <pinModeIn+0x97>
jmp    11ac <pinModeIn+0x9c>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
mov    $0x1,%edi
shl    %cl,%rdi
mov    -0x10(%rbp),%esi
call   1030 <ca5_writeR@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pinModeIn>:
mov    $0x20930008,%esi
cmp    $0x20,%edi
jb     1133 <pinModeIn+0x23>
mov    %edi,%eax
sar    $0x5,%eax
add    $0xffffffff,%eax
cmp    $0x2,%eax
ja     1148 <pinModeIn+0x38>
cltq
lea    0xed0(%rip),%rcx
mov    (%rcx,%rax,4),%esi
and    $0x1f,%edi
mov    $0x1,%eax
mov    %edi,%ecx
shl    %cl,%rax
mov    %rax,%rdi
jmp    1030 <ca5_writeR@plt>
ret

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

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