#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*/ replace_char(char *, char, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
char *xml_escape(const char *s) {
  static char escaped[1024];
  strcpy(escaped, s);
  replace_char(escaped, '&', "&amp;");
  replace_char(escaped, '<', "&lt;");
  replace_char(escaped, '>', "&gt;");
  return escaped;
}


x86 assembly (clang, -O0):
<xml_escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2f09(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2efd(%rip),%rdi
mov    $0x26,%esi
lea    0xeb1(%rip),%rdx
call   1040 <replace_char@plt>
lea    0x2ee5(%rip),%rdi
mov    $0x3c,%esi
lea    0xe9f(%rip),%rdx
call   1040 <replace_char@plt>
lea    0x2ecd(%rip),%rdi
mov    $0x3e,%esi
lea    0xe8c(%rip),%rdx
call   1040 <replace_char@plt>
lea    0x2eb5(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xml_escape>:
push   %rbx
mov    %rdi,%rsi
lea    0x2f15(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xec6(%rip),%rdx
mov    %rbx,%rdi
mov    $0x26,%esi
call   1040 <replace_char@plt>
lea    0xeb8(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3c,%esi
call   1040 <replace_char@plt>
lea    0xea9(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3e,%esi
call   1040 <replace_char@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@xml_escape.escaped = internal global [1024 x i8] zeroinitializer
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
define i8* @xml_escape(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0), i8* %3)
%5 = call i32 @replace_char(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0), i8 signext 38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @replace_char(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0), i8 signext 60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @replace_char(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0), i8 signext 62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0)
}

LLVM IR (-O2):
@xml_escape.escaped = internal global [1024 x i8] zeroinitializer
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
define i8* @xml_escape(i8* %0) {
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0), i8* %0)
%3 = tail call i32 @replace_char(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0), i8 signext 38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @replace_char(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0), i8 signext 60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @replace_char(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0), i8 signext 62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @xml_escape.escaped, i64 0, i64 0)
}