#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*/ assert(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
char *lace_compat_string_byte_translate(char *, char const *,
                                        char const *const *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main() {
  char *s;
  const char xml_needles[] = "&<>\"'";
  const char *const xml_replacements[] = {
      "&amp;", "&lt;", "&gt;", "&quot;", "&apos;",
  };
  s = lace_compat_string_byte_translate("Student's code: \"x > z && x < y\"",
                                        xml_needles, xml_replacements,
                                        "<example>", "</example>");
  fprintf(stderr, "Got: %s\n", s);
  assert(0 == strcmp(s, "<example>Student&apos;s code: &quot;x &gt; z "
                        "&amp;&amp; x &lt; y&quot;</example>"));
  free(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8b(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xe85(%rip),%ax
mov    %ax,-0x12(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xe6c(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe67(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe61(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe5b(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe57(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x16(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    0xe4b(%rip),%rdi
lea    0xe65(%rip),%rcx
lea    0xeb7(%rip),%r8
call   1080 <lace_compat_string_byte_translate@plt>
mov    %rax,-0x10(%rbp)
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe4b(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movw   $0x27,0xc(%rsp)
movl   $0x223e3c26,0x8(%rsp)
22
lea    0xe9b(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe95(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xe8e(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xe87(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xe82(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xe7d(%rip),%rdi
lea    0xe97(%rip),%rcx
lea    0xee9(%rip),%r8
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1070 <lace_compat_string_byte_translate@plt>
mov    %rax,%rbx
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.xml_needles = [6 x i8] c"&<>\22'\00"
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [7 x i8] c"&quot;\00"
@.str.4 = [7 x i8] c"&apos;\00"
@.str.5 = [33 x i8] c"Student's code: \22x > z && x < y\22\00"
@.str.6 = [10 x i8] c"<example>\00"
@.str.7 = [11 x i8] c"</example>\00"
@stderr = global i32 0
@.str.8 = [9 x i8] c"Got: %s\0A\00"
@.str.9 = [81 x i8] c"<example>Student&apos;s code: &quot;x &gt; z &amp;&amp; x &lt; y&quot;</example>\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [6 x i8]
%4 = alloca [5 x i8*]
store i32 0, i32* %1
%5 = bitcast [6 x i8]* %3 to i8*
%6 = bitcast [5 x i8*]* %4 to i8*
%7 = bitcast i8* %6 to [5 x i8*]*
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
%15 = call i8* @lace_compat_string_byte_translate(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %13, i8** %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
store i8* %15, i8** %2
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %2
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %2
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.9, i64 0, i64 0))
%21 = icmp eq i64 0, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i8*, i8** %2
%25 = call i32 @free(i8* %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.xml_needles = [6 x i8] c"&<>\22'\00"
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [7 x i8] c"&quot;\00"
@.str.4 = [7 x i8] c"&apos;\00"
@.str.5 = [33 x i8] c"Student's code: \22x > z && x < y\22\00"
@.str.6 = [10 x i8] c"<example>\00"
@.str.7 = [11 x i8] c"</example>\00"
@stderr = global i32 0
@.str.8 = [9 x i8] c"Got: %s\0A\00"
@.str.9 = [81 x i8] c"<example>Student&apos;s code: &quot;x &gt; z &amp;&amp; x &lt; y&quot;</example>\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [5 x i8*]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = bitcast [5 x i8*]* %2 to i8*
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %9
%10 = call i8* @lace_compat_string_byte_translate(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %3, i8** %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %10)
%13 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.9, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @free(i8* %10)
ret i32 0
}