#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*/ xdo_rb_ctr_row(int *);
int xgp_ahd_interpolate(int tile) {
  int p[4];
  switch (tile) {
  default:
  case 0:
  case 1:
    p[0] = 0;
    p[1] = 1;
    p[2] = 2;
    p[3] = 3;
    break;
  case 2:
  case 3:
    p[0] = 1;
    p[1] = 0;
    p[2] = 3;
    p[3] = 2;
    break;
  case 4:
  case 5:
    p[0] = 3;
    p[1] = 2;
    p[2] = 1;
    p[3] = 0;
    break;
  case 6:
  case 7:
    p[0] = 2;
    p[1] = 3;
    p[2] = 0;
    p[3] = 1;
    break;
  }
  xdo_rb_ctr_row(p);
  xdo_rb_ctr_row(p);
  return 0;
}


x86 assembly (clang, -O0):
<xgp_ahd_interpolate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x7,%rax
ja     1140 <xgp_ahd_interpolate+0x30>
mov    -0x28(%rbp),%rax
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1145 <xgp_ahd_interpolate+0x35>
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x2,-0x18(%rbp)
movl   $0x3,-0x14(%rbp)
jmp    11c4 <xgp_ahd_interpolate+0xb4>
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x3,-0x18(%rbp)
movl   $0x2,-0x14(%rbp)
jmp    11c4 <xgp_ahd_interpolate+0xb4>
movl   $0x3,-0x20(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    11c4 <xgp_ahd_interpolate+0xb4>
movl   $0x2,-0x20(%rbp)
movl   $0x3,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <xdo_rb_ctr_row@plt>
lea    -0x20(%rbp),%rdi
call   1030 <xdo_rb_ctr_row@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xgp_ahd_interpolate>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x7,%edi
ja     1177 <xgp_ahd_interpolate+0x67>
mov    $0xc,%eax
bt     %edi,%eax
jb     1162 <xgp_ahd_interpolate+0x52>
mov    $0x30,%eax
bt     %edi,%eax
jb     114d <xgp_ahd_interpolate+0x3d>
mov    $0xc0,%eax
bt     %edi,%eax
jae    1177 <xgp_ahd_interpolate+0x67>
movl   $0x2,(%rsp)
mov    $0x1,%eax
xor    %ecx,%ecx
mov    $0x3,%edx
jmp    118d <xgp_ahd_interpolate+0x7d>
movl   $0x3,(%rsp)
xor    %eax,%eax
mov    $0x1,%ecx
mov    $0x2,%edx
jmp    118d <xgp_ahd_interpolate+0x7d>
movl   $0x1,(%rsp)
mov    $0x2,%eax
mov    $0x3,%ecx
xor    %edx,%edx
jmp    118d <xgp_ahd_interpolate+0x7d>
movl   $0x0,(%rsp)
mov    $0x3,%eax
mov    $0x2,%ecx
mov    $0x1,%edx
mov    %edx,0x4(%rsp)
mov    %ecx,0x8(%rsp)
mov    %eax,0xc(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <xdo_rb_ctr_row@plt>
mov    %rbx,%rdi
call   1030 <xdo_rb_ctr_row@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @xgp_ahd_interpolate(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i32]
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %5 [
i32 0, label %6
i32 1, label %6
i32 2, label %11
i32 3, label %11
i32 4, label %16
i32 5, label %16
i32 6, label %21
i32 7, label %21
]
5: ; preds = %1
br label %6
6: ; preds = %1, %1, %5
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
store i32 0, i32* %7
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
store i32 1, i32* %8
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
store i32 2, i32* %9
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
store i32 3, i32* %10
br label %26
11: ; preds = %1, %1
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
store i32 1, i32* %12
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
store i32 0, i32* %13
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
store i32 3, i32* %14
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
store i32 2, i32* %15
br label %26
16: ; preds = %1, %1
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
store i32 3, i32* %17
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
store i32 2, i32* %18
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
store i32 1, i32* %19
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
store i32 0, i32* %20
br label %26
21: ; preds = %1, %1
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
store i32 2, i32* %22
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
store i32 3, i32* %23
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
store i32 0, i32* %24
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
store i32 1, i32* %25
br label %26
26: ; preds = %21, %16, %11, %6
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%28 = call i32 @xdo_rb_ctr_row(i32* %27)
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%30 = call i32 @xdo_rb_ctr_row(i32* %29)
ret i32 0
}

LLVM IR (-O2):
define i32 @xgp_ahd_interpolate(i32 %0) {
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %2 to i8*
switch i32 %0, label %4 [
i32 7, label %10
i32 6, label %10
i32 2, label %6
i32 3, label %6
i32 4, label %8
i32 5, label %8
]
4: ; preds = %1
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
store i32 0, i32* %5
br label %12
6: ; preds = %1, %1
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
store i32 1, i32* %7
br label %12
8: ; preds = %1, %1
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
store i32 3, i32* %9
br label %12
10: ; preds = %1, %1
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
store i32 2, i32* %11
br label %12
12: ; preds = %10, %8, %6, %4
%13 = phi i32 [ 3, %10 ], [ 2, %8 ], [ 0, %6 ], [ 1, %4 ]
%14 = phi i32 [ 0, %10 ], [ 1, %8 ], [ 3, %6 ], [ 2, %4 ]
%15 = phi i32 [ 1, %10 ], [ 0, %8 ], [ 2, %6 ], [ 3, %4 ]
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
store i32 %13, i32* %16
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
store i32 %14, i32* %17
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
store i32 %15, i32* %18
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%20 = call i32 @xdo_rb_ctr_row(i32* %19)
%21 = call i32 @xdo_rb_ctr_row(i32* %19)
ret i32 0
}