#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 ts_subtree__write_dot_string(FILE *f, const char *string) {
  for (const char *c = string; *c; c++) {
    if (*c == '"') {
      fputs("\\\"", f);
    } else if (*c == '\n') {
      fputs("\\n", f);
    } else {
      fputc(*c, f);
    }
  }
}


x86 assembly (clang, -O0):
<ts_subtree__write_dot_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bc <ts_subtree__write_dot_string+0x9c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    116a <ts_subtree__write_dot_string+0x4a>
mov    -0x8(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1030 <fputs@plt>
jmp    11a6 <ts_subtree__write_dot_string+0x86>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    118f <ts_subtree__write_dot_string+0x6f>
mov    -0x8(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1030 <fputs@plt>
jmp    11a1 <ts_subtree__write_dot_string+0x81>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
jmp    11a6 <ts_subtree__write_dot_string+0x86>
jmp    11ab <ts_subtree__write_dot_string+0x8b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <ts_subtree__write_dot_string+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_subtree__write_dot_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xece(%rip),%r15
lea    0xec4(%rip),%r12
jmp    1159 <ts_subtree__write_dot_string+0x39>
xchg   %ax,%ax
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0xa,%al
je     1180 <ts_subtree__write_dot_string+0x60>
cmp    $0x22,%al
je     1140 <ts_subtree__write_dot_string+0x20>
test   %al,%al
je     118f <ts_subtree__write_dot_string+0x6f>
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbx
jmp    1159 <ts_subtree__write_dot_string+0x39>
nopl   0x0(%rax)
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
jmp    114d <ts_subtree__write_dot_string+0x2d>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\\\22\00"
@.str.1 = [3 x i8] c"\\n\00"
define void @ts_subtree__write_dot_string(i32* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %13, %2
%4 = phi i8* [ %1, %2 ], [ %14, %13 ]
%5 = load i8, i8* %4
switch i8 %5, label %11 [
i8 0, label %6
i8 34, label %7
i8 10, label %9
]
6: ; preds = %3
ret void
7: ; preds = %3
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %13
9: ; preds = %3
%10 = 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 %13
11: ; preds = %3
%12 = tail call i32 @fputc(i8 signext %5, i32* %0)
br label %13
13: ; preds = %7, %11, %9
%14 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
}