#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 */
typedef int /*<<< orphan*/ enttable;

/* Variables and functions */
scalar_t__ strcmp(char *, char *);
int decodeEntity(char *ent, int *cp) {
  static struct {
    char *ent;
    char c;
  } enttable[] = {
      {"&amp;", '&'}, {"&apos;", '\''}, {"&lt;", '<'},
      {"&gt;", '>'},  {"&quot;", '"'},
  };
  for (int i = 0; i < (int)(sizeof(enttable) / sizeof(enttable[0])); i++) {
    if (strcmp(ent, enttable[i].ent) == 0) {
      *cp = enttable[i].c;
      return (1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<decodeEntity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    1194 <decodeEntity+0x84>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rcx
lea    0x2ef0(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1181 <decodeEntity+0x71>
movslq -0x1c(%rbp),%rcx
lea    0x2ecc(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movsbl 0x8(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    119b <decodeEntity+0x8b>
jmp    1186 <decodeEntity+0x76>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <decodeEntity+0x17>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decodeEntity>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1187 <decodeEntity+0x77>
lea    0xed4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     118b <decodeEntity+0x7b>
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1192 <decodeEntity+0x82>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1199 <decodeEntity+0x89>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11b6 <decodeEntity+0xa6>
mov    $0x4,%eax
jmp    119e <decodeEntity+0x8e>
xor    %eax,%eax
jmp    119e <decodeEntity+0x8e>
mov    $0x1,%eax
jmp    119e <decodeEntity+0x8e>
mov    $0x2,%eax
jmp    119e <decodeEntity+0x8e>
mov    $0x3,%eax
shl    $0x4,%rax
lea    0x2c27(%rip),%rcx
movsbl 0x8(%rax,%rcx,1),%eax
mov    %eax,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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