#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*/ printf(char *);
int /*<<< orphan*/ putchar(char);
void print_escaped(char *string, bool attribute) {
  while (*string != '\0') {
    if (*string == '&') {
      printf("&amp;");
    } else if (*string == '<') {
      printf("&lt;");
    } else if (*string == '>') {
      printf("&gt;");
    } else if (*string == '\r') {
      printf("&#xD;");
    } else if (attribute && *string == '\t') {
      printf("&#x9;");
    } else if (attribute && *string == '\n') {
      printf("&#xA;");
    } else {
      putchar(*string);
    }
    string++;
  }
}


x86 assembly (clang, -O0):
<print_escaped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     124f <print_escaped+0x12f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
jne    1160 <print_escaped+0x40>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
jmp    123e <print_escaped+0x11e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    1181 <print_escaped+0x61>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
jmp    1239 <print_escaped+0x119>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3e,%eax
jne    11a2 <print_escaped+0x82>
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
jmp    1234 <print_escaped+0x114>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    11c3 <print_escaped+0xa3>
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
jmp    122f <print_escaped+0x10f>
cmpl   $0x0,-0xc(%rbp)
je     11ee <print_escaped+0xce>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    11ee <print_escaped+0xce>
lea    0xe32(%rip),%rdi
call   1040 <printf@plt>
jmp    122a <print_escaped+0x10a>
cmpl   $0x0,-0xc(%rbp)
je     1219 <print_escaped+0xf9>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1219 <print_escaped+0xf9>
lea    0xe0d(%rip),%rdi
call   1040 <printf@plt>
jmp    1225 <print_escaped+0x105>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
jmp    122a <print_escaped+0x10a>
jmp    122f <print_escaped+0x10f>
jmp    1234 <print_escaped+0x114>
jmp    1239 <print_escaped+0x119>
jmp    123e <print_escaped+0x11e>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112f <print_escaped+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_escaped>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xed9(%rip),%r14
lea    0xec2(%rip),%r15
lea    0xec1(%rip),%r13
lea    0xebf(%rip),%r12
jmp    115a <print_escaped+0x3a>
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x3b,%al
jg     1170 <print_escaped+0x50>
cmp    $0xd,%al
je     114e <print_escaped+0x2e>
cmp    $0x26,%al
jne    1182 <print_escaped+0x62>
mov    %r15,%rdi
jmp    1151 <print_escaped+0x31>
xchg   %ax,%ax
cmp    $0x3c,%al
je     117d <print_escaped+0x5d>
cmp    $0x3e,%al
jne    1186 <print_escaped+0x66>
mov    %r12,%rdi
jmp    1151 <print_escaped+0x31>
mov    %r13,%rdi
jmp    1151 <print_escaped+0x31>
test   %al,%al
je     11b6 <print_escaped+0x96>
test   %ebp,%ebp
je     1197 <print_escaped+0x77>
cmp    $0x9,%al
jne    1197 <print_escaped+0x77>
lea    0xe81(%rip),%rdi
jmp    1151 <print_escaped+0x31>
test   %ebp,%ebp
je     11a8 <print_escaped+0x88>
cmp    $0xa,%al
jne    11a8 <print_escaped+0x88>
lea    0xe76(%rip),%rdi
jmp    1151 <print_escaped+0x31>
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
jmp    115a <print_escaped+0x3a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.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 = [6 x i8] c"&#xD;\00"
@.str.4 = [6 x i8] c"&#x9;\00"
@.str.5 = [6 x i8] c"&#xA;\00"
define void @print_escaped(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %67, %2
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %70
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 38
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %67
17: ; preds = %10
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 60
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %66
24: ; preds = %17
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 62
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %65
31: ; preds = %24
%32 = load i8*, i8** %3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 13
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %64
38: ; preds = %31
%39 = load i32, i32* %4
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i8*, i8** %3
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 9
br i1 %45, label %46, label %48
46: ; preds = %41
%47 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %63
48: ; preds = %41, %38
%49 = load i32, i32* %4
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = load i8*, i8** %3
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 10
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %62
58: ; preds = %51, %48
%59 = load i8*, i8** %3
%60 = load i8, i8* %59
%61 = call i32 @putchar(i8 signext %60)
br label %62
62: ; preds = %58, %56
br label %63
63: ; preds = %62, %46
br label %64
64: ; preds = %63, %36
br label %65
65: ; preds = %64, %29
br label %66
66: ; preds = %65, %22
br label %67
67: ; preds = %66, %15
%68 = load i8*, i8** %3
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %3
br label %5
70: ; preds = %5
ret void
}

LLVM IR (-O2):
@.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 = [6 x i8] c"&#xD;\00"
@.str.4 = [6 x i8] c"&#x9;\00"
@.str.5 = [6 x i8] c"&#xA;\00"
define void @print_escaped(i8* nocapture %0, i32 %1) {
%3 = icmp ne i32 %1, 0
br label %4
4: ; preds = %27, %2
%5 = phi i8* [ %0, %2 ], [ %28, %27 ]
%6 = load i8, i8* %5
switch i8 %6, label %15 [
i8 0, label %29
i8 38, label %7
i8 60, label %9
i8 62, label %11
i8 13, label %13
]
7: ; preds = %4
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %27
9: ; preds = %4
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %27
11: ; preds = %4
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %27
13: ; preds = %4
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %27
15: ; preds = %4
%16 = icmp eq i8 %6, 9
%17 = select i1 %3, i1 %16, i1 false
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %27
20: ; preds = %15
%21 = icmp eq i8 %6, 10
%22 = select i1 %3, i1 %21, i1 false
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %27
25: ; preds = %20
%26 = tail call i32 @putchar(i8 signext %6)
br label %27
27: ; preds = %9, %13, %23, %25, %18, %11, %7
%28 = getelementptr inbounds i8, i8* %5, i64 1
br label %4
29: ; preds = %4
ret void
}