#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 buf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bufput(struct buf *, char *, int);
void latex_text_escape(struct buf *ob, char *src, size_t size) {
  size_t i = 0, org;
  while (i < size) {
    org = i;
    while (i < size && src[i] != '&' && src[i] != '%' && src[i] != '$' &&
           src[i] != '#' && src[i] != '_' && src[i] != '{' && src[i] != '}' &&
           src[i] != '~' && src[i] != '^' && src[i] != '\\' && src[i] != '<' &&
           src[i] != '>')
      i += 1;
    if (i > org)
      bufput(ob, src + org, i - org);
    if (i >= size)
      break;
    else if (src[i] == '&')
      bufput(ob, "\\&", sizeof "\\&" - 1);
    else if (src[i] == '%')
      bufput(ob, "\\%", sizeof "\\%" - 1);
    else if (src[i] == '$')
      bufput(ob, "\\$", sizeof "\\$" - 1);
    else if (src[i] == '#')
      bufput(ob, "\\#", sizeof "\\#" - 1);
    else if (src[i] == '_')
      bufput(ob, "\\_", sizeof "\\_" - 1);
    else if (src[i] == '{')
      bufput(ob, "\\{", sizeof "\\{" - 1);
    else if (src[i] == '}')
      bufput(ob, "\\}", sizeof "\\}" - 1);
    else if (src[i] == '<')
      bufput(ob, "$<$", sizeof "$<$" - 1);
    else if (src[i] == '>')
      bufput(ob, "$<$", sizeof "$<$" - 1);
    else if (src[i] == '~')
      bufput(ob, "\\textasciitilde{}", sizeof "\\textasciitilde{}" - 1);
    else if (src[i] == '^')
      bufput(ob, "\\textasciicircum{}", sizeof "\\textasciicircum{}" - 1);
    else if (src[i] == '\\')
      bufput(ob, "\\textbackslash{}", sizeof "\\textbackslash{}" - 1);
    i += 1;
  }
}


x86 assembly (clang, -O0):
<latex_text_escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1561 <latex_text_escape+0x451>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x29(%rbp)
jae    1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x26,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x25,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x24,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x23,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x5f,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x7b,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x7d,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x7e,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x5e,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x5c,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x3c,%ecx
mov    %al,-0x29(%rbp)
je     1288 <latex_text_escape+0x178>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3e,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1298 <latex_text_escape+0x188>
jmp    12a9 <latex_text_escape+0x199>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1142 <latex_text_escape+0x32>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jbe    12d2 <latex_text_escape+0x1c2>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
call   1030 <bufput@plt>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jb     12e5 <latex_text_escape+0x1d5>
jmp    1561 <latex_text_escape+0x451>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x26,%eax
jne    1314 <latex_text_escape+0x204>
mov    -0x8(%rbp),%rdi
lea    0xcfb(%rip),%rsi
mov    $0x2,%edx
call   1030 <bufput@plt>
jmp    154b <latex_text_escape+0x43b>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x25,%eax
jne    1343 <latex_text_escape+0x233>
mov    -0x8(%rbp),%rdi
lea    0xccf(%rip),%rsi
mov    $0x2,%edx
call   1030 <bufput@plt>
jmp    1546 <latex_text_escape+0x436>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x24,%eax
jne    1372 <latex_text_escape+0x262>
mov    -0x8(%rbp),%rdi
lea    0xca3(%rip),%rsi
mov    $0x2,%edx
call   1030 <bufput@plt>
jmp    1541 <latex_text_escape+0x431>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
jne    13a1 <latex_text_escape+0x291>
mov    -0x8(%rbp),%rdi
lea    0xc77(%rip),%rsi
mov    $0x2,%edx
call   1030 <bufput@plt>
jmp    153c <latex_text_escape+0x42c>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
jne    13d0 <latex_text_escape+0x2c0>
mov    -0x8(%rbp),%rdi
lea    0xc4b(%rip),%rsi
mov    $0x2,%edx
call   1030 <bufput@plt>
jmp    1537 <latex_text_escape+0x427>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7b,%eax
jne    13ff <latex_text_escape+0x2ef>
mov    -0x8(%rbp),%rdi
lea    0xc1f(%rip),%rsi
mov    $0x2,%edx
call   1030 <bufput@plt>
jmp    1532 <latex_text_escape+0x422>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7d,%eax
jne    142e <latex_text_escape+0x31e>
mov    -0x8(%rbp),%rdi
lea    0xbf3(%rip),%rsi
mov    $0x2,%edx
call   1030 <bufput@plt>
jmp    152d <latex_text_escape+0x41d>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3c,%eax
jne    145d <latex_text_escape+0x34d>
mov    -0x8(%rbp),%rdi
lea    0xbc7(%rip),%rsi
mov    $0x3,%edx
call   1030 <bufput@plt>
jmp    1528 <latex_text_escape+0x418>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3e,%eax
jne    148c <latex_text_escape+0x37c>
mov    -0x8(%rbp),%rdi
lea    0xb98(%rip),%rsi
mov    $0x3,%edx
call   1030 <bufput@plt>
jmp    1523 <latex_text_escape+0x413>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jne    14bb <latex_text_escape+0x3ab>
mov    -0x8(%rbp),%rdi
lea    0xb6d(%rip),%rsi
mov    $0x11,%edx
call   1030 <bufput@plt>
jmp    151e <latex_text_escape+0x40e>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5e,%eax
jne    14ea <latex_text_escape+0x3da>
mov    -0x8(%rbp),%rdi
lea    0xb50(%rip),%rsi
mov    $0x12,%edx
call   1030 <bufput@plt>
jmp    1519 <latex_text_escape+0x409>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    1514 <latex_text_escape+0x404>
mov    -0x8(%rbp),%rdi
lea    0xb34(%rip),%rsi
mov    $0x10,%edx
call   1030 <bufput@plt>
jmp    1519 <latex_text_escape+0x409>
jmp    151e <latex_text_escape+0x40e>
jmp    1523 <latex_text_escape+0x413>
jmp    1528 <latex_text_escape+0x418>
jmp    152d <latex_text_escape+0x41d>
jmp    1532 <latex_text_escape+0x422>
jmp    1537 <latex_text_escape+0x427>
jmp    153c <latex_text_escape+0x42c>
jmp    1541 <latex_text_escape+0x431>
jmp    1546 <latex_text_escape+0x436>
jmp    154b <latex_text_escape+0x43b>
jmp    1550 <latex_text_escape+0x440>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <latex_text_escape+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<latex_text_escape>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     12b5 <latex_text_escape+0x1a5>
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %eax,%eax
lea    0xeca(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
cmp    %r13,%rax
jae    12b5 <latex_text_escape+0x1a5>
mov    $0x1,%bpl
mov    %rax,%r14
jmp    116d <latex_text_escape+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r13,%r14
setb   %bpl
je     11db <latex_text_escape+0xcb>
movzbl (%rbx,%r14,1),%ecx
add    $0xdd,%cl
cmp    $0x5b,%cl
ja     1160 <latex_text_escape+0x50>
movzbl %cl,%ecx
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
cmp    %rax,%r14
jbe    119c <latex_text_escape+0x8c>
lea    (%rbx,%rax,1),%rsi
mov    %r14d,%edx
sub    %eax,%edx
mov    %r15,%rdi
call   1030 <bufput@plt>
test   $0x1,%bpl
je     12b5 <latex_text_escape+0x1a5>
mov    (%rbx,%r14,1),%al
add    $0xdd,%al
cmp    $0x5b,%al
ja     12a5 <latex_text_escape+0x195>
movzbl %al,%eax
lea    0xfb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r15,%rdi
lea    0x1124(%rip),%rsi
mov    $0x3,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r13,%r14
cmp    %rax,%r14
ja     118b <latex_text_escape+0x7b>
jmp    119c <latex_text_escape+0x8c>
mov    %r15,%rdi
lea    0x10fa(%rip),%rsi
mov    $0x2,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r15,%rdi
lea    0x10e3(%rip),%rsi
mov    $0x2,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r15,%rdi
lea    0x10cc(%rip),%rsi
mov    $0x2,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r15,%rdi
lea    0x10b5(%rip),%rsi
mov    $0x2,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r15,%rdi
lea    0x10e2(%rip),%rsi
mov    $0x10,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r15,%rdi
lea    0x10be(%rip),%rsi
mov    $0x12,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r15,%rdi
lea    0x108e(%rip),%rsi
mov    $0x2,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r15,%rdi
lea    0x1080(%rip),%rsi
mov    $0x2,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r15,%rdi
lea    0x1072(%rip),%rsi
mov    $0x2,%edx
jmp    12a0 <latex_text_escape+0x190>
mov    %r15,%rdi
lea    0x1068(%rip),%rsi
mov    $0x11,%edx
cs nopw 0x0(%rax,%rax,1)
call   1030 <bufput@plt>
add    $0x1,%r14
mov    %r14,%rax
cmp    %r13,%r14
jb     1140 <latex_text_escape+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.buf = type { i32 }
@.str = [3 x i8] c"\\&\00"
@.str.1 = [3 x i8] c"\\%\00"
@.str.2 = [3 x i8] c"\\$\00"
@.str.3 = [3 x i8] c"\\#\00"
@.str.4 = [3 x i8] c"\\_\00"
@.str.5 = [3 x i8] c"\\{\00"
@.str.6 = [3 x i8] c"\\}\00"
@.str.7 = [4 x i8] c"$<$\00"
@.str.8 = [18 x i8] c"\\textasciitilde{}\00"
@.str.9 = [19 x i8] c"\\textasciicircum{}\00"
@.str.10 = [17 x i8] c"\\textbackslash{}\00"
define void @latex_text_escape(%struct.buf* %0, i8* %1, i64 %2) {
%4 = alloca %struct.buf*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store %struct.buf* %0, %struct.buf** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %9
9: ; preds = %259, %3
%10 = load i64, i64* %7
%11 = load i64, i64* %6
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %262
13: ; preds = %9
%14 = load i64, i64* %7
store i64 %14, i64* %8
br label %15
15: ; preds = %105, %13
%16 = load i64, i64* %7
%17 = load i64, i64* %6
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %103
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = load i64, i64* %7
%22 = getelementptr inbounds i8, i8* %20, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 38
br i1 %25, label %26, label %103
26: ; preds = %19
%27 = load i8*, i8** %5
%28 = load i64, i64* %7
%29 = getelementptr inbounds i8, i8* %27, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 37
br i1 %32, label %33, label %103
33: ; preds = %26
%34 = load i8*, i8** %5
%35 = load i64, i64* %7
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 36
br i1 %39, label %40, label %103
40: ; preds = %33
%41 = load i8*, i8** %5
%42 = load i64, i64* %7
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 35
br i1 %46, label %47, label %103
47: ; preds = %40
%48 = load i8*, i8** %5
%49 = load i64, i64* %7
%50 = getelementptr inbounds i8, i8* %48, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 95
br i1 %53, label %54, label %103
54: ; preds = %47
%55 = load i8*, i8** %5
%56 = load i64, i64* %7
%57 = getelementptr inbounds i8, i8* %55, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 123
br i1 %60, label %61, label %103
61: ; preds = %54
%62 = load i8*, i8** %5
%63 = load i64, i64* %7
%64 = getelementptr inbounds i8, i8* %62, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp ne i32 %66, 125
br i1 %67, label %68, label %103
68: ; preds = %61
%69 = load i8*, i8** %5
%70 = load i64, i64* %7
%71 = getelementptr inbounds i8, i8* %69, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp ne i32 %73, 126
br i1 %74, label %75, label %103
75: ; preds = %68
%76 = load i8*, i8** %5
%77 = load i64, i64* %7
%78 = getelementptr inbounds i8, i8* %76, i64 %77
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp ne i32 %80, 94
br i1 %81, label %82, label %103
82: ; preds = %75
%83 = load i8*, i8** %5
%84 = load i64, i64* %7
%85 = getelementptr inbounds i8, i8* %83, i64 %84
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp ne i32 %87, 92
br i1 %88, label %89, label %103
89: ; preds = %82
%90 = load i8*, i8** %5
%91 = load i64, i64* %7
%92 = getelementptr inbounds i8, i8* %90, i64 %91
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp ne i32 %94, 60
br i1 %95, label %96, label %103
96: ; preds = %89
%97 = load i8*, i8** %5
%98 = load i64, i64* %7
%99 = getelementptr inbounds i8, i8* %97, i64 %98
%100 = load i8, i8* %99
%101 = sext i8 %100 to i32
%102 = icmp ne i32 %101, 62
br label %103
103: ; preds = %96, %89, %82, %75, %68, %61, %54, %47, %40, %33, %26, %19, %15
%104 = phi i1 [ false, %89 ], [ false, %82 ], [ false, %75 ], [ false, %68 ], [ false, %61 ], [ false, %54 ], [ false, %47 ], [ false, %40 ], [ false, %33 ], [ false, %26 ], [ false, %19 ], [ false, %15 ], [ %102, %96 ]
br i1 %104, label %105, label %108
105: ; preds = %103
%106 = load i64, i64* %7
%107 = add i64 %106, 1
store i64 %107, i64* %7
br label %15
108: ; preds = %103
%109 = load i64, i64* %7
%110 = load i64, i64* %8
%111 = icmp ugt i64 %109, %110
br i1 %111, label %112, label %122
112: ; preds = %108
%113 = load %struct.buf*, %struct.buf** %4
%114 = load i8*, i8** %5
%115 = load i64, i64* %8
%116 = getelementptr inbounds i8, i8* %114, i64 %115
%117 = load i64, i64* %7
%118 = load i64, i64* %8
%119 = sub i64 %117, %118
%120 = trunc i64 %119 to i32
%121 = call i32 @bufput(%struct.buf* %113, i8* %116, i32 %120)
br label %122
122: ; preds = %112, %108
%123 = load i64, i64* %7
%124 = load i64, i64* %6
%125 = icmp uge i64 %123, %124
br i1 %125, label %126, label %127
126: ; preds = %122
br label %262
127: ; preds = %122
%128 = load i8*, i8** %5
%129 = load i64, i64* %7
%130 = getelementptr inbounds i8, i8* %128, i64 %129
%131 = load i8, i8* %130
%132 = sext i8 %131 to i32
%133 = icmp eq i32 %132, 38
br i1 %133, label %134, label %137
134: ; preds = %127
%135 = load %struct.buf*, %struct.buf** %4
%136 = call i32 @bufput(%struct.buf* %135, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %258
137: ; preds = %127
%138 = load i8*, i8** %5
%139 = load i64, i64* %7
%140 = getelementptr inbounds i8, i8* %138, i64 %139
%141 = load i8, i8* %140
%142 = sext i8 %141 to i32
%143 = icmp eq i32 %142, 37
br i1 %143, label %144, label %147
144: ; preds = %137
%145 = load %struct.buf*, %struct.buf** %4
%146 = call i32 @bufput(%struct.buf* %145, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %257
147: ; preds = %137
%148 = load i8*, i8** %5
%149 = load i64, i64* %7
%150 = getelementptr inbounds i8, i8* %148, i64 %149
%151 = load i8, i8* %150
%152 = sext i8 %151 to i32
%153 = icmp eq i32 %152, 36
br i1 %153, label %154, label %157
154: ; preds = %147
%155 = load %struct.buf*, %struct.buf** %4
%156 = call i32 @bufput(%struct.buf* %155, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
br label %256
157: ; preds = %147
%158 = load i8*, i8** %5
%159 = load i64, i64* %7
%160 = getelementptr inbounds i8, i8* %158, i64 %159
%161 = load i8, i8* %160
%162 = sext i8 %161 to i32
%163 = icmp eq i32 %162, 35
br i1 %163, label %164, label %167
164: ; preds = %157
%165 = load %struct.buf*, %struct.buf** %4
%166 = call i32 @bufput(%struct.buf* %165, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
br label %255
167: ; preds = %157
%168 = load i8*, i8** %5
%169 = load i64, i64* %7
%170 = getelementptr inbounds i8, i8* %168, i64 %169
%171 = load i8, i8* %170
%172 = sext i8 %171 to i32
%173 = icmp eq i32 %172, 95
br i1 %173, label %174, label %177
174: ; preds = %167
%175 = load %struct.buf*, %struct.buf** %4
%176 = call i32 @bufput(%struct.buf* %175, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
br label %254
177: ; preds = %167
%178 = load i8*, i8** %5
%179 = load i64, i64* %7
%180 = getelementptr inbounds i8, i8* %178, i64 %179
%181 = load i8, i8* %180
%182 = sext i8 %181 to i32
%183 = icmp eq i32 %182, 123
br i1 %183, label %184, label %187
184: ; preds = %177
%185 = load %struct.buf*, %struct.buf** %4
%186 = call i32 @bufput(%struct.buf* %185, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
br label %253
187: ; preds = %177
%188 = load i8*, i8** %5
%189 = load i64, i64* %7
%190 = getelementptr inbounds i8, i8* %188, i64 %189
%191 = load i8, i8* %190
%192 = sext i8 %191 to i32
%193 = icmp eq i32 %192, 125
br i1 %193, label %194, label %197
194: ; preds = %187
%195 = load %struct.buf*, %struct.buf** %4
%196 = call i32 @bufput(%struct.buf* %195, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 2)
br label %252
197: ; preds = %187
%198 = load i8*, i8** %5
%199 = load i64, i64* %7
%200 = getelementptr inbounds i8, i8* %198, i64 %199
%201 = load i8, i8* %200
%202 = sext i8 %201 to i32
%203 = icmp eq i32 %202, 60
br i1 %203, label %204, label %207
204: ; preds = %197
%205 = load %struct.buf*, %struct.buf** %4
%206 = call i32 @bufput(%struct.buf* %205, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
br label %251
207: ; preds = %197
%208 = load i8*, i8** %5
%209 = load i64, i64* %7
%210 = getelementptr inbounds i8, i8* %208, i64 %209
%211 = load i8, i8* %210
%212 = sext i8 %211 to i32
%213 = icmp eq i32 %212, 62
br i1 %213, label %214, label %217
214: ; preds = %207
%215 = load %struct.buf*, %struct.buf** %4
%216 = call i32 @bufput(%struct.buf* %215, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
br label %250
217: ; preds = %207
%218 = load i8*, i8** %5
%219 = load i64, i64* %7
%220 = getelementptr inbounds i8, i8* %218, i64 %219
%221 = load i8, i8* %220
%222 = sext i8 %221 to i32
%223 = icmp eq i32 %222, 126
br i1 %223, label %224, label %227
224: ; preds = %217
%225 = load %struct.buf*, %struct.buf** %4
%226 = call i32 @bufput(%struct.buf* %225, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 17)
br label %249
227: ; preds = %217
%228 = load i8*, i8** %5
%229 = load i64, i64* %7
%230 = getelementptr inbounds i8, i8* %228, i64 %229
%231 = load i8, i8* %230
%232 = sext i8 %231 to i32
%233 = icmp eq i32 %232, 94
br i1 %233, label %234, label %237
234: ; preds = %227
%235 = load %struct.buf*, %struct.buf** %4
%236 = call i32 @bufput(%struct.buf* %235, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 18)
br label %248
237: ; preds = %227
%238 = load i8*, i8** %5
%239 = load i64, i64* %7
%240 = getelementptr inbounds i8, i8* %238, i64 %239
%241 = load i8, i8* %240
%242 = sext i8 %241 to i32
%243 = icmp eq i32 %242, 92
br i1 %243, label %244, label %247
244: ; preds = %237
%245 = load %struct.buf*, %struct.buf** %4
%246 = call i32 @bufput(%struct.buf* %245, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i32 16)
br label %247
247: ; preds = %244, %237
br label %248
248: ; preds = %247, %234
br label %249
249: ; preds = %248, %224
br label %250
250: ; preds = %249, %214
br label %251
251: ; preds = %250, %204
br label %252
252: ; preds = %251, %194
br label %253
253: ; preds = %252, %184
br label %254
254: ; preds = %253, %174
br label %255
255: ; preds = %254, %164
br label %256
256: ; preds = %255, %154
br label %257
257: ; preds = %256, %144
br label %258
258: ; preds = %257, %134
br label %259
259: ; preds = %258
%260 = load i64, i64* %7
%261 = add i64 %260, 1
store i64 %261, i64* %7
br label %9
262: ; preds = %126, %9
ret void
}

LLVM IR (-O2):
%struct.buf = type { i32 }
@.str = [3 x i8] c"\\&\00"
@.str.1 = [3 x i8] c"\\%\00"
@.str.2 = [3 x i8] c"\\$\00"
@.str.3 = [3 x i8] c"\\#\00"
@.str.4 = [3 x i8] c"\\_\00"
@.str.5 = [3 x i8] c"\\{\00"
@.str.6 = [3 x i8] c"\\}\00"
@.str.7 = [4 x i8] c"$<$\00"
@.str.8 = [18 x i8] c"\\textasciitilde{}\00"
@.str.9 = [19 x i8] c"\\textasciicircum{}\00"
@.str.10 = [17 x i8] c"\\textbackslash{}\00"
define void @latex_text_escape(%struct.buf* %0, i8* %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %57, label %5
5: ; preds = %3, %54
%6 = phi i64 [ %55, %54 ], [ 0, %3 ]
%7 = icmp ult i64 %6, %2
br i1 %7, label %8, label %57
8: ; preds = %5, %13
%9 = phi i1 [ %15, %13 ], [ true, %5 ]
%10 = phi i64 [ %14, %13 ], [ %6, %5 ]
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 38, label %17
i8 37, label %17
i8 36, label %17
i8 35, label %17
i8 95, label %17
i8 123, label %17
i8 125, label %17
i8 126, label %17
i8 94, label %17
i8 92, label %17
i8 60, label %17
i8 62, label %17
]
13: ; preds = %8
%14 = add nuw i64 %10, 1
%15 = icmp ult i64 %14, %2
%16 = icmp eq i64 %14, %2
br i1 %16, label %17, label %8
17: ; preds = %13, %8, %8, %8, %8, %8, %8, %8, %8, %8, %8, %8, %8
%18 = phi i64 [ %2, %13 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ], [ %10, %8 ]
%19 = phi i1 [ %15, %13 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ], [ %9, %8 ]
%20 = icmp ugt i64 %18, %6
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = getelementptr inbounds i8, i8* %1, i64 %6
%23 = sub i64 %18, %6
%24 = trunc i64 %23 to i32
%25 = tail call i32 @bufput(%struct.buf* %0, i8* %22, i32 %24)
br i1 %19, label %27, label %57
26: ; preds = %17
br i1 %19, label %27, label %57
27: ; preds = %21, %26
%28 = getelementptr inbounds i8, i8* %1, i64 %18
%29 = load i8, i8* %28
switch i8 %29, label %54 [
i8 38, label %30
i8 37, label %32
i8 36, label %34
i8 35, label %36
i8 95, label %38
i8 123, label %40
i8 125, label %42
i8 60, label %44
i8 62, label %46
i8 126, label %48
i8 94, label %50
i8 92, label %52
]
30: ; preds = %27
%31 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %54
32: ; preds = %27
%33 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %54
34: ; preds = %27
%35 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
br label %54
36: ; preds = %27
%37 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
br label %54
38: ; preds = %27
%39 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
br label %54
40: ; preds = %27
%41 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
br label %54
42: ; preds = %27
%43 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 2)
br label %54
44: ; preds = %27
%45 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
br label %54
46: ; preds = %27
%47 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
br label %54
48: ; preds = %27
%49 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 17)
br label %54
50: ; preds = %27
%51 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 18)
br label %54
52: ; preds = %27
%53 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i32 16)
br label %54
54: ; preds = %27, %30, %34, %38, %42, %46, %50, %52, %48, %44, %40, %36, %32
%55 = add nuw i64 %18, 1
%56 = icmp ult i64 %55, %2
br i1 %56, label %5, label %57
57: ; preds = %5, %54, %26, %21, %3
ret void
}