#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*/ printf(char *, int);
int scanf(char *, int *);
int main() {
  int a[100], i, j;
  for (i = 0; i < 100; i++)
    if (scanf("%d", a + i), !a[i]) {
      for (j = i; j > 0; printf("%d ", a[--j]))
        ;
      return 0;
    }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    11f7 <main+0xd7>
lea    -0x1a0(%rbp),%rsi
movslq -0x1a4(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe9b(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x1a4(%rbp),%rax
cmpl   $0x0,-0x1a0(%rbp,%rax,4)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118b <main+0x6b>
jmp    11de <main+0xbe>
mov    -0x1a4(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
cmpl   $0x0,-0x1a8(%rbp)
jle    11d2 <main+0xb2>
jmp    11a9 <main+0x89>
mov    -0x1a8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1a8(%rbp)
cltq
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
jmp    1197 <main+0x77>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <main+0xd7>
jmp    11e3 <main+0xc3>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    113c <main+0x1c>
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x190,%rsp
mov    $0xffffffffffffffff,%r15
mov    %rsp,%rbx
lea    0xec3(%rip),%r14
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,(%rbx)
je     1160 <main+0x40>
add    $0xffffffffffffffff,%r15
add    $0x4,%rbx
cmp    $0xffffffffffffff9b,%r15
jne    1140 <main+0x20>
jmp    1187 <main+0x67>
cmp    $0xffffffff,%r15d
je     1187 <main+0x67>
neg    %r15
lea    0xe93(%rip),%rbx
mov    -0x8(%rsp,%r15,4),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%r15
cmp    $0x1,%r15
jg     1170 <main+0x50>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
br label %3
3: ; preds = %0, %19
%4 = phi i64 [ 0, %0 ], [ %20, %19 ]
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %4
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %3
%10 = trunc i64 %4 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %9, %12
%13 = phi i64 [ %14, %12 ], [ %4, %9 ]
%14 = add nsw i64 %13, -1
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = icmp sgt i64 %13, 1
br i1 %18, label %12, label %22
19: ; preds = %3
%20 = add nuw nsw i64 %4, 1
%21 = icmp eq i64 %20, 100
br i1 %21, label %22, label %3
22: ; preds = %19, %12, %9
ret i32 0
}