#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*/ assert(int);
char chess_piece_char(int piece, int side) {
  bool iswhite;
  char cpiece;
  assert(piece >= 1 && piece <= 6);
  assert(side == 0 || side == 1);
  iswhite = (side == 0);
  cpiece = 0;
  switch (piece) {
  case 1:
    cpiece = iswhite ? 'P' : 'p';
    break;
  case 2:
    cpiece = iswhite ? 'N' : 'n';
    break;
  case 3:
    cpiece = iswhite ? 'B' : 'b';
    break;
  case 4:
    cpiece = iswhite ? 'R' : 'r';
    break;
  case 5:
    cpiece = iswhite ? 'Q' : 'q';
    break;
  case 6:
    cpiece = iswhite ? 'K' : 'k';
    break;
  default:
    break;
  }
  return cpiece;
}


x86 assembly (clang, -O0):
<chess_piece_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0xe(%rbp)
jl     1137 <chess_piece_char+0x27>
cmpl   $0x6,-0x4(%rbp)
setle  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0xf(%rbp)
je     115d <chess_piece_char+0x4d>
cmpl   $0x1,-0x8(%rbp)
sete   %al
mov    %al,-0xf(%rbp)
mov    -0xf(%rbp),%al
movzbl %al,%edi
and    $0x1,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
test   %eax,%eax
sete   %al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
movb   $0x0,-0xd(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     1248 <chess_piece_char+0x138>
mov    -0x18(%rbp),%rax
lea    0xe63(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%edx
mov    $0x70,%eax
mov    $0x50,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0xd(%rbp)
jmp    124d <chess_piece_char+0x13d>
mov    -0xc(%rbp),%edx
mov    $0x6e,%eax
mov    $0x4e,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0xd(%rbp)
jmp    124d <chess_piece_char+0x13d>
mov    -0xc(%rbp),%edx
mov    $0x62,%eax
mov    $0x42,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0xd(%rbp)
jmp    124d <chess_piece_char+0x13d>
mov    -0xc(%rbp),%edx
mov    $0x72,%eax
mov    $0x52,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0xd(%rbp)
jmp    124d <chess_piece_char+0x13d>
mov    -0xc(%rbp),%edx
mov    $0x71,%eax
mov    $0x51,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0xd(%rbp)
jmp    124d <chess_piece_char+0x13d>
mov    -0xc(%rbp),%edx
mov    $0x6b,%eax
mov    $0x4b,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0xd(%rbp)
jmp    124d <chess_piece_char+0x13d>
jmp    124d <chess_piece_char+0x13d>
movsbl -0xd(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chess_piece_char>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
add    $0xffffffff,%ebx
xor    %edi,%edi
cmp    $0x6,%ebx
setb   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x2,%ebp
setb   %dil
call   1030 <assert@plt>
cmp    $0x5,%ebx
ja     1157 <chess_piece_char+0x47>
lea    0xebe(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
test   %ebp,%ebp
setne  %al
shl    $0x5,%al
or     $0x50,%al
jmp    1195 <chess_piece_char+0x85>
xor    %eax,%eax
jmp    1195 <chess_piece_char+0x85>
test   %ebp,%ebp
setne  %al
shl    $0x5,%al
or     $0x4e,%al
jmp    1195 <chess_piece_char+0x85>
test   %ebp,%ebp
setne  %al
shl    $0x5,%al
or     $0x42,%al
jmp    1195 <chess_piece_char+0x85>
test   %ebp,%ebp
setne  %al
shl    $0x5,%al
or     $0x52,%al
jmp    1195 <chess_piece_char+0x85>
test   %ebp,%ebp
setne  %al
shl    $0x5,%al
or     $0x51,%al
jmp    1195 <chess_piece_char+0x85>
test   %ebp,%ebp
setne  %al
shl    $0x5,%al
or     $0x4b,%al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @chess_piece_char(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = icmp sge i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 6
br label %12
12: ; preds = %9, %2
%13 = phi i1 [ false, %2 ], [ %11, %9 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 1
br label %21
21: ; preds = %18, %12
%22 = phi i1 [ true, %12 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
store i32 %27, i32* %5
store i8 0, i8* %6
%28 = load i32, i32* %3
switch i32 %28, label %65 [
i32 1, label %29
i32 2, label %35
i32 3, label %41
i32 4, label %47
i32 5, label %53
i32 6, label %59
]
29: ; preds = %21
%30 = load i32, i32* %5
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i32 80, i32 112
%34 = trunc i32 %33 to i8
store i8 %34, i8* %6
br label %66
35: ; preds = %21
%36 = load i32, i32* %5
%37 = icmp ne i32 %36, 0
%38 = zext i1 %37 to i64
%39 = select i1 %37, i32 78, i32 110
%40 = trunc i32 %39 to i8
store i8 %40, i8* %6
br label %66
41: ; preds = %21
%42 = load i32, i32* %5
%43 = icmp ne i32 %42, 0
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 66, i32 98
%46 = trunc i32 %45 to i8
store i8 %46, i8* %6
br label %66
47: ; preds = %21
%48 = load i32, i32* %5
%49 = icmp ne i32 %48, 0
%50 = zext i1 %49 to i64
%51 = select i1 %49, i32 82, i32 114
%52 = trunc i32 %51 to i8
store i8 %52, i8* %6
br label %66
53: ; preds = %21
%54 = load i32, i32* %5
%55 = icmp ne i32 %54, 0
%56 = zext i1 %55 to i64
%57 = select i1 %55, i32 81, i32 113
%58 = trunc i32 %57 to i8
store i8 %58, i8* %6
br label %66
59: ; preds = %21
%60 = load i32, i32* %5
%61 = icmp ne i32 %60, 0
%62 = zext i1 %61 to i64
%63 = select i1 %61, i32 75, i32 107
%64 = trunc i32 %63 to i8
store i8 %64, i8* %6
br label %66
65: ; preds = %21
br label %66
66: ; preds = %65, %59, %53, %47, %41, %35, %29
%67 = load i8, i8* %6
ret i8 %67
}

LLVM IR (-O2):
define signext i8 @chess_piece_char(i32 %0, i32 %1) {
%3 = add i32 %0, -1
%4 = icmp ult i32 %3, 6
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp eq i32 %1, 0
%8 = icmp ult i32 %1, 2
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
switch i32 %0, label %23 [
i32 1, label %11
i32 2, label %13
i32 3, label %15
i32 4, label %17
i32 5, label %19
i32 6, label %21
]
11: ; preds = %2
%12 = select i1 %7, i8 80, i8 112
br label %23
13: ; preds = %2
%14 = select i1 %7, i8 78, i8 110
br label %23
15: ; preds = %2
%16 = select i1 %7, i8 66, i8 98
br label %23
17: ; preds = %2
%18 = select i1 %7, i8 82, i8 114
br label %23
19: ; preds = %2
%20 = select i1 %7, i8 81, i8 113
br label %23
21: ; preds = %2
%22 = select i1 %7, i8 75, i8 107
br label %23
23: ; preds = %2, %21, %19, %17, %15, %13, %11
%24 = phi i8 [ 0, %2 ], [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ]
ret i8 %24
}