#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*/ fputs(char *, int /*<<< orphan*/ *);
void print_esc(FILE *p, char *s) {
  char buf[256];
  char *t;
  int i = 0;
  for (t = s; *t != '\0'; t++) {
    if (i > 250) {
      buf[i] = '\0';
      (void)fputs(buf, p);
      i = 0;
    }
    if (*t == '\\')
      buf[i++] = '\\';
    buf[i++] = *t;
  }
  if (i > 0) {
    buf[i] = '\0';
    (void)fputs(buf, p);
  }
}


x86 assembly (clang, -O0):
<print_esc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x11c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ec <print_esc+0xdc>
cmpl   $0xfa,-0x11c(%rbp)
jle    1184 <print_esc+0x74>
movslq -0x11c(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
movl   $0x0,-0x11c(%rbp)
mov    -0x118(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11b2 <print_esc+0xa2>
mov    -0x11c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x11c(%rbp)
cltq
movb   $0x5c,-0x110(%rbp,%rax,1)
5c
mov    -0x118(%rbp),%rax
mov    (%rax),%cl
mov    -0x11c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x11c(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x118(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x118(%rbp)
jmp    1138 <print_esc+0x28>
cmpl   $0x0,-0x11c(%rbp)
jle    1218 <print_esc+0x108>
movslq -0x11c(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_esc>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    (%rsi),%al
test   %al,%al
je     119a <print_esc+0x8a>
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x1,%rbx
xor    %ecx,%ecx
mov    %rsp,%r15
jmp    1156 <print_esc+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ecx,%edx
lea    0x1(%rdx),%ecx
movslq %edx,%rsi
mov    %al,(%rsp,%rsi,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1185 <print_esc+0x75>
cmp    $0xfb,%ecx
jl     1175 <print_esc+0x65>
mov    %ecx,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <fputs@plt>
movzbl -0x1(%rbx),%eax
xor    %ecx,%ecx
cmp    $0x5c,%al
jne    1140 <print_esc+0x30>
movslq %ecx,%rdx
add    $0x1,%ecx
movb   $0x5c,(%rsp,%rdx,1)
jmp    1140 <print_esc+0x30>
test   %edx,%edx
js     119a <print_esc+0x8a>
mov    %ecx,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
mov    %r14,%rsi
call   1030 <fputs@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @print_esc(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 0, i32* %7
%8 = load i8*, i8** %4
store i8* %8, i8** %6
br label %9
9: ; preds = %41, %2
%10 = load i8*, i8** %6
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %44
14: ; preds = %9
%15 = load i32, i32* %7
%16 = icmp sgt i32 %15, 250
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%22 = load i32*, i32** %3
%23 = call i32 @fputs(i8* %21, i32* %22)
store i32 0, i32* %7
br label %24
24: ; preds = %17, %14
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 92
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %32
store i8 92, i8* %33
br label %34
34: ; preds = %29, %24
%35 = load i8*, i8** %6
%36 = load i8, i8* %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %39
store i8 %36, i8* %40
br label %41
41: ; preds = %34
%42 = load i8*, i8** %6
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %6
br label %9
44: ; preds = %9
%45 = load i32, i32* %7
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %54
47: ; preds = %44
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %49
store i8 0, i8* %50
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%52 = load i32*, i32** %3
%53 = call i32 @fputs(i8* %51, i32* %52)
br label %54
54: ; preds = %47, %44
ret void
}

LLVM IR (-O2):
define void @print_esc(i32* nocapture %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %39, label %7
7: ; preds = %2, %25
%8 = phi i8 [ %31, %25 ], [ %5, %2 ]
%9 = phi i32 [ %27, %25 ], [ 0, %2 ]
%10 = phi i8* [ %30, %25 ], [ %1, %2 ]
%11 = icmp sgt i32 %9, 250
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = zext i32 %9 to i64
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %13
store i8 0, i8* %14
%15 = call i32 @fputs(i8* %4, i32* %0)
%16 = load i8, i8* %10
br label %17
17: ; preds = %12, %7
%18 = phi i8 [ %16, %12 ], [ %8, %7 ]
%19 = phi i32 [ 0, %12 ], [ %9, %7 ]
%20 = icmp eq i8 %18, 92
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = add nsw i32 %19, 1
%23 = sext i32 %19 to i64
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %23
store i8 92, i8* %24
br label %25
25: ; preds = %21, %17
%26 = phi i32 [ %22, %21 ], [ %19, %17 ]
%27 = add nsw i32 %26, 1
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %28
store i8 %18, i8* %29
%30 = getelementptr inbounds i8, i8* %10, i64 1
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %33, label %7
33: ; preds = %25
%34 = icmp sgt i32 %26, -1
br i1 %34, label %35, label %39
35: ; preds = %33
%36 = zext i32 %27 to i64
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %36
store i8 0, i8* %37
%38 = call i32 @fputs(i8* %4, i32* %0)
br label %39
39: ; preds = %2, %35, %33
ret void
}