#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int main() {
  int N, num;
  int i, count;
  int result[1024];
  while (scanf("%d\n", &N) != EOF && N != 0) {
    count = 0;
    for (i = 0; i < N; i++) {
      scanf("%d\n", &num);
      if (num > 0) {
        result[count++] = num;
      }
    }
    if (count == 0) {
      printf("%d\n", 0);
    } else {
      printf("%d", result[0]);
      for (i = 1; i < count; i++) {
        printf(" %d", result[i]);
      }
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e9a(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x1021(%rbp)
je     116a <main+0x4a>
cmpl   $0x0,-0x8(%rbp)
setne  %al
mov    %al,-0x1021(%rbp)
mov    -0x1021(%rbp),%al
test   $0x1,%al
jne    117d <main+0x5d>
jmp    125b <main+0x13b>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11db <main+0xbb>
lea    0xe62(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11c8 <main+0xa8>
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cltq
mov    %ecx,-0x1020(%rbp,%rax,4)
jmp    11cd <main+0xad>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118b <main+0x6b>
cmpl   $0x0,-0x14(%rbp)
jne    11fa <main+0xda>
lea    0xe14(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1256 <main+0x136>
mov    -0x1020(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1248 <main+0x128>
movslq -0x10(%rbp),%rax
mov    -0x1020(%rbp,%rax,4),%esi
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1215 <main+0xf5>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1132 <main+0x12>
xor    %eax,%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
lea    0xeb8(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e8f(%rip),%rbx
cmp    (%rbx),%rax
je     125a <main+0x12a>
mov    0x8(%rsp),%eax
test   %eax,%eax
je     125a <main+0x12a>
lea    0xe8b(%rip),%r13
lea    0xc(%rsp),%r14
lea    0xe83(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %eax,%eax
jle    1230 <main+0x100>
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    11a9 <main+0x79>
nop
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jge    11d0 <main+0xa0>
mov    %r13,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11a0 <main+0x70>
movslq %r15d,%rcx
add    $0x1,%r15d
mov    %eax,0x10(%rsp,%rcx,4)
jmp    11a0 <main+0x70>
nopl   0x0(%rax)
test   %r15d,%r15d
je     1230 <main+0x100>
mov    0x10(%rsp),%esi
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r15d
jl     1217 <main+0xe7>
mov    %r15d,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1200 <main+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2dc0(%rip),%rbx
jmp    123c <main+0x10c>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmp    (%rbx),%rax
je     125a <main+0x12a>
mov    0x8(%rsp),%eax
test   %eax,%eax
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@EOF = global i64 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c" %d\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i32]
store i32 0, i32* %1
br label %7
7: ; preds = %59, %0
%8 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i64, i64* @EOF
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br label %14
14: ; preds = %11, %7
%15 = phi i1 [ false, %7 ], [ %13, %11 ]
br i1 %15, label %16, label %60
16: ; preds = %14
store i32 0, i32* %5
store i32 0, i32* %4
br label %17
17: ; preds = %32, %16
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %3
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i32, i32* %3
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds [1024 x i32], [1024 x i32]* %6, i64 0, i64 %29
store i32 %26, i32* %30
br label %31
31: ; preds = %25, %21
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %17
35: ; preds = %17
%36 = load i32, i32* %5
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
br label %59
40: ; preds = %35
%41 = getelementptr inbounds [1024 x i32], [1024 x i32]* %6, i64 0, i64 0
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %42)
store i32 1, i32* %4
br label %44
44: ; preds = %54, %40
%45 = load i32, i32* %4
%46 = load i32, i32* %5
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %57
48: ; preds = %44
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1024 x i32], [1024 x i32]* %6, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %48
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %44
57: ; preds = %44
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %59
59: ; preds = %57, %38
br label %7
60: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@EOF = global i64 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c" %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [1024 x i32]* %3 to i8*
%7 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i64, i64* @EOF
%9 = icmp ne i64 %7, %8
%10 = load i32, i32* %1
%11 = icmp ne i32 %10, 0
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %13, label %59
13: ; preds = %0
%14 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 0
br label %15
15: ; preds = %13, %52
%16 = phi i32 [ %10, %13 ], [ %56, %52 ]
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %35
18: ; preds = %15, %28
%19 = phi i32 [ %29, %28 ], [ 0, %15 ]
%20 = phi i32 [ %30, %28 ], [ 0, %15 ]
%21 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = add nsw i32 %19, 1
%26 = sext i32 %19 to i64
%27 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 %26
store i32 %22, i32* %27
br label %28
28: ; preds = %18, %24
%29 = phi i32 [ %25, %24 ], [ %19, %18 ]
%30 = add nuw nsw i32 %20, 1
%31 = load i32, i32* %1
%32 = icmp slt i32 %30, %31
br i1 %32, label %18, label %33
33: ; preds = %28
%34 = icmp eq i32 %29, 0
br i1 %34, label %35, label %37
35: ; preds = %15, %33
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
br label %52
37: ; preds = %33
%38 = load i32, i32* %14
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = icmp sgt i32 %29, 1
br i1 %40, label %41, label %50
41: ; preds = %37
%42 = zext i32 %29 to i64
br label %43
43: ; preds = %41, %43
%44 = phi i64 [ 1, %41 ], [ %48, %43 ]
%45 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%48 = add nuw nsw i64 %44, 1
%49 = icmp eq i64 %48, %42
br i1 %49, label %50, label %43
50: ; preds = %43, %37
%51 = call i32 @putchar(i32 10)
br label %52
52: ; preds = %50, %35
%53 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%54 = load i64, i64* @EOF
%55 = icmp ne i64 %53, %54
%56 = load i32, i32* %1
%57 = icmp ne i32 %56, 0
%58 = select i1 %55, i1 %57, i1 false
br i1 %58, label %15, label %59
59: ; preds = %52, %0
ret i32 0
}