#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 *, int);
scalar_t__ scanf(char *, int *);
int main(void) {
  int stack[100], i = 0, j = 0, temp, ans[100] = {0};
  while (scanf("%d", &temp) != EOF) {
    if (temp != 0) {
      stack[i] = temp;
      i++;
    } else {
      ans[j] = stack[i - 1];
      j++;
      i--;
    }
  }
  for (i = 0; i < j; i++)
    printf("%d\n", ans[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1a4(%rbp)
movl   $0x0,-0x1a8(%rbp)
lea    -0x340(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
lea    0xe90(%rip),%rdi
lea    -0x1ac(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e65(%rip),%rcx
cmp    (%rcx),%rax
je     1204 <main+0xd4>
cmpl   $0x0,-0x1ac(%rbp)
je     11c1 <main+0x91>
mov    -0x1ac(%rbp),%ecx
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11ff <main+0xcf>
mov    -0x1a4(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1a8(%rbp),%rax
mov    %ecx,-0x340(%rbp,%rax,4)
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1a4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1169 <main+0x39>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1a8(%rbp),%eax
jge    124e <main+0x11e>
movslq -0x1a4(%rbp),%rax
mov    -0x340(%rbp,%rax,4),%esi
lea    0xdce(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    120e <main+0xde>
xor    %eax,%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x330,%rsp
lea    0x10(%rsp),%rdi
xor    %r13d,%r13d
mov    $0x190,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xea5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e7c(%rip),%r12
cmp    (%r12),%rax
je     1205 <main+0xd5>
lea    0xe83(%rip),%r14
lea    0xc(%rsp),%r15
xor    %ebx,%ebx
jmp    11ba <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
movslq %ebx,%rax
add    $0xffffffff,%ebx
mov    0x19c(%rsp,%rax,4),%eax
movslq %r13d,%r13
mov    %eax,0x10(%rsp,%r13,4)
add    $0x1,%r13d
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
cmp    (%r12),%rax
je     11d1 <main+0xa1>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1190 <main+0x60>
movslq %ebx,%rbx
mov    %eax,0x1a0(%rsp,%rbx,4)
add    $0x1,%ebx
jmp    11a9 <main+0x79>
test   %r13d,%r13d
jle    1205 <main+0xd5>
mov    %r13d,%r15d
xor    %ebx,%ebx
lea    0xe21(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11f0 <main+0xc0>
xor    %eax,%eax
add    $0x330,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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