const char *html_entity(const char ch) {
  static char s[2];
  switch (ch) {
  case ' ':
    return "&nbsp;";
    break;
  case '<':
    return "&lt;";
    break;
  case '>':
    return "&gt;";
    break;
  case '&':
    return "&amp;";
    break;
  default:
    s[0] = ch;
    s[1] = 0;
    return s;
    break;
  }
}


x86 assembly (clang, -O0):
<html_entity>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1e,%eax
ja     1174 <html_entity+0x74>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf41(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <html_entity+0x8f>
lea    0xf38(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <html_entity+0x8f>
lea    0xf2d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <html_entity+0x8f>
lea    0xf22(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <html_entity+0x8f>
mov    -0x9(%rbp),%al
mov    %al,0x2ea4(%rip)
movb   $0x0,0x2e9e(%rip)
lea    0x2e96(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<html_entity>:
lea    -0x20(%rdi),%ecx
cmp    $0x1e,%ecx
ja     1127 <html_entity+0x27>
lea    0xf6d(%rip),%rax
lea    0xeea(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf67(%rip),%rax
ret
mov    %dil,0x2ef3(%rip)
lea    0x2eec(%rip),%rax
movb   $0x0,0x2ee6(%rip)
ret
lea    0xf3f(%rip),%rax
ret
lea    0xf3c(%rip),%rax
ret

LLVM IR (-O0):
@html_entity.s = internal global [2 x i8] zeroinitializer
@.str = [7 x i8] c"&nbsp;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [6 x i8] c"&amp;\00"
define i8* @html_entity(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %10 [
i32 32, label %6
i32 60, label %7
i32 62, label %8
i32 38, label %9
]
6: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
br label %12
7: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %12
8: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %12
9: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %12
10: ; preds = %1
%11 = load i8, i8* %3
store i8 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @html_entity.s, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @html_entity.s, i64 0, i64 1)
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @html_entity.s, i64 0, i64 0), i8** %2
br label %12
12: ; preds = %10, %9, %8, %7, %6
%13 = load i8*, i8** %2
ret i8* %13
}

LLVM IR (-O2):
@html_entity.s = internal global [2 x i8] zeroinitializer
@.str = [7 x i8] c"&nbsp;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [6 x i8] c"&amp;\00"
define i8* @html_entity(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %6 [
i32 32, label %7
i32 60, label %3
i32 62, label %4
i32 38, label %5
]
3: ; preds = %1
br label %7
4: ; preds = %1
br label %7
5: ; preds = %1
br label %7
6: ; preds = %1
store i8 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @html_entity.s, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @html_entity.s, i64 0, i64 1)
br label %7
7: ; preds = %1, %6, %5, %4, %3
%8 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @html_entity.s, i64 0, i64 0), %6 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %8
}