#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fputc(char const, int /*<<< orphan*/ *);
void escape(char const *str, size_t n, FILE *fp) {
  size_t i;
  for (i = 0; i < n; i++) {
    switch (str[i]) {
    case '\\':
      (void)fprintf(fp, "\\\\");
      break;
    case '\a':
      (void)fprintf(fp, "\\a");
      break;
    case '\b':
      (void)fprintf(fp, "\\b");
      break;
    case '\f':
      (void)fprintf(fp, "\\f");
      break;
    case '\n':
      (void)fprintf(fp, "\\n");
      break;
    case '\r':
      (void)fprintf(fp, "\\r");
      break;
    case '\t':
      (void)fprintf(fp, "\\t");
      break;
    case '\v':
      (void)fprintf(fp, "\\v");
      break;
    case '"':
      (void)fprintf(fp, "\\\"");
      break;
    default:
      (void)fputc(str[i], fp);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<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    -0x10(%rbp),%rax
jae    1266 <escape+0x146>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xfffffff9,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x55,%eax
ja     1239 <escape+0x119>
mov    -0x28(%rbp),%rax
lea    0xe8d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
lea    0xfd1(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1250 <escape+0x130>
mov    -0x18(%rbp),%rdi
lea    0xfbf(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1250 <escape+0x130>
mov    -0x18(%rbp),%rdi
lea    0xfad(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1250 <escape+0x130>
mov    -0x18(%rbp),%rdi
lea    0xf9b(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1250 <escape+0x130>
mov    -0x18(%rbp),%rdi
lea    0xf89(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1250 <escape+0x130>
mov    -0x18(%rbp),%rdi
lea    0xf77(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1250 <escape+0x130>
mov    -0x18(%rbp),%rdi
lea    0xf65(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1250 <escape+0x130>
mov    -0x18(%rbp),%rdi
lea    0xf53(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1250 <escape+0x130>
mov    -0x18(%rbp),%rdi
lea    0xf41(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1250 <escape+0x130>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    1255 <escape+0x135>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113c <escape+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escape>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1244 <escape+0x124>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %r12d,%r12d
lea    0xeb9(%rip),%r13
lea    0x100a(%rip),%rbp
jmp    1175 <escape+0x55>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
nopl   (%rax)
mov    %r14,%rcx
call   1040 <fwrite@plt>
add    $0x1,%r12
cmp    %r12,%rbx
je     1244 <escape+0x124>
movsbl (%r15,%r12,1),%eax
lea    -0x7(%rax),%ecx
cmp    $0x55,%ecx
ja     121e <escape+0xfe>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xfba(%rip),%rdi
jmp    1160 <escape+0x40>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xfaa(%rip),%rdi
jmp    1160 <escape+0x40>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xfa3(%rip),%rdi
jmp    1160 <escape+0x40>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf8a(%rip),%rdi
jmp    1160 <escape+0x40>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf80(%rip),%rdi
jmp    1160 <escape+0x40>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf5e(%rip),%rdi
jmp    1160 <escape+0x40>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf4e(%rip),%rdi
jmp    1160 <escape+0x40>
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
jmp    1168 <escape+0x48>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf31(%rip),%rdi
jmp    1160 <escape+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\\\\\00"
@.str.1 = [3 x i8] c"\\a\00"
@.str.2 = [3 x i8] c"\\b\00"
@.str.3 = [3 x i8] c"\\f\00"
@.str.4 = [3 x i8] c"\\n\00"
@.str.5 = [3 x i8] c"\\r\00"
@.str.6 = [3 x i8] c"\\t\00"
@.str.7 = [3 x i8] c"\\v\00"
@.str.8 = [3 x i8] c"\\\22\00"
define void @escape(i8* %0, i64 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32* %2, i32** %6
store i64 0, i64* %7
br label %8
8: ; preds = %53, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %5
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %56
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i64, i64* %7
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %45 [
i32 92, label %18
i32 7, label %21
i32 8, label %24
i32 12, label %27
i32 10, label %30
i32 13, label %33
i32 9, label %36
i32 11, label %39
i32 34, label %42
]
18: ; preds = %12
%19 = load i32*, i32** %6
%20 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %52
21: ; preds = %12
%22 = load i32*, i32** %6
%23 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %52
24: ; preds = %12
%25 = load i32*, i32** %6
%26 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %52
27: ; preds = %12
%28 = load i32*, i32** %6
%29 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %52
30: ; preds = %12
%31 = load i32*, i32** %6
%32 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %52
33: ; preds = %12
%34 = load i32*, i32** %6
%35 = call i32 @fprintf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %52
36: ; preds = %12
%37 = load i32*, i32** %6
%38 = call i32 @fprintf(i32* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %52
39: ; preds = %12
%40 = load i32*, i32** %6
%41 = call i32 @fprintf(i32* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %52
42: ; preds = %12
%43 = load i32*, i32** %6
%44 = call i32 @fprintf(i32* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %52
45: ; preds = %12
%46 = load i8*, i8** %4
%47 = load i64, i64* %7
%48 = getelementptr inbounds i8, i8* %46, i64 %47
%49 = load i8, i8* %48
%50 = load i32*, i32** %6
%51 = call i32 @fputc(i8 signext %49, i32* %50)
br label %52
52: ; preds = %45, %42, %39, %36, %33, %30, %27, %24, %21, %18
br label %53
53: ; preds = %52
%54 = load i64, i64* %7
%55 = add i64 %54, 1
store i64 %55, i64* %7
br label %8
56: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\\\\00"
@.str.1 = [3 x i8] c"\\a\00"
@.str.2 = [3 x i8] c"\\b\00"
@.str.3 = [3 x i8] c"\\f\00"
@.str.4 = [3 x i8] c"\\n\00"
@.str.5 = [3 x i8] c"\\r\00"
@.str.6 = [3 x i8] c"\\t\00"
@.str.7 = [3 x i8] c"\\v\00"
@.str.8 = [3 x i8] c"\\\22\00"
define void @escape(i8* nocapture %0, i64 %1, i32* nocapture %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %33, label %5
5: ; preds = %3, %30
%6 = phi i64 [ %31, %30 ], [ 0, %3 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %28 [
i32 92, label %10
i32 7, label %12
i32 8, label %14
i32 12, label %16
i32 10, label %18
i32 13, label %20
i32 9, label %22
i32 11, label %24
i32 34, label %26
]
10: ; preds = %5
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %30
12: ; preds = %5
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %30
14: ; preds = %5
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %30
16: ; preds = %5
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %30
18: ; preds = %5
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %30
20: ; preds = %5
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %30
22: ; preds = %5
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %30
24: ; preds = %5
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %30
26: ; preds = %5
%27 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %30
28: ; preds = %5
%29 = tail call i32 @fputc(i8 signext %8, i32* %2)
br label %30
30: ; preds = %10, %12, %14, %16, %18, %20, %22, %24, %26, %28
%31 = add nuw i64 %6, 1
%32 = icmp eq i64 %31, %1
br i1 %32, label %33, label %5
33: ; preds = %30, %3
ret void
}