#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*/ strcat(char *, char *);
scalar_t__ strlen(char const *);
void make_html_friendly(unsigned char *string, char *html_version) {
  int i, html_pos;
  html_pos = 0;
  html_version[html_pos] = '\0';
  for (i = 0; i < (int)strlen((const char *)(string)); i++) {
    switch (string[i]) {
    case '>':
      strcat(html_version, "&gt;");
      html_pos += 4;
      break;
    case '<':
      strcat(html_version, "&lt;");
      html_pos += 4;
      break;
    case '&':
      strcat(html_version, "&amp;");
      html_pos += 5;
      break;
    case '"':
      strcat(html_version, "&quot;");
      html_pos += 6;
      break;
    case '\'':
      strcat(html_version, "&apos;");
      html_pos += 6;
      break;
    default:
      html_version[html_pos] = string[i];
      html_pos++;
      html_version[html_pos] = '\0';
      break;
    }
  }
}


x86 assembly (clang, -O0):
<make_html_friendly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    126d <make_html_friendly+0x14d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x1c,%eax
ja     122f <make_html_friendly+0x10f>
mov    -0x28(%rbp),%rax
lea    0xe70(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xed0(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    125a <make_html_friendly+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    125a <make_html_friendly+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x18(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x18(%rbp)
jmp    125a <make_html_friendly+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x18(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x18(%rbp)
jmp    125a <make_html_friendly+0x13a>
mov    -0x10(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x18(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x18(%rbp)
jmp    125a <make_html_friendly+0x13a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    125f <make_html_friendly+0x13f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <make_html_friendly+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_html_friendly>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x0,(%rsi)
call   1030 <strlen@plt>
test   %eax,%eax
jle    11e4 <make_html_friendly+0xc4>
xor    %r12d,%r12d
lea    0xeb5(%rip),%r13
lea    0xf22(%rip),%r15
xor    %ebp,%ebp
jmp    117b <make_html_friendly+0x5b>
mov    %r14,%rdi
lea    0xf24(%rip),%rsi
call   1040 <strcat@plt>
add    $0x6,%ebp
add    $0x1,%r12
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r12
jge    11e4 <make_html_friendly+0xc4>
movzbl (%rbx,%r12,1),%eax
lea    -0x22(%rax),%ecx
cmp    $0x1c,%cl
ja     11a9 <make_html_friendly+0x89>
movzbl %cl,%ecx
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
mov    %r14,%rdi
lea    0xedf(%rip),%rsi
call   1040 <strcat@plt>
add    $0x5,%ebp
jmp    1168 <make_html_friendly+0x48>
movslq %ebp,%rbp
mov    %al,(%r14,%rbp,1)
movb   $0x0,0x1(%r14,%rbp,1)
add    $0x1,%rbp
jmp    1168 <make_html_friendly+0x48>
mov    %r14,%rdi
lea    0xec5(%rip),%rsi
jmp    1160 <make_html_friendly+0x40>
mov    %r14,%rdi
lea    0xea7(%rip),%rsi
jmp    11da <make_html_friendly+0xba>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
add    $0x4,%ebp
jmp    1168 <make_html_friendly+0x48>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"&gt;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [6 x i8] c"&amp;\00"
@.str.3 = [7 x i8] c"&quot;\00"
@.str.4 = [7 x i8] c"&apos;\00"
define void @make_html_friendly(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = load i32, i32* %6
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
store i8 0, i8* %10
store i32 0, i32* %5
br label %11
11: ; preds = %66, %2
%12 = load i32, i32* %5
%13 = load i8*, i8** %3
%14 = call i64 @strlen(i8* %13)
%15 = trunc i64 %14 to i32
%16 = icmp slt i32 %12, %15
br i1 %16, label %17, label %69
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
switch i32 %23, label %49 [
i32 62, label %24
i32 60, label %29
i32 38, label %34
i32 34, label %39
i32 39, label %44
]
24: ; preds = %17
%25 = load i8*, i8** %4
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 4
store i32 %28, i32* %6
br label %65
29: ; preds = %17
%30 = load i8*, i8** %4
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 4
store i32 %33, i32* %6
br label %65
34: ; preds = %17
%35 = load i8*, i8** %4
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 5
store i32 %38, i32* %6
br label %65
39: ; preds = %17
%40 = load i8*, i8** %4
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 6
store i32 %43, i32* %6
br label %65
44: ; preds = %17
%45 = load i8*, i8** %4
%46 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 6
store i32 %48, i32* %6
br label %65
49: ; preds = %17
%50 = load i8*, i8** %3
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = load i8*, i8** %4
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8 %54, i8* %58
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
%61 = load i8*, i8** %4
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
store i8 0, i8* %64
br label %65
65: ; preds = %49, %44, %39, %34, %29, %24
br label %66
66: ; preds = %65
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 1
store i32 %68, i32* %5
br label %11
69: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"&gt;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [6 x i8] c"&amp;\00"
@.str.3 = [7 x i8] c"&quot;\00"
@.str.4 = [7 x i8] c"&apos;\00"
define void @make_html_friendly(i8* nocapture %0, i8* %1) {
store i8 0, i8* %1
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = trunc i64 %3 to i32
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %39
6: ; preds = %2, %32
%7 = phi i64 [ %34, %32 ], [ 0, %2 ]
%8 = phi i32 [ %33, %32 ], [ 0, %2 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
switch i8 %10, label %26 [
i8 62, label %11
i8 60, label %14
i8 38, label %17
i8 34, label %20
i8 39, label %23
]
11: ; preds = %6
%12 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = add nsw i32 %8, 4
br label %32
14: ; preds = %6
%15 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = add nsw i32 %8, 4
br label %32
17: ; preds = %6
%18 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%19 = add nsw i32 %8, 5
br label %32
20: ; preds = %6
%21 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%22 = add nsw i32 %8, 6
br label %32
23: ; preds = %6
%24 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%25 = add nsw i32 %8, 6
br label %32
26: ; preds = %6
%27 = sext i32 %8 to i64
%28 = getelementptr inbounds i8, i8* %1, i64 %27
store i8 %10, i8* %28
%29 = add nsw i32 %8, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %1, i64 %30
store i8 0, i8* %31
br label %32
32: ; preds = %11, %14, %17, %20, %23, %26
%33 = phi i32 [ %29, %26 ], [ %25, %23 ], [ %22, %20 ], [ %19, %17 ], [ %16, %14 ], [ %13, %11 ]
%34 = add nuw nsw i64 %7, 1
%35 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%36 = shl i64 %35, 32
%37 = ashr exact i64 %36, 32
%38 = icmp slt i64 %34, %37
br i1 %38, label %6, label %39
39: ; preds = %32, %2
ret void
}