#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 const *, char const *);
int decodeEntity(char *ent, int *cp) {
  static struct {
    const char *ent;
    char c;
  } enttable[] = {
      {"&amp;", '&'}, {"&apos;", '\''}, {"&lt;", '<'},
      {"&gt;", '>'},  {"&quot;", '"'},
  };
  unsigned int i;
  for (i = 0; i < 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)
mov    -0x1c(%rbp),%eax
cmp    $0x5,%rax
jae    1199 <decodeEntity+0x89>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
lea    0x2eec(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1186 <decodeEntity+0x76>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
lea    0x2ec7(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movsbl 0x8(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11a0 <decodeEntity+0x90>
jmp    118b <decodeEntity+0x7b>
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 = %29, %2
%8 = load i32, i32* %6
%9 = zext i32 %8 to i64
%10 = icmp ult i64 %9, 5
br i1 %10, label %11, label %32
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* @decodeEntity.enttable, i64 0, i64 %14
%16 = getelementptr inbounds %struct.anon, %struct.anon* %15, i32 0, i32 0
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %12, i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %11
%21 = load i32, i32* %6
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [5 x %struct.anon], [5 x %struct.anon]* @decodeEntity.enttable, i64 0, i64 %22
%24 = getelementptr inbounds %struct.anon, %struct.anon* %23, i32 0, i32 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i32*, i32** %5
store i32 %26, i32* %27
store i32 1, i32* %3
br label %33
28: ; preds = %11
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add i32 %30, 1
store i32 %31, i32* %6
br label %7
32: ; preds = %7
store i32 0, i32* %3
br label %33
33: ; preds = %32, %20
%34 = load i32, i32* %3
ret i32 %34
}

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
}