#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*/ fromto;

/* Variables and functions */
int ENOMEM;
char *calloc(size_t, int);
size_t htmlescape_count(char const *, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
int htmlescape(const char *src, char **dst) {
  char *p = 0;
  static char *fromto[] = {"&", "&amp;", "<",    "&lt;",
                           ">", "&gt;",  "\\\"", "&quot;"};
  size_t dstsz = 0;
  size_t fromtosz = 0;
  size_t i = 0;
  int rval = 0;
  if (!src || !dst || !strlen(src))
    return rval;
  fromtosz = sizeof(fromto) / sizeof(fromto[0]);
  dstsz = strlen(src);
  for (i = 0; i < fromtosz; i += 2) {
    size_t sz0 = strlen(fromto[i]);
    size_t sz1 = strlen(fromto[i + 1]);
    dstsz += htmlescape_count(src, fromto[i]) * (sz1 - sz0);
  }
  if ((*dst = calloc(dstsz + 1, 1)) == NULL)
    rval = ENOMEM;
  for (p = *dst; *src && !rval; src++) {
    for (i = 0; i < fromtosz; i += 2)
      if (!strncmp(src, fromto[i], strlen(fromto[i]))) {
        memcpy(p, fromto[i + 1], strlen(fromto[i + 1]));
        p += strlen(p);
        src += strlen(fromto[i]) - 1;
        break;
      }
    if (i == fromtosz)
      *p++ = *src;
  }
  return rval;
}


x86 assembly (clang, -O0):
<htmlescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b2 <htmlescape+0x62>
cmpq   $0x0,-0x18(%rbp)
je     11b2 <htmlescape+0x62>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    11bd <htmlescape+0x6d>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1400 <htmlescape+0x2b0>
movq   $0x8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cltq
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    125c <htmlescape+0x10c>
mov    -0x38(%rbp),%rcx
lea    0x2e5b(%rip),%rax
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
cltq
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rcx
lea    0x2e41(%rip),%rax
mov    0x8(%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
cltq
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rcx
lea    0x2e22(%rip),%rax
mov    (%rax,%rcx,8),%rsi
call   1070 <htmlescape_count@plt>
mov    -0x50(%rbp),%rcx
sub    -0x48(%rbp),%rcx
imul   %rcx,%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x38(%rbp)
jmp    11dc <htmlescape+0x8c>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    128b <htmlescape+0x13b>
mov    0x2d5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x51(%rbp)
je     12b7 <htmlescape+0x167>
cmpl   $0x0,-0x3c(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    12c7 <htmlescape+0x177>
jmp    13fa <htmlescape+0x2aa>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    13bf <htmlescape+0x26f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x38(%rbp),%rcx
lea    0x2d60(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rcx
lea    0x2d4d(%rip),%rax
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    13a9 <htmlescape+0x259>
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x38(%rbp),%rcx
lea    0x2d19(%rip),%rax
mov    0x8(%rax,%rcx,8),%rax
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rcx
lea    0x2d05(%rip),%rax
mov    0x8(%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rcx
lea    0x2cc8(%rip),%rax
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    13bf <htmlescape+0x26f>
jmp    13ae <htmlescape+0x25e>
mov    -0x38(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x38(%rbp)
jmp    12cf <htmlescape+0x17f>
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    13e4 <htmlescape+0x294>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    13e9 <htmlescape+0x299>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1296 <htmlescape+0x146>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<htmlescape>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
test   %rdi,%rdi
je     13d7 <htmlescape+0x287>
mov    %rsi,%rbp
test   %rsi,%rsi
je     13d7 <htmlescape+0x287>
mov    %rdi,%rbx
call   1040 <strlen@plt>
test   %eax,%eax
je     13d7 <htmlescape+0x287>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%r15
mov    %rbp,(%rsp)
lea    0xe67(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
movslq %eax,%r12
lea    0xe57(%rip),%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
sub    %r12,%rbp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <htmlescape_count@plt>
mov    %rax,%r13
imul   %rbp,%r13
add    %r15,%r13
lea    0xe36(%rip),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
lea    0xe26(%rip),%rdi
call   1040 <strlen@plt>
movslq %eax,%r15
sub    %rbp,%r15
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <htmlescape_count@plt>
mov    %rax,%r12
imul   %r15,%r12
add    %r13,%r12
lea    0xe04(%rip),%r13
mov    %r13,%rdi
call   1040 <strlen@plt>
movslq %eax,%r15
lea    0xdf4(%rip),%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
sub    %r15,%rbp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <htmlescape_count@plt>
mov    %rax,%r15
imul   %rbp,%r15
add    %r12,%r15
lea    0xdd2(%rip),%r13
mov    %r13,%rdi
call   1040 <strlen@plt>
movslq %eax,%r12
lea    0xdc3(%rip),%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
sub    %r12,%rbp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <htmlescape_count@plt>
imul   %rbp,%rax
lea    (%rax,%r15,1),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r13
mov    (%rsp),%rax
mov    %r13,(%rax)
xor    %r12d,%r12d
test   %r13,%r13
jne    129e <htmlescape+0x14e>
mov    0x2d3d(%rip),%rax
mov    (%rax),%r12d
cmpb   $0x0,(%rbx)
je     13d7 <htmlescape+0x287>
test   %r12d,%r12d
jne    13d7 <htmlescape+0x287>
lea    0xd51(%rip),%r15
lea    0xd51(%rip),%rbp
lea    0xd51(%rip),%r12
jmp    1336 <htmlescape+0x1e6>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%eax
mov    %r14,%r12
lea    0x2af1(%rip),%rcx
mov    (%rcx,%rax,8),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
add    %r13,%rbp
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
add    $0xffffffffffffffff,%rbx
mov    %rbp,%r13
lea    0xcee(%rip),%rbp
lea    0xcee(%rip),%r12
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     13d4 <htmlescape+0x284>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     12d0 <htmlescape+0x180>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     13b0 <htmlescape+0x260>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     13bd <htmlescape+0x26d>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     13ca <htmlescape+0x27a>
movzbl (%rbx),%eax
mov    %al,0x0(%r13)
add    $0x1,%r13
jmp    1328 <htmlescape+0x1d8>
nopw   0x0(%rax,%rax,1)
mov    $0x3,%eax
mov    %r15,%r12
jmp    12d8 <htmlescape+0x188>
mov    $0x5,%eax
mov    %rbp,%r12
jmp    12d8 <htmlescape+0x188>
mov    $0x7,%eax
jmp    12d8 <htmlescape+0x188>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@htmlescape.fromto = internal global [8 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0)]
@.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 = [3 x i8] c"\\\22\00"
@.str.7 = [7 x i8] c"&quot;\00"
@ENOMEM = global i32 0
define i32 @htmlescape(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i64 0, i64* %7
store i64 0, i64* %8
store i64 0, i64* %9
store i32 0, i32* %10
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = icmp ne i8** %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = call i32 @strlen(i8* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %18, %15, %2
%23 = load i32, i32* %10
store i32 %23, i32* %3
br label %140
24: ; preds = %18
store i64 8, i64* %8
%25 = load i8*, i8** %4
%26 = call i32 @strlen(i8* %25)
%27 = sext i32 %26 to i64
store i64 %27, i64* %7
store i64 0, i64* %9
br label %28
28: ; preds = %55, %24
%29 = load i64, i64* %9
%30 = load i64, i64* %8
%31 = icmp ult i64 %29, %30
br i1 %31, label %32, label %58
32: ; preds = %28
%33 = load i64, i64* %9
%34 = getelementptr inbounds [8 x i8*], [8 x i8*]* @htmlescape.fromto, i64 0, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @strlen(i8* %35)
%37 = sext i32 %36 to i64
store i64 %37, i64* %11
%38 = load i64, i64* %9
%39 = add i64 %38, 1
%40 = getelementptr inbounds [8 x i8*], [8 x i8*]* @htmlescape.fromto, i64 0, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @strlen(i8* %41)
%43 = sext i32 %42 to i64
store i64 %43, i64* %12
%44 = load i8*, i8** %4
%45 = load i64, i64* %9
%46 = getelementptr inbounds [8 x i8*], [8 x i8*]* @htmlescape.fromto, i64 0, i64 %45
%47 = load i8*, i8** %46
%48 = call i64 @htmlescape_count(i8* %44, i8* %47)
%49 = load i64, i64* %12
%50 = load i64, i64* %11
%51 = sub i64 %49, %50
%52 = mul i64 %48, %51
%53 = load i64, i64* %7
%54 = add i64 %53, %52
store i64 %54, i64* %7
br label %55
55: ; preds = %32
%56 = load i64, i64* %9
%57 = add i64 %56, 2
store i64 %57, i64* %9
br label %28
58: ; preds = %28
%59 = load i64, i64* %7
%60 = add i64 %59, 1
%61 = call i8* @calloc(i64 %60, i32 1)
%62 = load i8**, i8*** %5
store i8* %61, i8** %62
%63 = icmp eq i8* %61, null
br i1 %63, label %64, label %66
64: ; preds = %58
%65 = load i32, i32* @ENOMEM
store i32 %65, i32* %10
br label %66
66: ; preds = %64, %58
%67 = load i8**, i8*** %5
%68 = load i8*, i8** %67
store i8* %68, i8** %6
br label %69
69: ; preds = %135, %66
%70 = load i8*, i8** %4
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %69
%75 = load i32, i32* %10
%76 = icmp ne i32 %75, 0
%77 = xor i1 %76, true
br label %78
78: ; preds = %74, %69
%79 = phi i1 [ false, %69 ], [ %77, %74 ]
br i1 %79, label %80, label %138
80: ; preds = %78
store i64 0, i64* %9
br label %81
81: ; preds = %122, %80
%82 = load i64, i64* %9
%83 = load i64, i64* %8
%84 = icmp ult i64 %82, %83
br i1 %84, label %85, label %125
85: ; preds = %81
%86 = load i8*, i8** %4
%87 = load i64, i64* %9
%88 = getelementptr inbounds [8 x i8*], [8 x i8*]* @htmlescape.fromto, i64 0, i64 %87
%89 = load i8*, i8** %88
%90 = load i64, i64* %9
%91 = getelementptr inbounds [8 x i8*], [8 x i8*]* @htmlescape.fromto, i64 0, i64 %90
%92 = load i8*, i8** %91
%93 = call i32 @strlen(i8* %92)
%94 = call i32 @strncmp(i8* %86, i8* %89, i32 %93)
%95 = icmp ne i32 %94, 0
br i1 %95, label %121, label %96
96: ; preds = %85
%97 = load i8*, i8** %6
%98 = load i64, i64* %9
%99 = add i64 %98, 1
%100 = getelementptr inbounds [8 x i8*], [8 x i8*]* @htmlescape.fromto, i64 0, i64 %99
%101 = load i8*, i8** %100
%102 = load i64, i64* %9
%103 = add i64 %102, 1
%104 = getelementptr inbounds [8 x i8*], [8 x i8*]* @htmlescape.fromto, i64 0, i64 %103
%105 = load i8*, i8** %104
%106 = call i32 @strlen(i8* %105)
%107 = call i32 @memcpy(i8* %97, i8* %101, i32 %106)
%108 = load i8*, i8** %6
%109 = call i32 @strlen(i8* %108)
%110 = load i8*, i8** %6
%111 = sext i32 %109 to i64
%112 = getelementptr inbounds i8, i8* %110, i64 %111
store i8* %112, i8** %6
%113 = load i64, i64* %9
%114 = getelementptr inbounds [8 x i8*], [8 x i8*]* @htmlescape.fromto, i64 0, i64 %113
%115 = load i8*, i8** %114
%116 = call i32 @strlen(i8* %115)
%117 = sub nsw i32 %116, 1
%118 = load i8*, i8** %4
%119 = sext i32 %117 to i64
%120 = getelementptr inbounds i8, i8* %118, i64 %119
store i8* %120, i8** %4
br label %125
121: ; preds = %85
br label %122
122: ; preds = %121
%123 = load i64, i64* %9
%124 = add i64 %123, 2
store i64 %124, i64* %9
br label %81
125: ; preds = %96, %81
%126 = load i64, i64* %9
%127 = load i64, i64* %8
%128 = icmp eq i64 %126, %127
br i1 %128, label %129, label %134
129: ; preds = %125
%130 = load i8*, i8** %4
%131 = load i8, i8* %130
%132 = load i8*, i8** %6
%133 = getelementptr inbounds i8, i8* %132, i32 1
store i8* %133, i8** %6
store i8 %131, i8* %132
br label %134
134: ; preds = %129, %125
br label %135
135: ; preds = %134
%136 = load i8*, i8** %4
%137 = getelementptr inbounds i8, i8* %136, i32 1
store i8* %137, i8** %4
br label %69
138: ; preds = %78
%139 = load i32, i32* %10
store i32 %139, i32* %3
br label %140
140: ; preds = %138, %22
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
@htmlescape.fromto = internal unnamed_addr constant [8 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0)]
@.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 = [3 x i8] c"\\\22\00"
@.str.7 = [7 x i8] c"&quot;\00"
@ENOMEM = global i32 0
define i32 @htmlescape(i8* %0, i8** %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8** %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %94
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %94, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %0)
%11 = sext i32 %10 to i64
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = sext i32 %12 to i64
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = sext i32 %14 to i64
%16 = tail call i64 @htmlescape_count(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = sub nsw i64 %15, %13
%18 = mul i64 %17, %16
%19 = add i64 %18, %11
%20 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = sext i32 %20 to i64
%22 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%23 = sext i32 %22 to i64
%24 = tail call i64 @htmlescape_count(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = sub nsw i64 %23, %21
%26 = mul i64 %25, %24
%27 = add i64 %26, %19
%28 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%29 = sext i32 %28 to i64
%30 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%31 = sext i32 %30 to i64
%32 = tail call i64 @htmlescape_count(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%33 = sub nsw i64 %31, %29
%34 = mul i64 %33, %32
%35 = add i64 %34, %27
%36 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%37 = sext i32 %36 to i64
%38 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%39 = sext i32 %38 to i64
%40 = tail call i64 @htmlescape_count(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%41 = sub nsw i64 %39, %37
%42 = mul i64 %41, %40
%43 = add i64 %42, %35
%44 = add i64 %43, 1
%45 = tail call i8* @calloc(i64 %44, i32 1)
store i8* %45, i8** %1
%46 = icmp eq i8* %45, null
%47 = load i32, i32* @ENOMEM
%48 = select i1 %46, i32 %47, i32 0
%49 = icmp eq i32 %48, 0
%50 = load i8, i8* %0
%51 = icmp ne i8 %50, 0
%52 = select i1 %51, i1 %49, i1 false
br i1 %52, label %53, label %94
53: ; preds = %9, %88
%54 = phi i8* [ %91, %88 ], [ %0, %9 ]
%55 = phi i8* [ %90, %88 ], [ %45, %9 ]
%56 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%57 = tail call i32 @strncmp(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %73
59: ; preds = %81, %77, %73, %53
%60 = phi i64 [ 1, %53 ], [ 3, %73 ], [ 5, %77 ], [ 7, %81 ]
%61 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %53 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %73 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %77 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), %81 ]
%62 = getelementptr inbounds [8 x i8*], [8 x i8*]* @htmlescape.fromto, i64 0, i64 %60
%63 = load i8*, i8** %62
%64 = tail call i32 @strlen(i8* %63)
%65 = tail call i32 @memcpy(i8* %55, i8* %63, i32 %64)
%66 = tail call i32 @strlen(i8* %55)
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %55, i64 %67
%69 = tail call i32 @strlen(i8* %61)
%70 = add nsw i32 %69, -1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %54, i64 %71
br label %88
73: ; preds = %53
%74 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%75 = tail call i32 @strncmp(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %74)
%76 = icmp eq i32 %75, 0
br i1 %76, label %59, label %77
77: ; preds = %73
%78 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%79 = tail call i32 @strncmp(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %78)
%80 = icmp eq i32 %79, 0
br i1 %80, label %59, label %81
81: ; preds = %77
%82 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%83 = tail call i32 @strncmp(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %82)
%84 = icmp eq i32 %83, 0
br i1 %84, label %59, label %85
85: ; preds = %81
%86 = load i8, i8* %54
%87 = getelementptr inbounds i8, i8* %55, i64 1
store i8 %86, i8* %55
br label %88
88: ; preds = %59, %85
%89 = phi i8* [ %54, %85 ], [ %72, %59 ]
%90 = phi i8* [ %87, %85 ], [ %68, %59 ]
%91 = getelementptr inbounds i8, i8* %89, i64 1
%92 = load i8, i8* %91
%93 = icmp eq i8 %92, 0
br i1 %93, label %94, label %53
94: ; preds = %88, %9, %2, %6
%95 = phi i32 [ 0, %6 ], [ 0, %2 ], [ %48, %9 ], [ 0, %88 ]
ret i32 %95
}