#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 charEntityDecode(unsigned char *, unsigned char **);
unsigned char *strConvHTMLEntities2ISO(unsigned char *buf) {
  unsigned char *s, *t;
  unsigned char *d;
  int code;
  s = d = buf;
  while (*s) {
    if (*s != '&') {
      *d++ = *s++;
    } else {
      code = charEntityDecode(s, &t);
      if (code && (code < 256))
        *d++ = (unsigned char)code;
      s = t;
    }
  }
  *d = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<strConvHTMLEntities2ISO>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b6 <strConvHTMLEntities2ISO+0xa6>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x26,%eax
je     116c <strConvHTMLEntities2ISO+0x5c>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    11b1 <strConvHTMLEntities2ISO+0xa1>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <charEntityDecode@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11a9 <strConvHTMLEntities2ISO+0x99>
cmpl   $0x100,-0x24(%rbp)
jge    11a9 <strConvHTMLEntities2ISO+0x99>
mov    -0x24(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1128 <strConvHTMLEntities2ISO+0x18>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strConvHTMLEntities2ISO>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0x8(%rsp),%r15
mov    %rdi,%rbx
jmp    1135 <strConvHTMLEntities2ISO+0x25>
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
movzbl (%rdi),%eax
cmp    $0x26,%al
je     1150 <strConvHTMLEntities2ISO+0x40>
test   %al,%al
je     116b <strConvHTMLEntities2ISO+0x5b>
add    $0x1,%rdi
mov    %al,(%rbx)
add    $0x1,%rbx
jmp    1135 <strConvHTMLEntities2ISO+0x25>
nopl   0x0(%rax)
mov    %r15,%rsi
call   1030 <charEntityDecode@plt>
test   %eax,%eax
je     1130 <strConvHTMLEntities2ISO+0x20>
cmp    $0xff,%eax
jg     1130 <strConvHTMLEntities2ISO+0x20>
mov    %al,(%rbx)
add    $0x1,%rbx
jmp    1130 <strConvHTMLEntities2ISO+0x20>
movb   $0x0,(%rbx)
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @strConvHTMLEntities2ISO(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
store i8* %7, i8** %5
store i8* %7, i8** %3
br label %8
8: ; preds = %38, %1
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %39
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp ne i32 %15, 38
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
%20 = load i8, i8* %18
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %5
store i8 %20, i8* %21
br label %38
23: ; preds = %12
%24 = load i8*, i8** %3
%25 = call i32 @charEntityDecode(i8* %24, i8** %4)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %36
28: ; preds = %23
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 256
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i32, i32* %6
%33 = trunc i32 %32 to i8
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
store i8 %33, i8* %34
br label %36
36: ; preds = %31, %28, %23
%37 = load i8*, i8** %4
store i8* %37, i8** %3
br label %38
38: ; preds = %36, %17
br label %8
39: ; preds = %8
%40 = load i8*, i8** %5
store i8 0, i8* %40
%41 = load i8*, i8** %2
ret i8* %41
}

LLVM IR (-O2):
define i8* @strConvHTMLEntities2ISO(i8* returned %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
br label %4
4: ; preds = %22, %1
%5 = phi i8* [ %0, %1 ], [ %23, %22 ]
%6 = phi i8* [ %0, %1 ], [ %24, %22 ]
%7 = load i8, i8* %6
switch i8 %7, label %8 [
i8 0, label %25
i8 38, label %11
]
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %7, i8* %5
br label %22
11: ; preds = %4
%12 = call i32 @charEntityDecode(i8* %6, i8** %2)
%13 = icmp ne i32 %12, 0
%14 = icmp slt i32 %12, 256
%15 = and i1 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = trunc i32 %12 to i8
%18 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %17, i8* %5
br label %19
19: ; preds = %16, %11
%20 = phi i8* [ %18, %16 ], [ %5, %11 ]
%21 = load i8*, i8** %2
br label %22
22: ; preds = %19, %8
%23 = phi i8* [ %10, %8 ], [ %20, %19 ]
%24 = phi i8* [ %9, %8 ], [ %21, %19 ]
br label %4
25: ; preds = %4
store i8 0, i8* %5
ret i8* %0
}