int shade(char c, char *cp) {
  switch (c) {
  case '0':
    *cp = ' ';
    break;
  case '1':
    *cp = '.';
    break;
  case '2':
    *cp = ':';
    break;
  case '3':
    *cp = 'c';
    break;
  case '4':
    *cp = 'o';
    break;
  case '5':
    *cp = 'C';
    break;
  case '6':
    *cp = 'O';
    break;
  case '7':
    *cp = '8';
    break;
  case '8':
    *cp = '@';
    break;
  case '\n':
    break;
  case '\r':
    break;
  default:
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<shade>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x2e,%eax
ja     11ae <shade+0xae>
mov    -0x18(%rbp),%rax
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
movb   $0x20,(%rax)
jmp    11ba <shade+0xba>
mov    -0x10(%rbp),%rax
movb   $0x2e,(%rax)
jmp    11ba <shade+0xba>
mov    -0x10(%rbp),%rax
movb   $0x3a,(%rax)
jmp    11ba <shade+0xba>
mov    -0x10(%rbp),%rax
movb   $0x63,(%rax)
jmp    11ba <shade+0xba>
mov    -0x10(%rbp),%rax
movb   $0x6f,(%rax)
jmp    11ba <shade+0xba>
mov    -0x10(%rbp),%rax
movb   $0x43,(%rax)
jmp    11ba <shade+0xba>
mov    -0x10(%rbp),%rax
movb   $0x4f,(%rax)
jmp    11ba <shade+0xba>
mov    -0x10(%rbp),%rax
movb   $0x38,(%rax)
jmp    11ba <shade+0xba>
mov    -0x10(%rbp),%rax
movb   $0x40,(%rax)
jmp    11ba <shade+0xba>
jmp    11ba <shade+0xba>
jmp    11ba <shade+0xba>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <shade+0xc1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<shade>:
xor    %eax,%eax
add    $0xfffffff6,%edi
cmp    $0x2e,%edi
ja     1141 <shade+0x41>
mov    $0x20,%cl
lea    0xeed(%rip),%rdx
movslq (%rdx,%rdi,4),%rdi
add    %rdx,%rdi
jmp    *%rdi
mov    $0x2e,%cl
jmp    113a <shade+0x3a>
mov    $0x3a,%cl
jmp    113a <shade+0x3a>
mov    $0x63,%cl
jmp    113a <shade+0x3a>
mov    $0x6f,%cl
jmp    113a <shade+0x3a>
mov    $0x43,%cl
jmp    113a <shade+0x3a>
mov    $0x4f,%cl
jmp    113a <shade+0x3a>
mov    $0x38,%cl
jmp    113a <shade+0x3a>
mov    $0x40,%cl
mov    %cl,(%rsi)
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @shade(i8 signext %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8*
store i8 %0, i8* %4
store i8* %1, i8** %5
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
switch i32 %7, label %28 [
i32 48, label %8
i32 49, label %10
i32 50, label %12
i32 51, label %14
i32 52, label %16
i32 53, label %18
i32 54, label %20
i32 55, label %22
i32 56, label %24
i32 10, label %26
i32 13, label %27
]
8: ; preds = %2
%9 = load i8*, i8** %5
store i8 32, i8* %9
br label %29
10: ; preds = %2
%11 = load i8*, i8** %5
store i8 46, i8* %11
br label %29
12: ; preds = %2
%13 = load i8*, i8** %5
store i8 58, i8* %13
br label %29
14: ; preds = %2
%15 = load i8*, i8** %5
store i8 99, i8* %15
br label %29
16: ; preds = %2
%17 = load i8*, i8** %5
store i8 111, i8* %17
br label %29
18: ; preds = %2
%19 = load i8*, i8** %5
store i8 67, i8* %19
br label %29
20: ; preds = %2
%21 = load i8*, i8** %5
store i8 79, i8* %21
br label %29
22: ; preds = %2
%23 = load i8*, i8** %5
store i8 56, i8* %23
br label %29
24: ; preds = %2
%25 = load i8*, i8** %5
store i8 64, i8* %25
br label %29
26: ; preds = %2
br label %29
27: ; preds = %2
br label %29
28: ; preds = %2
store i32 0, i32* %3
br label %30
29: ; preds = %27, %26, %24, %22, %20, %18, %16, %14, %12, %10, %8
store i32 1, i32* %3
br label %30
30: ; preds = %29, %28
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @shade(i8 signext %0, i8* nocapture writeonly %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %15 [
i32 48, label %12
i32 49, label %4
i32 50, label %5
i32 51, label %6
i32 52, label %7
i32 53, label %8
i32 54, label %9
i32 55, label %10
i32 56, label %11
i32 10, label %14
i32 13, label %14
]
4: ; preds = %2
br label %12
5: ; preds = %2
br label %12
6: ; preds = %2
br label %12
7: ; preds = %2
br label %12
8: ; preds = %2
br label %12
9: ; preds = %2
br label %12
10: ; preds = %2
br label %12
11: ; preds = %2
br label %12
12: ; preds = %2, %4, %5, %6, %7, %8, %9, %10, %11
%13 = phi i8 [ 64, %11 ], [ 56, %10 ], [ 79, %9 ], [ 67, %8 ], [ 111, %7 ], [ 99, %6 ], [ 58, %5 ], [ 46, %4 ], [ 32, %2 ]
store i8 %13, i8* %1
br label %14
14: ; preds = %12, %2, %2
br label %15
15: ; preds = %2, %14
%16 = phi i32 [ 1, %14 ], [ 0, %2 ]
ret i32 %16
}