#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*/ assert(int /*<<< orphan*/);
bool char_entity(char const **tag, size_t *ps, int c) {
  assert(tag != NULL);
  assert(ps != NULL);
  switch (c) {
  case '<':
    *tag = "&lt;";
    *ps = 4;
    return true;
  case '>':
    *tag = "&gt;";
    *ps = 4;
    return true;
  case '&':
    *tag = "&amp;";
    *ps = 5;
    return true;
  case '"':
    *tag = "&quot;";
    *ps = 6;
    return true;
  default:
    return false;
  }
}


x86 assembly (clang, -O0):
<char_entity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
test   %rax,%rax
setne  %al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
test   %rax,%rax
setne  %al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x1c,%eax
ja     1204 <char_entity+0xf4>
mov    -0x28(%rbp),%rax
lea    0xe99(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
lea    0xef9(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x4,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    120b <char_entity+0xfb>
mov    -0x10(%rbp),%rax
lea    0xed9(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x4,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    120b <char_entity+0xfb>
mov    -0x10(%rbp),%rax
lea    0xeb9(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x5,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    120b <char_entity+0xfb>
mov    -0x10(%rbp),%rax
lea    0xe9a(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x6,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    120b <char_entity+0xfb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char_entity>:
push   %r15
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0xffffffde,%ebx
cmp    $0x1c,%ebx
ja     118d <char_entity+0x7d>
mov    $0x4,%ecx
lea    0xf25(%rip),%rdx
lea    0xeaa(%rip),%rsi
movslq (%rsi,%rbx,4),%rdi
add    %rsi,%rdi
jmp    *%rdi
mov    $0x6,%ecx
lea    0xf19(%rip),%rdx
jmp    1182 <char_entity+0x72>
mov    $0x5,%ecx
lea    0xf05(%rip),%rdx
jmp    1182 <char_entity+0x72>
lea    0xef7(%rip),%rdx
mov    %rdx,(%r15)
mov    %rcx,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"&lt;\00"
@.str.1 = [5 x i8] c"&gt;\00"
@.str.2 = [6 x i8] c"&amp;\00"
@.str.3 = [7 x i8] c"&quot;\00"
define i32 @char_entity(i8** writeonly %0, i64* writeonly %1, i32 %2) {
%4 = icmp ne i8** %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp ne i64* %1, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
switch i32 %2, label %16 [
i32 60, label %13
i32 62, label %10
i32 38, label %11
i32 34, label %12
]
10: ; preds = %3
br label %13
11: ; preds = %3
br label %13
12: ; preds = %3
br label %13
13: ; preds = %3, %10, %11, %12
%14 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %12 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %11 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %3 ]
%15 = phi i64 [ 6, %12 ], [ 5, %11 ], [ 4, %10 ], [ 4, %3 ]
store i8* %14, i8** %0
store i64 %15, i64* %1
br label %16
16: ; preds = %13, %3
%17 = phi i32 [ 0, %3 ], [ 1, %13 ]
ret i32 %17
}