void display_card(int card) {
  int suit, value, joker;
  suit = (card >> 4) & 3;
  value = card & 15;
  joker = card >> 6 & 1;
  char pre = '[';
  char post = ']';
  char jokerChar = '\0';
  char *color = malloc(70);
  if (joker) {
    jokerChar = 'J';
  }
  switch (suit) {
  case 0:
    color = "\x1B[35m";
    break;
  case 1:
    color = "\x1B[32m";
    break;
  case 2:
    color = "\x1B[34m";
    break;
  case 3:
    color = "\x1B[33m";
    break;
  }
  if (value == 0) {
    printf("%s%c%c%c%s", color, pre, jokerChar, post, "\x1B[37m");
  } else {
    printf("%s%c%c%i%c%s", color, pre, jokerChar, value, post, "\x1B[37m");
  }
}


x86 assembly (clang, -O0):
<display_card>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x4,%eax
and    $0x3,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
and    $0x1,%eax
mov    %eax,-0x10(%rbp)
movb   $0x5b,-0x11(%rbp)
movb   $0x5d,-0x12(%rbp)
movb   $0x0,-0x13(%rbp)
mov    $0x46,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1174 <display_card+0x54>
movb   $0x4a,-0x13(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     11d4 <display_card+0xb4>
mov    -0x28(%rbp),%rax
lea    0xe70(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe70(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d4 <display_card+0xb4>
lea    0xe66(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d4 <display_card+0xb4>
lea    0xe5c(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d4 <display_card+0xb4>
lea    0xe52(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1209 <display_card+0xe9>
mov    -0x20(%rbp),%rsi
movsbl -0x11(%rbp),%edx
movsbl -0x13(%rbp),%ecx
movsbl -0x12(%rbp),%r8d
lea    0xe32(%rip),%rdi
lea    0xe36(%rip),%r9
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1237 <display_card+0x117>
mov    -0x20(%rbp),%rsi
movsbl -0x11(%rbp),%edx
movsbl -0x13(%rbp),%ecx
mov    -0xc(%rbp),%r8d
movsbl -0x12(%rbp),%r9d
lea    0xe14(%rip),%rdi
lea    0xe07(%rip),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_card>:
push   %rax
mov    %edi,%r8d
mov    %edi,%eax
shr    $0x4,%eax
and    $0x3,%eax
mov    %edi,%ecx
shl    $0x19,%ecx
sar    $0x1f,%ecx
and    $0x4a,%ecx
lea    0x2cd2(%rip),%rdx
mov    (%rdx,%rax,8),%rsi
and    $0xf,%r8d
je     115e <display_card+0x4e>
lea    0xee4(%rip),%rax
mov    %rax,(%rsp)
lea    0xedf(%rip),%rdi
mov    $0x5b,%edx
mov    $0x5d,%r9d
xor    %eax,%eax
call   1030 <printf@plt>
pop    %rax
ret
lea    0xeb3(%rip),%rdi
lea    0xeb7(%rip),%r9
mov    $0x5b,%edx
mov    $0x5d,%r8d
xor    %eax,%eax
pop    %r11
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\1B[35m\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [6 x i8] c"\1B[34m\00"
@.str.3 = [6 x i8] c"\1B[33m\00"
@.str.4 = [11 x i8] c"%s%c%c%c%s\00"
@.str.5 = [6 x i8] c"\1B[37m\00"
@.str.6 = [13 x i8] c"%s%c%c%i%c%s\00"
define void @display_card(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8*
store i32 %0, i32* %2
%10 = load i32, i32* %2
%11 = ashr i32 %10, 4
%12 = and i32 %11, 3
store i32 %12, i32* %3
%13 = load i32, i32* %2
%14 = and i32 %13, 15
store i32 %14, i32* %4
%15 = load i32, i32* %2
%16 = ashr i32 %15, 6
%17 = and i32 %16, 1
store i32 %17, i32* %5
store i8 91, i8* %6
store i8 93, i8* %7
store i8 0, i8* %8
%18 = call i8* @malloc(i64 70)
store i8* %18, i8** %9
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %1
store i8 74, i8* %8
br label %22
22: ; preds = %21, %1
%23 = load i32, i32* %3
switch i32 %23, label %28 [
i32 0, label %24
i32 1, label %25
i32 2, label %26
i32 3, label %27
]
24: ; preds = %22
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %9
br label %28
25: ; preds = %22
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %9
br label %28
26: ; preds = %22
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %9
br label %28
27: ; preds = %22
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %9
br label %28
28: ; preds = %22, %27, %26, %25, %24
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i8*, i8** %9
%33 = load i8, i8* %6
%34 = sext i8 %33 to i32
%35 = load i8, i8* %8
%36 = sext i8 %35 to i32
%37 = load i8, i8* %7
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %32, i32 %34, i32 %36, i32 %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %50
40: ; preds = %28
%41 = load i8*, i8** %9
%42 = load i8, i8* %6
%43 = sext i8 %42 to i32
%44 = load i8, i8* %8
%45 = sext i8 %44 to i32
%46 = load i32, i32* %4
%47 = load i8, i8* %7
%48 = sext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %41, i32 %43, i32 %45, i32 %46, i32 %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %50
50: ; preds = %40, %31
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\1B[35m\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [6 x i8] c"\1B[34m\00"
@.str.3 = [6 x i8] c"\1B[33m\00"
@.str.4 = [11 x i8] c"%s%c%c%c%s\00"
@.str.5 = [6 x i8] c"\1B[37m\00"
@.str.6 = [13 x i8] c"%s%c%c%i%c%s\00"
@switch.table.display_card = [4 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)]
define void @display_card(i32 %0) {
%2 = lshr i32 %0, 4
%3 = and i32 %2, 3
%4 = and i32 %0, 15
%5 = and i32 %0, 64
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i32 0, i32 74
%8 = zext i32 %3 to i64
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* @switch.table.display_card, i64 0, i64 %8
%10 = load i8*, i8** %9
%11 = icmp eq i32 %4, 0
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %10, i32 91, i32 %7, i32 93, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %16
14: ; preds = %1
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %10, i32 91, i32 %7, i32 %4, i32 93, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
ret void
}