#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 */
void *hexDigit(char);
int /*<<< orphan*/ write(int, char *, int);
void fwriteStrEscaped(int f, const char *s) {
  static char buffer[200 * 4];
  char *t = buffer;
  int numChars = 0;
  while (*s != '\0' && numChars < 200) {
    char c = *s++;
    numChars++;
    if (c >= 32 && c <= 126) {
      *t++ = c;
    } else {
      *t++ = '\\';
      switch (c) {
      case '\n':
        *t++ = 'n';
        break;
      case '\t':
        *t++ = 't';
        break;
      default:
        *t++ = 'x';
        *t++ = hexDigit(c >> 4);
        *t++ = hexDigit(c);
        break;
      }
    }
  }
  write(f, buffer, t - buffer);
}


x86 assembly (clang, -O0):
<fwriteStrEscaped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0x2f0a(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1e(%rbp)
je     1163 <fwriteStrEscaped+0x43>
cmpl   $0xc8,-0x1c(%rbp)
setl   %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    1173 <fwriteStrEscaped+0x53>
jmp    1283 <fwriteStrEscaped+0x163>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x1d(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x20,%eax
jl     11c3 <fwriteStrEscaped+0xa3>
movsbl -0x1d(%rbp),%eax
cmp    $0x7e,%eax
jg     11c3 <fwriteStrEscaped+0xa3>
mov    -0x1d(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    127e <fwriteStrEscaped+0x15e>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5c,(%rax)
movsbl -0x1d(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x9,%eax
je     1212 <fwriteStrEscaped+0xf2>
jmp    11ea <fwriteStrEscaped+0xca>
mov    -0x24(%rbp),%eax
sub    $0xa,%eax
jne    1229 <fwriteStrEscaped+0x109>
jmp    11fb <fwriteStrEscaped+0xdb>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x6e,(%rax)
jmp    1279 <fwriteStrEscaped+0x159>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x74,(%rax)
jmp    1279 <fwriteStrEscaped+0x159>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x78,(%rax)
movsbl -0x1d(%rbp),%eax
sar    $0x4,%eax
movsbl %al,%edi
call   1040 <hexDigit@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
movsbl -0x1d(%rbp),%edi
call   1040 <hexDigit@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    127e <fwriteStrEscaped+0x15e>
jmp    1141 <fwriteStrEscaped+0x21>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rax
lea    0x2daf(%rip),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    0x2da3(%rip),%rsi
call   1030 <write@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fwriteStrEscaped>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
mov    (%rsi),%al
test   %al,%al
je     11cb <fwriteStrEscaped+0xab>
mov    %rsi,%r15
lea    0x2f01(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x20(%rax),%ecx
cmp    $0x5e,%cl
ja     1160 <fwriteStrEscaped+0x40>
mov    %al,(%rbx)
add    $0x1,%rbx
jmp    11b0 <fwriteStrEscaped+0x90>
movsbl %al,%r12d
movb   $0x5c,(%rbx)
cmp    $0x9,%r12d
je     117d <fwriteStrEscaped+0x5d>
cmp    $0xa,%r12d
jne    1187 <fwriteStrEscaped+0x67>
movb   $0x6e,0x1(%rbx)
add    $0x2,%rbx
jmp    11b0 <fwriteStrEscaped+0x90>
movb   $0x74,0x1(%rbx)
add    $0x2,%rbx
jmp    11b0 <fwriteStrEscaped+0x90>
movb   $0x78,0x1(%rbx)
sar    $0x4,%al
movsbl %al,%edi
call   1040 <hexDigit@plt>
mov    %al,0x2(%rbx)
mov    %r12d,%edi
call   1040 <hexDigit@plt>
mov    %al,0x3(%rbx)
add    $0x4,%rbx
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%r15,%rbp,1),%eax
test   %al,%al
je     11d2 <fwriteStrEscaped+0xb2>
lea    0x1(%rbp),%rcx
cmp    $0xc7,%ebp
mov    %rcx,%rbp
jb     1150 <fwriteStrEscaped+0x30>
jmp    11d2 <fwriteStrEscaped+0xb2>
lea    0x2e6e(%rip),%rbx
lea    0x2e67(%rip),%rsi
sub    %esi,%ebx
mov    %r14d,%edi
mov    %ebx,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <write@plt>

LLVM IR (-O0):
@fwriteStrEscaped.buffer = internal global [800 x i8] zeroinitializer
define void @fwriteStrEscaped(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
store i32 %0, i32* %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([800 x i8], [800 x i8]* @fwriteStrEscaped.buffer, i64 0, i64 0), i8** %5
store i32 0, i32* %6
br label %8
8: ; preds = %63, %2
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 200
br label %16
16: ; preds = %13, %8
%17 = phi i1 [ false, %8 ], [ %15, %13 ]
br i1 %17, label %18, label %64
18: ; preds = %16
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %4
%21 = load i8, i8* %19
store i8 %21, i8* %7
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = icmp sge i32 %25, 32
br i1 %26, label %27, label %35
27: ; preds = %18
%28 = load i8, i8* %7
%29 = sext i8 %28 to i32
%30 = icmp sle i32 %29, 126
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i8, i8* %7
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %5
store i8 %32, i8* %33
br label %63
35: ; preds = %27, %18
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %5
store i8 92, i8* %36
%38 = load i8, i8* %7
%39 = sext i8 %38 to i32
switch i32 %39, label %46 [
i32 10, label %40
i32 9, label %43
]
40: ; preds = %35
%41 = load i8*, i8** %5
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %5
store i8 110, i8* %41
br label %62
43: ; preds = %35
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %5
store i8 116, i8* %44
br label %62
46: ; preds = %35
%47 = load i8*, i8** %5
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %5
store i8 120, i8* %47
%49 = load i8, i8* %7
%50 = sext i8 %49 to i32
%51 = ashr i32 %50, 4
%52 = trunc i32 %51 to i8
%53 = call i8* @hexDigit(i8 signext %52)
%54 = ptrtoint i8* %53 to i8
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %5
store i8 %54, i8* %55
%57 = load i8, i8* %7
%58 = call i8* @hexDigit(i8 signext %57)
%59 = ptrtoint i8* %58 to i8
%60 = load i8*, i8** %5
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %5
store i8 %59, i8* %60
br label %62
62: ; preds = %46, %43, %40
br label %63
63: ; preds = %62, %31
br label %8
64: ; preds = %16
%65 = load i32, i32* %3
%66 = load i8*, i8** %5
%67 = ptrtoint i8* %66 to i64
%68 = sub i64 %67, ptrtoint ([800 x i8]* @fwriteStrEscaped.buffer to i64)
%69 = trunc i64 %68 to i32
%70 = call i32 @write(i32 %65, i8* getelementptr inbounds ([800 x i8], [800 x i8]* @fwriteStrEscaped.buffer, i64 0, i64 0), i32 %69)
ret void
}

LLVM IR (-O2):
@fwriteStrEscaped.buffer = internal global [800 x i8] zeroinitializer
define void @fwriteStrEscaped(i32 %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %40, label %5
5: ; preds = %2, %34
%6 = phi i8 [ %36, %34 ], [ %3, %2 ]
%7 = phi i8* [ %10, %34 ], [ %1, %2 ]
%8 = phi i32 [ %11, %34 ], [ 0, %2 ]
%9 = phi i8* [ %35, %34 ], [ getelementptr inbounds ([800 x i8], [800 x i8]* @fwriteStrEscaped.buffer, i64 0, i64 0), %2 ]
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = add nuw nsw i32 %8, 1
%12 = add i8 %6, -32
%13 = icmp ult i8 %12, 95
br i1 %13, label %14, label %16
14: ; preds = %5
%15 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %6, i8* %9
br label %34
16: ; preds = %5
%17 = sext i8 %6 to i32
%18 = getelementptr inbounds i8, i8* %9, i64 1
store i8 92, i8* %9
switch i32 %17, label %23 [
i32 10, label %19
i32 9, label %21
]
19: ; preds = %16
%20 = getelementptr inbounds i8, i8* %9, i64 2
store i8 110, i8* %18
br label %34
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %9, i64 2
store i8 116, i8* %18
br label %34
23: ; preds = %16
%24 = getelementptr inbounds i8, i8* %9, i64 2
store i8 120, i8* %18
%25 = ashr i8 %6, 4
%26 = tail call i8* @hexDigit(i8 signext %25)
%27 = ptrtoint i8* %26 to i64
%28 = trunc i64 %27 to i8
%29 = getelementptr inbounds i8, i8* %9, i64 3
store i8 %28, i8* %24
%30 = tail call i8* @hexDigit(i8 signext %6)
%31 = ptrtoint i8* %30 to i64
%32 = trunc i64 %31 to i8
%33 = getelementptr inbounds i8, i8* %9, i64 4
store i8 %32, i8* %29
br label %34
34: ; preds = %19, %21, %23, %14
%35 = phi i8* [ %15, %14 ], [ %33, %23 ], [ %22, %21 ], [ %20, %19 ]
%36 = load i8, i8* %10
%37 = icmp ne i8 %36, 0
%38 = icmp ult i32 %8, 199
%39 = select i1 %37, i1 %38, i1 false
br i1 %39, label %5, label %40
40: ; preds = %34, %2
%41 = phi i8* [ getelementptr inbounds ([800 x i8], [800 x i8]* @fwriteStrEscaped.buffer, i64 0, i64 0), %2 ], [ %35, %34 ]
%42 = ptrtoint i8* %41 to i64
%43 = trunc i64 %42 to i32
%44 = sub i32 %43, ptrtoint ([800 x i8]* @fwriteStrEscaped.buffer to i32)
%45 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([800 x i8], [800 x i8]* @fwriteStrEscaped.buffer, i64 0, i64 0), i32 %44)
ret void
}