char *onion_html_add_enc(char c, char *p) {
  switch (c) {
  case '<':
    *p++ = '&';
    *p++ = 'l';
    *p++ = 't';
    *p++ = ';';
    break;
  case '>':
    *p++ = '&';
    *p++ = 'g';
    *p++ = 't';
    *p++ = ';';
    break;
  case '"':
    *p++ = '&';
    *p++ = 'q';
    *p++ = 'u';
    *p++ = 'o';
    *p++ = 't';
    *p++ = ';';
    break;
  case '&':
    *p++ = '&';
    *p++ = 'a';
    *p++ = 'm';
    *p++ = 'p';
    *p++ = ';';
    break;
  case '\'':
    *p++ = '&';
    *p++ = '#';
    *p++ = '3';
    *p++ = '9';
    *p++ = ';';
    break;
  default:
    *p++ = c;
  }
  return p;
}


x86 assembly (clang, -O0):
<onion_html_add_enc>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1c,%eax
ja     1301 <onion_html_add_enc+0x201>
mov    -0x18(%rbp),%rax
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x26,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x6c,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x74,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x3b,(%rax)
jmp    1315 <onion_html_add_enc+0x215>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x26,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x67,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x74,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x3b,(%rax)
jmp    1315 <onion_html_add_enc+0x215>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x26,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x71,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x75,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x6f,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x74,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x3b,(%rax)
jmp    1315 <onion_html_add_enc+0x215>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x26,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x61,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x6d,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x70,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x3b,(%rax)
jmp    1315 <onion_html_add_enc+0x215>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x26,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x23,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x33,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x39,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x3b,(%rax)
jmp    1315 <onion_html_add_enc+0x215>
mov    -0x1(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<onion_html_add_enc>:
mov    %rsi,%rax
lea    -0x22(%rdi),%ecx
cmp    $0x1c,%ecx
ja     112c <onion_html_add_enc+0x2c>
lea    0xeee(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
movl   $0x6f757126,(%rax)
movw   $0x3b74,0x4(%rax)
add    $0x6,%rax
ret
mov    %dil,(%rax)
add    $0x1,%rax
ret
movl   $0x706d6126,(%rax)
jmp    1142 <onion_html_add_enc+0x42>
movl   $0x39332326,(%rax)
movb   $0x3b,0x4(%rax)
add    $0x5,%rax
ret
movl   $0x3b746c26,(%rax)
add    $0x4,%rax
ret
movl   $0x3b746726,(%rax)
add    $0x4,%rax
ret

LLVM IR (-O0):
define i8* @onion_html_add_enc(i8 signext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
store i8 %0, i8* %3
store i8* %1, i8** %4
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
switch i32 %6, label %60 [
i32 60, label %7
i32 62, label %16
i32 34, label %25
i32 38, label %38
i32 39, label %49
]
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %4
store i8 38, i8* %8
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %4
store i8 108, i8* %10
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
store i8 116, i8* %12
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
store i8 59, i8* %14
br label %64
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %4
store i8 38, i8* %17
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %4
store i8 103, i8* %19
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
store i8 116, i8* %21
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
store i8 59, i8* %23
br label %64
25: ; preds = %2
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
store i8 38, i8* %26
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
store i8 113, i8* %28
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %4
store i8 117, i8* %30
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %4
store i8 111, i8* %32
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %4
store i8 116, i8* %34
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %4
store i8 59, i8* %36
br label %64
38: ; preds = %2
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
store i8 38, i8* %39
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %4
store i8 97, i8* %41
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %4
store i8 109, i8* %43
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %4
store i8 112, i8* %45
%47 = load i8*, i8** %4
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %4
store i8 59, i8* %47
br label %64
49: ; preds = %2
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %4
store i8 38, i8* %50
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %4
store i8 35, i8* %52
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %4
store i8 51, i8* %54
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %4
store i8 57, i8* %56
%58 = load i8*, i8** %4
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %4
store i8 59, i8* %58
br label %64
60: ; preds = %2
%61 = load i8, i8* %3
%62 = load i8*, i8** %4
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %4
store i8 %61, i8* %62
br label %64
64: ; preds = %60, %49, %38, %25, %16, %7
%65 = load i8*, i8** %4
ret i8* %65
}

LLVM IR (-O2):
define i8* @onion_html_add_enc(i8 signext %0, i8* writeonly %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %33 [
i32 60, label %4
i32 62, label %9
i32 34, label %14
i32 38, label %21
i32 39, label %27
]
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %1, i64 1
store i8 38, i8* %1
%6 = getelementptr inbounds i8, i8* %1, i64 2
store i8 108, i8* %5
%7 = getelementptr inbounds i8, i8* %1, i64 3
store i8 116, i8* %6
%8 = getelementptr inbounds i8, i8* %1, i64 4
store i8 59, i8* %7
br label %35
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %1, i64 1
store i8 38, i8* %1
%11 = getelementptr inbounds i8, i8* %1, i64 2
store i8 103, i8* %10
%12 = getelementptr inbounds i8, i8* %1, i64 3
store i8 116, i8* %11
%13 = getelementptr inbounds i8, i8* %1, i64 4
store i8 59, i8* %12
br label %35
14: ; preds = %2
%15 = getelementptr inbounds i8, i8* %1, i64 1
store i8 38, i8* %1
%16 = getelementptr inbounds i8, i8* %1, i64 2
store i8 113, i8* %15
%17 = getelementptr inbounds i8, i8* %1, i64 3
store i8 117, i8* %16
%18 = getelementptr inbounds i8, i8* %1, i64 4
store i8 111, i8* %17
%19 = getelementptr inbounds i8, i8* %1, i64 5
store i8 116, i8* %18
%20 = getelementptr inbounds i8, i8* %1, i64 6
store i8 59, i8* %19
br label %35
21: ; preds = %2
%22 = getelementptr inbounds i8, i8* %1, i64 1
store i8 38, i8* %1
%23 = getelementptr inbounds i8, i8* %1, i64 2
store i8 97, i8* %22
%24 = getelementptr inbounds i8, i8* %1, i64 3
store i8 109, i8* %23
%25 = getelementptr inbounds i8, i8* %1, i64 4
store i8 112, i8* %24
%26 = getelementptr inbounds i8, i8* %1, i64 5
store i8 59, i8* %25
br label %35
27: ; preds = %2
%28 = getelementptr inbounds i8, i8* %1, i64 1
store i8 38, i8* %1
%29 = getelementptr inbounds i8, i8* %1, i64 2
store i8 35, i8* %28
%30 = getelementptr inbounds i8, i8* %1, i64 3
store i8 51, i8* %29
%31 = getelementptr inbounds i8, i8* %1, i64 4
store i8 57, i8* %30
%32 = getelementptr inbounds i8, i8* %1, i64 5
store i8 59, i8* %31
br label %35
33: ; preds = %2
%34 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %0, i8* %1
br label %35
35: ; preds = %33, %27, %21, %14, %9, %4
%36 = phi i8* [ %34, %33 ], [ %32, %27 ], [ %26, %21 ], [ %20, %14 ], [ %13, %9 ], [ %8, %4 ]
ret i8* %36
}