#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*/ repls;

/* Variables and functions */
scalar_t__ memcmp(char const *, char *, size_t);
void decode(char *s) {
  const char *src;
  char *dest;
  src = s;
  dest = s;
  while (*src != '\0') {
    if (*src != '\\')
      *dest = *src++;
    else {
      static const struct repl {
        char orig[4];
        size_t len;
        char new;
      } repls[] = {{"\\", sizeof("\\") - 1, '\\'},
                   {"011", sizeof("011") - 1, '\t'},
                   {"012", sizeof("012") - 1, '\n'},
                   {"040", sizeof("040") - 1, ' '},
                   {"134", sizeof("134") - 1, '\\'}};
      size_t i;
      for (i = 0; i < sizeof(repls) / sizeof(repls[0]); i++) {
        if (memcmp(src + 1, repls[i].orig, repls[i].len) == 0) {
          *dest = repls[i].new;
          src += 1 + repls[i].len;
          goto found;
        }
      }
      *dest = *src++;
    found:;
    }
    dest++;
  }
  *dest = '\0';
}


x86 assembly (clang, -O0):
<decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1233 <decode+0x123>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     1168 <decode+0x58>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
jmp    1222 <decode+0x112>
movq   $0x0,-0x20(%rbp)
cmpq   $0x5,-0x20(%rbp)
jae    1206 <decode+0xf6>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xe76(%rip),%rsi
imul   $0x18,-0x20(%rbp),%rax
add    %rax,%rsi
lea    0xe67(%rip),%rax
imul   $0x18,-0x20(%rbp),%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    11f0 <decode+0xe0>
lea    0xe45(%rip),%rax
imul   $0x18,-0x20(%rbp),%rcx
add    %rcx,%rax
mov    0x10(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
lea    0xe2d(%rip),%rax
imul   $0x18,-0x20(%rbp),%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
add    $0x1,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    121d <decode+0x10d>
jmp    11f5 <decode+0xe5>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1170 <decode+0x60>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
jmp    1222 <decode+0x112>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <decode+0x1c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xedb(%rip),%r15
mov    %rdi,%r13
jmp    1148 <decode+0x38>
mov    $0x2,%r12d
xor    %r14d,%r14d
lea    (%r14,%r14,2),%rax
movzbl 0x10(%r15,%rax,8),%eax
mov    %al,0x0(%r13)
add    %r12,%rbx
add    $0x1,%r13
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     1170 <decode+0x60>
test   %al,%al
je     1237 <decode+0x127>
add    $0x1,%rbx
mov    %al,0x0(%r13)
add    $0x1,%r13
jmp    1148 <decode+0x38>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbx),%rbp
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <memcmp@plt>
test   %rax,%rax
je     112a <decode+0x1a>
mov    $0x3,%edx
mov    %rbp,%rdi
lea    0xe80(%rip),%rsi
call   1030 <memcmp@plt>
mov    $0x4,%r12d
test   %rax,%rax
je     1210 <decode+0x100>
mov    $0x3,%edx
mov    %rbp,%rdi
lea    0xe79(%rip),%rsi
call   1030 <memcmp@plt>
test   %rax,%rax
je     121b <decode+0x10b>
mov    $0x3,%r14d
mov    $0x3,%edx
mov    %rbp,%rdi
lea    0xe72(%rip),%rsi
call   1030 <memcmp@plt>
test   %rax,%rax
je     1133 <decode+0x23>
mov    $0x3,%edx
mov    %rbp,%rdi
lea    0xe6d(%rip),%rsi
call   1030 <memcmp@plt>
test   %rax,%rax
je     1226 <decode+0x116>
movzbl (%rbx),%eax
mov    %al,0x0(%r13)
add    $0x1,%r13
mov    %rbp,%rbx
jmp    1148 <decode+0x38>
mov    $0x1,%r14d
jmp    1133 <decode+0x23>
mov    $0x2,%r14d
jmp    1133 <decode+0x23>
mov    $0x4,%r14d
mov    $0x4,%r12d
jmp    1133 <decode+0x23>
movb   $0x0,0x0(%r13)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.repl = type { [4 x i8], i64, i8 }
@decode.repls = internal constant [5 x %struct.repl] [%struct.repl { [4 x i8] c"\\\00\00\00", i64 1, i8 92 }, %struct.repl { [4 x i8] c"011\00", i64 3, i8 9 }, %struct.repl { [4 x i8] c"012\00", i64 3, i8 10 }, %struct.repl { [4 x i8] c"040\00", i64 3, i8 32 }, %struct.repl { [4 x i8] c"134\00", i64 3, i8 92 }]
define void @decode(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %3
%7 = load i8*, i8** %2
store i8* %7, i8** %4
br label %8
8: ; preds = %63, %1
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %66
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 92
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
%21 = load i8, i8* %19
%22 = load i8*, i8** %4
store i8 %21, i8* %22
br label %63
23: ; preds = %13
store i64 0, i64* %5
br label %24
24: ; preds = %54, %23
%25 = load i64, i64* %5
%26 = icmp ult i64 %25, 5
br i1 %26, label %27, label %57
27: ; preds = %24
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i64, i64* %5
%31 = getelementptr inbounds [5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 %30
%32 = getelementptr inbounds %struct.repl, %struct.repl* %31, i32 0, i32 0
%33 = getelementptr inbounds [4 x i8], [4 x i8]* %32, i64 0, i64 0
%34 = load i64, i64* %5
%35 = getelementptr inbounds [5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 %34
%36 = getelementptr inbounds %struct.repl, %struct.repl* %35, i32 0, i32 1
%37 = load i64, i64* %36
%38 = call i64 @memcmp(i8* %29, i8* %33, i64 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %53
40: ; preds = %27
%41 = load i64, i64* %5
%42 = getelementptr inbounds [5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 %41
%43 = getelementptr inbounds %struct.repl, %struct.repl* %42, i32 0, i32 2
%44 = load i8, i8* %43
%45 = load i8*, i8** %4
store i8 %44, i8* %45
%46 = load i64, i64* %5
%47 = getelementptr inbounds [5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 %46
%48 = getelementptr inbounds %struct.repl, %struct.repl* %47, i32 0, i32 1
%49 = load i64, i64* %48
%50 = add i64 1, %49
%51 = load i8*, i8** %3
%52 = getelementptr inbounds i8, i8* %51, i64 %50
store i8* %52, i8** %3
br label %62
53: ; preds = %27
br label %54
54: ; preds = %53
%55 = load i64, i64* %5
%56 = add i64 %55, 1
store i64 %56, i64* %5
br label %24
57: ; preds = %24
%58 = load i8*, i8** %3
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %3
%60 = load i8, i8* %58
%61 = load i8*, i8** %4
store i8 %60, i8* %61
br label %62
62: ; preds = %57, %40
br label %63
63: ; preds = %62, %18
%64 = load i8*, i8** %4
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %4
br label %8
66: ; preds = %8
%67 = load i8*, i8** %4
store i8 0, i8* %67
ret void
}

LLVM IR (-O2):
%struct.repl = type { [4 x i8], i64, i8 }
@decode.repls = internal constant [5 x %struct.repl] [%struct.repl { [4 x i8] c"\\\00\00\00", i64 1, i8 92 }, %struct.repl { [4 x i8] c"011\00", i64 3, i8 9 }, %struct.repl { [4 x i8] c"012\00", i64 3, i8 10 }, %struct.repl { [4 x i8] c"040\00", i64 3, i8 32 }, %struct.repl { [4 x i8] c"134\00", i64 3, i8 92 }]
define void @decode(i8* %0) {
br label %2
2: ; preds = %32, %1
%3 = phi i8* [ %0, %1 ], [ %33, %32 ]
%4 = phi i8* [ %0, %1 ], [ %34, %32 ]
%5 = load i8, i8* %3
switch i8 %5, label %10 [
i8 0, label %35
i8 92, label %6
]
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %3, i64 1
%8 = tail call i64 @memcmp(i8* %7, i8* getelementptr inbounds ([5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 0, i32 0, i64 0), i64 1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %18
10: ; preds = %2
%11 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %5, i8* %4
br label %32
12: ; preds = %27, %24, %21, %18, %6
%13 = phi i64 [ 0, %6 ], [ 1, %18 ], [ 2, %21 ], [ 3, %24 ], [ 4, %27 ]
%14 = phi i64 [ 2, %6 ], [ 4, %18 ], [ 4, %21 ], [ 4, %24 ], [ 4, %27 ]
%15 = getelementptr inbounds [5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 %13, i32 2
%16 = load i8, i8* %15
store i8 %16, i8* %4
%17 = getelementptr inbounds i8, i8* %3, i64 %14
br label %32
18: ; preds = %6
%19 = tail call i64 @memcmp(i8* %7, i8* getelementptr inbounds ([5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 1, i32 0, i64 0), i64 3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %12, label %21
21: ; preds = %18
%22 = tail call i64 @memcmp(i8* %7, i8* getelementptr inbounds ([5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 2, i32 0, i64 0), i64 3)
%23 = icmp eq i64 %22, 0
br i1 %23, label %12, label %24
24: ; preds = %21
%25 = tail call i64 @memcmp(i8* %7, i8* getelementptr inbounds ([5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 3, i32 0, i64 0), i64 3)
%26 = icmp eq i64 %25, 0
br i1 %26, label %12, label %27
27: ; preds = %24
%28 = tail call i64 @memcmp(i8* %7, i8* getelementptr inbounds ([5 x %struct.repl], [5 x %struct.repl]* @decode.repls, i64 0, i64 4, i32 0, i64 0), i64 3)
%29 = icmp eq i64 %28, 0
br i1 %29, label %12, label %30
30: ; preds = %27
%31 = load i8, i8* %3
store i8 %31, i8* %4
br label %32
32: ; preds = %12, %30, %10
%33 = phi i8* [ %11, %10 ], [ %17, %12 ], [ %7, %30 ]
%34 = getelementptr inbounds i8, i8* %4, i64 1
br label %2
35: ; preds = %2
store i8 0, i8* %4
ret void
}