#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ strcpy(char *, char *);
char *nohtml(char *s) {
  static char buf[5000];
  int i = 0;
  while (*s && i < sizeof(buf) - 10) {
    if (*s == '<') {
      strcpy(buf + i, "&lt;");
      i += 4;
    } else if (*s == '>') {
      strcpy(buf + i, "&gt;");
      i += 4;
    } 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     1148 <nohtml+0x38>
movslq -0xc(%rbp),%rax
cmp    $0x137e,%rax
setb   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1158 <nohtml+0x48>
jmp    11fb <nohtml+0xeb>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    1190 <nohtml+0x80>
movslq -0xc(%rbp),%rax
lea    0x2ecd(%rip),%rdi
add    %rax,%rdi
lea    0xe83(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    11ea <nohtml+0xda>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3e,%eax
jne    11c8 <nohtml+0xb8>
movslq -0xc(%rbp),%rax
lea    0x2e95(%rip),%rdi
add    %rax,%rdi
lea    0xe50(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    11e5 <nohtml+0xd5>
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
movslq -0xc(%rbp),%rcx
lea    0x2e67(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ea <nohtml+0xda>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <nohtml+0x13>
movslq -0xc(%rbp),%rcx
lea    0x2e3a(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e2f(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nohtml>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    (%rdi),%al
xor    %ebx,%ebx
test   %al,%al
je     1195 <nohtml+0x85>
mov    %rdi,%r12
add    $0x1,%r12
lea    0x2f11(%rip),%r13
lea    0xecf(%rip),%r14
lea    0xec3(%rip),%r15
xor    %edi,%edi
nop
cmp    $0x3e,%al
je     1150 <nohtml+0x40>
cmp    $0x3c,%al
jne    1170 <nohtml+0x60>
add    %r13,%rdi
mov    %r15,%rsi
jmp    1156 <nohtml+0x46>
add    %r13,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    $0x4,%eax
jmp    1179 <nohtml+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %al,(%rdi,%r13,1)
mov    $0x1,%eax
add    %eax,%ebx
movzbl (%r12),%eax
test   %al,%al
je     1193 <nohtml+0x83>
add    $0x1,%r12
mov    %rbx,%rdi
cmp    $0x137e,%ebx
jb     1140 <nohtml+0x30>
mov    %ebx,%ebx
lea    0x2ea4(%rip),%rax
movb   $0x0,(%rbx,%rax,1)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@nohtml.buf = internal global [5000 x i8] zeroinitializer
@.str = [5 x i8] c"&lt;\00"
@.str.1 = [5 x i8] c"&gt;\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 = %48, %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 %13
9: ; preds = %4
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = icmp ult i64 %11, 4990
br label %13
13: ; preds = %9, %4
%14 = phi i1 [ false, %4 ], [ %12, %9 ]
br i1 %14, label %15, label %51
15: ; preds = %13
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 60
br i1 %19, label %20, label %27
20: ; preds = %15
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* getelementptr inbounds ([5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 0), i64 %22
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 4
store i32 %26, i32* %3
br label %48
27: ; preds = %15
%28 = load i8*, i8** %2
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 62
br i1 %31, label %32, label %39
32: ; preds = %27
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* getelementptr inbounds ([5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 0), i64 %34
%36 = call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 4
store i32 %38, i32* %3
br label %47
39: ; preds = %27
%40 = load i8*, i8** %2
%41 = load i8, i8* %40
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 %43
store i8 %41, i8* %44
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %47
47: ; preds = %39, %32
br label %48
48: ; preds = %47, %20
%49 = load i8*, i8** %2
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %2
br label %4
51: ; preds = %13
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 %53
store i8 0, i8* %54
ret i8* getelementptr inbounds ([5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@nohtml.buf = internal global [5000 x i8] zeroinitializer
@.str = [5 x i8] c"&lt;\00"
@.str.1 = [5 x i8] c"&gt;\00"
define i8* @nohtml(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %28, label %4
4: ; preds = %1, %17
%5 = phi i64 [ %23, %17 ], [ 0, %1 ]
%6 = phi i8 [ %21, %17 ], [ %2, %1 ]
%7 = phi i32 [ %19, %17 ], [ 0, %1 ]
%8 = phi i8* [ %20, %17 ], [ %0, %1 ]
switch i8 %6, label %15 [
i8 60, label %9
i8 62, label %12
]
9: ; preds = %4
%10 = getelementptr inbounds [5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 %5
%11 = tail call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %17
12: ; preds = %4
%13 = getelementptr inbounds [5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 %5
%14 = tail call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %17
15: ; preds = %4
%16 = getelementptr inbounds [5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 %5
store i8 %6, i8* %16
br label %17
17: ; preds = %12, %15, %9
%18 = phi i32 [ 4, %12 ], [ 1, %15 ], [ 4, %9 ]
%19 = add nuw nsw i32 %7, %18
%20 = getelementptr inbounds i8, i8* %8, i64 1
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
%23 = zext i32 %19 to i64
%24 = icmp ult i32 %19, 4990
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %4, label %26
26: ; preds = %17
%27 = zext i32 %19 to i64
br label %28
28: ; preds = %26, %1
%29 = phi i64 [ 0, %1 ], [ %27, %26 ]
%30 = getelementptr inbounds [5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 %29
store i8 0, i8* %30
ret i8* getelementptr inbounds ([5000 x i8], [5000 x i8]* @nohtml.buf, i64 0, i64 0)
}