#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 */
scalar_t__ printf(char *, ...);
int printLiteral(const char *value) {
  int chars = 0;
  chars += printf("\"");
  for (int i = 0; value[i] != '\0'; i++) {
    switch (value[i]) {
    case '\r':
      chars += printf("\\r");
      break;
    case '\n':
      chars += printf("\\n");
      break;
    case '\t':
      chars += printf("\\t");
      break;
    case '\"':
      chars += printf("\\\"");
      break;
    case '\\':
      chars += printf("\\\\");
      break;
    default:
      chars += printf("%c", value[i]);
    }
  }
  chars += printf("\"");
  return chars;
}


x86 assembly (clang, -O0):
<printLiteral>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1295 <printLiteral+0x185>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
sub    $0x9,%eax
je     11fb <printLiteral+0xeb>
jmp    1177 <printLiteral+0x67>
mov    -0x14(%rbp),%eax
sub    $0xa,%eax
je     11db <printLiteral+0xcb>
jmp    1188 <printLiteral+0x78>
mov    -0x14(%rbp),%eax
sub    $0xd,%eax
je     11bb <printLiteral+0xab>
jmp    1199 <printLiteral+0x89>
mov    -0x14(%rbp),%eax
sub    $0x22,%eax
je     121b <printLiteral+0x10b>
jmp    11aa <printLiteral+0x9a>
mov    -0x14(%rbp),%eax
sub    $0x5c,%eax
je     123b <printLiteral+0x12b>
jmp    125b <printLiteral+0x14b>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
jmp    1282 <printLiteral+0x172>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
jmp    1282 <printLiteral+0x172>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
jmp    1282 <printLiteral+0x172>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
jmp    1282 <printLiteral+0x172>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
jmp    1282 <printLiteral+0x172>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
jmp    1287 <printLiteral+0x177>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <printLiteral+0x35>
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printLiteral>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xf4d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rax,%r14
mov    (%rbx),%al
test   %al,%al
je     11c8 <printLiteral+0xb8>
add    $0x1,%rbx
lea    0xf33(%rip),%r12
lea    0xeb5(%rip),%rbp
lea    0xf16(%rip),%r15
lea    0xf18(%rip),%r13
jmp    1173 <printLiteral+0x63>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    %eax,%r14d
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11c8 <printLiteral+0xb8>
movsbl %al,%esi
lea    -0x9(%rsi),%eax
cmp    $0x19,%eax
ja     11a0 <printLiteral+0x90>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xedf(%rip),%rdi
jmp    115e <printLiteral+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x5c,%esi
jne    11ae <printLiteral+0x9e>
lea    0xec8(%rip),%rdi
jmp    115e <printLiteral+0x4e>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1165 <printLiteral+0x55>
lea    0xeaa(%rip),%rdi
jmp    115e <printLiteral+0x4e>
mov    %r13,%rdi
jmp    115e <printLiteral+0x4e>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\22\00"
@.str.1 = [3 x i8] c"\\r\00"
@.str.2 = [3 x i8] c"\\n\00"
@.str.3 = [3 x i8] c"\\t\00"
@.str.4 = [3 x i8] c"\\\22\00"
@.str.5 = [3 x i8] c"\\\\\00"
@.str.6 = [3 x i8] c"%c\00"
define i32 @printLiteral(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = add nsw i64 %7, %5
%9 = trunc i64 %8 to i32
store i32 %9, i32* %3
store i32 0, i32* %4
br label %10
10: ; preds = %68, %1
%11 = load i8*, i8** %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %71
18: ; preds = %10
%19 = load i8*, i8** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
switch i32 %24, label %55 [
i32 13, label %25
i32 10, label %31
i32 9, label %37
i32 34, label %43
i32 92, label %49
]
25: ; preds = %18
%26 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = add nsw i64 %28, %26
%30 = trunc i64 %29 to i32
store i32 %30, i32* %3
br label %67
31: ; preds = %18
%32 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = add nsw i64 %34, %32
%36 = trunc i64 %35 to i32
store i32 %36, i32* %3
br label %67
37: ; preds = %18
%38 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = add nsw i64 %40, %38
%42 = trunc i64 %41 to i32
store i32 %42, i32* %3
br label %67
43: ; preds = %18
%44 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = add nsw i64 %46, %44
%48 = trunc i64 %47 to i32
store i32 %48, i32* %3
br label %67
49: ; preds = %18
%50 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = add nsw i64 %52, %50
%54 = trunc i64 %53 to i32
store i32 %54, i32* %3
br label %67
55: ; preds = %18
%56 = load i8*, i8** %2
%57 = load i32, i32* %4
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %3
%64 = sext i32 %63 to i64
%65 = add nsw i64 %64, %62
%66 = trunc i64 %65 to i32
store i32 %66, i32* %3
br label %67
67: ; preds = %55, %49, %43, %37, %31, %25
br label %68
68: ; preds = %67
%69 = load i32, i32* %4
%70 = add nsw i32 %69, 1
store i32 %70, i32* %4
br label %10
71: ; preds = %10
%72 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%73 = load i32, i32* %3
%74 = sext i32 %73 to i64
%75 = add nsw i64 %74, %72
%76 = trunc i64 %75 to i32
store i32 %76, i32* %3
%77 = load i32, i32* %3
ret i32 %77
}

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