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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e95(%rip),%rcx
cmp    (%rcx),%eax
je     1179 <main+0x49>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0xc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
cltq
mov    %cl,-0x400(%rbp,%rax,1)
jmp    1142 <main+0x12>
lea    -0x400(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
call   1050 <escape@plt>
lea    -0x7f0(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x7d8,%rsp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2ea0(%rip),%r14
cmp    (%r14),%eax
je     1162 <main+0x32>
mov    %rsp,%rbx
mov    %al,(%rbx)
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%rbx
cmp    (%r14),%eax
jne    1150 <main+0x20>
mov    %rsp,%rdi
lea    0x3f0(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <escape@plt>
lea    0xe84(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%s\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
%5 = tail call i32 (...) @getchar()
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %17, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %12, %8 ], [ 0, %0 ]
%10 = phi i32 [ %14, %8 ], [ %5, %0 ]
%11 = trunc i32 %10 to i8
%12 = add i64 %9, 1
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %9
store i8 %11, i8* %13
%14 = tail call i32 (...) @getchar()
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %8
17: ; preds = %8, %0
%18 = call i32 @escape(i8* %3, i8* %4)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}