#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*/ fputc(char const, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void write_token(FILE *f, const char *s) {
  fputs(" \'", f);
  while (s && (*s != '\0')) {
    switch (*s) {
    case '\\':
      fputs("\\\\", f);
      break;
    case '\'':
      fputs("\\\'", f);
      break;
    case '\"':
      fputs("\\\"", f);
      break;
    case '\t':
      fputs("\\t", f);
      break;
    case '\r':
      fputs("\\r", f);
      break;
    case '\n':
      fputs("\\n", f);
      break;
    case '\f':
      fputs("\\f", f);
      break;
    default:
      fputc(*s, f);
      break;
    }
    s++;
  }
  fputc('\'', f);
}


x86 assembly (clang, -O0):
<write_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1030 <fputs@plt>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     1160 <write_token+0x40>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1170 <write_token+0x50>
jmp    12a4 <write_token+0x184>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x9,%eax
je     122d <write_token+0x10d>
jmp    1188 <write_token+0x68>
mov    -0x18(%rbp),%eax
sub    $0xa,%eax
je     1257 <write_token+0x137>
jmp    1199 <write_token+0x79>
mov    -0x18(%rbp),%eax
sub    $0xc,%eax
je     126c <write_token+0x14c>
jmp    11aa <write_token+0x8a>
mov    -0x18(%rbp),%eax
sub    $0xd,%eax
je     1242 <write_token+0x122>
jmp    11bb <write_token+0x9b>
mov    -0x18(%rbp),%eax
sub    $0x22,%eax
je     1218 <write_token+0xf8>
jmp    11cc <write_token+0xac>
mov    -0x18(%rbp),%eax
sub    $0x27,%eax
je     1203 <write_token+0xe3>
jmp    11dd <write_token+0xbd>
mov    -0x18(%rbp),%eax
sub    $0x5c,%eax
jne    1281 <write_token+0x161>
jmp    11ee <write_token+0xce>
mov    -0x8(%rbp),%rsi
lea    0xe0a(%rip),%rdi
call   1030 <fputs@plt>
jmp    1293 <write_token+0x173>
mov    -0x8(%rbp),%rsi
lea    0xdf8(%rip),%rdi
call   1030 <fputs@plt>
jmp    1293 <write_token+0x173>
mov    -0x8(%rbp),%rsi
lea    0xde6(%rip),%rdi
call   1030 <fputs@plt>
jmp    1293 <write_token+0x173>
mov    -0x8(%rbp),%rsi
lea    0xdd4(%rip),%rdi
call   1030 <fputs@plt>
jmp    1293 <write_token+0x173>
mov    -0x8(%rbp),%rsi
lea    0xdc2(%rip),%rdi
call   1030 <fputs@plt>
jmp    1293 <write_token+0x173>
mov    -0x8(%rbp),%rsi
lea    0xdb0(%rip),%rdi
call   1030 <fputs@plt>
jmp    1293 <write_token+0x173>
mov    -0x8(%rbp),%rsi
lea    0xd9e(%rip),%rdi
call   1030 <fputs@plt>
jmp    1293 <write_token+0x173>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1140 <write_token+0x20>
mov    -0x8(%rbp),%rsi
mov    $0x27,%edi
call   1040 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_token>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xf44(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
test   %rbx,%rbx
je     123a <write_token+0x11a>
mov    (%rbx),%al
test   %al,%al
je     123a <write_token+0x11a>
add    $0x1,%rbx
lea    0xe98(%rip),%rbp
lea    0xf1c(%rip),%r15
lea    0xf0f(%rip),%r12
lea    0xf05(%rip),%r13
jmp    11a7 <write_token+0x87>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf01(%rip),%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     123a <write_token+0x11a>
movsbl %al,%edi
lea    -0x9(%rdi),%eax
cmp    $0x1e,%eax
ja     11cf <write_token+0xaf>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xebb(%rip),%rdi
jmp    1190 <write_token+0x70>
cmp    $0x5c,%edi
jne    11e7 <write_token+0xc7>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xe9a(%rip),%rdi
jmp    1190 <write_token+0x70>
mov    %r14,%rsi
call   1030 <fputc@plt>
jmp    1198 <write_token+0x78>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xe8c(%rip),%rdi
jmp    1190 <write_token+0x70>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
jmp    1190 <write_token+0x70>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rdi
jmp    1190 <write_token+0x70>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r13,%rdi
jmp    1190 <write_token+0x70>
mov    $0x27,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

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

LLVM IR (-O2):
@.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"\\\22\00"
@.str.4 = [3 x i8] c"\\t\00"
@.str.5 = [3 x i8] c"\\r\00"
@.str.6 = [3 x i8] c"\\n\00"
@.str.7 = [3 x i8] c"\\f\00"
define void @write_token(i32* nocapture %0, i8* %1) {
%3 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %0)
%4 = icmp eq i8* %1, null
br i1 %4, label %32, label %5
5: ; preds = %2
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %32, label %8
8: ; preds = %5, %28
%9 = phi i8 [ %30, %28 ], [ %6, %5 ]
%10 = phi i8* [ %29, %28 ], [ %1, %5 ]
%11 = sext i8 %9 to i32
switch i32 %11, label %26 [
i32 92, label %12
i32 39, label %14
i32 34, label %16
i32 9, label %18
i32 13, label %20
i32 10, label %22
i32 12, label %24
]
12: ; preds = %8
%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* %0)
br label %28
14: ; preds = %8
%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* %0)
br label %28
16: ; preds = %8
%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* %0)
br label %28
18: ; preds = %8
%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* %0)
br label %28
20: ; preds = %8
%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* %0)
br label %28
22: ; preds = %8
%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* %0)
br label %28
24: ; preds = %8
%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* %0)
br label %28
26: ; preds = %8
%27 = tail call i32 @fputc(i8 signext %9, i32* %0)
br label %28
28: ; preds = %26, %24, %22, %20, %18, %16, %14, %12
%29 = getelementptr inbounds i8, i8* %10, i64 1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %8
32: ; preds = %28, %5, %2
%33 = tail call i32 @fputc(i8 signext 39, i32* %0)
ret void
}