#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*/ substr_replace(char **, int *, int *, int, int, char *, int);
void string_unescape(char **strp, int *strp_len, int *strp_size) {
  int i;
  char *repl;
  int repl_len;
  int orig_len;
  for (i = 0; i < *strp_len; i++) {
    repl_len = 0;
    orig_len = 0;
    if ((*strp)[i] == '\\') {
      switch ((*strp)[i + 1]) {
      case 't':
        repl = "\t";
        repl_len = 1;
        orig_len = 2;
        break;
      case 'n':
        repl = "\n";
        repl_len = 1;
        orig_len = 2;
        break;
      case 'b':
        repl = "\b";
        repl_len = 1;
        orig_len = 2;
        break;
      case 'r':
        repl = "\r";
        repl_len = 1;
        orig_len = 2;
        break;
      case 'a':
        repl = "\a";
        repl_len = 1;
        orig_len = 2;
        break;
      case 'f':
        repl = "\f";
        repl_len = 1;
        orig_len = 2;
        break;
      case 'v':
        repl = "\v";
        repl_len = 1;
        orig_len = 2;
        break;
      case '"':
        repl = "\"";
        repl_len = 1;
        orig_len = 2;
        break;
      }
      if (repl_len > 0) {
        substr_replace(strp, strp_len, strp_size, i, i + orig_len, repl,
                       repl_len);
      }
    }
  }
}


x86 assembly (clang, -O0):
<string_unescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    132b <string_unescape+0x21b>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    1318 <string_unescape+0x208>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
movslq -0x1c(%rbp),%rax
movsbl 0x1(%rax,%rcx,1),%eax
mov    %eax,-0x34(%rbp)
sub    $0x22,%eax
je     12ca <string_unescape+0x1ba>
jmp    1181 <string_unescape+0x71>
mov    -0x34(%rbp),%eax
sub    $0x61,%eax
je     1270 <string_unescape+0x160>
jmp    1192 <string_unescape+0x82>
mov    -0x34(%rbp),%eax
sub    $0x62,%eax
je     1234 <string_unescape+0x124>
jmp    11a3 <string_unescape+0x93>
mov    -0x34(%rbp),%eax
sub    $0x66,%eax
je     128e <string_unescape+0x17e>
jmp    11b4 <string_unescape+0xa4>
mov    -0x34(%rbp),%eax
sub    $0x6e,%eax
je     1216 <string_unescape+0x106>
jmp    11c5 <string_unescape+0xb5>
mov    -0x34(%rbp),%eax
sub    $0x72,%eax
je     1252 <string_unescape+0x142>
jmp    11d6 <string_unescape+0xc6>
mov    -0x34(%rbp),%eax
sub    $0x74,%eax
je     11f8 <string_unescape+0xe8>
jmp    11e7 <string_unescape+0xd7>
mov    -0x34(%rbp),%eax
sub    $0x76,%eax
je     12ac <string_unescape+0x19c>
jmp    12e3 <string_unescape+0x1d3>
lea    0xe01(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
jmp    12e3 <string_unescape+0x1d3>
lea    0xde5(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
jmp    12e3 <string_unescape+0x1d3>
lea    0xdc9(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
jmp    12e3 <string_unescape+0x1d3>
lea    0xdad(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
jmp    12e3 <string_unescape+0x1d3>
lea    0xd91(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
jmp    12e3 <string_unescape+0x1d3>
lea    0xd75(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
jmp    12e3 <string_unescape+0x1d3>
lea    0xd59(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
jmp    12e3 <string_unescape+0x1d3>
lea    0xd3d(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    1313 <string_unescape+0x203>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
add    -0x30(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    -0x2c(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <substr_replace@plt>
jmp    1318 <string_unescape+0x208>
jmp    131d <string_unescape+0x20d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <string_unescape+0x1b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_unescape>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rsi),%eax
test   %eax,%eax
jle    11dc <string_unescape+0xcc>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %ebp,%ebp
lea    0xf21(%rip),%r12
lea    0xec2(%rip),%r13
jmp    1174 <string_unescape+0x64>
lea    0xf1d(%rip),%r9
nopw   0x0(%rax,%rax,1)
lea    0x2(%rcx),%r8d
movl   $0x1,(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <substr_replace@plt>
mov    (%r15),%eax
movslq %eax,%rcx
cmp    %rcx,%rbp
jge    11dc <string_unescape+0xcc>
mov    %rbp,%rcx
mov    (%rbx),%rdx
add    $0x1,%rbp
cmpb   $0x5c,(%rdx,%rcx,1)
jne    116c <string_unescape+0x5c>
movsbl 0x1(%rdx,%rcx,1),%edx
lea    -0x61(%rdx),%esi
cmp    $0x15,%esi
ja     11a7 <string_unescape+0x97>
movslq 0x0(%r13,%rsi,4),%rdx
add    %r13,%rdx
mov    %r12,%r9
jmp    *%rdx
lea    0xebb(%rip),%r9
jmp    1150 <string_unescape+0x40>
cmp    $0x22,%edx
jne    116c <string_unescape+0x5c>
lea    0xeb3(%rip),%r9
jmp    1150 <string_unescape+0x40>
lea    0xea0(%rip),%r9
jmp    1150 <string_unescape+0x40>
lea    0xe9d(%rip),%r9
jmp    1150 <string_unescape+0x40>
lea    0xe8c(%rip),%r9
jmp    1150 <string_unescape+0x40>
lea    0xe87(%rip),%r9
jmp    1150 <string_unescape+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\09\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c"\08\00"
@.str.3 = [2 x i8] c"\0D\00"
@.str.4 = [2 x i8] c"\07\00"
@.str.5 = [2 x i8] c"\0C\00"
@.str.6 = [2 x i8] c"\0B\00"
@.str.7 = [2 x i8] c"\22\00"
define void @string_unescape(i8** %0, i32* %1, i32* %2) {
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8** %0, i8*** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
br label %11
11: ; preds = %58, %3
%12 = load i32, i32* %7
%13 = load i32*, i32** %5
%14 = load i32, i32* %13
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %61
16: ; preds = %11
store i32 0, i32* %9
store i32 0, i32* %10
%17 = load i8**, i8*** %4
%18 = load i8*, i8** %17
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 92
br i1 %24, label %25, label %57
25: ; preds = %16
%26 = load i8**, i8*** %4
%27 = load i8*, i8** %26
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
switch i32 %33, label %42 [
i32 116, label %34
i32 110, label %35
i32 98, label %36
i32 114, label %37
i32 97, label %38
i32 102, label %39
i32 118, label %40
i32 34, label %41
]
34: ; preds = %25
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8
store i32 1, i32* %9
store i32 2, i32* %10
br label %42
35: ; preds = %25
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %8
store i32 1, i32* %9
store i32 2, i32* %10
br label %42
36: ; preds = %25
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %8
store i32 1, i32* %9
store i32 2, i32* %10
br label %42
37: ; preds = %25
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %8
store i32 1, i32* %9
store i32 2, i32* %10
br label %42
38: ; preds = %25
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %8
store i32 1, i32* %9
store i32 2, i32* %10
br label %42
39: ; preds = %25
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %8
store i32 1, i32* %9
store i32 2, i32* %10
br label %42
40: ; preds = %25
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8** %8
store i32 1, i32* %9
store i32 2, i32* %10
br label %42
41: ; preds = %25
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8** %8
store i32 1, i32* %9
store i32 2, i32* %10
br label %42
42: ; preds = %25, %41, %40, %39, %38, %37, %36, %35, %34
%43 = load i32, i32* %9
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %56
45: ; preds = %42
%46 = load i8**, i8*** %4
%47 = load i32*, i32** %5
%48 = load i32*, i32** %6
%49 = load i32, i32* %7
%50 = load i32, i32* %7
%51 = load i32, i32* %10
%52 = add nsw i32 %50, %51
%53 = load i8*, i8** %8
%54 = load i32, i32* %9
%55 = call i32 @substr_replace(i8** %46, i32* %47, i32* %48, i32 %49, i32 %52, i8* %53, i32 %54)
br label %56
56: ; preds = %45, %42
br label %57
57: ; preds = %56, %16
br label %58
58: ; preds = %57
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %11
61: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\09\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c"\08\00"
@.str.3 = [2 x i8] c"\0D\00"
@.str.4 = [2 x i8] c"\07\00"
@.str.5 = [2 x i8] c"\0C\00"
@.str.6 = [2 x i8] c"\0B\00"
@.str.7 = [2 x i8] c"\22\00"
define void @string_unescape(i8** %0, i32* %1, i32* %2) {
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %35
6: ; preds = %3, %31
%7 = phi i32 [ %32, %31 ], [ %4, %3 ]
%8 = phi i64 [ %14, %31 ], [ 0, %3 ]
%9 = trunc i64 %8 to i32
%10 = load i8*, i8** %0
%11 = getelementptr inbounds i8, i8* %10, i64 %8
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 92
%14 = add nuw nsw i64 %8, 1
br i1 %13, label %15, label %31
15: ; preds = %6
%16 = getelementptr inbounds i8, i8* %10, i64 %14
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %31 [
i32 116, label %26
i32 110, label %19
i32 98, label %20
i32 114, label %21
i32 97, label %22
i32 102, label %23
i32 118, label %24
i32 34, label %25
]
19: ; preds = %15
br label %26
20: ; preds = %15
br label %26
21: ; preds = %15
br label %26
22: ; preds = %15
br label %26
23: ; preds = %15
br label %26
24: ; preds = %15
br label %26
25: ; preds = %15
br label %26
26: ; preds = %15, %25, %24, %23, %22, %21, %20, %19
%27 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %19 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %20 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %21 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %22 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %23 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), %24 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), %25 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %15 ]
%28 = add nuw nsw i32 %9, 2
%29 = tail call i32 @substr_replace(i8** %0, i32* %1, i32* %2, i32 %9, i32 %28, i8* %27, i32 1)
%30 = load i32, i32* %1
br label %31
31: ; preds = %6, %15, %26
%32 = phi i32 [ %7, %15 ], [ %30, %26 ], [ %7, %6 ]
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %14, %33
br i1 %34, label %6, label %35
35: ; preds = %31, %3
ret void
}