#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 */
struct html {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ htprintf(struct html *, char *, ...);
void htescape(struct html *ctx, const char *s, int n, int italics) {
  while (n > 0 && *s) {
    unsigned char c = (unsigned char)*s++;
    if (c == '&')
      htprintf(ctx, "&amp;");
    else if (c == '<')
      htprintf(ctx, "&lt;");
    else if (c == '>')
      htprintf(ctx, "&gt;");
    else if (c >= ' ' && c < '\177')
      htprintf(ctx, "%c", c);
    else {
      if (italics)
        htprintf(ctx, "<i>");
      htprintf(ctx, "[%02x]", c);
      if (italics)
        htprintf(ctx, "</i>");
    }
    n--;
  }
}


x86 assembly (clang, -O0):
<htescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x1a(%rbp)
jle    1145 <htescape+0x35>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    1155 <htescape+0x45>
jmp    127a <htescape+0x16a>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x26,%eax
jne    118d <htescape+0x7d>
mov    -0x8(%rbp),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1030 <htprintf@plt>
jmp    126c <htescape+0x15c>
movzbl -0x19(%rbp),%eax
cmp    $0x3c,%eax
jne    11b1 <htescape+0xa1>
mov    -0x8(%rbp),%rdi
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1030 <htprintf@plt>
jmp    1267 <htescape+0x157>
movzbl -0x19(%rbp),%eax
cmp    $0x3e,%eax
jne    11d5 <htescape+0xc5>
mov    -0x8(%rbp),%rdi
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1030 <htprintf@plt>
jmp    1262 <htescape+0x152>
movzbl -0x19(%rbp),%eax
cmp    $0x20,%eax
jl     120a <htescape+0xfa>
movzbl -0x19(%rbp),%eax
cmp    $0x7f,%eax
jge    120a <htescape+0xfa>
mov    -0x8(%rbp),%rdi
movzbl -0x19(%rbp),%edx
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   1030 <htprintf@plt>
jmp    125d <htescape+0x14d>
cmpl   $0x0,-0x18(%rbp)
je     1226 <htescape+0x116>
mov    -0x8(%rbp),%rdi
lea    0xdf4(%rip),%rsi
mov    $0x0,%al
call   1030 <htprintf@plt>
mov    -0x8(%rbp),%rdi
movzbl -0x19(%rbp),%edx
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1030 <htprintf@plt>
cmpl   $0x0,-0x18(%rbp)
je     1258 <htescape+0x148>
mov    -0x8(%rbp),%rdi
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1030 <htprintf@plt>
jmp    125d <htescape+0x14d>
jmp    1262 <htescape+0x152>
jmp    1267 <htescape+0x157>
jmp    126c <htescape+0x15c>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <htescape+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<htescape>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    11f8 <htescape+0xe8>
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r15
add    $0x1,%ebp
lea    0xec8(%rip),%r12
jmp    115d <htescape+0x4d>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <htprintf@plt>
add    $0x1,%rbx
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jle    11f8 <htescape+0xe8>
movzbl (%rbx),%r13d
test   %r13d,%r13d
je     11f8 <htescape+0xe8>
cmp    $0x3e,%r13b
je     1190 <htescape+0x80>
cmp    $0x3c,%r13b
je     11a0 <htescape+0x90>
cmp    $0x26,%r13b
je     1140 <htescape+0x30>
lea    -0x20(%r13),%eax
mov    %r15,%rdi
cmp    $0x5e,%al
ja     11ac <htescape+0x9c>
lea    0xe82(%rip),%rsi
jmp    11e9 <htescape+0xd9>
mov    %r15,%rdi
lea    0xe71(%rip),%rsi
jmp    1146 <htescape+0x36>
nopl   0x0(%rax)
mov    %r15,%rdi
lea    0xe5c(%rip),%rsi
jmp    1146 <htescape+0x36>
test   %r14d,%r14d
je     11e2 <htescape+0xd2>
lea    0xe5b(%rip),%rsi
xor    %eax,%eax
call   1030 <htprintf@plt>
mov    %r15,%rdi
lea    0xe4e(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1030 <htprintf@plt>
mov    %r15,%rdi
lea    0xe41(%rip),%rsi
jmp    1146 <htescape+0x36>
lea    0xe2e(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1030 <htprintf@plt>
jmp    114d <htescape+0x3d>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.html = type { i32 }
@.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 = [3 x i8] c"%c\00"
@.str.4 = [4 x i8] c"<i>\00"
@.str.5 = [7 x i8] c"[%02x]\00"
@.str.6 = [5 x i8] c"</i>\00"
define void @htescape(%struct.html* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca %struct.html*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store %struct.html* %0, %struct.html** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
br label %10
10: ; preds = %77, %4
%11 = load i32, i32* %7
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %13, %10
%19 = phi i1 [ false, %10 ], [ %17, %13 ]
br i1 %19, label %20, label %80
20: ; preds = %18
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %6
%23 = load i8, i8* %21
store i8 %23, i8* %9
%24 = load i8, i8* %9
%25 = zext i8 %24 to i32
%26 = icmp eq i32 %25, 38
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load %struct.html*, %struct.html** %5
%29 = call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %77
30: ; preds = %20
%31 = load i8, i8* %9
%32 = zext i8 %31 to i32
%33 = icmp eq i32 %32, 60
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load %struct.html*, %struct.html** %5
%36 = call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %76
37: ; preds = %30
%38 = load i8, i8* %9
%39 = zext i8 %38 to i32
%40 = icmp eq i32 %39, 62
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load %struct.html*, %struct.html** %5
%43 = call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %75
44: ; preds = %37
%45 = load i8, i8* %9
%46 = zext i8 %45 to i32
%47 = icmp sge i32 %46, 32
br i1 %47, label %48, label %57
48: ; preds = %44
%49 = load i8, i8* %9
%50 = zext i8 %49 to i32
%51 = icmp slt i32 %50, 127
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = load %struct.html*, %struct.html** %5
%54 = load i8, i8* %9
%55 = zext i8 %54 to i32
%56 = call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %55)
br label %74
57: ; preds = %48, %44
%58 = load i32, i32* %8
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load %struct.html*, %struct.html** %5
%62 = call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %63
63: ; preds = %60, %57
%64 = load %struct.html*, %struct.html** %5
%65 = load i8, i8* %9
%66 = zext i8 %65 to i32
%67 = call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %64, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %66)
%68 = load i32, i32* %8
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %63
%71 = load %struct.html*, %struct.html** %5
%72 = call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %73
73: ; preds = %70, %63
br label %74
74: ; preds = %73, %52
br label %75
75: ; preds = %74, %41
br label %76
76: ; preds = %75, %34
br label %77
77: ; preds = %76, %27
%78 = load i32, i32* %7
%79 = add nsw i32 %78, -1
store i32 %79, i32* %7
br label %10
80: ; preds = %18
ret void
}

LLVM IR (-O2):
%struct.html = type { i32 }
@.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 = [3 x i8] c"%c\00"
@.str.4 = [4 x i8] c"<i>\00"
@.str.5 = [7 x i8] c"[%02x]\00"
@.str.6 = [5 x i8] c"</i>\00"
define void @htescape(%struct.html* %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %37
6: ; preds = %4
%7 = icmp eq i32 %3, 0
br label %8
8: ; preds = %6, %34
%9 = phi i8* [ %1, %6 ], [ %14, %34 ]
%10 = phi i32 [ %2, %6 ], [ %35, %34 ]
%11 = load i8, i8* %9
%12 = icmp eq i8 %11, 0
br i1 %12, label %37, label %13
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = zext i8 %11 to i32
switch i8 %11, label %22 [
i8 38, label %16
i8 60, label %18
i8 62, label %20
]
16: ; preds = %13
%17 = tail call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %34
18: ; preds = %13
%19 = tail call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %34
20: ; preds = %13
%21 = tail call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %34
22: ; preds = %13
%23 = add i8 %11, -32
%24 = icmp ult i8 %23, 95
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %34
27: ; preds = %22
br i1 %7, label %32, label %28
28: ; preds = %27
%29 = tail call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%30 = tail call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%31 = tail call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %34
32: ; preds = %27
%33 = tail call i32 (%struct.html*, i8*, ...) @htprintf(%struct.html* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %15)
br label %34
34: ; preds = %32, %18, %25, %28, %20, %16
%35 = add nsw i32 %10, -1
%36 = icmp sgt i32 %10, 1
br i1 %36, label %8, label %37
37: ; preds = %8, %34, %4
ret void
}