#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__ check_generation(int *, int);
int /*<<< orphan*/ next_generation(int *, int *, int);
int /*<<< orphan*/ print_generation(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, i;
  int j;
  int n1[n];
  do {
    scanf("%d", &n);
  } while (n > 20 || n < 0);
  int c1[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &c1[i]);
  }
  print_generation(c1, n);
  for (i = 0; i < 1000 && check_generation(c1, n) != 0; i++) {
    next_generation(c1, n1, n);
    print_generation(n1, n);
    for (j = 0; j < n; j++) {
      c1[j] = n1[j];
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe83(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x1,%al
cmpl   $0x14,-0x8(%rbp)
mov    %al,-0x31(%rbp)
jg     119f <main+0x5f>
cmpl   $0x0,-0x8(%rbp)
setl   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1176 <main+0x36>
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1206 <main+0xc6>
mov    -0x40(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe0d(%rip),%rdi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d1 <main+0x91>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <print_generation@plt>
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x3e8,-0xc(%rbp)
mov    %al,-0x41(%rbp)
jge    1241 <main+0x101>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <check_generation@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1251 <main+0x111>
jmp    12b7 <main+0x177>
mov    -0x30(%rbp),%rsi
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
call   1030 <next_generation@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <print_generation@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a4 <main+0x164>
mov    -0x40(%rbp),%rax
mov    -0x30(%rbp),%rcx
movslq -0x10(%rbp),%rdx
mov    (%rcx,%rdx,4),%edx
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1274 <main+0x134>
jmp    12a9 <main+0x169>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1219 <main+0xd9>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsp,%r12
lea    0xe98(%rip),%r14
lea    -0x2c(%rbp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%eax
cmp    $0x14,%rax
ja     1170 <main+0x20>
mov    %rsp,%r15
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r15
mov    %r15,%rsp
test   %rax,%rax
je     11ce <main+0x7e>
xor    %r13d,%r13d
lea    0xe58(%rip),%r14
mov    %r15,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rsi
add    $0x4,%rbx
cmp    %rsi,%r13
jl     11b0 <main+0x60>
jmp    11d0 <main+0x80>
xor    %esi,%esi
mov    %r15,%rdi
call   1060 <print_generation@plt>
mov    $0x3e8,%ebx
mov    -0x2c(%rbp),%r13d
lea    -0x30(%rbp),%r14
jmp    11f5 <main+0xa5>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
je     123c <main+0xec>
mov    %r15,%rdi
mov    %r13d,%esi
call   1040 <check_generation@plt>
test   %rax,%rax
je     123c <main+0xec>
mov    -0x2c(%rbp),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <next_generation@plt>
mov    -0x2c(%rbp),%esi
mov    %r14,%rdi
call   1060 <print_generation@plt>
mov    -0x2c(%rbp),%r13d
test   %r13d,%r13d
jle    11f0 <main+0xa0>
lea    0x0(,%r13,4),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <memcpy@plt>
jmp    11f0 <main+0xa0>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %5
%11 = alloca i32, i64 %9
store i64 %9, i64* %6
br label %12
12: ; preds = %20, %0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %14
14: ; preds = %12
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 20
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 0
br label %20
20: ; preds = %17, %14
%21 = phi i1 [ true, %14 ], [ %19, %17 ]
br i1 %21, label %12, label %22
22: ; preds = %20
%23 = load i32, i32* %2
%24 = zext i32 %23 to i64
%25 = alloca i32, i64 %24
store i64 %24, i64* %7
store i32 0, i32* %3
br label %26
26: ; preds = %35, %22
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %38
30: ; preds = %26
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %25, i64 %32
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %33)
br label %35
35: ; preds = %30
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %26
38: ; preds = %26
%39 = load i32, i32* %2
%40 = call i32 @print_generation(i32* %25, i32 %39)
store i32 0, i32* %3
br label %41
41: ; preds = %71, %38
%42 = load i32, i32* %3
%43 = icmp slt i32 %42, 1000
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i32, i32* %2
%46 = call i64 @check_generation(i32* %25, i32 %45)
%47 = icmp ne i64 %46, 0
br label %48
48: ; preds = %44, %41
%49 = phi i1 [ false, %41 ], [ %47, %44 ]
br i1 %49, label %50, label %74
50: ; preds = %48
%51 = load i32, i32* %2
%52 = call i32 @next_generation(i32* %25, i32* %11, i32 %51)
%53 = load i32, i32* %2
%54 = call i32 @print_generation(i32* %11, i32 %53)
store i32 0, i32* %4
br label %55
55: ; preds = %67, %50
%56 = load i32, i32* %4
%57 = load i32, i32* %2
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %70
59: ; preds = %55
%60 = load i32, i32* %4
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %11, i64 %61
%63 = load i32, i32* %62
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i32, i32* %25, i64 %65
store i32 %63, i32* %66
br label %67
67: ; preds = %59
%68 = load i32, i32* %4
%69 = add nsw i32 %68, 1
store i32 %69, i32* %4
br label %55
70: ; preds = %55
br label %71
71: ; preds = %70
%72 = load i32, i32* %3
%73 = add nsw i32 %72, 1
store i32 %73, i32* %3
br label %41
74: ; preds = %48
%75 = load i8*, i8** %5
%76 = load i32, i32* %1
ret i32 %76
}

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