#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*/ Unescape(char const *, char *, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, char *);
int strlen(char const *);
int main(void) {
  char buffer[256] = {0};
  const char *str = "Hello\\nworld!\\n";
  Unescape(str, buffer, strlen(str) * 2);
  printf("%s.\n", buffer);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    0xe84(%rip),%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x118(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x128(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    %eax,%edx
shl    $0x1,%edx
call   1070 <Unescape@plt>
lea    -0x110(%rbp),%rsi
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe45(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    (%rax,%rax,1),%edx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <Unescape@plt>
lea    0xe35(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Hello\\nworld!\\n\00"
@.str.1 = [5 x i8] c"%s.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [256 x i8]* %2 to i8*
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = mul nsw i32 %8, 2
%10 = call i32 @Unescape(i8* %5, i8* %6, i32 %9)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Hello\\nworld!\\n\00"
@.str.1 = [5 x i8] c"%s.\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = shl nsw i32 %3, 1
%5 = call i32 @Unescape(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = call i32 (...) @getchar()
ret i32 0
}