#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 ssize_t;

/* Variables and functions */
int /*<<< orphan*/ gg_append(char *, size_t *, char *, int);
int strlen(char const *);
size_t gg_message_text_to_html_110_buff(char *dst, const char *text,
                                        ssize_t text_len) {
  size_t i, dst_len;
  if (text_len == -1)
    text_len = strlen(text);
  dst_len = 0;
  gg_append(dst, &dst_len, "<span>", 6);
  for (i = 0; i < (size_t)text_len; i++) {
    char c = text[i];
    if (c == '<')
      gg_append(dst, &dst_len, "&lt;", 4);
    else if (c == '>')
      gg_append(dst, &dst_len, "&gt;", 4);
    else if (c == '&')
      gg_append(dst, &dst_len, "&amp;", 5);
    else if (c == '"')
      gg_append(dst, &dst_len, "&quot;", 6);
    else if (c == '\'')
      gg_append(dst, &dst_len, "&apos;", 6);
    else if (c == '\n')
      gg_append(dst, &dst_len, "<br>", 4);
    else if (c == '\r')
      continue;
    else if (c == '\xc2' && text[i + 1] == '\xa0') {
      gg_append(dst, &dst_len, "&nbsp;", 6);
      i++;
    } else {
      if (dst)
        dst[dst_len] = c;
      dst_len++;
    }
  }
  gg_append(dst, &dst_len, "</span>", 7);
  if (dst)
    dst[dst_len] = '\0';
  return dst_len;
}


x86 assembly (clang, -O0):
<gg_message_text_to_html_110_buff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1149 <gg_message_text_to_html_110_buff+0x29>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    0xea0(%rip),%rdx
mov    $0x6,%ecx
call   1040 <gg_append@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jae    1350 <gg_message_text_to_html_110_buff+0x230>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x3c,%eax
jne    11bc <gg_message_text_to_html_110_buff+0x9c>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    0xe5a(%rip),%rdx
mov    $0x4,%ecx
call   1040 <gg_append@plt>
jmp    133a <gg_message_text_to_html_110_buff+0x21a>
movsbl -0x29(%rbp),%eax
cmp    $0x3e,%eax
jne    11e7 <gg_message_text_to_html_110_buff+0xc7>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    0xe34(%rip),%rdx
mov    $0x4,%ecx
call   1040 <gg_append@plt>
jmp    1335 <gg_message_text_to_html_110_buff+0x215>
movsbl -0x29(%rbp),%eax
cmp    $0x26,%eax
jne    1212 <gg_message_text_to_html_110_buff+0xf2>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    0xe0e(%rip),%rdx
mov    $0x5,%ecx
call   1040 <gg_append@plt>
jmp    1330 <gg_message_text_to_html_110_buff+0x210>
movsbl -0x29(%rbp),%eax
cmp    $0x22,%eax
jne    123d <gg_message_text_to_html_110_buff+0x11d>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    0xde9(%rip),%rdx
mov    $0x6,%ecx
call   1040 <gg_append@plt>
jmp    132b <gg_message_text_to_html_110_buff+0x20b>
movsbl -0x29(%rbp),%eax
cmp    $0x27,%eax
jne    1268 <gg_message_text_to_html_110_buff+0x148>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    0xdc5(%rip),%rdx
mov    $0x6,%ecx
call   1040 <gg_append@plt>
jmp    1326 <gg_message_text_to_html_110_buff+0x206>
movsbl -0x29(%rbp),%eax
cmp    $0xa,%eax
jne    1293 <gg_message_text_to_html_110_buff+0x173>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    0xda1(%rip),%rdx
mov    $0x4,%ecx
call   1040 <gg_append@plt>
jmp    1321 <gg_message_text_to_html_110_buff+0x201>
movsbl -0x29(%rbp),%eax
cmp    $0xd,%eax
jne    12a5 <gg_message_text_to_html_110_buff+0x185>
jmp    133f <gg_message_text_to_html_110_buff+0x21f>
movsbl -0x29(%rbp),%eax
cmp    $0xffffffc2,%eax
jne    12f2 <gg_message_text_to_html_110_buff+0x1d2>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl 0x1(%rax,%rcx,1),%eax
cmp    $0xffffffa0,%eax
jne    12f2 <gg_message_text_to_html_110_buff+0x1d2>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    0xd53(%rip),%rdx
mov    $0x6,%ecx
call   1040 <gg_append@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1317 <gg_message_text_to_html_110_buff+0x1f7>
cmpq   $0x0,-0x8(%rbp)
je     130b <gg_message_text_to_html_110_buff+0x1eb>
mov    -0x29(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    131c <gg_message_text_to_html_110_buff+0x1fc>
jmp    1321 <gg_message_text_to_html_110_buff+0x201>
jmp    1326 <gg_message_text_to_html_110_buff+0x206>
jmp    132b <gg_message_text_to_html_110_buff+0x20b>
jmp    1330 <gg_message_text_to_html_110_buff+0x210>
jmp    1335 <gg_message_text_to_html_110_buff+0x215>
jmp    133a <gg_message_text_to_html_110_buff+0x21a>
jmp    133f <gg_message_text_to_html_110_buff+0x21f>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1172 <gg_message_text_to_html_110_buff+0x52>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    0xcd2(%rip),%rdx
mov    $0x7,%ecx
call   1040 <gg_append@plt>
cmpq   $0x0,-0x8(%rbp)
je     1380 <gg_message_text_to_html_110_buff+0x260>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gg_message_text_to_html_110_buff>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
cmp    $0xffffffff,%edx
jne    1142 <gg_message_text_to_html_110_buff+0x22>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
movq   $0x0,(%rsp)
lea    0xf83(%rip),%rdx
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x6,%ecx
call   1040 <gg_append@plt>
test   %ebp,%ebp
je     1249 <gg_message_text_to_html_110_buff+0x129>
movslq %ebp,%r13
xor    %ebp,%ebp
mov    %rsp,%r12
lea    0xe88(%rip),%r15
jmp    119e <gg_message_text_to_html_110_buff+0x7e>
mov    %r14,%rdi
mov    %r12,%rsi
lea    0xf54(%rip),%rdx
mov    $0x4,%ecx
call   1040 <gg_append@plt>
add    $0x1,%rbp
cmp    %r13,%rbp
jae    1249 <gg_message_text_to_html_110_buff+0x129>
movzbl (%rbx,%rbp,1),%eax
lea    -0xa(%rax),%ecx
cmp    $0x34,%cl
ja     11c5 <gg_message_text_to_html_110_buff+0xa5>
movzbl %cl,%ecx
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
mov    %r14,%rdi
mov    %r12,%rsi
lea    0xf36(%rip),%rdx
jmp    1187 <gg_message_text_to_html_110_buff+0x67>
cmp    $0xc2,%al
jne    11e3 <gg_message_text_to_html_110_buff+0xc3>
cmpb   $0xa0,0x1(%rbx,%rbp,1)
jne    11e3 <gg_message_text_to_html_110_buff+0xc3>
add    $0x1,%rbp
mov    %r14,%rdi
mov    %r12,%rsi
lea    0xf1d(%rip),%rdx
jmp    122d <gg_message_text_to_html_110_buff+0x10d>
mov    (%rsp),%rcx
test   %r14,%r14
je     11f0 <gg_message_text_to_html_110_buff+0xd0>
mov    %al,(%r14,%rcx,1)
add    $0x1,%rcx
mov    %rcx,(%rsp)
jmp    1191 <gg_message_text_to_html_110_buff+0x71>
mov    %r14,%rdi
mov    %r12,%rsi
lea    0xee4(%rip),%rdx
jmp    122d <gg_message_text_to_html_110_buff+0x10d>
mov    %r14,%rdi
mov    %r12,%rsi
lea    0xecf(%rip),%rdx
mov    $0x5,%ecx
jmp    118c <gg_message_text_to_html_110_buff+0x6c>
mov    %r14,%rdi
mov    %r12,%rsi
lea    0xec5(%rip),%rdx
mov    $0x6,%ecx
jmp    118c <gg_message_text_to_html_110_buff+0x6c>
mov    %r14,%rdi
mov    %r12,%rsi
lea    0xe9c(%rip),%rdx
jmp    1187 <gg_message_text_to_html_110_buff+0x67>
lea    0xeb5(%rip),%rdx
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x7,%ecx
call   1040 <gg_append@plt>
mov    (%rsp),%rax
test   %r14,%r14
je     126e <gg_message_text_to_html_110_buff+0x14e>
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"<span>\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [6 x i8] c"&amp;\00"
@.str.4 = [7 x i8] c"&quot;\00"
@.str.5 = [7 x i8] c"&apos;\00"
@.str.6 = [5 x i8] c"<br>\00"
@.str.7 = [7 x i8] c"&nbsp;\00"
@.str.8 = [8 x i8] c"</span>\00"
define i64 @gg_message_text_to_html_110_buff(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %6
br label %15
15: ; preds = %12, %3
store i64 0, i64* %8
%16 = load i8*, i8** %4
%17 = call i32 @gg_append(i8* %16, i64* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
store i64 0, i64* %7
br label %18
18: ; preds = %110, %15
%19 = load i64, i64* %7
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = icmp ult i64 %19, %21
br i1 %22, label %23, label %113
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = load i64, i64* %7
%26 = getelementptr inbounds i8, i8* %24, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %9
%28 = load i8, i8* %9
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 60
br i1 %30, label %31, label %34
31: ; preds = %23
%32 = load i8*, i8** %4
%33 = call i32 @gg_append(i8* %32, i64* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
br label %109
34: ; preds = %23
%35 = load i8, i8* %9
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 62
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i8*, i8** %4
%40 = call i32 @gg_append(i8* %39, i64* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
br label %108
41: ; preds = %34
%42 = load i8, i8* %9
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 38
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i8*, i8** %4
%47 = call i32 @gg_append(i8* %46, i64* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
br label %107
48: ; preds = %41
%49 = load i8, i8* %9
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 34
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i8*, i8** %4
%54 = call i32 @gg_append(i8* %53, i64* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
br label %106
55: ; preds = %48
%56 = load i8, i8* %9
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 39
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i8*, i8** %4
%61 = call i32 @gg_append(i8* %60, i64* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
br label %105
62: ; preds = %55
%63 = load i8, i8* %9
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 10
br i1 %65, label %66, label %69
66: ; preds = %62
%67 = load i8*, i8** %4
%68 = call i32 @gg_append(i8* %67, i64* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
br label %104
69: ; preds = %62
%70 = load i8, i8* %9
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 13
br i1 %72, label %73, label %74
73: ; preds = %69
br label %110
74: ; preds = %69
%75 = load i8, i8* %9
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, -62
br i1 %77, label %78, label %91
78: ; preds = %74
%79 = load i8*, i8** %5
%80 = load i64, i64* %7
%81 = add i64 %80, 1
%82 = getelementptr inbounds i8, i8* %79, i64 %81
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, -96
br i1 %85, label %86, label %91
86: ; preds = %78
%87 = load i8*, i8** %4
%88 = call i32 @gg_append(i8* %87, i64* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%89 = load i64, i64* %7
%90 = add i64 %89, 1
store i64 %90, i64* %7
br label %102
91: ; preds = %78, %74
%92 = load i8*, i8** %4
%93 = icmp ne i8* %92, null
br i1 %93, label %94, label %99
94: ; preds = %91
%95 = load i8, i8* %9
%96 = load i8*, i8** %4
%97 = load i64, i64* %8
%98 = getelementptr inbounds i8, i8* %96, i64 %97
store i8 %95, i8* %98
br label %99
99: ; preds = %94, %91
%100 = load i64, i64* %8
%101 = add i64 %100, 1
store i64 %101, i64* %8
br label %102
102: ; preds = %99, %86
br label %103
103: ; preds = %102
br label %104
104: ; preds = %103, %66
br label %105
105: ; preds = %104, %59
br label %106
106: ; preds = %105, %52
br label %107
107: ; preds = %106, %45
br label %108
108: ; preds = %107, %38
br label %109
109: ; preds = %108, %31
br label %110
110: ; preds = %109, %73
%111 = load i64, i64* %7
%112 = add i64 %111, 1
store i64 %112, i64* %7
br label %18
113: ; preds = %18
%114 = load i8*, i8** %4
%115 = call i32 @gg_append(i8* %114, i64* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 7)
%116 = load i8*, i8** %4
%117 = icmp ne i8* %116, null
br i1 %117, label %118, label %122
118: ; preds = %113
%119 = load i8*, i8** %4
%120 = load i64, i64* %8
%121 = getelementptr inbounds i8, i8* %119, i64 %120
store i8 0, i8* %121
br label %122
122: ; preds = %118, %113
%123 = load i64, i64* %8
ret i64 %123
}

LLVM IR (-O2):
@.str = [7 x i8] c"<span>\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [6 x i8] c"&amp;\00"
@.str.4 = [7 x i8] c"&quot;\00"
@.str.5 = [7 x i8] c"&apos;\00"
@.str.6 = [5 x i8] c"<br>\00"
@.str.7 = [7 x i8] c"&nbsp;\00"
@.str.8 = [8 x i8] c"</span>\00"
define i64 @gg_message_text_to_html_110_buff(i8* %0, i8* %1, i32 %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = icmp eq i32 %2, -1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %1)
br label %9
9: ; preds = %7, %3
%10 = phi i32 [ %8, %7 ], [ %2, %3 ]
store i64 0, i64* %4
%11 = call i32 @gg_append(i8* %0, i64* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%12 = sext i32 %10 to i64
%13 = icmp eq i32 %10, 0
br i1 %13, label %49, label %14
14: ; preds = %9
%15 = icmp eq i8* %0, null
br label %16
16: ; preds = %14, %45
%17 = phi i64 [ 0, %14 ], [ %47, %45 ]
%18 = getelementptr inbounds i8, i8* %1, i64 %17
%19 = load i8, i8* %18
switch i8 %19, label %39 [
i8 60, label %20
i8 62, label %22
i8 38, label %24
i8 34, label %26
i8 39, label %28
i8 10, label %30
i8 13, label %45
i8 -62, label %32
]
20: ; preds = %16
%21 = call i32 @gg_append(i8* %0, i64* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
br label %45
22: ; preds = %16
%23 = call i32 @gg_append(i8* %0, i64* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
br label %45
24: ; preds = %16
%25 = call i32 @gg_append(i8* %0, i64* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
br label %45
26: ; preds = %16
%27 = call i32 @gg_append(i8* %0, i64* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
br label %45
28: ; preds = %16
%29 = call i32 @gg_append(i8* %0, i64* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
br label %45
30: ; preds = %16
%31 = call i32 @gg_append(i8* %0, i64* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
br label %45
32: ; preds = %16
%33 = add nuw i64 %17, 1
%34 = getelementptr inbounds i8, i8* %1, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, -96
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 @gg_append(i8* %0, i64* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
br label %45
39: ; preds = %16, %32
%40 = load i64, i64* %4
br i1 %15, label %43, label %41
41: ; preds = %39
%42 = getelementptr inbounds i8, i8* %0, i64 %40
store i8 %19, i8* %42
br label %43
43: ; preds = %39, %41
%44 = add i64 %40, 1
store i64 %44, i64* %4
br label %45
45: ; preds = %20, %24, %28, %43, %37, %30, %26, %22, %16
%46 = phi i64 [ %17, %16 ], [ %17, %20 ], [ %17, %22 ], [ %17, %24 ], [ %17, %26 ], [ %17, %28 ], [ %17, %30 ], [ %33, %37 ], [ %17, %43 ]
%47 = add i64 %46, 1
%48 = icmp ult i64 %47, %12
br i1 %48, label %16, label %49
49: ; preds = %45, %9
%50 = call i32 @gg_append(i8* %0, i64* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 7)
%51 = icmp eq i8* %0, null
%52 = load i64, i64* %4
br i1 %51, label %55, label %53
53: ; preds = %49
%54 = getelementptr inbounds i8, i8* %0, i64 %52
store i8 0, i8* %54
br label %55
55: ; preds = %49, %53
ret i64 %52
}