#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 int uint8_t;

/* Variables and functions */
char *num_str(uint8_t card) {
  switch ((card & 0xF0) >> 4) {
  case 1:
    return "Ace";
  case 2:
    return "2";
  case 3:
    return "3";
  case 4:
    return "4";
  case 5:
    return "5";
  case 6:
    return "6";
  case 7:
    return "7";
  case 8:
    return "8";
  case 9:
    return "9";
  case 10:
    return "10";
  case 11:
    return "Jack";
  case 12:
    return "Queen";
  case 13:
    return "King";
  default:
    return "NULL";
  }
}


x86 assembly (clang, -O0):
<num_str>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
movzbl -0xc(%rbp),%eax
shr    $0x4,%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xc,%eax
ja     1204 <num_str+0x104>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xeed(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xedf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xec3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xeb5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xea7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xe7d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xe70(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xe65(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xe5b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <num_str+0x10f>
lea    0xe50(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_str>:
shr    $0x4,%edi
and    $0xf,%edi
add    $0xffffffff,%edi
cmp    $0xc,%edi
ja     1120 <num_str+0x20>
movslq %edi,%rax
lea    0xf14(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xf00(%rip),%rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"Ace\00"
@.str.1 = [2 x i8] c"2\00"
@.str.2 = [2 x i8] c"3\00"
@.str.3 = [2 x i8] c"4\00"
@.str.4 = [2 x i8] c"5\00"
@.str.5 = [2 x i8] c"6\00"
@.str.6 = [2 x i8] c"7\00"
@.str.7 = [2 x i8] c"8\00"
@.str.8 = [2 x i8] c"9\00"
@.str.9 = [3 x i8] c"10\00"
@.str.10 = [5 x i8] c"Jack\00"
@.str.11 = [6 x i8] c"Queen\00"
@.str.12 = [5 x i8] c"King\00"
@.str.13 = [5 x i8] c"NULL\00"
define i8* @num_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 240
%6 = ashr i32 %5, 4
switch i32 %6, label %20 [
i32 1, label %7
i32 2, label %8
i32 3, label %9
i32 4, label %10
i32 5, label %11
i32 6, label %12
i32 7, label %13
i32 8, label %14
i32 9, label %15
i32 10, label %16
i32 11, label %17
i32 12, label %18
i32 13, label %19
]
7: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %21
8: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %21
9: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %21
10: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %21
11: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %21
12: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %21
13: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %21
14: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %21
15: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %21
16: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %21
17: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %21
18: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %21
19: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %21
20: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %21
21: ; preds = %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
@.str = [4 x i8] c"Ace\00"
@.str.1 = [2 x i8] c"2\00"
@.str.2 = [2 x i8] c"3\00"
@.str.3 = [2 x i8] c"4\00"
@.str.4 = [2 x i8] c"5\00"
@.str.5 = [2 x i8] c"6\00"
@.str.6 = [2 x i8] c"7\00"
@.str.7 = [2 x i8] c"8\00"
@.str.8 = [2 x i8] c"9\00"
@.str.9 = [3 x i8] c"10\00"
@.str.10 = [5 x i8] c"Jack\00"
@.str.11 = [6 x i8] c"Queen\00"
@.str.12 = [5 x i8] c"King\00"
@.str.13 = [5 x i8] c"NULL\00"
@reltable.num_str = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.num_str to i64)) to i32)]
define i8* @num_str(i32 %0) {
%2 = lshr i32 %0, 4
%3 = and i32 %2, 15
%4 = add nsw i32 %3, -1
%5 = icmp ult i32 %4, 13
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.num_str to i8*), i64 %8)
br label %10
10: ; preds = %1, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), %1 ]
ret i8* %11
}