#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*/ sprintf(char *, char *);
void print_piece(unsigned int piece, char *text) {
  if (0) {
  } else if ((piece & 7) == 1)
    sprintf(text, "PW");
  else if ((piece & 7) == 2)
    sprintf(text, "TW");
  else if ((piece & 7) == 3)
    sprintf(text, "HR");
  else if ((piece & 7) == 4)
    sprintf(text, "BI");
  else if ((piece & 7) == 5)
    sprintf(text, "QE");
  else if ((piece & 7) == 6)
    sprintf(text, "KI");
}


x86 assembly (clang, -O0):
<print_piece>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cmp    $0x1,%eax
jne    1143 <print_piece+0x33>
mov    -0x10(%rbp),%rdi
lea    0xec7(%rip),%rsi
call   1030 <sprintf@plt>
jmp    120b <print_piece+0xfb>
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cmp    $0x2,%eax
jne    1167 <print_piece+0x57>
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1206 <print_piece+0xf6>
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cmp    $0x3,%eax
jne    118b <print_piece+0x7b>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1201 <print_piece+0xf1>
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cmp    $0x4,%eax
jne    11af <print_piece+0x9f>
mov    -0x10(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11fc <print_piece+0xec>
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cmp    $0x5,%eax
jne    11d3 <print_piece+0xc3>
mov    -0x10(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11f7 <print_piece+0xe7>
mov    -0x4(%rbp),%eax
and    $0x7,%eax
cmp    $0x6,%eax
jne    11f2 <print_piece+0xe2>
mov    -0x10(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11f7 <print_piece+0xe7>
jmp    11fc <print_piece+0xec>
jmp    1201 <print_piece+0xf1>
jmp    1206 <print_piece+0xf6>
jmp    120b <print_piece+0xfb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_piece>:
and    $0x7,%edi
add    $0xffffffff,%edi
cmp    $0x5,%edi
ja     1156 <print_piece+0x56>
lea    0xeee(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movb   $0x0,0x2(%rsi)
movw   $0x5750,(%rsi)
ret
movb   $0x0,0x2(%rsi)
movw   $0x5754,(%rsi)
ret
movb   $0x0,0x2(%rsi)
movw   $0x5248,(%rsi)
ret
movb   $0x0,0x2(%rsi)
movw   $0x4942,(%rsi)
ret
movb   $0x0,0x2(%rsi)
movw   $0x4551,(%rsi)
ret
movb   $0x0,0x2(%rsi)
movw   $0x494b,(%rsi)
ret

LLVM IR (-O0):
@.str = [3 x i8] c"PW\00"
@.str.1 = [3 x i8] c"TW\00"
@.str.2 = [3 x i8] c"HR\00"
@.str.3 = [3 x i8] c"BI\00"
@.str.4 = [3 x i8] c"QE\00"
@.str.5 = [3 x i8] c"KI\00"
define void @print_piece(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = and i32 %5, 7
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %51
11: ; preds = %2
%12 = load i32, i32* %3
%13 = and i32 %12, 7
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %50
18: ; preds = %11
%19 = load i32, i32* %3
%20 = and i32 %19, 7
%21 = icmp eq i32 %20, 3
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %49
25: ; preds = %18
%26 = load i32, i32* %3
%27 = and i32 %26, 7
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %48
32: ; preds = %25
%33 = load i32, i32* %3
%34 = and i32 %33, 7
%35 = icmp eq i32 %34, 5
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i8*, i8** %4
%38 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %47
39: ; preds = %32
%40 = load i32, i32* %3
%41 = and i32 %40, 7
%42 = icmp eq i32 %41, 6
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %4
%45 = call i32 @sprintf(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %43, %39
br label %47
47: ; preds = %46, %36
br label %48
48: ; preds = %47, %29
br label %49
49: ; preds = %48, %22
br label %50
50: ; preds = %49, %15
br label %51
51: ; preds = %50, %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"PW\00"
@.str.1 = [3 x i8] c"TW\00"
@.str.2 = [3 x i8] c"HR\00"
@.str.3 = [3 x i8] c"BI\00"
@.str.4 = [3 x i8] c"QE\00"
@.str.5 = [3 x i8] c"KI\00"
define void @print_piece(i32 %0, i8* nocapture writeonly %1) {
%3 = and i32 %0, 7
switch i32 %3, label %10 [
i32 1, label %4
i32 2, label %5
i32 3, label %6
i32 4, label %7
i32 5, label %8
i32 6, label %9
]
4: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %1, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 3, i1 false)
br label %10
5: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %1, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 3, i1 false)
br label %10
6: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %1, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 3, i1 false)
br label %10
7: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %1, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 3, i1 false)
br label %10
8: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %1, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 3, i1 false)
br label %10
9: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %1, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 3, i1 false)
br label %10
10: ; preds = %2, %5, %7, %9, %8, %6, %4
ret void
}