#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 */
int /*<<< orphan*/ safe_copy_chr(char, char *, char **, int);
void safe_copy_esccode(char **s, char *buff, char **bufc) {
  safe_copy_chr((**s), (buff), (bufc), (8192 - 1));
  ++(*s);
  if (**s == '[') {
    do {
      safe_copy_chr((**s), (buff), (bufc), (8192 - 1));
      ++(*s);
    } while ((**s & 0xf0) == 0x30);
  }
  while ((**s & 0xf0) == 0x20) {
    safe_copy_chr((**s), (buff), (bufc), (8192 - 1));
    ++(*s);
  }
  if (**s) {
    safe_copy_chr((**s), (buff), (bufc), (8192 - 1));
    ++(*s);
  }
}


x86 assembly (clang, -O0):
<safe_copy_esccode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1fff,%ecx
movsbl %al,%edi
call   1030 <safe_copy_chr@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    11b1 <safe_copy_esccode+0xa1>
jmp    1168 <safe_copy_esccode+0x58>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1fff,%ecx
movsbl %al,%edi
call   1030 <safe_copy_chr@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
and    $0xf0,%eax
cmp    $0x30,%eax
je     1168 <safe_copy_esccode+0x58>
jmp    11b1 <safe_copy_esccode+0xa1>
jmp    11b6 <safe_copy_esccode+0xa6>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
and    $0xf0,%eax
cmp    $0x20,%eax
jne    11ff <safe_copy_esccode+0xef>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1fff,%ecx
movsbl %al,%edi
call   1030 <safe_copy_chr@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    11b6 <safe_copy_esccode+0xa6>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
je     123b <safe_copy_esccode+0x12b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1fff,%ecx
movsbl %al,%edi
call   1030 <safe_copy_chr@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safe_copy_esccode>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rdi),%rax
movsbl (%rax),%edi
mov    $0x1fff,%ecx
call   1030 <safe_copy_chr@plt>
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
mov    0x1(%rax),%al
cmp    $0x5b,%al
jne    11a1 <safe_copy_esccode+0x91>
mov    $0x5b,%al
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x1fff,%ecx
call   1030 <safe_copy_chr@plt>
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
movzbl 0x1(%rax),%eax
mov    %eax,%ecx
and    $0xf0,%cl
cmp    $0x30,%cl
je     1150 <safe_copy_esccode+0x40>
jmp    11a1 <safe_copy_esccode+0x91>
nopl   (%rax)
movsbl %al,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x1fff,%ecx
call   1030 <safe_copy_chr@plt>
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
movzbl 0x1(%rax),%eax
mov    %eax,%ecx
and    $0xf0,%cl
cmp    $0x20,%cl
je     1180 <safe_copy_esccode+0x70>
test   %al,%al
je     11c6 <safe_copy_esccode+0xb6>
movsbl %al,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x1fff,%ecx
call   1030 <safe_copy_chr@plt>
addq   $0x1,(%rbx)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @safe_copy_esccode(i8** nocapture %0, i8* %1, i8** %2) {
%4 = load i8*, i8** %0
%5 = load i8, i8* %4
%6 = tail call i32 @safe_copy_chr(i8 signext %5, i8* %1, i8** %2, i32 8191)
%7 = load i8*, i8** %0
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %8, i8** %0
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 91
br i1 %10, label %11, label %19
11: ; preds = %3, %11
%12 = phi i8 [ %16, %11 ], [ 91, %3 ]
%13 = tail call i32 @safe_copy_chr(i8 signext %12, i8* %1, i8** %2, i32 8191)
%14 = load i8*, i8** %0
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8* %15, i8** %0
%16 = load i8, i8* %15
%17 = and i8 %16, -16
%18 = icmp eq i8 %17, 48
br i1 %18, label %11, label %19
19: ; preds = %11, %3
%20 = phi i8 [ %9, %3 ], [ %16, %11 ]
%21 = and i8 %20, -16
%22 = icmp eq i8 %21, 32
br i1 %22, label %23, label %31
23: ; preds = %19, %23
%24 = phi i8 [ %28, %23 ], [ %20, %19 ]
%25 = tail call i32 @safe_copy_chr(i8 signext %24, i8* %1, i8** %2, i32 8191)
%26 = load i8*, i8** %0
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %0
%28 = load i8, i8* %27
%29 = and i8 %28, -16
%30 = icmp eq i8 %29, 32
br i1 %30, label %23, label %31
31: ; preds = %23, %19
%32 = phi i8 [ %20, %19 ], [ %28, %23 ]
%33 = icmp eq i8 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %31
%35 = tail call i32 @safe_copy_chr(i8 signext %32, i8* %1, i8** %2, i32 8191)
%36 = load i8*, i8** %0
%37 = getelementptr inbounds i8, i8* %36, i64 1
store i8* %37, i8** %0
br label %38
38: ; preds = %34, %31
ret void
}