#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 {
      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    125c <nohtml+0x14c>
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    124b <nohtml+0x13b>
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    1246 <nohtml+0x136>
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    1241 <nohtml+0x131>
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
movslq -0xc(%rbp),%rcx
lea    0x2e0b(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1246 <nohtml+0x136>
jmp    124b <nohtml+0x13b>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <nohtml+0x13>
movslq -0xc(%rbp),%rcx
lea    0x2dd9(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2dce(%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    %ebx,%ebx
test   %al,%al
je     11e7 <nohtml+0xd7>
mov    %rdi,%r13
add    $0x1,%r13
lea    0x2f0b(%rip),%rbp
lea    0xec9(%rip),%r14
lea    0xebd(%rip),%r15
lea    0xec0(%rip),%r12
nopw   0x0(%rax,%rax,1)
cmp    $0x3e,%al
je     1170 <nohtml+0x60>
cmp    $0x3c,%al
jne    1190 <nohtml+0x80>
mov    %ebx,%edi
add    %rbp,%rdi
mov    %r15,%rsi
jmp    1178 <nohtml+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
add    %rbp,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    $0x4,%eax
jmp    11ca <nohtml+0xba>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x20,%al
jne    11c0 <nohtml+0xb0>
test   %ebx,%ebx
je     11c0 <nohtml+0xb0>
movslq %ebx,%rcx
cmpb   $0x20,-0x1(%rcx,%rbp,1)
jne    11c0 <nohtml+0xb0>
mov    %ebx,%edi
add    %rbp,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    $0x6,%eax
jmp    11ca <nohtml+0xba>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%ecx
mov    %al,(%rcx,%rbp,1)
mov    $0x1,%eax
add    %eax,%ebx
movzbl 0x0(%r13),%eax
test   %al,%al
je     11e5 <nohtml+0xd5>
add    $0x1,%r13
cmp    $0x3e8,%ebx
jb     1150 <nohtml+0x40>
mov    %ebx,%ebx
lea    0x2e52(%rip),%rax
movb   $0x0,(%rbx,%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"
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 = %71, %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 %74
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 %71
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 %70
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 %69
61: ; preds = %46, %43, %38
%62 = load i8*, i8** %2
%63 = load i8, i8* %62
%64 = load i32, i32* %3
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %65
store i8 %63, i8* %66
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
store i32 %68, i32* %3
br label %69
69: ; preds = %61, %54
br label %70
70: ; preds = %69, %31
br label %71
71: ; preds = %70, %19
%72 = load i8*, i8** %2
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %2
br label %4
74: ; preds = %12
%75 = load i32, i32* %3
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %76
store i8 0, i8* %77
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"
define i8* @nohtml(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %43, label %4
4: ; preds = %1, %33
%5 = phi i8 [ %37, %33 ], [ %2, %1 ]
%6 = phi i32 [ %35, %33 ], [ 0, %1 ]
%7 = phi i8* [ %36, %33 ], [ %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 %33
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 %33
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 %30
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 %33
30: ; preds = %20, %16
%31 = zext i32 %6 to i64
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %31
store i8 %5, i8* %32
br label %33
33: ; preds = %12, %30, %26, %8
%34 = phi i32 [ 4, %12 ], [ 1, %30 ], [ 6, %26 ], [ 4, %8 ]
%35 = add nuw nsw i32 %6, %34
%36 = getelementptr inbounds i8, i8* %7, i64 1
%37 = load i8, i8* %36
%38 = icmp ne i8 %37, 0
%39 = icmp ult i32 %35, 1000
%40 = select i1 %38, i1 %39, i1 false
br i1 %40, label %4, label %41
41: ; preds = %33
%42 = zext i32 %35 to i64
br label %43
43: ; preds = %41, %1
%44 = phi i64 [ 0, %1 ], [ %42, %41 ]
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 %44
store i8 0, i8* %45
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @nohtml.buf, i64 0, i64 0)
}