#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 */
char *replace_all_str(char *, char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *encode_html(char *html) {
  static char buf[4080];
  char *replace_all_buf;
  strncpy(buf, html, 4080);
  replace_all_buf = replace_all_str(buf, "&", "&amp;");
  strncpy(buf, replace_all_buf, 4080);
  replace_all_buf = replace_all_str(buf, "<", "&lt;");
  strncpy(buf, replace_all_buf, 4080);
  replace_all_buf = replace_all_str(buf, ">", "&gt;");
  strncpy(buf, replace_all_buf, 4080);
  replace_all_buf = replace_all_str(buf, "\"", "&quot;");
  strncpy(buf, replace_all_buf, 4080);
  replace_all_buf = replace_all_str(buf, "'", "&apos;");
  strncpy(buf, replace_all_buf, 4080);
  buf[4080 - 1] = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<encode_html>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2f09(%rip),%rdi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0x2ef8(%rip),%rdi
lea    0xeb1(%rip),%rsi
lea    0xeac(%rip),%rdx
call   1040 <replace_all_str@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2ed6(%rip),%rdi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0x2ec5(%rip),%rdi
lea    0xe86(%rip),%rsi
lea    0xe81(%rip),%rdx
call   1040 <replace_all_str@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2ea3(%rip),%rdi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0x2e92(%rip),%rdi
lea    0xe5a(%rip),%rsi
lea    0xe55(%rip),%rdx
call   1040 <replace_all_str@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2e70(%rip),%rdi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0x2e5f(%rip),%rdi
lea    0xe2e(%rip),%rsi
lea    0xe29(%rip),%rdx
call   1040 <replace_all_str@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2e3d(%rip),%rdi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0x2e2c(%rip),%rdi
lea    0xe04(%rip),%rsi
lea    0xdff(%rip),%rdx
call   1040 <replace_all_str@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2e0a(%rip),%rdi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x3de8(%rip)
lea    0x2df2(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_html>:
push   %rbx
mov    %rdi,%rsi
lea    0x2f15(%rip),%rbx
mov    %rbx,%rdi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0xec1(%rip),%rsi
lea    0xebc(%rip),%rdx
mov    %rbx,%rdi
call   1040 <replace_all_str@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0xea3(%rip),%rsi
lea    0xe9e(%rip),%rdx
mov    %rbx,%rdi
call   1040 <replace_all_str@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0xe84(%rip),%rsi
lea    0xe7f(%rip),%rdx
mov    %rbx,%rdi
call   1040 <replace_all_str@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0xe65(%rip),%rsi
lea    0xe60(%rip),%rdx
mov    %rbx,%rdi
call   1040 <replace_all_str@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
lea    0xe48(%rip),%rsi
lea    0xe43(%rip),%rdx
mov    %rbx,%rdi
call   1040 <replace_all_str@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0xff0,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x3e32(%rip)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@encode_html.buf = internal global [4080 x i8] zeroinitializer
@.str = [2 x i8] c"&\00"
@.str.1 = [6 x i8] c"&amp;\00"
@.str.2 = [2 x i8] c"<\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [2 x i8] c">\00"
@.str.5 = [5 x i8] c"&gt;\00"
@.str.6 = [2 x i8] c"\22\00"
@.str.7 = [7 x i8] c"&quot;\00"
@.str.8 = [2 x i8] c"'\00"
@.str.9 = [7 x i8] c"&apos;\00"
define i8* @encode_html(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %4, i32 4080)
%6 = call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %7, i32 4080)
%9 = call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %10, i32 4080)
%12 = call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %13, i32 4080)
%15 = call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
store i8* %15, i8** %3
%16 = load i8*, i8** %3
%17 = call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %16, i32 4080)
%18 = call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %19, i32 4080)
store i8 0, i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 4079)
ret i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@encode_html.buf = internal global [4080 x i8] zeroinitializer
@.str = [2 x i8] c"&\00"
@.str.1 = [6 x i8] c"&amp;\00"
@.str.2 = [2 x i8] c"<\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [2 x i8] c">\00"
@.str.5 = [5 x i8] c"&gt;\00"
@.str.6 = [2 x i8] c"\22\00"
@.str.7 = [7 x i8] c"&quot;\00"
@.str.8 = [2 x i8] c"'\00"
@.str.9 = [7 x i8] c"&apos;\00"
define i8* @encode_html(i8* %0) {
%2 = tail call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %0, i32 4080)
%3 = tail call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %3, i32 4080)
%5 = tail call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %5, i32 4080)
%7 = tail call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%8 = tail call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %7, i32 4080)
%9 = tail call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%10 = tail call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %9, i32 4080)
%11 = tail call i8* @replace_all_str(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%12 = tail call i32 @strncpy(i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0), i8* %11, i32 4080)
store i8 0, i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 4079)
ret i8* getelementptr inbounds ([4080 x i8], [4080 x i8]* @encode_html.buf, i64 0, i64 0)
}