#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 n;
  int counter;
  int curr_generation[20];
  int next[20];
  scanf("%d", &n);
  for (counter = 0; counter < n; counter++) {
    scanf("%d", (curr_generation + counter));
  }
  for (counter = 0; counter < 1000; counter++) {
    int i = 0;
    int isAlive = 0;
    next_generation(curr_generation, next, n);
    for (i = 0; i < n; i++) {
      if (curr_generation[i]) {
        printf("*");
        isAlive = 1;
      } else {
        printf(".");
      }
      curr_generation[i] = next[i];
    }
    if (!isAlive) {
      break;
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118e <main+0x5e>
lea    -0x60(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe85(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1159 <main+0x29>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jge    1274 <main+0x144>
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <next_generation@plt>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1248 <main+0x118>
movslq -0xb4(%rbp),%rax
cmpl   $0x0,-0x60(%rbp,%rax,4)
je     120f <main+0xdf>
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0xb8(%rbp)
jmp    121b <main+0xeb>
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
movslq -0xb4(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%ecx
movslq -0xb4(%rbp),%rax
mov    %ecx,-0x60(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    11d3 <main+0xa3>
cmpl   $0x0,-0xb8(%rbp)
jne    125a <main+0x12a>
jmp    1274 <main+0x144>
lea    0xda6(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1195 <main+0x65>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
lea    0xeb8(%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    0xe98(%rip),%r14
nopl   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    1231 <main+0x101>
xor    %r12d,%r12d
mov    $0x1,%r13d
lea    0x10(%rsp),%r14
lea    0x60(%rsp),%r15
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
cmpl   $0x0,0x10(%rsp,%rbp,4)
sete   %al
lea    0x2a(,%rax,4),%edi
cmovne %r13d,%ebx
call   1040 <putchar@plt>
mov    0x60(%rsp,%rbp,4),%eax
mov    %eax,0x10(%rsp,%rbp,4)
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
cmp    %rax,%rbp
jl     11d0 <main+0xa0>
test   %ebx,%ebx
je     1231 <main+0x101>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%r12d
cmp    $0x3e8,%r12d
je     1231 <main+0x101>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <next_generation@plt>
cmpl   $0x0,0xc(%rsp)
jg     11c0 <main+0x90>
xor    %eax,%eax
add    $0xb8,%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 i32
%4 = alloca [20 x i32]
%5 = alloca [20 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %9
9: ; preds = %19, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, 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 = %13
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %9
22: ; preds = %9
store i32 0, i32* %3
br label %23
23: ; preds = %62, %22
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 1000
br i1 %25, label %26, label %65
26: ; preds = %23
store i32 0, i32* %6
store i32 0, i32* %7
%27 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%28 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 0
%29 = load i32, i32* %2
%30 = call i32 @next_generation(i32* %27, i32* %28, i32 %29)
store i32 0, i32* %6
br label %31
31: ; preds = %53, %26
%32 = load i32, i32* %6
%33 = load i32, i32* %2
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %56
35: ; preds = %31
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = 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 %45
43: ; preds = %35
%44 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %51
store i32 %49, i32* %52
br label %53
53: ; preds = %45
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %31
56: ; preds = %31
%57 = load i32, i32* %7
%58 = icmp ne i32 %57, 0
br i1 %58, label %60, label %59
59: ; preds = %56
br label %65
60: ; preds = %56
%61 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %62
62: ; preds = %60
%63 = load i32, i32* %3
%64 = add nsw i32 %63, 1
store i32 %64, i32* %3
br label %23
65: ; preds = %59, %23
ret i32 0
}

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