#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*/ strcpy(char *, char *);
char *nohtml(char *s) {
  static char buf[1024];
  int i = 0;
  while (*s && i < 1000) {
    if (*s == '<') {
      strcpy(buf + i, "&lt;");
      i += 4;
    } else if (*s == '>') {
      strcpy(buf + i, "&gt;");
      i += 4;
    } else if (*s == ' ' && i && buf[i - 1] == ' ') {
      strcpy(buf + i, "&nbsp;");
      i += 6;
    } else if (*s == '&') {
      strcpy(buf + i, "&amp;");
      i += 5;
    } else {
      buf[i] = *s;
      i++;
    }
    s++;
  }
  buf[i] = 0;
  return buf;
}


x86 assembly (clang, -O0):
<nohtml>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     1145 <nohtml+0x35>
cmpl   $0x3e8,-0xc(%rbp)
setl   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1155 <nohtml+0x45>
jmp    1299 <nohtml+0x189>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    118d <nohtml+0x7d>
movslq -0xc(%rbp),%rax
lea    0x2ed0(%rip),%rdi
add    %rax,%rdi
lea    0xe86(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    1288 <nohtml+0x178>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3e,%eax
jne    11c5 <nohtml+0xb5>
movslq -0xc(%rbp),%rax
lea    0x2e98(%rip),%rdi
add    %rax,%rdi
lea    0xe53(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    1283 <nohtml+0x173>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1224 <nohtml+0x114>
cmpl   $0x0,-0xc(%rbp)
je     1224 <nohtml+0x114>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2e51(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1224 <nohtml+0x114>
movslq -0xc(%rbp),%rax
lea    0x2e39(%rip),%rdi
add    %rax,%rdi
lea    0xdf9(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0xc(%rbp)
jmp    127e <nohtml+0x16e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
jne    125c <nohtml+0x14c>
movslq -0xc(%rbp),%rax
lea    0x2e01(%rip),%rdi
add    %rax,%rdi
lea    0xdc8(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
jmp    1279 <nohtml+0x169>
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
movslq -0xc(%rbp),%rcx
lea    0x2dd3(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    127e <nohtml+0x16e>
jmp    1283 <nohtml+0x173>
jmp    1288 <nohtml+0x178>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <nohtml+0x13>
movslq -0xc(%rbp),%rcx
lea    0x2d9c(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2d91(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nohtml>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
xor    %ebp,%ebp
test   %al,%al
je     11f2 <nohtml+0xe2>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0x2f0b(%rip),%r12
lea    0xec9(%rip),%r14
lea    0xebd(%rip),%r15
lea    0xec7(%rip),%r13
nopw   0x0(%rax,%rax,1)
cmp    $0x3e,%al
je     1170 <nohtml+0x60>
cmp    $0x3c,%al
jne    11a0 <nohtml+0x90>
mov    %ebp,%edi
add    %r12,%rdi
mov    %r15,%rsi
jmp    1178 <nohtml+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
add    %r12,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    $0x4,%eax
add    %eax,%ebp
movzbl (%rbx),%eax
test   %al,%al
je     11f0 <nohtml+0xe0>
add    $0x1,%rbx
cmp    $0x3e8,%ebp
jb     1150 <nohtml+0x40>
jmp    11f0 <nohtml+0xe0>
nopl   0x0(%rax)
cmp    $0x20,%al
jne    11cb <nohtml+0xbb>
test   %ebp,%ebp
je     11cb <nohtml+0xbb>
movslq %ebp,%rcx
cmpb   $0x20,-0x1(%rcx,%r12,1)
jne    11e3 <nohtml+0xd3>
mov    %ebp,%edi
add    %r12,%rdi
lea    0xe4b(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x6,%eax
jmp    1182 <nohtml+0x72>
cmp    $0x26,%al
jne    11e3 <nohtml+0xd3>
mov    %ebp,%edi
add    %r12,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    $0x5,%eax
jmp    1182 <nohtml+0x72>
mov    %ebp,%ecx
mov    %al,(%rcx,%r12,1)
mov    $0x1,%eax
jmp    1182 <nohtml+0x72>
mov    %ebp,%ebp
lea    0x2e47(%rip),%rax
movb   $0x0,0x0(%rbp,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@nohtml.buf = internal global [1024 x i8] zeroinitializer
@.str = [5 x i8] c"&lt;\00"
@.str.1 = [5 x i8] c"&gt;\00"
@.str.2 = [7 x i8] c"&nbsp;\00"
@.str.3 = [6 x i8] c"&amp;\00"
define i8* @nohtml(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %49, label %4
4: ; preds = %1, %39
%5 = phi i8 [ %43, %39 ], [ %2, %1 ]
%6 = phi i32 [ %41, %39 ], [ 0, %1 ]
%7 = phi i8* [ %42, %39 ], [ %0, %1 ]
switch i8 %5, label %16 [
i8 60, label %8
i8 62, label %12
]
8: ; preds = %4
%9 = zext i32 %6 to i64
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %9
%11 = tail call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %39
12: ; preds = %4
%13 = zext i32 %6 to i64
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %13
%15 = tail call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %39
16: ; preds = %4
%17 = icmp eq i8 %5, 32
%18 = icmp ne i32 %6, 0
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = add nsw i32 %6, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 32
br i1 %25, label %26, label %36
26: ; preds = %20
%27 = zext i32 %6 to i64
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %27
%29 = tail call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %39
30: ; preds = %16
%31 = icmp eq i8 %5, 38
br i1 %31, label %32, label %36
32: ; preds = %30
%33 = zext i32 %6 to i64
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %33
%35 = tail call i32 @strcpy(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %39
36: ; preds = %20, %30
%37 = zext i32 %6 to i64
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %37
store i8 %5, i8* %38
br label %39
39: ; preds = %12, %32, %36, %26, %8
%40 = phi i32 [ 4, %12 ], [ 5, %32 ], [ 1, %36 ], [ 6, %26 ], [ 4, %8 ]
%41 = add nuw nsw i32 %6, %40
%42 = getelementptr inbounds i8, i8* %7, i64 1
%43 = load i8, i8* %42
%44 = icmp ne i8 %43, 0
%45 = icmp ult i32 %41, 1000
%46 = select i1 %44, i1 %45, i1 false
br i1 %46, label %4, label %47
47: ; preds = %39
%48 = zext i32 %41 to i64
br label %49
49: ; preds = %47, %1
%50 = phi i64 [ 0, %1 ], [ %48, %47 ]
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %50
store i8 0, i8* %51
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 0)
}