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

/* Variables and functions */
int /*<<< orphan*/ escape(char *, char *);
int /*<<< orphan*/ escapeback(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char t[] = "Hello, world.\nThis is a test.\t\n";
  char s[sizeof(t) + 4];
  char a[sizeof(t) + 1];
  escape(s, t);
  printf("Escaped:\n%s\n", s);
  escapeback(a, s);
  printf("Escaped back:\n%s\n", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <escape@plt>
lea    -0x60(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <escapeback@plt>
lea    -0x90(%rbp),%rsi
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x50(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <escape@plt>
lea    0xebb(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <escapeback@plt>
lea    0xea9(%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.t = [32 x i8] c"Hello, world.\0AThis is a test.\09\0A\00"
@.str = [13 x i8] c"Escaped:\0A%s\0A\00"
@.str.1 = [18 x i8] c"Escaped back:\0A%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = alloca [36 x i8]
%4 = alloca [33 x i8]
store i32 0, i32* %1
%5 = bitcast [32 x i8]* %2 to i8*
%6 = getelementptr inbounds [36 x i8], [36 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%8 = call i32 @escape(i8* %6, i8* %7)
%9 = getelementptr inbounds [36 x i8], [36 x i8]* %3, i64 0, i64 0
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [36 x i8], [36 x i8]* %3, i64 0, i64 0
%13 = call i32 @escapeback(i8* %11, i8* %12)
%14 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %14)
ret i32 0
}

LLVM IR (-O2):
@__const.main.t = [32 x i8] c"Hello, world.\0AThis is a test.\09\0A\00"
@.str = [13 x i8] c"Escaped:\0A%s\0A\00"
@.str.1 = [18 x i8] c"Escaped back:\0A%s\0A\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = alloca [36 x i8]
%3 = alloca [33 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [36 x i8], [36 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%7 = call i32 @escape(i8* %5, i8* %4)
%8 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %5)
%9 = call i32 @escapeback(i8* %6, i8* %5)
%10 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %6)
ret i32 0
}