#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 */

/* Variables and functions */
int /*<<< orphan*/ strcat(char *, char const *);
int strlen(char const *);
int htmlize_character(char *dest, char ch) {
  const char *str;
  str = NULL;
  switch (ch) {
  case '"':
    str = "&quot;";
    break;
  case '\'':
    str = "&apos;";
    break;
  case '&':
    str = "&amp;";
    break;
  case '<':
    str = "&lt;";
    break;
  case '>':
    str = "&gt;";
    break;
  default:
    *dest++ = ch;
    *dest = '\0';
    return 1;
  }
  *dest = '\0';
  strcat(dest, str);
  return strlen(str);
}


x86 assembly (clang, -O0):
<htmlize_character>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movq   $0x0,-0x20(%rbp)
movsbl -0x11(%rbp),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x1c,%eax
ja     11b4 <htmlize_character+0x94>
mov    -0x28(%rbp),%rax
lea    0xea5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf09(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11db <htmlize_character+0xbb>
lea    0xf00(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11db <htmlize_character+0xbb>
lea    0xef7(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11db <htmlize_character+0xbb>
lea    0xeed(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11db <htmlize_character+0xbb>
lea    0xee2(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11db <htmlize_character+0xbb>
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11fb <htmlize_character+0xdb>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<htmlize_character>:
push   %rbx
lea    -0x22(%rsi),%eax
cmp    $0x1c,%eax
ja     1149 <htmlize_character+0x29>
lea    0xf44(%rip),%rbx
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf3b(%rip),%rbx
jmp    1170 <htmlize_character+0x50>
mov    %sil,(%rdi)
movb   $0x0,0x1(%rdi)
mov    $0x1,%eax
pop    %rbx
ret
lea    0xf1d(%rip),%rbx
jmp    1170 <htmlize_character+0x50>
lea    0xf21(%rip),%rbx
jmp    1170 <htmlize_character+0x50>
lea    0xf1d(%rip),%rbx
movb   $0x0,(%rdi)
mov    %rbx,%rsi
call   1040 <strcat@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <strlen@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"&quot;\00"
@.str.1 = [7 x i8] c"&apos;\00"
@.str.2 = [6 x i8] c"&amp;\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [5 x i8] c"&gt;\00"
define i32 @htmlize_character(i8* %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8* null, i8** %6
%7 = load i8, i8* %5
%8 = sext i8 %7 to i32
switch i32 %8, label %14 [
i32 34, label %9
i32 39, label %10
i32 38, label %11
i32 60, label %12
i32 62, label %13
]
9: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %6
br label %19
10: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %19
11: ; preds = %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %19
12: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %6
br label %19
13: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %6
br label %19
14: ; preds = %2
%15 = load i8, i8* %5
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %4
store i8 %15, i8* %16
%18 = load i8*, i8** %4
store i8 0, i8* %18
store i32 1, i32* %3
br label %26
19: ; preds = %13, %12, %11, %10, %9
%20 = load i8*, i8** %4
store i8 0, i8* %20
%21 = load i8*, i8** %4
%22 = load i8*, i8** %6
%23 = call i32 @strcat(i8* %21, i8* %22)
%24 = load i8*, i8** %6
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %3
br label %26
26: ; preds = %19, %14
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [7 x i8] c"&quot;\00"
@.str.1 = [7 x i8] c"&apos;\00"
@.str.2 = [6 x i8] c"&amp;\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [5 x i8] c"&gt;\00"
define i32 @htmlize_character(i8* %0, i8 signext %1) {
%3 = sext i8 %1 to i32
switch i32 %3, label %8 [
i32 34, label %10
i32 39, label %4
i32 38, label %5
i32 60, label %6
i32 62, label %7
]
4: ; preds = %2
br label %10
5: ; preds = %2
br label %10
6: ; preds = %2
br label %10
7: ; preds = %2
br label %10
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %1, i8* %0
store i8 0, i8* %9
br label %14
10: ; preds = %2, %7, %6, %5, %4
%11 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %2 ]
store i8 0, i8* %0
%12 = tail call i32 @strcat(i8* %0, i8* %11)
%13 = tail call i32 @strlen(i8* %11)
br label %14
14: ; preds = %10, %8
%15 = phi i32 [ 1, %8 ], [ %13, %10 ]
ret i32 %15
}