#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 */
char EOF;
int /*<<< orphan*/ escape(char *, char *);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ unescape(char *, char *);
int main(void) {
  int i = 0;
  char s[1000];
  char t[1000];
  while ((s[i] = getchar()) != EOF && i < 1000)
    i++;
  s[i] = '\0';
  escape(s, t);
  printf("%s", t);
  printf("\n\n");
  unescape(s, t);
  printf("%s", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
movslq -0x8(%rbp),%rcx
mov    %al,-0x3f0(%rbp,%rcx,1)
movsbl %al,%ecx
mov    0x2e73(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x7e1(%rbp)
je     1198 <main+0x58>
cmpl   $0x3e8,-0x8(%rbp)
setl   %al
mov    %al,-0x7e1(%rbp)
mov    -0x7e1(%rbp),%al
test   $0x1,%al
jne    11ab <main+0x6b>
jmp    11b9 <main+0x79>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <main+0x19>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x3f0(%rbp,%rax,1)
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
call   1060 <escape@plt>
lea    -0x7e0(%rbp),%rsi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
call   1050 <unescape@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x7e0,%rsp
mov    0x2e85(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,(%rsp,%rbx,1)
lea    0x1(%rbx),%rcx
cmp    (%r14),%al
je     118f <main+0x3f>
cmp    $0x3e8,%rbx
mov    %rcx,%rbx
jb     1170 <main+0x20>
movb   $0x0,-0x1(%rsp,%rcx,1)
mov    %rsp,%r14
lea    0x3f0(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <escape@plt>
lea    0xe4f(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <unescape@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
br label %5
5: ; preds = %19, %0
%6 = call signext i8 (...) @getchar()
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %8
store i8 %6, i8* %9
%10 = sext i8 %6 to i32
%11 = load i8, i8* @EOF
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %10, %12
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 1000
br label %17
17: ; preds = %14, %5
%18 = phi i1 [ false, %5 ], [ %16, %14 ]
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %5
22: ; preds = %17
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%28 = call i32 @escape(i8* %26, i8* %27)
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%34 = call i32 @unescape(i8* %32, i8* %33)
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %35)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [3 x i8] c"%s\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ %13, %5 ], [ 0, %0 ]
%7 = tail call signext i8 (...) @getchar()
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %6
store i8 %7, i8* %8
%9 = load i8, i8* @EOF
%10 = icmp ne i8 %7, %9
%11 = icmp ult i64 %6, 1000
%12 = select i1 %10, i1 %11, i1 false
%13 = add nuw nsw i64 %6, 1
br i1 %12, label %5, label %14
14: ; preds = %5
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %6
store i8 0, i8* %15
%16 = call i32 @escape(i8* %3, i8* %4)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%19 = call i32 @unescape(i8* %3, i8* %4)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
ret i32 0
}