#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 */
typedef char uint8_t;
typedef int uint32_t;

/* Variables and functions */
#define EOF 128
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ eat_newlines();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int filter(char *, int, char *, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, char **);
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(void) {
  uint8_t *in;
  uint32_t in_sz;
  uint8_t out[1024];
  uint32_t out_sz = 1024;
  uint32_t actual_out_sz;
  while (1) {
    switch (scanf("%a[^\n]", &in)) {
    case EOF:
      eat_newlines();
      return 0;
    case 1:
      in_sz = strlen((char *)in);
      assert(in_sz < 1024);
      actual_out_sz = filter(in, in_sz, out, out_sz);
      assert(actual_out_sz < 1024);
      out[actual_out_sz] = 0;
      printf("%s", out);
      fflush(stdout);
      break;
    }
    if (in)
      free(in);
    eat_newlines();
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x400,-0x424(%rbp)
lea    0xe5d(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   10a0 <scanf@plt>
mov    %eax,%ecx
mov    %ecx,-0x42c(%rbp)
sub    $0x1,%eax
je     11ea <main+0x6a>
jmp    11c2 <main+0x42>
mov    -0x42c(%rbp),%eax
sub    $0x80,%eax
jne    1272 <main+0xf2>
jmp    11d8 <main+0x58>
mov    $0x0,%al
call   1080 <eat_newlines@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x420(%rbp),%rdx
mov    -0x424(%rbp),%ecx
call   1060 <filter@plt>
mov    %eax,-0x428(%rbp)
cmpl   $0x400,-0x428(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movslq -0x428(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rsi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
cmpq   $0x0,-0x10(%rbp)
je     1286 <main+0x106>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1080 <eat_newlines@plt>
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    119c <main+0x1c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
lea    0xe58(%rip),%r14
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%r15
lea    0xe4e(%rip),%r12
mov    0x2e20(%rip),%r13
jmp    11e1 <main+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1090 <eat_newlines@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <scanf@plt>
cmp    $0x1,%eax
je     1200 <main+0x70>
cmp    $0x80,%eax
jne    1260 <main+0xd0>
jmp    1278 <main+0xe8>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    $0x400,%eax
setl   %dil
call   1080 <assert@plt>
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    $0x400,%ecx
call   1070 <filter@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    $0x400,%eax
setl   %dil
call   1080 <assert@plt>
movslq %ebp,%rax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edi
call   10a0 <fflush@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     11d0 <main+0x40>
call   1030 <free@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1090 <eat_newlines@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%a[^\0A]\00"
@.str.1 = [3 x i8] c"%s\00"
@stdout = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1024, i32* %5
br label %7
7: ; preds = %0, %40
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2)
switch i32 %8, label %34 [
i32 128, label %9
i32 1, label %11
]
9: ; preds = %7
%10 = call i32 (...) @eat_newlines()
ret i32 0
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 1024
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %2
%19 = load i32, i32* %3
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%21 = load i32, i32* %5
%22 = call i32 @filter(i8* %18, i32 %19, i8* %20, i32 %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp slt i32 %23, 1024
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %28
store i8 0, i8* %29
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @stdout
%33 = call i32 @fflush(i32 %32)
br label %34
34: ; preds = %7, %11
%35 = load i8*, i8** %2
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i8*, i8** %2
%39 = call i32 @free(i8* %38)
br label %40
40: ; preds = %37, %34
%41 = call i32 (...) @eat_newlines()
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %7
}

LLVM IR (-O2):
@.str = [7 x i8] c"%a[^\0A]\00"
@.str.1 = [3 x i8] c"%s\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i8*
%2 = alloca [1024 x i8]
%3 = bitcast i8** %1 to i8*
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %30, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %1)
switch i32 %6, label %25 [
i32 128, label %7
i32 1, label %9
]
7: ; preds = %5
%8 = call i32 (...) @eat_newlines()
ret i32 0
9: ; preds = %5
%10 = load i8*, i8** %1
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %11, 1024
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %1
%16 = call i32 @filter(i8* %15, i32 %11, i8* %4, i32 1024)
%17 = icmp slt i32 %16, 1024
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = sext i32 %16 to i64
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
br label %25
25: ; preds = %5, %9
%26 = load i8*, i8** %1
%27 = icmp eq i8* %26, null
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = call i32 @free(i8* %26)
br label %30
30: ; preds = %28, %25
%31 = call i32 (...) @eat_newlines()
%32 = call i32 @putchar(i32 10)
br label %5
}