#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 */
scalar_t__ EOF;
int errno;
scalar_t__ putc(char const, int /*<<< orphan*/ *);
int cl_write_netlog_quoted(FILE *fp, char const *s, char const *e) {
  for (; s < e; s++)
    if (*s == '\n'
            ? (putc('\\', fp) == EOF || putc('n', fp) == EOF)
            : (*s == '\t' ? (putc('\\', fp) == EOF || putc('t', fp) == EOF)
                          : ((*s == '\\' && putc('\\', fp) == EOF) ||
                             putc(*s, fp) == EOF)))
      return errno;
  return 0;
}


x86 assembly (clang, -O0):
<cl_write_netlog_quoted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    124b <cl_write_netlog_quoted+0x13b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1183 <cl_write_netlog_quoted+0x73>
mov    -0x10(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <putc@plt>
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%rax
je     1224 <cl_write_netlog_quoted+0x114>
mov    -0x10(%rbp),%rsi
mov    $0x6e,%edi
call   1030 <putc@plt>
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%rax
je     1224 <cl_write_netlog_quoted+0x114>
jmp    1235 <cl_write_netlog_quoted+0x125>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    11d4 <cl_write_netlog_quoted+0xc4>
mov    -0x10(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <putc@plt>
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%rax
je     1224 <cl_write_netlog_quoted+0x114>
mov    -0x10(%rbp),%rsi
mov    $0x74,%edi
call   1030 <putc@plt>
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%rax
je     1224 <cl_write_netlog_quoted+0x114>
jmp    1235 <cl_write_netlog_quoted+0x125>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1202 <cl_write_netlog_quoted+0xf2>
mov    -0x10(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <putc@plt>
mov    0x2def(%rip),%rcx
cmp    (%rcx),%rax
je     1224 <cl_write_netlog_quoted+0x114>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <putc@plt>
mov    0x2dcd(%rip),%rcx
cmp    (%rcx),%rax
jne    1235 <cl_write_netlog_quoted+0x125>
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1252 <cl_write_netlog_quoted+0x142>
jmp    123a <cl_write_netlog_quoted+0x12a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1124 <cl_write_netlog_quoted+0x14>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cl_write_netlog_quoted>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %eax,%eax
cmp    %rdx,%rsi
jae    11d3 <cl_write_netlog_quoted+0xc3>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
sub    %rsi,%r14
xor    %ebx,%ebx
mov    0x2eaf(%rip),%r13
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%eax
cmp    $0x9,%al
je     1170 <cl_write_netlog_quoted+0x60>
cmp    $0x5c,%al
je     1190 <cl_write_netlog_quoted+0x80>
cmp    $0xa,%al
jne    11a8 <cl_write_netlog_quoted+0x98>
mov    $0x5c,%edi
mov    %r12,%rsi
call   1030 <putc@plt>
cmp    0x0(%r13),%rax
je     11ca <cl_write_netlog_quoted+0xba>
mov    $0x6e,%edi
jmp    11ab <cl_write_netlog_quoted+0x9b>
nopl   0x0(%rax,%rax,1)
mov    $0x5c,%edi
mov    %r12,%rsi
call   1030 <putc@plt>
cmp    0x0(%r13),%rax
je     11ca <cl_write_netlog_quoted+0xba>
mov    $0x74,%edi
jmp    11ab <cl_write_netlog_quoted+0x9b>
nopw   0x0(%rax,%rax,1)
mov    $0x5c,%edi
mov    %r12,%rsi
call   1030 <putc@plt>
cmp    0x0(%r13),%rax
je     11ca <cl_write_netlog_quoted+0xba>
movzbl (%r15,%rbx,1),%eax
movsbl %al,%edi
mov    %r12,%rsi
call   1030 <putc@plt>
cmp    0x0(%r13),%rax
je     11ca <cl_write_netlog_quoted+0xba>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <cl_write_netlog_quoted+0x30>
xor    %eax,%eax
jmp    11d3 <cl_write_netlog_quoted+0xc3>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i64 0
@errno = global i32 0
define i32 @cl_write_netlog_quoted(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
br label %8
8: ; preds = %62, %3
%9 = load i8*, i8** %6
%10 = load i8*, i8** %7
%11 = icmp ult i8* %9, %10
br i1 %11, label %12, label %65
12: ; preds = %8
%13 = load i8*, i8** %6
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %27
17: ; preds = %12
%18 = load i32*, i32** %5
%19 = call i64 @putc(i8 signext 92, i32* %18)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %59, label %22
22: ; preds = %17
%23 = load i32*, i32** %5
%24 = call i64 @putc(i8 signext 110, i32* %23)
%25 = load i64, i64* @EOF
%26 = icmp eq i64 %24, %25
br i1 %26, label %59, label %61
27: ; preds = %12
%28 = load i8*, i8** %6
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 9
br i1 %31, label %32, label %42
32: ; preds = %27
%33 = load i32*, i32** %5
%34 = call i64 @putc(i8 signext 92, i32* %33)
%35 = load i64, i64* @EOF
%36 = icmp eq i64 %34, %35
br i1 %36, label %59, label %37
37: ; preds = %32
%38 = load i32*, i32** %5
%39 = call i64 @putc(i8 signext 116, i32* %38)
%40 = load i64, i64* @EOF
%41 = icmp eq i64 %39, %40
br i1 %41, label %59, label %61
42: ; preds = %27
%43 = load i8*, i8** %6
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 92
br i1 %46, label %47, label %52
47: ; preds = %42
%48 = load i32*, i32** %5
%49 = call i64 @putc(i8 signext 92, i32* %48)
%50 = load i64, i64* @EOF
%51 = icmp eq i64 %49, %50
br i1 %51, label %59, label %52
52: ; preds = %47, %42
%53 = load i8*, i8** %6
%54 = load i8, i8* %53
%55 = load i32*, i32** %5
%56 = call i64 @putc(i8 signext %54, i32* %55)
%57 = load i64, i64* @EOF
%58 = icmp eq i64 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %52, %47, %37, %32, %22, %17
%60 = load i32, i32* @errno
store i32 %60, i32* %4
br label %66
61: ; preds = %52, %37, %22
br label %62
62: ; preds = %61
%63 = load i8*, i8** %6
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %6
br label %8
65: ; preds = %8
store i32 0, i32* %4
br label %66
66: ; preds = %65, %59
%67 = load i32, i32* %4
ret i32 %67
}

LLVM IR (-O2):
@EOF = global i64 0
@errno = global i32 0
define i32 @cl_write_netlog_quoted(i32* nocapture %0, i8* %1, i8* readnone %2) {
%4 = icmp ult i8* %1, %2
br i1 %4, label %5, label %45
5: ; preds = %3
%6 = ptrtoint i8* %2 to i64
%7 = ptrtoint i8* %1 to i64
%8 = sub i64 %6, %7
%9 = getelementptr i8, i8* %1, i64 %8
br label %10
10: ; preds = %5, %42
%11 = phi i8* [ %43, %42 ], [ %1, %5 ]
%12 = load i8, i8* %11
switch i8 %12, label %35 [
i8 10, label %13
i8 9, label %21
i8 92, label %29
]
13: ; preds = %10
%14 = tail call i64 @putc(i8 signext 92, i32* %0)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %40, label %17
17: ; preds = %13
%18 = tail call i64 @putc(i8 signext 110, i32* %0)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %40, label %42
21: ; preds = %10
%22 = tail call i64 @putc(i8 signext 92, i32* %0)
%23 = load i64, i64* @EOF
%24 = icmp eq i64 %22, %23
br i1 %24, label %40, label %25
25: ; preds = %21
%26 = tail call i64 @putc(i8 signext 116, i32* %0)
%27 = load i64, i64* @EOF
%28 = icmp eq i64 %26, %27
br i1 %28, label %40, label %42
29: ; preds = %10
%30 = tail call i64 @putc(i8 signext 92, i32* %0)
%31 = load i64, i64* @EOF
%32 = icmp eq i64 %30, %31
br i1 %32, label %40, label %33
33: ; preds = %29
%34 = load i8, i8* %11
br label %35
35: ; preds = %33, %10
%36 = phi i8 [ %34, %33 ], [ %12, %10 ]
%37 = tail call i64 @putc(i8 signext %36, i32* %0)
%38 = load i64, i64* @EOF
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %35, %29, %25, %21, %17, %13
%41 = load i32, i32* @errno
br label %45
42: ; preds = %17, %25, %35
%43 = getelementptr inbounds i8, i8* %11, i64 1
%44 = icmp eq i8* %43, %9
br i1 %44, label %45, label %10
45: ; preds = %42, %3, %40
%46 = phi i32 [ %41, %40 ], [ 0, %3 ], [ 0, %42 ]
ret i32 %46
}