#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*/ escape(char *);
int /*<<< orphan*/ *gets(char *);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int strlen(char *);
int main() {
  char s[10000];
  char *t = s;
  while (gets(t) != NULL) {
    t = t + strlen(t);
    *(t++) = '\n';
  }
  *t = '\0';
  puts(escape(s));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x2720(%rbp),%rax
mov    %rax,-0x2728(%rbp)
mov    -0x2728(%rbp),%rdi
call   1050 <gets@plt>
cmp    $0x0,%rax
je     11c3 <main+0x83>
mov    -0x2728(%rbp),%rax
mov    %rax,-0x2730(%rbp)
mov    -0x2728(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2730(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x2728(%rbp)
mov    -0x2728(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x2728(%rbp)
movb   $0xa,(%rax)
jmp    1160 <main+0x20>
mov    -0x2728(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x2720(%rbp),%rdi
call   1060 <escape@plt>
mov    %eax,%edi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x2718,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     1186 <main+0x46>
mov    %rsp,%rbx
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%r14
add    $0x1,%r14
movb   $0xa,(%rbx,%rax,1)
mov    %r14,%rdi
call   1050 <gets@plt>
mov    %r14,%rbx
test   %rax,%rax
jne    1160 <main+0x20>
movb   $0x0,(%r14)
mov    %rsp,%rdi
call   1060 <escape@plt>
mov    %eax,%edi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x2718,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [10000 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
store i8* %4, i8** %3
br label %5
5: ; preds = %9, %0
%6 = load i8*, i8** %3
%7 = call i32* @gets(i8* %6)
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
store i8 10, i8* %15
br label %5
17: ; preds = %5
%18 = load i8*, i8** %3
store i8 0, i8* %18
%19 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%20 = call i32 @escape(i8* %19)
%21 = call i32 @puts(i32 %20)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [10000 x i8]
%2 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 0
%3 = call i32* @gets(i8* %2)
%4 = icmp eq i32* %3, null
br i1 %4, label %13, label %5
5: ; preds = %0, %5
%6 = phi i8* [ %10, %5 ], [ %2, %0 ]
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8 10, i8* %9
%11 = call i32* @gets(i8* %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %5
13: ; preds = %5, %0
%14 = phi i8* [ %2, %0 ], [ %10, %5 ]
store i8 0, i8* %14
%15 = call i32 @escape(i8* %2)
%16 = call i32 @puts(i32 %15)
ret i32 0
}