#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);
int /*<<< orphan*/ next_generation(int *, int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ strcpy_int(int *, int *, int);
int main() {
  int array_lenght;
  do {
    scanf("%d", &array_lenght);
  } while (array_lenght < 0 || array_lenght > 20);
  int current[array_lenght];
  int next[array_lenght];
  int count, count_print;
  for (count = 0; count < array_lenght; count++) {
    scanf("%d", &current[count]);
  }
  for (count_print = 0; count_print < array_lenght; count_print++) {
    if (current[count_print]) {
      printf("*");
    } else
      printf(".");
  }
  printf("\n");
  for (count = 0; count < 1000 && check_generation(current, next, array_lenght);
       count++) {
    next_generation(current, next, array_lenght);
    for (count_print = 0; count_print < array_lenght; count_print++) {
      if (next[count_print]) {
        printf("*");
      } else
        printf(".");
    }
    printf("\n");
    strcpy_int(current, next, array_lenght);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x29(%rbp)
jl     1188 <main+0x38>
cmpl   $0x14,-0x8(%rbp)
setg   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    115f <main+0xf>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1216 <main+0xc6>
mov    -0x40(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdfd(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e1 <main+0x91>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126b <main+0x11b>
mov    -0x40(%rbp),%rax
movslq -0x28(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     124c <main+0xfc>
lea    0xdc1(%rip),%rdi
call   1050 <printf@plt>
jmp    1258 <main+0x108>
lea    0xdb2(%rip),%rdi
call   1050 <printf@plt>
jmp    125d <main+0x10d>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    121d <main+0xcd>
lea    0xd95(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x24(%rbp)
xor    %eax,%eax
cmpl   $0x3e8,-0x24(%rbp)
mov    %al,-0x41(%rbp)
jge    12aa <main+0x15a>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
call   1060 <check_generation@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    12ba <main+0x16a>
jmp    1349 <main+0x1f9>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
call   1030 <next_generation@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    131f <main+0x1cf>
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1300 <main+0x1b0>
lea    0xd0d(%rip),%rdi
call   1050 <printf@plt>
jmp    130c <main+0x1bc>
lea    0xcfe(%rip),%rdi
call   1050 <printf@plt>
jmp    1311 <main+0x1c1>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12d1 <main+0x181>
lea    0xce1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1040 <strcpy_int@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    127e <main+0x12e>
mov    -0x10(%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
sub    $0x18,%rsp
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,%r13
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r12
mov    %r12,%rsp
test   %eax,%eax
jle    1223 <main+0xd3>
mov    %r13,-0x38(%rbp)
xor    %r13d,%r13d
lea    0xe3a(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     11d0 <main+0x80>
test   %eax,%eax
mov    -0x38(%rbp),%r13
jle    1223 <main+0xd3>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
cmpl   $0x0,(%r14,%rbx,4)
sete   %al
lea    0x2a(,%rax,4),%edi
call   1040 <putchar@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1200 <main+0xb0>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %r15d,%r15d
jmp    1265 <main+0x115>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    -0x2c(%rbp),%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <strcpy_int@plt>
add    $0x1,%r15d
cmp    $0x3e8,%r15d
je     12b5 <main+0x165>
mov    -0x2c(%rbp),%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <check_generation@plt>
test   %rax,%rax
je     12b5 <main+0x165>
mov    -0x2c(%rbp),%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <next_generation@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    1240 <main+0xf0>
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
cmpl   $0x0,(%r12,%rbx,4)
sete   %al
lea    0x2a(,%rax,4),%edi
call   1040 <putchar@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1290 <main+0x140>
jmp    1240 <main+0xf0>
mov    %r13,%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"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
br label %8
8: ; preds = %16, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %8
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 20
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %8, label %18
18: ; preds = %16
%19 = load i32, i32* %2
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %3
%22 = alloca i32, i64 %20
store i64 %20, i64* %4
%23 = load i32, i32* %2
%24 = zext i32 %23 to i64
%25 = alloca i32, i64 %24
store i64 %24, i64* %5
store i32 0, i32* %6
br label %26
26: ; preds = %35, %18
%27 = load i32, i32* %6
%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* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %22, 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* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %26
38: ; preds = %26
store i32 0, i32* %7
br label %39
39: ; preds = %54, %38
%40 = load i32, i32* %7
%41 = load i32, i32* %2
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %57
43: ; preds = %39
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %22, i64 %45
%47 = load i32, i32* %46
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %43
%50 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %53
51: ; preds = %43
%52 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
br label %54
54: ; preds = %53
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %39
57: ; preds = %39
%58 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %59
59: ; preds = %93, %57
%60 = load i32, i32* %6
%61 = icmp slt i32 %60, 1000
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load i32, i32* %2
%64 = call i64 @check_generation(i32* %22, i32* %25, i32 %63)
%65 = icmp ne i64 %64, 0
br label %66
66: ; preds = %62, %59
%67 = phi i1 [ false, %59 ], [ %65, %62 ]
br i1 %67, label %68, label %96
68: ; preds = %66
%69 = load i32, i32* %2
%70 = call i32 @next_generation(i32* %22, i32* %25, i32 %69)
store i32 0, i32* %7
br label %71
71: ; preds = %86, %68
%72 = load i32, i32* %7
%73 = load i32, i32* %2
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %89
75: ; preds = %71
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %25, i64 %77
%79 = load i32, i32* %78
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %75
%82 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %85
83: ; preds = %75
%84 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %85
85: ; preds = %83, %81
br label %86
86: ; preds = %85
%87 = load i32, i32* %7
%88 = add nsw i32 %87, 1
store i32 %88, i32* %7
br label %71
89: ; preds = %71
%90 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%91 = load i32, i32* %2
%92 = call i32 @strcpy_int(i32* %22, i32* %25, i32 %91)
br label %93
93: ; preds = %89
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 1
store i32 %95, i32* %6
br label %59
96: ; preds = %66
%97 = load i8*, i8** %3
%98 = load i32, i32* %1
ret i32 %98
}

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