#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*/ html(char const *);
int /*<<< orphan*/ html_raw(char const *, int);
void html_txt(const char *txt) {
  const char *t = txt;
  while (t && *t) {
    int c = *t;
    if (c == '<' || c == '>' || c == '&') {
      html_raw(txt, t - txt);
      if (c == '>')
        html("&gt;");
      else if (c == '<')
        html("&lt;");
      else if (c == '&')
        html("&amp;");
      txt = t + 1;
    }
    t++;
  }
  if (t != txt)
    html(txt);
}


x86 assembly (clang, -O0):
<html_txt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x15(%rbp)
je     1154 <html_txt+0x34>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1164 <html_txt+0x44>
jmp    1215 <html_txt+0xf5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3c,-0x14(%rbp)
je     118c <html_txt+0x6c>
cmpl   $0x3e,-0x14(%rbp)
je     118c <html_txt+0x6c>
cmpl   $0x26,-0x14(%rbp)
jne    1204 <html_txt+0xe4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1030 <html_raw@plt>
cmpl   $0x3e,-0x14(%rbp)
jne    11bd <html_txt+0x9d>
lea    0xe4d(%rip),%rdi
call   1040 <html@plt>
jmp    11f8 <html_txt+0xd8>
cmpl   $0x3c,-0x14(%rbp)
jne    11d8 <html_txt+0xb8>
lea    0xe37(%rip),%rdi
call   1040 <html@plt>
jmp    11f3 <html_txt+0xd3>
cmpl   $0x26,-0x14(%rbp)
jne    11ee <html_txt+0xce>
lea    0xe21(%rip),%rdi
call   1040 <html@plt>
jmp    11f3 <html_txt+0xd3>
jmp    11f8 <html_txt+0xd8>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <html_txt+0x14>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     122c <html_txt+0x10c>
mov    -0x8(%rbp),%rdi
call   1040 <html@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<html_txt>:
test   %rdi,%rdi
je     11c3 <html_txt+0xa3>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xec5(%rip),%r12
lea    0xec8(%rip),%r14
lea    0xebc(%rip),%r15
mov    %edi,%r13d
mov    %rdi,%rbp
jmp    1165 <html_txt+0x45>
mov    %r14,%rdi
call   1040 <html@plt>
lea    0x1(%rbp),%rdi
add    $0x1,%rbp
add    $0x1,%r13d
movzbl 0x0(%rbp),%ebx
cmp    $0x3b,%bl
jle    1180 <html_txt+0x60>
cmp    $0x3e,%bl
je     1185 <html_txt+0x65>
cmp    $0x3c,%bl
je     1185 <html_txt+0x65>
jmp    115d <html_txt+0x3d>
nopw   0x0(%rax,%rax,1)
cmp    $0x26,%bl
jne    11a6 <html_txt+0x86>
mov    %r13d,%esi
sub    %edi,%esi
call   1030 <html_raw@plt>
cmp    $0x26,%bl
je     1151 <html_txt+0x31>
mov    %r12,%rdi
cmp    $0x3e,%bl
je     1154 <html_txt+0x34>
cmp    $0x3c,%bl
jne    1159 <html_txt+0x39>
mov    %r15,%rdi
jmp    1154 <html_txt+0x34>
test   %bl,%bl
jne    115d <html_txt+0x3d>
cmp    %rdi,%rbp
lea    0x8(%rsp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
je     11c3 <html_txt+0xa3>
jmp    1040 <html@plt>
ret

LLVM IR (-O0):
@.str = [5 x i8] c"&gt;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [6 x i8] c"&amp;\00"
define void @html_txt(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
br label %6
6: ; preds = %56, %1
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br label %14
14: ; preds = %9, %6
%15 = phi i1 [ false, %6 ], [ %13, %9 ]
br i1 %15, label %16, label %59
16: ; preds = %14
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 60
br i1 %21, label %28, label %22
22: ; preds = %16
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 62
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 38
br i1 %27, label %28, label %56
28: ; preds = %25, %22, %16
%29 = load i8*, i8** %2
%30 = load i8*, i8** %3
%31 = load i8*, i8** %2
%32 = ptrtoint i8* %30 to i64
%33 = ptrtoint i8* %31 to i64
%34 = sub i64 %32, %33
%35 = trunc i64 %34 to i32
%36 = call i32 @html_raw(i8* %29, i32 %35)
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 62
br i1 %38, label %39, label %41
39: ; preds = %28
%40 = call i32 @html(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %53
41: ; preds = %28
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 60
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @html(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %52
46: ; preds = %41
%47 = load i32, i32* %4
%48 = icmp eq i32 %47, 38
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 @html(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49, %46
br label %52
52: ; preds = %51, %44
br label %53
53: ; preds = %52, %39
%54 = load i8*, i8** %3
%55 = getelementptr inbounds i8, i8* %54, i64 1
store i8* %55, i8** %2
br label %56
56: ; preds = %53, %25
%57 = load i8*, i8** %3
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %3
br label %6
59: ; preds = %14
%60 = load i8*, i8** %3
%61 = load i8*, i8** %2
%62 = icmp ne i8* %60, %61
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = load i8*, i8** %2
%65 = call i32 @html(i8* %64)
br label %66
66: ; preds = %63, %59
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"&gt;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [6 x i8] c"&amp;\00"
define void @html_txt(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %27, label %3
3: ; preds = %1, %20
%4 = phi i8* [ %21, %20 ], [ %0, %1 ]
%5 = phi i8* [ %22, %20 ], [ %0, %1 ]
%6 = load i8, i8* %5
switch i8 %6, label %20 [
i8 0, label %23
i8 62, label %7
i8 60, label %7
i8 38, label %7
]
7: ; preds = %3, %3, %3
%8 = ptrtoint i8* %5 to i64
%9 = ptrtoint i8* %4 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
%12 = tail call i32 @html_raw(i8* %4, i32 %11)
switch i8 %6, label %18 [
i8 62, label %15
i8 60, label %13
i8 38, label %14
]
13: ; preds = %7
br label %15
14: ; preds = %7
br label %15
15: ; preds = %7, %14, %13
%16 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %13 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %14 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %7 ]
%17 = tail call i32 @html(i8* %16)
br label %18
18: ; preds = %15, %7
%19 = getelementptr inbounds i8, i8* %5, i64 1
br label %20
20: ; preds = %3, %18
%21 = phi i8* [ %19, %18 ], [ %4, %3 ]
%22 = getelementptr inbounds i8, i8* %5, i64 1
br label %3
23: ; preds = %3
%24 = icmp eq i8* %5, %4
br i1 %24, label %27, label %25
25: ; preds = %23
%26 = tail call i32 @html(i8* %4)
br label %27
27: ; preds = %1, %25, %23
ret void
}