#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*/ memmove(char *, char *, int /*<<< orphan*/);
char *strchr(char *, char);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncasecmp(char *, char *, int);
void htmlstrip(char *bb) {
  char *start, *end;
  while ((start = strchr(bb, '<')) != NULL)
    if ((end = strchr(start, '>')) != NULL)
      memmove(start, end + 1, strlen(end));
    else
      break;
  end = bb;
  while ((start = strchr(end, '&')) != NULL)
    if ((end = strchr(start, ';')) != NULL) {
      if (strncasecmp(start + 1, "nbsp;", 5) == 0)
        *start = ' ';
      else if (strncasecmp(start + 1, "amp;", 4) == 0)
        *start = '&';
      else if (strncasecmp(start + 1, "gt;", 3) == 0)
        *start = '>';
      else if (strncasecmp(start + 1, "lt;", 3) == 0)
        *start = '<';
      else if (strncasecmp(start + 1, "quot;", 5) == 0)
        *start = '"';
      else
        continue;
      memmove(start + 1, end + 1, strlen(end));
      end = start + 1;
    } else
      break;
}


x86 assembly (clang, -O0):
<htmlstrip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11bf <htmlstrip+0x7f>
mov    -0x10(%rbp),%rdi
mov    $0x3e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11b5 <htmlstrip+0x75>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1060 <memmove@plt>
jmp    11ba <htmlstrip+0x7a>
jmp    11bf <htmlstrip+0x7f>
jmp    114c <htmlstrip+0xc>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x26,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     134e <htmlstrip+0x20e>
mov    -0x10(%rbp),%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1344 <htmlstrip+0x204>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xdf2(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    122e <htmlstrip+0xee>
mov    -0x10(%rbp),%rax
movb   $0x20,(%rax)
jmp    1303 <htmlstrip+0x1c3>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xdc9(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    125d <htmlstrip+0x11d>
mov    -0x10(%rbp),%rax
movb   $0x26,(%rax)
jmp    12fe <htmlstrip+0x1be>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xd9f(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    128c <htmlstrip+0x14c>
mov    -0x10(%rbp),%rax
movb   $0x3e,(%rax)
jmp    12f9 <htmlstrip+0x1b9>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xd74(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    12bb <htmlstrip+0x17b>
mov    -0x10(%rbp),%rax
movb   $0x3c,(%rax)
jmp    12f4 <htmlstrip+0x1b4>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xd49(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    12ea <htmlstrip+0x1aa>
mov    -0x10(%rbp),%rax
movb   $0x22,(%rax)
jmp    12ef <htmlstrip+0x1af>
jmp    11c7 <htmlstrip+0x87>
jmp    12f4 <htmlstrip+0x1b4>
jmp    12f9 <htmlstrip+0x1b9>
jmp    12fe <htmlstrip+0x1be>
jmp    1303 <htmlstrip+0x1c3>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1060 <memmove@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1349 <htmlstrip+0x209>
jmp    134e <htmlstrip+0x20e>
jmp    11c7 <htmlstrip+0x87>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<htmlstrip>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x3c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11a3 <htmlstrip+0x63>
mov    %rax,%rbp
mov    %rbp,%rdi
mov    $0x3e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11a3 <htmlstrip+0x63>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <memmove@plt>
mov    %r14,%rdi
mov    $0x3c,%esi
call   1040 <strchr@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1160 <htmlstrip+0x20>
mov    %r14,%rdi
mov    $0x26,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     12d8 <htmlstrip+0x198>
mov    %rax,%rbp
lea    0xe3d(%rip),%rbx
lea    0xe3c(%rip),%r14
lea    0xe3a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     12d8 <htmlstrip+0x198>
mov    %rax,%r13
lea    0x1(%rbp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1280 <htmlstrip+0x140>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1290 <htmlstrip+0x150>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1294 <htmlstrip+0x154>
mov    %r12,%rdi
lea    0xdc9(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     1298 <htmlstrip+0x158>
mov    %r12,%rdi
lea    0xdb4(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     129c <htmlstrip+0x15c>
mov    %r13,%r12
jmp    12bf <htmlstrip+0x17f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%al
jmp    12a0 <htmlstrip+0x160>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x26,%al
jmp    12a0 <htmlstrip+0x160>
mov    $0x3e,%al
jmp    12a0 <htmlstrip+0x160>
mov    $0x3c,%al
jmp    12a0 <htmlstrip+0x160>
mov    $0x22,%al
xchg   %ax,%ax
mov    %al,0x0(%rbp)
mov    %r13,%rbp
add    $0x1,%rbp
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <memmove@plt>
mov    %r12,%rdi
mov    $0x26,%esi
call   1040 <strchr@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11e0 <htmlstrip+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"nbsp;\00"
@.str.1 = [5 x i8] c"amp;\00"
@.str.2 = [4 x i8] c"gt;\00"
@.str.3 = [4 x i8] c"lt;\00"
@.str.4 = [6 x i8] c"quot;\00"
define void @htmlstrip(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
br label %5
5: ; preds = %21, %1
%6 = load i8*, i8** %2
%7 = call i8* @strchr(i8* %6, i8 signext 60)
store i8* %7, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = call i8* @strchr(i8* %10, i8 signext 62)
store i8* %11, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8*, i8** %4
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @memmove(i8* %14, i8* %16, i32 %18)
br label %21
20: ; preds = %9
br label %22
21: ; preds = %13
br label %5
22: ; preds = %20, %5
%23 = load i8*, i8** %2
store i8* %23, i8** %4
br label %24
24: ; preds = %83, %67, %22
%25 = load i8*, i8** %4
%26 = call i8* @strchr(i8* %25, i8 signext 38)
store i8* %26, i8** %3
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %84
28: ; preds = %24
%29 = load i8*, i8** %3
%30 = call i8* @strchr(i8* %29, i8 signext 59)
store i8* %30, i8** %4
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %82
32: ; preds = %28
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = call i64 @strncasecmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = load i8*, i8** %3
store i8 32, i8* %38
br label %72
39: ; preds = %32
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = call i64 @strncasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = load i8*, i8** %3
store i8 38, i8* %45
br label %71
46: ; preds = %39
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i64 1
%49 = call i64 @strncasecmp(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = load i8*, i8** %3
store i8 62, i8* %52
br label %70
53: ; preds = %46
%54 = load i8*, i8** %3
%55 = getelementptr inbounds i8, i8* %54, i64 1
%56 = call i64 @strncasecmp(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = load i8*, i8** %3
store i8 60, i8* %59
br label %69
60: ; preds = %53
%61 = load i8*, i8** %3
%62 = getelementptr inbounds i8, i8* %61, i64 1
%63 = call i64 @strncasecmp(i8* %62, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %60
%66 = load i8*, i8** %3
store i8 34, i8* %66
br label %68
67: ; preds = %60
br label %24
68: ; preds = %65
br label %69
69: ; preds = %68, %58
br label %70
70: ; preds = %69, %51
br label %71
71: ; preds = %70, %44
br label %72
72: ; preds = %71, %37
%73 = load i8*, i8** %3
%74 = getelementptr inbounds i8, i8* %73, i64 1
%75 = load i8*, i8** %4
%76 = getelementptr inbounds i8, i8* %75, i64 1
%77 = load i8*, i8** %4
%78 = call i32 @strlen(i8* %77)
%79 = call i32 @memmove(i8* %74, i8* %76, i32 %78)
%80 = load i8*, i8** %3
%81 = getelementptr inbounds i8, i8* %80, i64 1
store i8* %81, i8** %4
br label %83
82: ; preds = %28
br label %84
83: ; preds = %72
br label %24
84: ; preds = %82, %24
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"nbsp;\00"
@.str.1 = [5 x i8] c"amp;\00"
@.str.2 = [4 x i8] c"gt;\00"
@.str.3 = [4 x i8] c"lt;\00"
@.str.4 = [6 x i8] c"quot;\00"
define void @htmlstrip(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 60)
%3 = icmp eq i8* %2, null
br i1 %3, label %14, label %4
4: ; preds = %1, %8
%5 = phi i8* [ %12, %8 ], [ %2, %1 ]
%6 = tail call i8* @strchr(i8* %5, i8 signext 62)
%7 = icmp eq i8* %6, null
br i1 %7, label %14, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = tail call i32 @strlen(i8* %6)
%11 = tail call i32 @memmove(i8* %5, i8* %9, i32 %10)
%12 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 60)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %4
14: ; preds = %8, %4, %1
%15 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 38)
%16 = icmp eq i8* %15, null
br i1 %16, label %46, label %17
17: ; preds = %14, %42
%18 = phi i8* [ %44, %42 ], [ %15, %14 ]
%19 = tail call i8* @strchr(i8* %18, i8 signext 59)
%20 = icmp eq i8* %19, null
br i1 %20, label %46, label %21
21: ; preds = %17
%22 = getelementptr inbounds i8, i8* %18, i64 1
%23 = tail call i64 @strncasecmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%24 = icmp eq i64 %23, 0
br i1 %24, label %37, label %25
25: ; preds = %21
%26 = tail call i64 @strncasecmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%27 = icmp eq i64 %26, 0
br i1 %27, label %37, label %28
28: ; preds = %25
%29 = tail call i64 @strncasecmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%30 = icmp eq i64 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %28
%32 = tail call i64 @strncasecmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = tail call i64 @strncasecmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %34, %31, %28, %25, %21
%38 = phi i8 [ 32, %21 ], [ 38, %25 ], [ 62, %28 ], [ 60, %31 ], [ 34, %34 ]
store i8 %38, i8* %18
%39 = getelementptr inbounds i8, i8* %19, i64 1
%40 = tail call i32 @strlen(i8* %19)
%41 = tail call i32 @memmove(i8* %22, i8* %39, i32 %40)
br label %42
42: ; preds = %37, %34
%43 = phi i8* [ %22, %37 ], [ %19, %34 ]
%44 = tail call i8* @strchr(i8* dereferenceable(1) %43, i8 signext 38)
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %17
46: ; preds = %42, %17, %14
ret void
}