#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*/ next_generation(int *, int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int current[20];
  int next[20];
  int lenght;
  int counter;
  int helper = 0;
  int boolean = 0;
  scanf("%d", &lenght);
  for (counter = 0; counter <= lenght - 1; counter++) {
    scanf("%d", &current[counter]);
  }
  counter = 0;
  while (counter <= 1000) {
    next_generation(current, next, lenght);
    for (helper = 0; helper <= lenght - 1; helper++) {
      if (current[helper] == 1) {
        printf("*");
        boolean = 1;
      } else {
        printf(".");
      }
      current[helper] = next[helper];
    }
    printf("\n");
    if (boolean == 0) {
      break;
    }
    boolean = 0;
    counter++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xbc(%rbp)
movl   $0x0,-0xc0(%rbp)
lea    0xea3(%rip),%rdi
lea    -0xb4(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
mov    -0xb4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11bc <main+0x8c>
movslq -0xb8(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5d(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    1173 <main+0x43>
movl   $0x0,-0xb8(%rbp)
cmpl   $0x3e8,-0xb8(%rbp)
jg     12af <main+0x17f>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0xb4(%rbp),%edx
call   1030 <next_generation@plt>
movl   $0x0,-0xbc(%rbp)
mov    -0xbc(%rbp),%eax
mov    -0xb4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1273 <main+0x143>
movslq -0xbc(%rbp),%rax
cmpl   $0x1,-0x60(%rbp,%rax,4)
jne    123a <main+0x10a>
lea    0xddd(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0xc0(%rbp)
jmp    1246 <main+0x116>
lea    0xdc4(%rip),%rdi
call   1040 <printf@plt>
movslq -0xbc(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%ecx
movslq -0xbc(%rbp),%rax
mov    %ecx,-0x60(%rbp,%rax,4)
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    11f6 <main+0xc6>
lea    0xd8d(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0xc0(%rbp)
jne    1291 <main+0x161>
jmp    12af <main+0x17f>
movl   $0x0,-0xc0(%rbp)
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    11c6 <main+0x96>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb0,%rsp
lea    0xeba(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    118d <main+0x5d>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe9a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rdx
add    $0x4,%rbx
cmp    %rdx,%rbp
jl     1170 <main+0x40>
lea    0x10(%rsp),%rdi
lea    0x60(%rsp),%rsi
call   1030 <next_generation@plt>
cmpl   $0x0,0xc(%rsp)
jle    1222 <main+0xf2>
xor    %r12d,%r12d
lea    0x10(%rsp),%r14
lea    0x60(%rsp),%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp,%rbx,4),%eax
xor    %ecx,%ecx
cmp    $0x1,%eax
setne  %cl
lea    0x2a(,%rcx,4),%edi
cmove  %eax,%ebp
call   1040 <putchar@plt>
mov    0x60(%rsp,%rbx,4),%eax
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11c0 <main+0x90>
mov    $0xa,%edi
call   1040 <putchar@plt>
test   %ebp,%ebp
je     122c <main+0xfc>
add    $0x1,%r12d
cmp    $0x3e9,%r12d
je     122c <main+0xfc>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <next_generation@plt>
cmpl   $0x0,0xc(%rsp)
jg     11b0 <main+0x80>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r12
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 [20 x i32]
%3 = alloca [20 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 0, i32* %5
br label %9
9: ; preds = %19, %0
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = icmp sle i32 %10, %12
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
br label %19
19: ; preds = %14
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %9
22: ; preds = %9
store i32 0, i32* %5
br label %23
23: ; preds = %62, %22
%24 = load i32, i32* %5
%25 = icmp sle i32 %24, 1000
br i1 %25, label %26, label %65
26: ; preds = %23
%27 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%28 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%29 = load i32, i32* %4
%30 = call i32 @next_generation(i32* %27, i32* %28, i32 %29)
store i32 0, i32* %6
br label %31
31: ; preds = %54, %26
%32 = load i32, i32* %6
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 1
%35 = icmp sle i32 %32, %34
br i1 %35, label %36, label %57
36: ; preds = %31
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %7
br label %46
44: ; preds = %36
%45 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %52
store i32 %50, i32* %53
br label %54
54: ; preds = %46
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %31
57: ; preds = %31
%58 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%59 = load i32, i32* %7
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %57
br label %65
62: ; preds = %57
store i32 0, i32* %7
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 1
store i32 %64, i32* %5
br label %23
65: ; preds = %61, %23
ret i32 0
}

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