#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*/ assert(int);
int re_byte(char **, int, int, int, int);
int /*<<< orphan*/ re_escape_utf8(char **, int);
char *re_escape(char *s, int liberal) {
  char *in = s, *out = s;
  int c;
  while ((c = *in++)) {
    int u = 0;
    if ('\\' == c) {
      c = *in++;
      switch (c) {
      case '0':
      case '1':
        c = re_byte(&in, 1, 3, 8, liberal);
        break;
      case '\\':
        c = '\\';
        break;
      case 'a':
        c = '\a';
        break;
      case 'b':
        c = '\b';
        break;
      case 'f':
        c = '\f';
        break;
      case 'n':
        c = '\n';
        break;
      case 'r':
        c = '\r';
        break;
      case 't':
        c = '\t';
        break;
      case 'U':
        c = re_byte(&in, 8, 8, 16, liberal);
        u = 1;
        break;
      case 'u':
        c = re_byte(&in, 4, 4, 16, liberal);
        u = 1;
        break;
      case 'v':
        c = '\v';
        break;
      case 'x':
        c = re_byte(&in, 1, 2, 16, liberal);
        break;
      default: {
        if (!liberal) {
          --in;
          c = '\\';
        }
        break;
      }
      }
    }
    if (u)
      re_escape_utf8(&out, c);
    else
      *out++ = c;
  }
  assert(out <= in);
  *out = 0;
  return s;
}


x86 assembly (clang, -O0):
<re_escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     1315 <re_escape+0x1e5>
movl   $0x0,-0x28(%rbp)
mov    $0x5c,%eax
cmp    -0x24(%rbp),%eax
jne    12df <re_escape+0x1af>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x48,%eax
ja     12b8 <re_escape+0x188>
mov    -0x30(%rbp),%rax
lea    0xe49(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%r8d
lea    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x8,%ecx
call   1040 <re_byte@plt>
mov    %eax,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
movl   $0x5c,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
movl   $0x7,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
movl   $0x8,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
movl   $0xc,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
movl   $0xa,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
movl   $0xd,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
movl   $0x9,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
mov    -0xc(%rbp),%r8d
lea    -0x18(%rbp),%rdi
mov    $0x8,%edx
mov    $0x10,%ecx
mov    %edx,%esi
call   1040 <re_byte@plt>
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    12da <re_escape+0x1aa>
mov    -0xc(%rbp),%r8d
lea    -0x18(%rbp),%rdi
mov    $0x4,%edx
mov    $0x10,%ecx
mov    %edx,%esi
call   1040 <re_byte@plt>
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    12da <re_escape+0x1aa>
movl   $0xb,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
mov    -0xc(%rbp),%r8d
lea    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x10,%ecx
call   1040 <re_byte@plt>
mov    %eax,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
cmpl   $0x0,-0xc(%rbp)
jne    12d5 <re_escape+0x1a5>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
movl   $0x5c,-0x24(%rbp)
jmp    12da <re_escape+0x1aa>
jmp    12df <re_escape+0x1af>
cmpl   $0x0,-0x28(%rbp)
je     12fa <re_escape+0x1ca>
mov    -0x24(%rbp),%esi
lea    -0x20(%rbp),%rdi
call   1030 <re_escape_utf8@plt>
jmp    1310 <re_escape+0x1e0>
mov    -0x24(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    114f <re_escape+0x1f>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<re_escape>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rdi,(%rsp)
lea    0x1(%rdi),%rcx
mov    %rcx,0x8(%rsp)
mov    (%rdi),%al
test   %al,%al
je     127d <re_escape+0x14d>
mov    %esi,%r12d
lea    0xea0(%rip),%rbp
lea    0x8(%rsp),%r14
mov    %rsp,%r15
mov    %rbx,%rdx
nopl   0x0(%rax,%rax,1)
cmp    $0x5c,%al
jne    11b0 <re_escape+0x80>
add    $0x2,%rdx
mov    %rdx,0x8(%rsp)
movsbl (%rcx),%eax
lea    -0x30(%rax),%edx
cmp    $0x48,%edx
ja     11db <re_escape+0xab>
movslq 0x0(%rbp,%rdx,4),%rdx
add    %rbp,%rdx
jmp    *%rdx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x8,%ecx
jmp    126a <re_escape+0x13a>
nopl   0x0(%rax)
movzbl %al,%eax
mov    (%rsp),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%rsp)
mov    %al,(%rcx)
mov    0x8(%rsp),%rdx
lea    0x1(%rdx),%rcx
mov    %rcx,0x8(%rsp)
movzbl (%rdx),%eax
test   %al,%al
jne    1170 <re_escape+0x40>
jmp    1277 <re_escape+0x147>
test   %r12d,%r12d
jne    11b3 <re_escape+0x83>
mov    %rcx,0x8(%rsp)
mov    $0x5c,%eax
jmp    11b3 <re_escape+0x83>
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x8,%edx
jmp    1232 <re_escape+0x102>
mov    $0x7,%eax
jmp    11b3 <re_escape+0x83>
mov    $0x8,%eax
jmp    11b3 <re_escape+0x83>
mov    $0xc,%eax
jmp    11b3 <re_escape+0x83>
mov    $0xa,%eax
jmp    11b3 <re_escape+0x83>
mov    $0xd,%eax
jmp    11b3 <re_escape+0x83>
mov    $0x9,%eax
jmp    11b3 <re_escape+0x83>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x4,%edx
mov    $0x10,%ecx
mov    %r12d,%r8d
call   1040 <re_byte@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <re_escape_utf8@plt>
jmp    11c1 <re_escape+0x91>
mov    $0xb,%eax
jmp    11b3 <re_escape+0x83>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x10,%ecx
mov    %r12d,%r8d
call   1040 <re_byte@plt>
jmp    11b3 <re_escape+0x83>
mov    (%rsp),%rax
jmp    1280 <re_escape+0x150>
mov    %rbx,%rax
xor    %edi,%edi
cmp    %rcx,%rax
setbe  %dil
call   1050 <assert@plt>
mov    (%rsp),%rax
movb   $0x0,(%rax)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @re_escape(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = load i8*, i8** %3
store i8* %9, i8** %5
%10 = load i8*, i8** %3
store i8* %10, i8** %6
br label %11
11: ; preds = %65, %2
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %5
%14 = load i8, i8* %12
%15 = sext i8 %14 to i32
store i32 %15, i32* %7
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %66
17: ; preds = %11
store i32 0, i32* %8
%18 = load i32, i32* %7
%19 = icmp eq i32 92, %18
br i1 %19, label %20, label %54
20: ; preds = %17
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %5
%23 = load i8, i8* %21
%24 = sext i8 %23 to i32
store i32 %24, i32* %7
%25 = load i32, i32* %7
switch i32 %25, label %46 [
i32 48, label %26
i32 49, label %26
i32 92, label %29
i32 97, label %30
i32 98, label %31
i32 102, label %32
i32 110, label %33
i32 114, label %34
i32 116, label %35
i32 85, label %36
i32 117, label %39
i32 118, label %42
i32 120, label %43
]
26: ; preds = %20, %20
%27 = load i32, i32* %4
%28 = call i32 @re_byte(i8** %5, i32 1, i32 3, i32 8, i32 %27)
store i32 %28, i32* %7
br label %53
29: ; preds = %20
store i32 92, i32* %7
br label %53
30: ; preds = %20
store i32 7, i32* %7
br label %53
31: ; preds = %20
store i32 8, i32* %7
br label %53
32: ; preds = %20
store i32 12, i32* %7
br label %53
33: ; preds = %20
store i32 10, i32* %7
br label %53
34: ; preds = %20
store i32 13, i32* %7
br label %53
35: ; preds = %20
store i32 9, i32* %7
br label %53
36: ; preds = %20
%37 = load i32, i32* %4
%38 = call i32 @re_byte(i8** %5, i32 8, i32 8, i32 16, i32 %37)
store i32 %38, i32* %7
store i32 1, i32* %8
br label %53
39: ; preds = %20
%40 = load i32, i32* %4
%41 = call i32 @re_byte(i8** %5, i32 4, i32 4, i32 16, i32 %40)
store i32 %41, i32* %7
store i32 1, i32* %8
br label %53
42: ; preds = %20
store i32 11, i32* %7
br label %53
43: ; preds = %20
%44 = load i32, i32* %4
%45 = call i32 @re_byte(i8** %5, i32 1, i32 2, i32 16, i32 %44)
store i32 %45, i32* %7
br label %53
46: ; preds = %20
%47 = load i32, i32* %4
%48 = icmp ne i32 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %46
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i32 -1
store i8* %51, i8** %5
store i32 92, i32* %7
br label %52
52: ; preds = %49, %46
br label %53
53: ; preds = %52, %43, %42, %39, %36, %35, %34, %33, %32, %31, %30, %29, %26
br label %54
54: ; preds = %53, %17
%55 = load i32, i32* %8
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32, i32* %7
%59 = call i32 @re_escape_utf8(i8** %6, i32 %58)
br label %65
60: ; preds = %54
%61 = load i32, i32* %7
%62 = trunc i32 %61 to i8
%63 = load i8*, i8** %6
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %6
store i8 %62, i8* %63
br label %65
65: ; preds = %60, %57
br label %11
66: ; preds = %11
%67 = load i8*, i8** %6
%68 = load i8*, i8** %5
%69 = icmp ule i8* %67, %68
%70 = zext i1 %69 to i32
%71 = call i32 @assert(i32 %70)
%72 = load i8*, i8** %6
store i8 0, i8* %72
%73 = load i8*, i8** %3
ret i8* %73
}

LLVM IR (-O2):
define i8* @re_escape(i8* returned %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %3 to i8*
%6 = bitcast i8** %4 to i8*
store i8* %0, i8** %4
%7 = getelementptr inbounds i8, i8* %0, i64 1
store i8* %7, i8** %3
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %54, label %10
10: ; preds = %2
%11 = icmp eq i32 %1, 0
br label %12
12: ; preds = %10, %47
%13 = phi i8 [ %8, %10 ], [ %50, %47 ]
%14 = phi i8* [ %7, %10 ], [ %49, %47 ]
%15 = phi i8* [ %0, %10 ], [ %48, %47 ]
%16 = zext i8 %13 to i32
%17 = icmp eq i8 %13, 92
br i1 %17, label %18, label %42
18: ; preds = %12
%19 = getelementptr inbounds i8, i8* %15, i64 2
store i8* %19, i8** %3
%20 = load i8, i8* %14
%21 = sext i8 %20 to i32
switch i32 %21, label %37 [
i32 48, label %22
i32 49, label %22
i32 92, label %42
i32 97, label %24
i32 98, label %25
i32 102, label %26
i32 110, label %27
i32 114, label %28
i32 116, label %29
i32 85, label %30
i32 117, label %32
i32 118, label %34
i32 120, label %35
]
22: ; preds = %18, %18
%23 = call i32 @re_byte(i8** %3, i32 1, i32 3, i32 8, i32 %1)
br label %42
24: ; preds = %18
br label %42
25: ; preds = %18
br label %42
26: ; preds = %18
br label %42
27: ; preds = %18
br label %42
28: ; preds = %18
br label %42
29: ; preds = %18
br label %42
30: ; preds = %18
%31 = call i32 @re_byte(i8** %3, i32 8, i32 8, i32 16, i32 %1)
br label %39
32: ; preds = %18
%33 = call i32 @re_byte(i8** %3, i32 4, i32 4, i32 16, i32 %1)
br label %39
34: ; preds = %18
br label %42
35: ; preds = %18
%36 = call i32 @re_byte(i8** %3, i32 1, i32 2, i32 16, i32 %1)
br label %42
37: ; preds = %18
br i1 %11, label %38, label %42
38: ; preds = %37
store i8* %14, i8** %3
br label %42
39: ; preds = %32, %30
%40 = phi i32 [ %33, %32 ], [ %31, %30 ]
%41 = call i32 @re_escape_utf8(i8** %4, i32 %40)
br label %47
42: ; preds = %37, %38, %35, %34, %29, %28, %27, %26, %25, %24, %22, %12, %18
%43 = phi i32 [ %21, %18 ], [ %16, %12 ], [ %23, %22 ], [ 7, %24 ], [ 8, %25 ], [ 12, %26 ], [ 10, %27 ], [ 13, %28 ], [ 9, %29 ], [ 11, %34 ], [ %36, %35 ], [ 92, %38 ], [ %21, %37 ]
%44 = trunc i32 %43 to i8
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 1
store i8* %46, i8** %4
store i8 %44, i8* %45
br label %47
47: ; preds = %42, %39
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i64 1
store i8* %49, i8** %3
%50 = load i8, i8* %48
%51 = icmp eq i8 %50, 0
br i1 %51, label %52, label %12
52: ; preds = %47
%53 = load i8*, i8** %4
br label %54
54: ; preds = %52, %2
%55 = phi i8* [ %0, %2 ], [ %53, %52 ]
%56 = phi i8* [ %7, %2 ], [ %49, %52 ]
%57 = icmp ule i8* %55, %56
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = load i8*, i8** %4
store i8 0, i8* %60
ret i8* %0
}