#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*/ printf(char *, ...);
void escape_rev(char dest[], char source[], int n) {
  int i = 0, j = 0;
  while (i < n) {
    switch (source[i]) {
    case '\\':
      i++;
      switch (source[i]) {
      case 'n':
        dest[j] = '\n';
        break;
      case 't':
        dest[j] = '\t';
        break;
      default:
        dest[j] = source[i];
        break;
      }
      break;
    default:
      dest[j] = source[i];
      break;
    }
    i++;
    j++;
  }
  dest[j] = source[i];
  printf("\n****************************************************\nFunc "
         "escape-rev\n****************************************************\n");
  printf("\nSource String:%s", source);
  printf("\nDestination String:%s\n", dest);
}


x86 assembly (clang, -O0):
<escape_rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f6 <escape_rev+0xe6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
sub    $0x5c,%al
jne    11c9 <escape_rev+0xb9>
jmp    1155 <escape_rev+0x45>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
sub    $0x6e,%eax
je     118c <escape_rev+0x7c>
jmp    117b <escape_rev+0x6b>
mov    -0x20(%rbp),%eax
sub    $0x74,%eax
je     119d <escape_rev+0x8d>
jmp    11ae <escape_rev+0x9e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
jmp    11c4 <escape_rev+0xb4>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x9,(%rax,%rcx,1)
jmp    11c4 <escape_rev+0xb4>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11df <escape_rev+0xcf>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <escape_rev+0x21>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escape_rev>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
xor    %ecx,%ecx
test   %edx,%edx
jg     114f <escape_rev+0x2f>
jmp    117d <escape_rev+0x5d>
mov    $0xa,%bl
nopw   0x0(%rax,%rax,1)
mov    %bl,(%r14,%rcx,1)
add    $0x1,%eax
add    $0x1,%rcx
cmp    %edx,%eax
jge    1179 <escape_rev+0x59>
movslq %eax,%rsi
movzbl (%r15,%rsi,1),%ebx
cmp    $0x5c,%bl
jne    1140 <escape_rev+0x20>
movzbl 0x1(%r15,%rsi,1),%ebx
add    $0x1,%rsi
mov    %esi,%eax
movsbl %bl,%esi
cmp    $0x6e,%esi
je     1135 <escape_rev+0x15>
cmp    $0x74,%esi
jne    1140 <escape_rev+0x20>
mov    $0x9,%bl
jmp    1140 <escape_rev+0x20>
cltq
mov    %ecx,%ecx
mov    (%r15,%rax,1),%al
mov    %al,(%r14,%rcx,1)
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe68(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [124 x i8] c"\0A****************************************************\0AFunc escape-rev\0A****************************************************\0A\00"
@.str.1 = [18 x i8] c"\0ASource String:%s\00"
@.str.2 = [24 x i8] c"\0ADestination String:%s\0A\00"
define void @escape_rev(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %60, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %65
13: ; preds = %9
%14 = load i8*, i8** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %50 [
i32 92, label %20
]
20: ; preds = %13
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
%23 = load i8*, i8** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
switch i32 %28, label %39 [
i32 110, label %29
i32 116, label %34
]
29: ; preds = %20
%30 = load i8*, i8** %4
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 10, i8* %33
br label %49
34: ; preds = %20
%35 = load i8*, i8** %4
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 9, i8* %38
br label %49
39: ; preds = %20
%40 = load i8*, i8** %5
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = load i8*, i8** %4
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
store i8 %44, i8* %48
br label %49
49: ; preds = %39, %34, %29
br label %60
50: ; preds = %13
%51 = load i8*, i8** %5
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = load i8*, i8** %4
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 %55, i8* %59
br label %60
60: ; preds = %50, %49
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
store i32 %64, i32* %8
br label %9
65: ; preds = %9
%66 = load i8*, i8** %5
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
%70 = load i8, i8* %69
%71 = load i8*, i8** %4
%72 = load i32, i32* %8
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
store i8 %70, i8* %74
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str, i64 0, i64 0))
%76 = load i8*, i8** %5
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %76)
%78 = load i8*, i8** %4
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %78)
ret void
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"\0ASource String:%s\00"
@.str.2 = [24 x i8] c"\0ADestination String:%s\0A\00"
@str = [123 x i8] c"\0A****************************************************\0AFunc escape-rev\0A****************************************************\00"
define void @escape_rev(i8* %0, i8* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %30
5: ; preds = %3, %20
%6 = phi i64 [ %25, %20 ], [ 0, %3 ]
%7 = phi i32 [ %24, %20 ], [ 0, %3 ]
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 92
br i1 %11, label %12, label %20
12: ; preds = %5
%13 = add nsw i32 %7, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %19 [
i32 110, label %20
i32 116, label %18
]
18: ; preds = %12
br label %20
19: ; preds = %12
br label %20
20: ; preds = %5, %12, %18, %19
%21 = phi i8 [ 9, %18 ], [ %16, %19 ], [ 10, %12 ], [ %10, %5 ]
%22 = phi i32 [ %13, %18 ], [ %13, %19 ], [ %13, %12 ], [ %7, %5 ]
%23 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %21, i8* %23
%24 = add nsw i32 %22, 1
%25 = add nuw i64 %6, 1
%26 = icmp slt i32 %24, %2
br i1 %26, label %5, label %27
27: ; preds = %20
%28 = sext i32 %24 to i64
%29 = and i64 %25, 4294967295
br label %30
30: ; preds = %27, %3
%31 = phi i64 [ 0, %3 ], [ %28, %27 ]
%32 = phi i64 [ 0, %3 ], [ %29, %27 ]
%33 = getelementptr inbounds i8, i8* %1, i64 %31
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 %34, i8* %35
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([123 x i8], [123 x i8]* @str, i64 0, i64 0))
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %0)
ret void
}