#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*/ emit_indent(unsigned long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(unsigned char);
void emit_literal(unsigned char *line, unsigned long startindex,
                  unsigned long endindex, unsigned long lineno,
                  const char *textvar, unsigned long indent) {
  unsigned long i;
restart:
  if (startindex == endindex)
    return;
  emit_indent(indent);
  printf("TEXT_addstring (%s, %lu, \"", textvar, lineno);
  for (i = startindex; i < endindex; i++) {
    unsigned char ch = line[i];
    if (ch == '\\' || ch == '"') {
      putchar('\\');
      putchar(ch);
    } else if (ch >= ' ' && ch != '\'') {
      putchar(ch);
    } else if (ch == '\n') {
      printf("\\n\");\n");
      startindex = i + 1;
      if (lineno > 0)
        lineno++;
      goto restart;
    } else if (ch == '\t') {
      printf("\\t");
    } else if (ch == '\b') {
      printf("\\b");
    } else if (ch == '\r') {
      printf("\\r");
    } else if (ch == '\f') {
      printf("\\f");
    } else if (ch == '\v') {
      printf("\\v");
    } else {
      putchar('\\');
      putchar('0' + ((ch / 64) % 8));
      putchar('0' + ((ch / 8) % 8));
      putchar('0' + (ch % 8));
    }
  }
  printf("\");\n");
}


x86 assembly (clang, -O0):
<emit_literal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1163 <emit_literal+0x33>
jmp    138f <emit_literal+0x25f>
mov    -0x30(%rbp),%rdi
call   1050 <emit_indent@plt>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1381 <emit_literal+0x251>
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x39(%rbp)
movzbl -0x39(%rbp),%eax
cmp    $0x5c,%eax
je     11c0 <emit_literal+0x90>
movzbl -0x39(%rbp),%eax
cmp    $0x22,%eax
jne    11d8 <emit_literal+0xa8>
mov    $0x5c,%edi
call   1030 <putchar@plt>
movzbl -0x39(%rbp),%edi
call   1030 <putchar@plt>
jmp    136b <emit_literal+0x23b>
movzbl -0x39(%rbp),%eax
cmp    $0x20,%eax
jl     1200 <emit_literal+0xd0>
movzbl -0x39(%rbp),%eax
cmp    $0x27,%eax
je     1200 <emit_literal+0xd0>
movzbl -0x39(%rbp),%edi
call   1030 <putchar@plt>
jmp    1366 <emit_literal+0x236>
movzbl -0x39(%rbp),%eax
cmp    $0xa,%eax
jne    1243 <emit_literal+0x113>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x20(%rbp)
jbe    123e <emit_literal+0x10e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1150 <emit_literal+0x20>
movzbl -0x39(%rbp),%eax
cmp    $0x9,%eax
jne    1263 <emit_literal+0x133>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    135c <emit_literal+0x22c>
movzbl -0x39(%rbp),%eax
cmp    $0x8,%eax
jne    1283 <emit_literal+0x153>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1357 <emit_literal+0x227>
movzbl -0x39(%rbp),%eax
cmp    $0xd,%eax
jne    12a3 <emit_literal+0x173>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1352 <emit_literal+0x222>
movzbl -0x39(%rbp),%eax
cmp    $0xc,%eax
jne    12c3 <emit_literal+0x193>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    134d <emit_literal+0x21d>
movzbl -0x39(%rbp),%eax
cmp    $0xb,%eax
jne    12e3 <emit_literal+0x1b3>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1348 <emit_literal+0x218>
mov    $0x5c,%edi
call   1030 <putchar@plt>
movzbl -0x39(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%al
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x39(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%al
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x39(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%al
movzbl %al,%edi
call   1030 <putchar@plt>
jmp    134d <emit_literal+0x21d>
jmp    1352 <emit_literal+0x222>
jmp    1357 <emit_literal+0x227>
jmp    135c <emit_literal+0x22c>
jmp    1361 <emit_literal+0x231>
jmp    1366 <emit_literal+0x236>
jmp    136b <emit_literal+0x23b>
jmp    1370 <emit_literal+0x240>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    118a <emit_literal+0x5a>
lea    0xc95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_literal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,(%rsp)
cmp    %rdx,%rsi
jne    116b <emit_literal+0x2b>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rdx,%r13
neg    %r13
lea    0xe97(%rip),%rbp
mov    %r9,0x8(%rsp)
mov    %r9,%rdi
call   1060 <emit_indent@plt>
mov    %rbp,%rdi
mov    0x10(%rsp),%rsi
mov    (%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %r14,%rbx
jae    12b6 <emit_literal+0x176>
add    $0x1,%rbx
jmp    11d9 <emit_literal+0x99>
mov    $0x5c,%edi
call   1030 <putchar@plt>
movzbl %r12b,%edi
call   1030 <putchar@plt>
lea    (%rbx,%r13,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
je     12b6 <emit_literal+0x176>
movzbl -0x1(%r15,%rbx,1),%r12d
cmp    $0x5c,%r12b
je     11b0 <emit_literal+0x70>
cmp    $0x22,%r12b
je     11b0 <emit_literal+0x70>
cmp    $0x20,%r12b
jb     11f7 <emit_literal+0xb7>
cmp    $0x27,%r12b
jne    11ba <emit_literal+0x7a>
lea    -0x8(%r12),%eax
cmp    $0x5,%al
ja     121c <emit_literal+0xdc>
movzbl %al,%eax
lea    0xdf6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe1c(%rip),%rdi
jmp    1275 <emit_literal+0x135>
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    %r12d,%eax
shr    $0x6,%al
or     $0x30,%al
movzbl %al,%edi
call   1030 <putchar@plt>
mov    %r12d,%eax
shr    $0x3,%al
or     $0x30,%al
movzbl %al,%edi
call   1030 <putchar@plt>
and    $0x7,%r12b
or     $0x30,%r12b
jmp    11ba <emit_literal+0x7a>
lea    0xdd9(%rip),%rdi
jmp    1275 <emit_literal+0x135>
lea    0xddc(%rip),%rdi
jmp    1275 <emit_literal+0x135>
lea    0xdd0(%rip),%rdi
jmp    1275 <emit_literal+0x135>
lea    0xdc4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c3 <emit_literal+0x83>
lea    0xdba(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rcx
lea    0x1(%rcx),%rax
test   %rcx,%rcx
cmovne %rax,%rcx
mov    %rcx,(%rsp)
mov    %r13,%rax
add    %rbx,%rax
mov    0x8(%rsp),%r9
jne    1186 <emit_literal+0x46>
jmp    115c <emit_literal+0x1c>
lea    0xd87(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"TEXT_addstring (%s, %lu, \22\00"
@.str.1 = [7 x i8] c"\\n\22);\0A\00"
@.str.2 = [3 x i8] c"\\t\00"
@.str.3 = [3 x i8] c"\\b\00"
@.str.4 = [3 x i8] c"\\r\00"
@.str.5 = [3 x i8] c"\\f\00"
@.str.6 = [3 x i8] c"\\v\00"
@.str.7 = [5 x i8] c"\22);\0A\00"
define void @emit_literal(i8* %0, i64 %1, i64 %2, i64 %3, i8* %4, i64 %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64
%14 = alloca i8
store i8* %0, i8** %7
store i64 %1, i64* %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i8* %4, i8** %11
store i64 %5, i64* %12
br label %15
15: ; preds = %71, %6
%16 = load i64, i64* %8
%17 = load i64, i64* %9
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15
br label %137
20: ; preds = %15
%21 = load i64, i64* %12
%22 = call i32 @emit_indent(i64 %21)
%23 = load i8*, i8** %11
%24 = load i64, i64* %10
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %23, i64 %24)
%26 = load i64, i64* %8
store i64 %26, i64* %13
br label %27
27: ; preds = %132, %20
%28 = load i64, i64* %13
%29 = load i64, i64* %9
%30 = icmp ult i64 %28, %29
br i1 %30, label %31, label %135
31: ; preds = %27
%32 = load i8*, i8** %7
%33 = load i64, i64* %13
%34 = getelementptr inbounds i8, i8* %32, i64 %33
%35 = load i8, i8* %34
store i8 %35, i8* %14
%36 = load i8, i8* %14
%37 = zext i8 %36 to i32
%38 = icmp eq i32 %37, 92
br i1 %38, label %43, label %39
39: ; preds = %31
%40 = load i8, i8* %14
%41 = zext i8 %40 to i32
%42 = icmp eq i32 %41, 34
br i1 %42, label %43, label %47
43: ; preds = %39, %31
%44 = call i32 @putchar(i8 zeroext 92)
%45 = load i8, i8* %14
%46 = call i32 @putchar(i8 zeroext %45)
br label %131
47: ; preds = %39
%48 = load i8, i8* %14
%49 = zext i8 %48 to i32
%50 = icmp sge i32 %49, 32
br i1 %50, label %51, label %58
51: ; preds = %47
%52 = load i8, i8* %14
%53 = zext i8 %52 to i32
%54 = icmp ne i32 %53, 39
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i8, i8* %14
%57 = call i32 @putchar(i8 zeroext %56)
br label %130
58: ; preds = %51, %47
%59 = load i8, i8* %14
%60 = zext i8 %59 to i32
%61 = icmp eq i32 %60, 10
br i1 %61, label %62, label %72
62: ; preds = %58
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%64 = load i64, i64* %13
%65 = add i64 %64, 1
store i64 %65, i64* %8
%66 = load i64, i64* %10
%67 = icmp ugt i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %62
%69 = load i64, i64* %10
%70 = add i64 %69, 1
store i64 %70, i64* %10
br label %71
71: ; preds = %68, %62
br label %15
72: ; preds = %58
%73 = load i8, i8* %14
%74 = zext i8 %73 to i32
%75 = icmp eq i32 %74, 9
br i1 %75, label %76, label %78
76: ; preds = %72
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %128
78: ; preds = %72
%79 = load i8, i8* %14
%80 = zext i8 %79 to i32
%81 = icmp eq i32 %80, 8
br i1 %81, label %82, label %84
82: ; preds = %78
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %127
84: ; preds = %78
%85 = load i8, i8* %14
%86 = zext i8 %85 to i32
%87 = icmp eq i32 %86, 13
br i1 %87, label %88, label %90
88: ; preds = %84
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %126
90: ; preds = %84
%91 = load i8, i8* %14
%92 = zext i8 %91 to i32
%93 = icmp eq i32 %92, 12
br i1 %93, label %94, label %96
94: ; preds = %90
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %125
96: ; preds = %90
%97 = load i8, i8* %14
%98 = zext i8 %97 to i32
%99 = icmp eq i32 %98, 11
br i1 %99, label %100, label %102
100: ; preds = %96
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %124
102: ; preds = %96
%103 = call i32 @putchar(i8 zeroext 92)
%104 = load i8, i8* %14
%105 = zext i8 %104 to i32
%106 = sdiv i32 %105, 64
%107 = srem i32 %106, 8
%108 = add nsw i32 48, %107
%109 = trunc i32 %108 to i8
%110 = call i32 @putchar(i8 zeroext %109)
%111 = load i8, i8* %14
%112 = zext i8 %111 to i32
%113 = sdiv i32 %112, 8
%114 = srem i32 %113, 8
%115 = add nsw i32 48, %114
%116 = trunc i32 %115 to i8
%117 = call i32 @putchar(i8 zeroext %116)
%118 = load i8, i8* %14
%119 = zext i8 %118 to i32
%120 = srem i32 %119, 8
%121 = add nsw i32 48, %120
%122 = trunc i32 %121 to i8
%123 = call i32 @putchar(i8 zeroext %122)
br label %124
124: ; preds = %102, %100
br label %125
125: ; preds = %124, %94
br label %126
126: ; preds = %125, %88
br label %127
127: ; preds = %126, %82
br label %128
128: ; preds = %127, %76
br label %129
129: ; preds = %128
br label %130
130: ; preds = %129, %55
br label %131
131: ; preds = %130, %43
br label %132
132: ; preds = %131
%133 = load i64, i64* %13
%134 = add i64 %133, 1
store i64 %134, i64* %13
br label %27
135: ; preds = %27
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %137
137: ; preds = %135, %19
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"TEXT_addstring (%s, %lu, \22\00"
@.str.2 = [3 x i8] c"\\t\00"
@.str.3 = [3 x i8] c"\\b\00"
@.str.4 = [3 x i8] c"\\r\00"
@.str.5 = [3 x i8] c"\\f\00"
@.str.6 = [3 x i8] c"\\v\00"
@str = [4 x i8] c"\22);\00"
@str.8 = [6 x i8] c"\\n\22);\00"
define void @emit_literal(i8* nocapture %0, i64 %1, i64 %2, i64 %3, i8* %4, i64 %5) {
%7 = icmp eq i64 %1, %2
br i1 %7, label %61, label %8
8: ; preds = %6, %49
%9 = phi i64 [ %51, %49 ], [ %1, %6 ]
%10 = phi i64 [ %54, %49 ], [ %3, %6 ]
%11 = tail call i32 @emit_indent(i64 %5)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %4, i64 %10)
%13 = icmp ult i64 %9, %2
br i1 %13, label %14, label %59
14: ; preds = %8, %56
%15 = phi i64 [ %57, %56 ], [ %9, %8 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
switch i8 %17, label %21 [
i8 92, label %18
i8 34, label %18
]
18: ; preds = %14, %14
%19 = tail call i32 @putchar(i8 zeroext 92)
%20 = tail call i32 @putchar(i8 zeroext %17)
br label %56
21: ; preds = %14
%22 = icmp ugt i8 %17, 31
%23 = icmp ne i8 %17, 39
%24 = and i1 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = tail call i32 @putchar(i8 zeroext %17)
br label %56
27: ; preds = %21
switch i8 %17, label %38 [
i8 10, label %49
i8 9, label %28
i8 8, label %30
i8 13, label %32
i8 12, label %34
i8 11, label %36
]
28: ; preds = %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %56
30: ; preds = %27
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %56
32: ; preds = %27
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %56
34: ; preds = %27
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %56
36: ; preds = %27
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %56
38: ; preds = %27
%39 = tail call i32 @putchar(i8 zeroext 92)
%40 = lshr i8 %17, 6
%41 = or i8 %40, 48
%42 = tail call i32 @putchar(i8 zeroext %41)
%43 = lshr i8 %17, 3
%44 = or i8 %43, 48
%45 = tail call i32 @putchar(i8 zeroext %44)
%46 = and i8 %17, 7
%47 = or i8 %46, 48
%48 = tail call i32 @putchar(i8 zeroext %47)
br label %56
49: ; preds = %27
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
%51 = add nuw i64 %15, 1
%52 = icmp eq i64 %10, 0
%53 = add i64 %10, 1
%54 = select i1 %52, i64 0, i64 %53
%55 = icmp eq i64 %51, %2
br i1 %55, label %61, label %8
56: ; preds = %25, %28, %32, %36, %38, %34, %30, %18
%57 = add i64 %15, 1
%58 = icmp eq i64 %57, %2
br i1 %58, label %59, label %14
59: ; preds = %8, %56
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %61
61: ; preds = %49, %6, %59
ret void
}