#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*/ escape(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ unescape(char *, char *);
int main(void) {
  char text1[50] = "\aHello,\n\tWorld! Mistakee\b was \"Extra 'e'\"!\n";
  char text2[51];
  printf("Original string:\n%s\n", text1);
  escape(text2, text1);
  printf("Escaped string:\n%s\n", text2);
  unescape(text1, text2);
  printf("Unescaped string:\n%s\n", text1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x32,%edx
call   1040 <memcpy@plt>
lea    -0x40(%rbp),%rsi
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <escape@plt>
lea    -0x80(%rbp),%rsi
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1050 <unescape@plt>
lea    -0x40(%rbp),%rsi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x0,0x30(%rsp)
lea    0xeca(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1030 <printf@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <escape@plt>
lea    0xebd(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <unescape@plt>
lea    0xeb7(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.text1 = [50 x i8] c"\07Hello,\0A\09World! Mistakee\08 was \22Extra 'e'\22!\0A\00\00\00\00\00\00\00"
@.str = [21 x i8] c"Original string:\0A%s\0A\00"
@.str.1 = [20 x i8] c"Escaped string:\0A%s\0A\00"
@.str.2 = [22 x i8] c"Unescaped string:\0A%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [51 x i8]
store i32 0, i32* %1
%4 = bitcast [50 x i8]* %2 to i8*
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%9 = call i32 @escape(i8* %7, i8* %8)
%10 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%14 = call i32 @unescape(i8* %12, i8* %13)
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %15)
ret i32 0
}

LLVM IR (-O2):
@__const.main.text1 = [50 x i8] c"\07Hello,\0A\09World! Mistakee\08 was \22Extra 'e'\22!\0A\00\00\00\00\00\00\00"
@.str = [21 x i8] c"Original string:\0A%s\0A\00"
@.str.1 = [20 x i8] c"Escaped string:\0A%s\0A\00"
@.str.2 = [22 x i8] c"Unescaped string:\0A%s\0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [51 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [51 x i8], [51 x i8]* %2, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 @escape(i8* %4, i8* %3)
%7 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = call i32 @unescape(i8* %3, i8* %4)
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret i32 0
}