#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 escape(char const *, char *);
int /*<<< orphan*/ printf(char *, char const *);
void main() {
  const char string[30] = "Le petit\tchat gris\nest beau!";
  char str2[30];
  int len = 30;
  printf("%s\n", string);
  len = escape(string, str2);
  printf("New string : %s\n", str2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec9(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xec3(%rip),%ax
mov    %ax,-0x4(%rbp)
movl   $0x1e,-0x44(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <escape@plt>
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movups 0xee0(%rip),%xmm0
movups %xmm0,0xe(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xee6(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0x20(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <escape@plt>
lea    0xeb7(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.string = [30 x i8] c"Le petit\09chat gris\0Aest beau!\00\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [17 x i8] c"New string : %s\0A\00"
define void @main() {
%1 = alloca [30 x i8]
%2 = alloca [30 x i8]
%3 = alloca i32
%4 = bitcast [30 x i8]* %1 to i8*
store i32 30, i32* %3
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%9 = call i32 @escape(i8* %7, i8* %8)
store i32 %9, i32* %3
%10 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %10)
ret void
}

LLVM IR (-O2):
@__const.main.string = [30 x i8] c"Le petit\09chat gris\0Aest beau!\00\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [17 x i8] c"New string : %s\0A\00"
define void @main() {
%1 = alloca [30 x i8]
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 @escape(i8* %3, i8* %4)
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret void
}