#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 descape(char *, char *);
int escape(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *, int);
int main() {
  char to[1000];
  char from[] = "Hi there\t\ns";
  int num = escape(to, from);
  printf("from: '%s'  \n  to: '%s'\n num: %i \n", from, to, num);
  char desc[14];
  desc[0] = 'H';
  desc[1] = 'i';
  desc[2] = ' ';
  desc[3] = 't';
  desc[4] = 'h';
  desc[5] = 'e';
  desc[6] = 'r';
  desc[7] = 'e';
  desc[8] = '\\';
  desc[9] = 't';
  desc[10] = '\\';
  desc[11] = 'n';
  desc[12] = 's';
  desc[13] = '\0';
  num = descape(to, from);
  printf("from: '%s'  \n  to: '%s'\n num: %i \n", desc, to, num);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    0xebe(%rip),%rax
mov    %rax,-0x3fc(%rbp)
mov    0xeb9(%rip),%eax
mov    %eax,-0x3f4(%rbp)
lea    -0x3f0(%rbp),%rdi
lea    -0x3fc(%rbp),%rsi
call   1050 <escape@plt>
mov    %eax,-0x400(%rbp)
lea    -0x3fc(%rbp),%rsi
lea    -0x3f0(%rbp),%rdx
mov    -0x400(%rbp),%ecx
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
movb   $0x48,-0x40e(%rbp)
movb   $0x69,-0x40d(%rbp)
movb   $0x20,-0x40c(%rbp)
movb   $0x74,-0x40b(%rbp)
movb   $0x68,-0x40a(%rbp)
movb   $0x65,-0x409(%rbp)
movb   $0x72,-0x408(%rbp)
movb   $0x65,-0x407(%rbp)
movb   $0x5c,-0x406(%rbp)
movb   $0x74,-0x405(%rbp)
movb   $0x5c,-0x404(%rbp)
movb   $0x6e,-0x403(%rbp)
movb   $0x73,-0x402(%rbp)
movb   $0x0,-0x401(%rbp)
lea    -0x3f0(%rbp),%rdi
lea    -0x3fc(%rbp),%rsi
call   1040 <descape@plt>
mov    %eax,-0x400(%rbp)
lea    -0x40e(%rbp),%rsi
lea    -0x3f0(%rbp),%rdx
mov    -0x400(%rbp),%ecx
lea    0xde8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
movabs $0x6572656874206948,%r12
65 72 65
mov    %r12,0x10(%rsp)
movl   $0x730a09,0x18(%rsp)
lea    0x20(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <escape@plt>
lea    0xe9b(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    %r12,0x2(%rsp)
movl   $0x6e5c745c,0xa(%rsp)
6e
movw   $0x73,0xe(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <descape@plt>
lea    0x2(%rsp),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.from = [12 x i8] c"Hi there\09\0As\00"
@.str = [35 x i8] c"from: '%s' \0A to: '%s'\0A num: %i \0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [12 x i8]
%3 = alloca i32
%4 = alloca [14 x i8]
%5 = bitcast [12 x i8]* %2 to i8*
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%8 = call i32 @escape(i8* %6, i8* %7)
store i32 %8, i32* %3
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%11 = load i32, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10, i32 %11)
%13 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
store i8 72, i8* %13
%14 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 1
store i8 105, i8* %14
%15 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 2
store i8 32, i8* %15
%16 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 3
store i8 116, i8* %16
%17 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 4
store i8 104, i8* %17
%18 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 5
store i8 101, i8* %18
%19 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 6
store i8 114, i8* %19
%20 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 7
store i8 101, i8* %20
%21 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 8
store i8 92, i8* %21
%22 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 9
store i8 116, i8* %22
%23 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 10
store i8 92, i8* %23
%24 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 11
store i8 110, i8* %24
%25 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 12
store i8 115, i8* %25
%26 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 13
store i8 0, i8* %26
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%28 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%29 = call i32 @descape(i8* %27, i8* %28)
store i32 %29, i32* %3
%30 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%32 = load i32, i32* %3
%33 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %30, i8* %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@__const.main.from = [12 x i8] c"Hi there\09\0As\00"
@.str = [35 x i8] c"from: '%s' \0A to: '%s'\0A num: %i \0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [12 x i8]
%3 = alloca [14 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%6 = call i32 @escape(i8* %4, i8* %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %4, i32 %6)
%8 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 0
store i8 72, i8* %8
%9 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 1
store i8 105, i8* %9
%10 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 2
store i8 32, i8* %10
%11 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 3
store i8 116, i8* %11
%12 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 4
store i8 104, i8* %12
%13 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 5
store i8 101, i8* %13
%14 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 6
store i8 114, i8* %14
%15 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 7
store i8 101, i8* %15
%16 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 8
store i8 92, i8* %16
%17 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 9
store i8 116, i8* %17
%18 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 10
store i8 92, i8* %18
%19 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 11
store i8 110, i8* %19
%20 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 12
store i8 115, i8* %20
%21 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 13
store i8 0, i8* %21
%22 = call i32 @descape(i8* %4, i8* %5)
%23 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %4, i32 %22)
ret i32 0
}