#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*/ isspace(char);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ strcpy(char *, char *);
void picolEscape(char *str) {
  char buf[1024], *cp, *cp2;
  int ichar;
  for (cp = str, cp2 = buf; *cp; cp++) {
    if (*cp == '\\') {
      switch (*(cp + 1)) {
      case 'n':
        *cp2++ = '\n';
        cp++;
        break;
      case 'r':
        *cp2++ = '\r';
        cp++;
        break;
      case 't':
        *cp2++ = '\t';
        cp++;
        break;
      case 'x':
        sscanf(cp + 2, "%x", &ichar);
        *cp2++ = (char)ichar & 0xFF;
        cp += 3;
        break;
      case '\\':
        *cp2++ = '\\';
        cp++;
        break;
      case '\n':
        cp += 2;
        while (isspace(*cp))
          cp++;
        cp--;
        break;
      default:;
      }
    } else
      *cp2++ = *cp;
  }
  *cp2 = '\0';
  strcpy(str, buf);
}


x86 assembly (clang, -O0):
<picolEscape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0x418(%rbp),%rax
cmpb   $0x0,(%rax)
je     13b4 <picolEscape+0x284>
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1378 <picolEscape+0x248>
mov    -0x418(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x428(%rbp)
sub    $0xa,%eax
je     1316 <picolEscape+0x1e6>
jmp    119a <picolEscape+0x6a>
mov    -0x428(%rbp),%eax
sub    $0x5c,%eax
je     12e7 <picolEscape+0x1b7>
jmp    11ae <picolEscape+0x7e>
mov    -0x428(%rbp),%eax
sub    $0x6e,%eax
je     11fe <picolEscape+0xce>
jmp    11c2 <picolEscape+0x92>
mov    -0x428(%rbp),%eax
sub    $0x72,%eax
je     122d <picolEscape+0xfd>
jmp    11d6 <picolEscape+0xa6>
mov    -0x428(%rbp),%eax
sub    $0x74,%eax
je     125c <picolEscape+0x12c>
jmp    11ea <picolEscape+0xba>
mov    -0x428(%rbp),%eax
sub    $0x78,%eax
je     128b <picolEscape+0x15b>
jmp    136e <picolEscape+0x23e>
mov    -0x420(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x420(%rbp)
movb   $0xa,(%rax)
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    1373 <picolEscape+0x243>
mov    -0x420(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x420(%rbp)
movb   $0xd,(%rax)
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    1373 <picolEscape+0x243>
mov    -0x420(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x420(%rbp)
movb   $0x9,(%rax)
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    1373 <picolEscape+0x243>
mov    -0x418(%rbp),%rdi
add    $0x2,%rdi
lea    0xd63(%rip),%rsi
lea    -0x424(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x424(%rbp),%eax
movsbl %al,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x420(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x420(%rbp)
mov    %cl,(%rax)
mov    -0x418(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x418(%rbp)
jmp    1373 <picolEscape+0x243>
mov    -0x420(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x420(%rbp)
movb   $0x5c,(%rax)
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    1373 <picolEscape+0x243>
mov    -0x418(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
je     1357 <picolEscape+0x227>
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    1328 <picolEscape+0x1f8>
mov    -0x418(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x418(%rbp)
jmp    1373 <picolEscape+0x243>
jmp    1373 <picolEscape+0x243>
jmp    1398 <picolEscape+0x268>
mov    -0x418(%rbp),%rax
mov    (%rax),%cl
mov    -0x420(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x420(%rbp)
mov    %cl,(%rax)
jmp    139d <picolEscape+0x26d>
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    1158 <picolEscape+0x28>
mov    -0x420(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<picolEscape>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rdi,%r12
lea    0x10(%rsp),%rbx
lea    0xeb0(%rip),%r13
lea    0xf1d(%rip),%r14
lea    0xc(%rsp),%r15
mov    %rdi,%rbp
jmp    116f <picolEscape+0x3f>
movb   $0xa,(%rbx)
add    $0x1,%rbx
mov    %rax,%rbp
add    $0x1,%rbp
mov    0x0(%rbp),%al
cmp    $0x5c,%al
je     1190 <picolEscape+0x60>
test   %al,%al
je     1203 <picolEscape+0xd3>
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0x1,%rbp
jmp    116f <picolEscape+0x3f>
nopw   0x0(%rax,%rax,1)
movsbl 0x1(%rbp),%eax
lea    -0x5c(%rax),%ecx
cmp    $0x1c,%ecx
ja     11af <picolEscape+0x7f>
lea    0x1(%rbp),%rax
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
movb   $0x5c,(%rbx)
jmp    1164 <picolEscape+0x34>
cmp    $0xa,%eax
jne    11fa <picolEscape+0xca>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x2(%rbp),%edi
call   1040 <isspace@plt>
add    $0x1,%rbp
test   %eax,%eax
jne    11c0 <picolEscape+0x90>
jmp    11fa <picolEscape+0xca>
movb   $0xd,(%rbx)
jmp    1164 <picolEscape+0x34>
movb   $0x9,(%rbx)
jmp    1164 <picolEscape+0x34>
lea    0x2(%rbp),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%al
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0x3,%rbp
add    $0x1,%rbp
jmp    116f <picolEscape+0x3f>
movb   $0x0,(%rbx)
lea    0x10(%rsp),%rsi
mov    %r12,%rdi
call   1030 <strcpy@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%x\00"
define void @picolEscape(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
store i8* %7, i8** %4
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8* %8, i8** %5
br label %9
9: ; preds = %78, %1
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %81
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 92
br i1 %17, label %18, label %72
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %70 [
i32 110, label %23
i32 114, label %28
i32 116, label %33
i32 120, label %38
i32 92, label %51
i32 10, label %56
]
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %5
store i8 10, i8* %24
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
br label %71
28: ; preds = %18
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %5
store i8 13, i8* %29
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
br label %71
33: ; preds = %18
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
store i8 9, i8* %34
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %4
br label %71
38: ; preds = %18
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%42 = load i32, i32* %6
%43 = trunc i32 %42 to i8
%44 = sext i8 %43 to i32
%45 = and i32 %44, 255
%46 = trunc i32 %45 to i8
%47 = load i8*, i8** %5
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %5
store i8 %46, i8* %47
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i64 3
store i8* %50, i8** %4
br label %71
51: ; preds = %18
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %5
store i8 92, i8* %52
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %4
br label %71
56: ; preds = %18
%57 = load i8*, i8** %4
%58 = getelementptr inbounds i8, i8* %57, i64 2
store i8* %58, i8** %4
br label %59
59: ; preds = %64, %56
%60 = load i8*, i8** %4
%61 = load i8, i8* %60
%62 = call i32 @isspace(i8 signext %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = load i8*, i8** %4
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %4
br label %59
67: ; preds = %59
%68 = load i8*, i8** %4
%69 = getelementptr inbounds i8, i8* %68, i32 -1
store i8* %69, i8** %4
br label %71
70: ; preds = %18
br label %71
71: ; preds = %70, %67, %51, %38, %33, %28, %23
br label %77
72: ; preds = %13
%73 = load i8*, i8** %4
%74 = load i8, i8* %73
%75 = load i8*, i8** %5
%76 = getelementptr inbounds i8, i8* %75, i32 1
store i8* %76, i8** %5
store i8 %74, i8* %75
br label %77
77: ; preds = %72, %71
br label %78
78: ; preds = %77
%79 = load i8*, i8** %4
%80 = getelementptr inbounds i8, i8* %79, i32 1
store i8* %80, i8** %4
br label %9
81: ; preds = %9
%82 = load i8*, i8** %5
store i8 0, i8* %82
%83 = load i8*, i8** %2
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%85 = call i32 @strcpy(i8* %83, i8* %84)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
define void @picolEscape(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
br label %6
6: ; preds = %41, %1
%7 = phi i8* [ %0, %1 ], [ %44, %41 ]
%8 = phi i8* [ %4, %1 ], [ %43, %41 ]
%9 = load i8, i8* %7
switch i8 %9, label %39 [
i8 0, label %45
i8 92, label %10
]
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
switch i32 %13, label %41 [
i32 110, label %14
i32 114, label %16
i32 116, label %18
i32 120, label %20
i32 92, label %27
i32 10, label %29
]
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %8, i64 1
store i8 10, i8* %8
br label %41
16: ; preds = %10
%17 = getelementptr inbounds i8, i8* %8, i64 1
store i8 13, i8* %8
br label %41
18: ; preds = %10
%19 = getelementptr inbounds i8, i8* %8, i64 1
store i8 9, i8* %8
br label %41
20: ; preds = %10
%21 = getelementptr inbounds i8, i8* %7, i64 2
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %3
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %24, i8* %8
%26 = getelementptr inbounds i8, i8* %7, i64 3
br label %41
27: ; preds = %10
%28 = getelementptr inbounds i8, i8* %8, i64 1
store i8 92, i8* %8
br label %41
29: ; preds = %10
%30 = getelementptr inbounds i8, i8* %7, i64 2
br label %31
31: ; preds = %31, %29
%32 = phi i8* [ %30, %29 ], [ %36, %31 ]
%33 = load i8, i8* %32
%34 = call i32 @isspace(i8 signext %33)
%35 = icmp eq i32 %34, 0
%36 = getelementptr inbounds i8, i8* %32, i64 1
br i1 %35, label %37, label %31
37: ; preds = %31
%38 = getelementptr inbounds i8, i8* %32, i64 -1
br label %41
39: ; preds = %6
%40 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %9, i8* %8
br label %41
41: ; preds = %39, %10, %37, %27, %20, %18, %16, %14
%42 = phi i8* [ %7, %10 ], [ %38, %37 ], [ %11, %27 ], [ %26, %20 ], [ %11, %18 ], [ %11, %16 ], [ %11, %14 ], [ %7, %39 ]
%43 = phi i8* [ %8, %10 ], [ %8, %37 ], [ %28, %27 ], [ %25, %20 ], [ %19, %18 ], [ %17, %16 ], [ %15, %14 ], [ %40, %39 ]
%44 = getelementptr inbounds i8, i8* %42, i64 1
br label %6
45: ; preds = %6
store i8 0, i8* %8
%46 = call i32 @strcpy(i8* %0, i8* %4)
ret void
}