#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 */
typedef scalar_t__ piece;

/* Variables and functions */
int /*<<< orphan*/ dbg_error(char *);
int /*<<< orphan*/ exit(int);
int san_piece(int piece) {
  switch (((piece)&0xe)) {
  case 10:
    return 5;
  case 8:
    return 4;
  case 6:
    return 3;
  case 4:
    return 2;
  case 2:
    return 1;
  case 0:
    return 0;
  }
  dbg_error("failed to convert user interface piece to SAN piece");
  exit(1);
}


x86 assembly (clang, -O0):
<san_piece>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xe,%eax
mov    %rax,-0x10(%rbp)
sub    $0xa,%eax
ja     119a <san_piece+0x7a>
mov    -0x10(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x5,-0x4(%rbp)
jmp    11b0 <san_piece+0x90>
movl   $0x4,-0x4(%rbp)
jmp    11b0 <san_piece+0x90>
movl   $0x3,-0x4(%rbp)
jmp    11b0 <san_piece+0x90>
movl   $0x2,-0x4(%rbp)
jmp    11b0 <san_piece+0x90>
movl   $0x1,-0x4(%rbp)
jmp    11b0 <san_piece+0x90>
movl   $0x0,-0x4(%rbp)
jmp    11b0 <san_piece+0x90>
lea    0xe8b(%rip),%rdi
call   1030 <dbg_error@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<san_piece>:
push   %rax
and    $0xe,%edi
cmp    $0xb,%edi
jae    1141 <san_piece+0x21>
mov    $0x555,%eax
bt     %edi,%eax
jae    1141 <san_piece+0x21>
mov    %edi,%eax
lea    0xef8(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret
lea    0xeb8(%rip),%rdi
call   1030 <dbg_error@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"failed to convert user interface piece to SAN piece\00"
define i32 @san_piece(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 14
switch i32 %5, label %12 [
i32 10, label %6
i32 8, label %7
i32 6, label %8
i32 4, label %9
i32 2, label %10
i32 0, label %11
]
6: ; preds = %1
store i32 5, i32* %2
br label %15
7: ; preds = %1
store i32 4, i32* %2
br label %15
8: ; preds = %1
store i32 3, i32* %2
br label %15
9: ; preds = %1
store i32 2, i32* %2
br label %15
10: ; preds = %1
store i32 1, i32* %2
br label %15
11: ; preds = %1
store i32 0, i32* %2
br label %15
12: ; preds = %1
%13 = call i32 @dbg_error(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %11, %10, %9, %8, %7, %6
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
@.str = [52 x i8] c"failed to convert user interface piece to SAN piece\00"
@switch.table.san_piece = [11 x i32] [i32 0, i32 5, i32 1, i32 5, i32 2, i32 5, i32 3, i32 5, i32 4, i32 5, i32 5]
define i32 @san_piece(i32 %0) {
%2 = and i32 %0, 14
%3 = icmp ult i32 %2, 11
br i1 %3, label %7, label %4
4: ; preds = %7, %1
%5 = tail call i32 @dbg_error(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = trunc i32 %2 to i16
%9 = lshr i16 1365, %8
%10 = and i16 %9, 1
%11 = icmp eq i16 %10, 0
br i1 %11, label %4, label %12
12: ; preds = %7
%13 = zext i32 %2 to i64
%14 = getelementptr inbounds [11 x i32], [11 x i32]* @switch.table.san_piece, i64 0, i64 %13
%15 = load i32, i32* %14
ret i32 %15
}