#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*/ free(unsigned char *);
unsigned char *malloc(int);
int /*<<< orphan*/ memcpy(unsigned char *, char *, int);
unsigned char *strdup(unsigned char *);
int strlen(unsigned char *);
unsigned char *rss_html_filter(unsigned char *s) {
  int intag = 0;
  unsigned char *d, *c;
  d = malloc(strlen(s) * 6 + 1);
  if (!d)
    return NULL;
  for (c = d; *s; s++) {
    switch (*s) {
    case '<':
      intag = 1;
      break;
    case '>':
      intag = 0;
      break;
    case '|':
      if (!intag) {
        memcpy(c, "&#134;", 6);
        c += 6;
      }
      break;
    default:
      if (!intag)
        *c++ = *s;
    }
  }
  *c = 0;
  c = d;
  d = strdup(c);
  free(c);
  return d;
}


x86 assembly (clang, -O0):
<rss_html_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
imul   $0x6,%eax,%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1193 <rss_html_filter+0x43>
movq   $0x0,-0x8(%rbp)
jmp    1293 <rss_html_filter+0x143>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1266 <rss_html_filter+0x116>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x3c,%eax
je     11e2 <rss_html_filter+0x92>
jmp    11c0 <rss_html_filter+0x70>
mov    -0x2c(%rbp),%eax
sub    $0x3e,%eax
je     11ee <rss_html_filter+0x9e>
jmp    11d1 <rss_html_filter+0x81>
mov    -0x2c(%rbp),%eax
sub    $0x7c,%eax
je     11fa <rss_html_filter+0xaa>
jmp    122a <rss_html_filter+0xda>
movl   $0x1,-0x14(%rbp)
jmp    1250 <rss_html_filter+0x100>
movl   $0x0,-0x14(%rbp)
jmp    1250 <rss_html_filter+0x100>
cmpl   $0x0,-0x14(%rbp)
jne    1225 <rss_html_filter+0xd5>
mov    -0x28(%rbp),%rdi
lea    0xdf1(%rip),%rsi
mov    $0x6,%edx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x28(%rbp)
jmp    1250 <rss_html_filter+0x100>
cmpl   $0x0,-0x14(%rbp)
jne    124b <rss_html_filter+0xfb>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
jmp    1250 <rss_html_filter+0x100>
jmp    1255 <rss_html_filter+0x105>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    119b <rss_html_filter+0x4b>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rss_html_filter>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
add    %eax,%eax
lea    (%rax,%rax,2),%edi
or     $0x1,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1203 <rss_html_filter+0xb3>
mov    %rax,%r14
xor    %ecx,%ecx
lea    0xe7e(%rip),%r15
mov    %rax,%r12
jmp    11a3 <rss_html_filter+0x53>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1050 <memcpy@plt>
add    $0x6,%r12
xor    %eax,%eax
add    $0x1,%rbx
mov    %eax,%ecx
movzbl (%rbx),%edx
mov    $0x1,%eax
cmp    $0x3d,%dl
jle    11c0 <rss_html_filter+0x70>
cmp    $0x7c,%dl
je     11e0 <rss_html_filter+0x90>
cmp    $0x3e,%dl
je     119b <rss_html_filter+0x4b>
jmp    11c9 <rss_html_filter+0x79>
nopl   0x0(%rax)
cmp    $0x3c,%dl
je     119d <rss_html_filter+0x4d>
test   %dl,%dl
je     11e6 <rss_html_filter+0x96>
test   %ecx,%ecx
jne    119d <rss_html_filter+0x4d>
mov    %dl,(%r12)
add    $0x1,%r12
jmp    119b <rss_html_filter+0x4b>
nopw   0x0(%rax,%rax,1)
test   %ecx,%ecx
jne    119d <rss_html_filter+0x4d>
jmp    1187 <rss_html_filter+0x37>
movb   $0x0,(%r12)
mov    %r14,%rdi
call   1070 <strdup@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
jmp    1205 <rss_html_filter+0xb5>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"&;\00"
define i8* @rss_html_filter(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = mul nsw i32 %8, 6
%10 = add nsw i32 %9, 1
%11 = call i8* @malloc(i32 %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %1
store i8* null, i8** %2
br label %57
15: ; preds = %1
%16 = load i8*, i8** %5
store i8* %16, i8** %6
br label %17
17: ; preds = %46, %15
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %49
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
switch i32 %24, label %36 [
i32 60, label %25
i32 62, label %26
i32 124, label %27
]
25: ; preds = %21
store i32 1, i32* %4
br label %45
26: ; preds = %21
store i32 0, i32* %4
br label %45
27: ; preds = %21
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 0
br i1 %29, label %35, label %30
30: ; preds = %27
%31 = load i8*, i8** %6
%32 = call i32 @memcpy(i8* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 6
store i8* %34, i8** %6
br label %35
35: ; preds = %30, %27
br label %45
36: ; preds = %21
%37 = load i32, i32* %4
%38 = icmp ne i32 %37, 0
br i1 %38, label %44, label %39
39: ; preds = %36
%40 = load i8*, i8** %3
%41 = load i8, i8* %40
%42 = load i8*, i8** %6
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %6
store i8 %41, i8* %42
br label %44
44: ; preds = %39, %36
br label %45
45: ; preds = %44, %35, %26, %25
br label %46
46: ; preds = %45
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %3
br label %17
49: ; preds = %17
%50 = load i8*, i8** %6
store i8 0, i8* %50
%51 = load i8*, i8** %5
store i8* %51, i8** %6
%52 = load i8*, i8** %6
%53 = call i8* @strdup(i8* %52)
store i8* %53, i8** %5
%54 = load i8*, i8** %6
%55 = call i32 @free(i8* %54)
%56 = load i8*, i8** %5
store i8* %56, i8** %2
br label %57
57: ; preds = %49, %14
%58 = load i8*, i8** %2
ret i8* %58
}

LLVM IR (-O2):
@.str = [7 x i8] c"&;\00"
define noalias i8* @rss_html_filter(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = mul nsw i32 %2, 6
%4 = or i32 %3, 1
%5 = tail call i8* @malloc(i32 %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %29, label %7
7: ; preds = %1, %22
%8 = phi i8* [ %25, %22 ], [ %0, %1 ]
%9 = phi i32 [ %23, %22 ], [ 0, %1 ]
%10 = phi i8* [ %24, %22 ], [ %5, %1 ]
%11 = load i8, i8* %8
switch i8 %11, label %18 [
i8 0, label %26
i8 60, label %22
i8 62, label %12
i8 124, label %13
]
12: ; preds = %7
br label %22
13: ; preds = %7
%14 = icmp eq i32 %9, 0
br i1 %14, label %15, label %22
15: ; preds = %13
%16 = tail call i32 @memcpy(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%17 = getelementptr inbounds i8, i8* %10, i64 6
br label %22
18: ; preds = %7
%19 = icmp eq i32 %9, 0
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %11, i8* %10
br label %22
22: ; preds = %7, %12, %15, %13, %20, %18
%23 = phi i32 [ 1, %18 ], [ 0, %20 ], [ 1, %13 ], [ 0, %15 ], [ 0, %12 ], [ 1, %7 ]
%24 = phi i8* [ %10, %18 ], [ %21, %20 ], [ %10, %13 ], [ %17, %15 ], [ %10, %12 ], [ %10, %7 ]
%25 = getelementptr inbounds i8, i8* %8, i64 1
br label %7
26: ; preds = %7
store i8 0, i8* %10
%27 = tail call i8* @strdup(i8* %5)
%28 = tail call i32 @free(i8* %5)
br label %29
29: ; preds = %1, %26
%30 = phi i8* [ %27, %26 ], [ null, %1 ]
ret i8* %30
}