#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 pinModeOut(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;
  }
  ca5_writeR((1UL << (index)), phyaddr);
  ca5_writeR((1UL << (index)), base_address + (0x14));
}


x86 assembly (clang, -O0):
<pinModeOut>:
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 <pinModeOut+0x46>
movl   $0x20930000,-0x14(%rbp)
jmp    11ac <pinModeOut+0x9c>
cmpl   $0x1,-0x8(%rbp)
jne    116c <pinModeOut+0x5c>
movl   $0x20931000,-0x14(%rbp)
jmp    11a7 <pinModeOut+0x97>
cmpl   $0x2,-0x8(%rbp)
jne    1182 <pinModeOut+0x72>
movl   $0x11a08000,-0x14(%rbp)
jmp    11a2 <pinModeOut+0x92>
cmpl   $0x3,-0x8(%rbp)
jne    1198 <pinModeOut+0x88>
movl   $0x20932000,-0x14(%rbp)
jmp    119d <pinModeOut+0x8d>
jmp    11d9 <pinModeOut+0xc9>
jmp    11a2 <pinModeOut+0x92>
jmp    11a7 <pinModeOut+0x97>
jmp    11ac <pinModeOut+0x9c>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
mov    $0x1,%edi
shl    %cl,%rdi
mov    -0x10(%rbp),%esi
call   1030 <ca5_writeR@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
mov    $0x1,%edi
shl    %cl,%rdi
mov    -0x14(%rbp),%esi
add    $0x14,%esi
call   1030 <ca5_writeR@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pinModeOut>:
push   %rbp
push   %rbx
push   %rax
mov    $0x20930014,%ebp
cmp    $0x20,%edi
jb     1136 <pinModeOut+0x26>
mov    %edi,%eax
sar    $0x5,%eax
add    $0xffffffff,%eax
cmp    $0x2,%eax
ja     115d <pinModeOut+0x4d>
cltq
lea    0xecd(%rip),%rcx
mov    (%rcx,%rax,4),%ebp
and    $0x1f,%edi
mov    $0x1,%ebx
mov    %edi,%ecx
shl    %cl,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <ca5_writeR@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ca5_writeR@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @pinModeOut(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 %44
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* %4
%34 = zext i32 %33 to i64
%35 = shl i64 1, %34
%36 = load i32, i32* %5
%37 = call i32 @ca5_writeR(i64 %35, i32 %36)
%38 = load i32, i32* %4
%39 = zext i32 %38 to i64
%40 = shl i64 1, %39
%41 = load i32, i32* %6
%42 = add i32 %41, 20
%43 = call i32 @ca5_writeR(i64 %40, i32 %42)
br label %44
44: ; preds = %32, %28
ret void
}

LLVM IR (-O2):
@switch.table.pinModeOut = [3 x i32] [i32 546508820, i32 295731220, i32 546512916]
define void @pinModeOut(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 %18
8: ; preds = %4
%9 = sext i32 %6 to i64
%10 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.pinModeOut, i64 0, i64 %9
%11 = load i32, i32* %10
br label %12
12: ; preds = %8, %1
%13 = phi i32 [ 546504724, %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 0)
%17 = tail call i32 @ca5_writeR(i64 %15, i32 %13)
br label %18
18: ; preds = %4, %12
ret void
}