#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a, af, f, i, n;
  scanf("%d\n", &n);
  while (n != 0) {
    af = 0;
    f = 1;
    if (n == 1)
      printf("0\n");
    else if (n == 2)
      printf("0 1\n");
    else if (n > 2) {
      printf("0 1 ");
      for (i = 2; i < n; ++i) {
        a = f + af;
        if (i < (n - 1))
          printf("%d ", a);
        else
          printf("%d\n", a);
        af = f;
        f = a;
      }
    }
    scanf("%d\n", &n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x18(%rbp)
je     123b <main+0x11b>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    1174 <main+0x54>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1226 <main+0x106>
cmpl   $0x2,-0x18(%rbp)
jne    1191 <main+0x71>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1221 <main+0x101>
cmpl   $0x2,-0x18(%rbp)
jle    121c <main+0xfc>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1217 <main+0xf7>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ec <main+0xcc>
mov    -0x8(%rbp),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <main+0xdd>
mov    -0x8(%rbp),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b0 <main+0x90>
jmp    121c <main+0xfc>
jmp    1221 <main+0x101>
jmp    1226 <main+0x106>
lea    0xdd3(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rbx
lea    0xec8(%rip),%r12
lea    0xeb9(%rip),%r15
jmp    116c <main+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
mov    %r12,%rdi
cmp    $0x1,%eax
je     1167 <main+0x37>
cmp    $0x2,%eax
je     1160 <main+0x30>
test   %eax,%eax
je     11f1 <main+0xc1>
cmp    $0x3,%eax
jl     116c <main+0x3c>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
jl     116c <main+0x3c>
xor    %r13d,%r13d
mov    $0x1,%ebp
mov    $0x2,%r14d
jmp    11d6 <main+0xa6>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
mov    0x4(%rsp),%eax
cmp    %eax,%r14d
jge    116c <main+0x3c>
mov    %r13d,%ecx
mov    %ebp,%r13d
mov    %ecx,%ebp
add    %r13d,%ebp
add    $0xffffffff,%eax
mov    %r15,%rdi
cmp    %eax,%r14d
jl     11c0 <main+0x90>
mov    %rbx,%rdi
jmp    11c0 <main+0x90>
xor    %eax,%eax
add    $0x8,%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"
@.str.1 = [3 x i8] c"0\0A\00"
@.str.2 = [5 x i8] c"0 1\0A\00"
@.str.3 = [5 x i8] c"0 1 \00"
@.str.4 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %8
8: ; preds = %53, %0
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %55
11: ; preds = %8
store i32 0, i32* %3
store i32 1, i32* %4
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %53
16: ; preds = %11
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %52
21: ; preds = %16
%22 = load i32, i32* %6
%23 = icmp sgt i32 %22, 2
br i1 %23, label %24, label %51
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %5
br label %26
26: ; preds = %47, %24
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %50
30: ; preds = %26
%31 = load i32, i32* %4
%32 = load i32, i32* %3
%33 = add nsw i32 %31, %32
store i32 %33, i32* %2
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 1
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %41
38: ; preds = %30
%39 = load i32, i32* %2
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %39)
br label %44
41: ; preds = %30
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41, %38
%45 = load i32, i32* %4
store i32 %45, i32* %3
%46 = load i32, i32* %2
store i32 %46, i32* %4
br label %47
47: ; preds = %44
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %26
50: ; preds = %26
br label %51
51: ; preds = %50, %21
br label %52
52: ; preds = %51, %19
br label %53
53: ; preds = %52, %14
%54 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %8
55: ; preds = %8
ret i32 0
}

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