int *movptr(int attack, int pc) {
  static int knightd[9] = {-31, -33, -14, -18, 14, 18, 33, 31, 0};
  static int bishopd[5] = {-15, -17, 15, 17, 0};
  static int rookd[5] = {-16, -1, 16, 1, 0};
  static int queend[9] = {-15, -17, 15, 17, -16, -1, 16, 1, 0};
  static int kingd[9] = {-15, -17, 15, 17, -16, -1, 16, 1, 0};
  static int wpattd[3] = {-15, -17, 0};
  static int bpattd[3] = {15, 17, 0};
  static int wpmovd[4] = {-15, -16, -17, 0};
  static int bpmovd[4] = {15, 16, 17, 0};
  switch (pc) {
  case 2:
  case 3:
    return knightd;
  case 4:
  case 5:
    return bishopd;
  case 6:
  case 7:
    return rookd;
  case 8:
  case 9:
    return queend;
  case 0:
    switch (attack) {
    case 1:
      return wpattd;
    default:
      return wpmovd;
    }
  case 1:
    switch (attack) {
    case 1:
      return bpattd;
    default:
      return bpmovd;
    }
  default:
    return kingd;
  }
}


x86 assembly (clang, -O0):
<movptr>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x9,%rax
ja     11d1 <movptr+0xd1>
mov    -0x18(%rbp),%rax
lea    0xeda(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x2efa(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <movptr+0xdc>
lea    0x2f1a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <movptr+0xdc>
lea    0x2f2a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <movptr+0xdc>
lea    0x2f3a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <movptr+0xdc>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
jne    1190 <movptr+0x90>
jmp    1180 <movptr+0x80>
lea    0x2f6d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <movptr+0xdc>
lea    0x2f79(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <movptr+0xdc>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
jne    11c1 <movptr+0xc1>
jmp    11b1 <movptr+0xb1>
lea    0x2f48(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <movptr+0xdc>
lea    0x2f58(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <movptr+0xdc>
lea    0x2ef8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<movptr>:
cmp    $0x9,%esi
ja     1162 <movptr+0x62>
lea    0x2f24(%rip),%rax
mov    %esi,%ecx
lea    0xeeb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0x2f3b(%rip),%rax
ret
lea    0x2f53(%rip),%rax
ret
lea    0x2f6b(%rip),%rax
ret
cmp    $0x1,%edi
lea    0x2fb4(%rip),%rcx
lea    0x2fc9(%rip),%rax
cmove  %rcx,%rax
ret
cmp    $0x1,%edi
lea    0x2faa(%rip),%rcx
lea    0x2fc3(%rip),%rax
cmove  %rcx,%rax
ret
lea    0x2f67(%rip),%rax
ret

LLVM IR (-O0):
@movptr.knightd = internal global [9 x i32] [i32 -31, i32 -33, i32 -14, i32 -18, i32 14, i32 18, i32 33, i32 31, i32 0]
@movptr.bishopd = internal global [5 x i32] [i32 -15, i32 -17, i32 15, i32 17, i32 0]
@movptr.rookd = internal global [5 x i32] [i32 -16, i32 -1, i32 16, i32 1, i32 0]
@movptr.queend = internal global [9 x i32] [i32 -15, i32 -17, i32 15, i32 17, i32 -16, i32 -1, i32 16, i32 1, i32 0]
@movptr.kingd = internal global [9 x i32] [i32 -15, i32 -17, i32 15, i32 17, i32 -16, i32 -1, i32 16, i32 1, i32 0]
@movptr.wpattd = internal global [3 x i32] [i32 -15, i32 -17, i32 0]
@movptr.bpattd = internal global [3 x i32] [i32 15, i32 17, i32 0]
@movptr.wpmovd = internal global [4 x i32] [i32 -15, i32 -16, i32 -17, i32 0]
@movptr.bpmovd = internal global [4 x i32] [i32 15, i32 16, i32 17, i32 0]
define i32* @movptr(i32 %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %19 [
i32 2, label %7
i32 3, label %7
i32 4, label %8
i32 5, label %8
i32 6, label %9
i32 7, label %9
i32 8, label %10
i32 9, label %10
i32 0, label %11
i32 1, label %15
]
7: ; preds = %2, %2
store i32* getelementptr inbounds ([9 x i32], [9 x i32]* @movptr.knightd, i64 0, i64 0), i32** %3
br label %20
8: ; preds = %2, %2
store i32* getelementptr inbounds ([5 x i32], [5 x i32]* @movptr.bishopd, i64 0, i64 0), i32** %3
br label %20
9: ; preds = %2, %2
store i32* getelementptr inbounds ([5 x i32], [5 x i32]* @movptr.rookd, i64 0, i64 0), i32** %3
br label %20
10: ; preds = %2, %2
store i32* getelementptr inbounds ([9 x i32], [9 x i32]* @movptr.queend, i64 0, i64 0), i32** %3
br label %20
11: ; preds = %2
%12 = load i32, i32* %4
switch i32 %12, label %14 [
i32 1, label %13
]
13: ; preds = %11
store i32* getelementptr inbounds ([3 x i32], [3 x i32]* @movptr.wpattd, i64 0, i64 0), i32** %3
br label %20
14: ; preds = %11
store i32* getelementptr inbounds ([4 x i32], [4 x i32]* @movptr.wpmovd, i64 0, i64 0), i32** %3
br label %20
15: ; preds = %2
%16 = load i32, i32* %4
switch i32 %16, label %18 [
i32 1, label %17
]
17: ; preds = %15
store i32* getelementptr inbounds ([3 x i32], [3 x i32]* @movptr.bpattd, i64 0, i64 0), i32** %3
br label %20
18: ; preds = %15
store i32* getelementptr inbounds ([4 x i32], [4 x i32]* @movptr.bpmovd, i64 0, i64 0), i32** %3
br label %20
19: ; preds = %2
store i32* getelementptr inbounds ([9 x i32], [9 x i32]* @movptr.kingd, i64 0, i64 0), i32** %3
br label %20
20: ; preds = %19, %18, %17, %14, %13, %10, %9, %8, %7
%21 = load i32*, i32** %3
ret i32* %21
}

LLVM IR (-O2):
@movptr.knightd = internal global [9 x i32] [i32 -31, i32 -33, i32 -14, i32 -18, i32 14, i32 18, i32 33, i32 31, i32 0]
@movptr.bishopd = internal global [5 x i32] [i32 -15, i32 -17, i32 15, i32 17, i32 0]
@movptr.rookd = internal global [5 x i32] [i32 -16, i32 -1, i32 16, i32 1, i32 0]
@movptr.queend = internal global [9 x i32] [i32 -15, i32 -17, i32 15, i32 17, i32 -16, i32 -1, i32 16, i32 1, i32 0]
@movptr.kingd = internal global [9 x i32] [i32 -15, i32 -17, i32 15, i32 17, i32 -16, i32 -1, i32 16, i32 1, i32 0]
@movptr.wpattd = internal global [3 x i32] [i32 -15, i32 -17, i32 0]
@movptr.bpattd = internal global [3 x i32] [i32 15, i32 17, i32 0]
@movptr.wpmovd = internal global [4 x i32] [i32 -15, i32 -16, i32 -17, i32 0]
@movptr.bpmovd = internal global [4 x i32] [i32 15, i32 16, i32 17, i32 0]
define i32* @movptr(i32 %0, i32 %1) {
switch i32 %1, label %12 [
i32 2, label %13
i32 3, label %13
i32 4, label %3
i32 5, label %3
i32 6, label %4
i32 7, label %4
i32 8, label %5
i32 9, label %5
i32 0, label %6
i32 1, label %9
]
3: ; preds = %2, %2
br label %13
4: ; preds = %2, %2
br label %13
5: ; preds = %2, %2
br label %13
6: ; preds = %2
%7 = icmp eq i32 %0, 1
%8 = select i1 %7, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @movptr.wpattd, i64 0, i64 0), i32* getelementptr inbounds ([4 x i32], [4 x i32]* @movptr.wpmovd, i64 0, i64 0)
br label %13
9: ; preds = %2
%10 = icmp eq i32 %0, 1
%11 = select i1 %10, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @movptr.bpattd, i64 0, i64 0), i32* getelementptr inbounds ([4 x i32], [4 x i32]* @movptr.bpmovd, i64 0, i64 0)
br label %13
12: ; preds = %2
br label %13
13: ; preds = %9, %6, %2, %2, %12, %5, %4, %3
%14 = phi i32* [ getelementptr inbounds ([9 x i32], [9 x i32]* @movptr.kingd, i64 0, i64 0), %12 ], [ getelementptr inbounds ([9 x i32], [9 x i32]* @movptr.queend, i64 0, i64 0), %5 ], [ getelementptr inbounds ([5 x i32], [5 x i32]* @movptr.rookd, i64 0, i64 0), %4 ], [ getelementptr inbounds ([5 x i32], [5 x i32]* @movptr.bishopd, i64 0, i64 0), %3 ], [ getelementptr inbounds ([9 x i32], [9 x i32]* @movptr.knightd, i64 0, i64 0), %2 ], [ getelementptr inbounds ([9 x i32], [9 x i32]* @movptr.knightd, i64 0, i64 0), %2 ], [ %8, %6 ], [ %11, %9 ]
ret i32* %14
}