#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*/ PutLitChar(char);
int /*<<< orphan*/ PutLitStr(char *);
void PutEscapedLitStr(char *s) {
  int i = 0;
  while (s[i]) {
    switch (s[i]) {
    case '_':
      PutLitStr("\\_");
      break;
    case '%':
      PutLitStr("\\%");
      break;
    case '\\':
      PutLitStr("\\textbackslash{}");
      break;
    default:
      PutLitChar(s[i]);
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<PutEscapedLitStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11d6 <PutEscapedLitStr+0xb6>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x10(%rbp)
sub    $0x25,%eax
je     1195 <PutEscapedLitStr+0x75>
jmp    1162 <PutEscapedLitStr+0x42>
mov    -0x10(%rbp),%eax
sub    $0x5c,%eax
je     11a6 <PutEscapedLitStr+0x86>
jmp    1173 <PutEscapedLitStr+0x53>
mov    -0x10(%rbp),%eax
sub    $0x5f,%eax
jne    11b7 <PutEscapedLitStr+0x97>
jmp    1184 <PutEscapedLitStr+0x64>
lea    0xe75(%rip),%rdi
call   1030 <PutLitStr@plt>
jmp    11c8 <PutEscapedLitStr+0xa8>
lea    0xe67(%rip),%rdi
call   1030 <PutLitStr@plt>
jmp    11c8 <PutEscapedLitStr+0xa8>
lea    0xe59(%rip),%rdi
call   1030 <PutLitStr@plt>
jmp    11c8 <PutEscapedLitStr+0xa8>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <PutLitChar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <PutEscapedLitStr+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PutEscapedLitStr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1197 <PutEscapedLitStr+0x77>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xec7(%rip),%r14
lea    0xec3(%rip),%r15
lea    0xeb6(%rip),%r12
jmp    1163 <PutEscapedLitStr+0x43>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <PutLitStr@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1197 <PutEscapedLitStr+0x77>
movsbl %al,%edi
cmp    $0x25,%edi
je     1180 <PutEscapedLitStr+0x60>
cmp    $0x5c,%edi
je     1150 <PutEscapedLitStr+0x30>
cmp    $0x5f,%edi
jne    1190 <PutEscapedLitStr+0x70>
mov    %r12,%rdi
jmp    1153 <PutEscapedLitStr+0x33>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
jmp    1153 <PutEscapedLitStr+0x33>
cs nopw 0x0(%rax,%rax,1)
nop
call   1040 <PutLitChar@plt>
jmp    1158 <PutEscapedLitStr+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\\_\00"
@.str.1 = [3 x i8] c"\\%\00"
@.str.2 = [17 x i8] c"\\textbackslash{}\00"
define void @PutEscapedLitStr(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %31, %1
%5 = load i8*, i8** %2
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %34
11: ; preds = %4
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %24 [
i32 95, label %18
i32 37, label %20
i32 92, label %22
]
18: ; preds = %11
%19 = call i32 @PutLitStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %31
20: ; preds = %11
%21 = call i32 @PutLitStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %31
22: ; preds = %11
%23 = call i32 @PutLitStr(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %31
24: ; preds = %11
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @PutLitChar(i8 signext %29)
br label %31
31: ; preds = %24, %22, %20, %18
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %4
34: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\_\00"
@.str.1 = [3 x i8] c"\\%\00"
@.str.2 = [17 x i8] c"\\textbackslash{}\00"
define void @PutEscapedLitStr(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %21, label %4
4: ; preds = %1, %16
%5 = phi i64 [ %17, %16 ], [ 0, %1 ]
%6 = phi i8 [ %19, %16 ], [ %2, %1 ]
%7 = sext i8 %6 to i32
switch i32 %7, label %14 [
i32 95, label %8
i32 37, label %10
i32 92, label %12
]
8: ; preds = %4
%9 = tail call i32 @PutLitStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %16
10: ; preds = %4
%11 = tail call i32 @PutLitStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %16
12: ; preds = %4
%13 = tail call i32 @PutLitStr(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %16
14: ; preds = %4
%15 = tail call i32 @PutLitChar(i8 signext %6)
br label %16
16: ; preds = %14, %12, %10, %8
%17 = add nuw i64 %5, 1
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %4
21: ; preds = %16, %1
ret void
}