#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*/ strcpy(char *, char *);
char *printf_htm_entity(char *b, char *p) {
  switch (*p) {
  case '<':
    strcpy(b, "&lt;");
    b += 4;
    break;
  case '>':
    strcpy(b, "&gt;");
    b += 4;
    break;
  case '"':
    strcpy(b, "&quot;");
    b += 6;
    break;
  case '\'':
    strcpy(b, "&apos;");
    b += 6;
    break;
  case '&':
    strcpy(b, "&amp;");
    b += 5;
    break;
  default:
    *b++ = *p;
    break;
  }
  return (b);
}


x86 assembly (clang, -O0):
<printf_htm_entity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1c,%eax
ja     11f2 <printf_htm_entity+0xe2>
mov    -0x18(%rbp),%rax
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xf1c(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1209 <printf_htm_entity+0xf9>
mov    -0x8(%rbp),%rdi
lea    0xf00(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1209 <printf_htm_entity+0xf9>
mov    -0x8(%rbp),%rdi
lea    0xee4(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x8(%rbp)
jmp    1209 <printf_htm_entity+0xf9>
mov    -0x8(%rbp),%rdi
lea    0xeca(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x8(%rbp)
jmp    1209 <printf_htm_entity+0xf9>
mov    -0x8(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x8(%rbp)
jmp    1209 <printf_htm_entity+0xf9>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf_htm_entity>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rsi),%eax
lea    -0x22(%rax),%ecx
cmp    $0x1c,%ecx
ja     1138 <printf_htm_entity+0x28>
lea    0xeda(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf48(%rip),%rsi
jmp    115c <printf_htm_entity+0x4c>
mov    %al,(%rbx)
add    $0x1,%rbx
jmp    1186 <printf_htm_entity+0x76>
lea    0xf45(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
add    $0x5,%rbx
jmp    1186 <printf_htm_entity+0x76>
lea    0xf29(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
add    $0x6,%rbx
jmp    1186 <printf_htm_entity+0x76>
lea    0xf03(%rip),%rsi
jmp    117a <printf_htm_entity+0x6a>
lea    0xeff(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
add    $0x4,%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

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