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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1195 <main+0x65>
movslq -0xc(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7e(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1160 <main+0x30>
jmp    119a <main+0x6a>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e2 <main+0xb2>
movslq -0xc(%rbp),%rax
cmpl   $0x1,-0x60(%rbp,%rax,4)
jne    11cf <main+0x9f>
movl   $0x1,-0x10(%rbp)
jmp    11e2 <main+0xb2>
jmp    11d4 <main+0xa4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <main+0x78>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1234 <main+0x104>
movslq -0xc(%rbp),%rax
cmpl   $0x1,-0x60(%rbp,%rax,4)
jne    1215 <main+0xe5>
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
jmp    1221 <main+0xf1>
lea    0xde9(%rip),%rdi
call   1040 <printf@plt>
jmp    1226 <main+0xf6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e9 <main+0xb9>
lea    0xdcc(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <next_generation@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1287 <main+0x157>
movslq -0xc(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0x60(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    125a <main+0x12a>
jmp    128c <main+0x15c>
cmpl   $0x1,-0x10(%rbp)
je     119a <main+0x6a>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb0,%rsp
lea    0xeaa(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%r15d
test   %r15d,%r15d
jle    119d <main+0x5d>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe88(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%r15
add    $0x4,%rbx
cmp    %r15,%rbp
jl     1180 <main+0x40>
lea    0x10(%rsp),%r14
lea    0x60(%rsp),%r12
jmp    11b9 <main+0x79>
nopl   0x0(%rax)
test   %bpl,%bpl
je     1271 <main+0x131>
test   %r15d,%r15d
jle    1230 <main+0xf0>
mov    $0x1,%bpl
cmpl   $0x1,0x10(%rsp)
je     11ea <main+0xaa>
mov    %r15d,%eax
mov    $0x1,%edx
mov    %rdx,%rcx
cmp    %rdx,%rax
je     11e3 <main+0xa3>
lea    0x1(%rcx),%rdx
cmpl   $0x1,0x10(%rsp,%rcx,4)
jne    11d0 <main+0x90>
cmp    %rax,%rcx
setb   %bpl
test   %r15d,%r15d
jle    1232 <main+0xf2>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
cmpl   $0x1,0x10(%rsp,%rbx,4)
setne  %al
lea    0x2a(,%rax,4),%edi
call   1040 <putchar@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1200 <main+0xc0>
jmp    1232 <main+0xf2>
cs nopw 0x0(%rax,%rax,1)
xor    %ebp,%ebp
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <next_generation@plt>
mov    0xc(%rsp),%r15d
test   %r15d,%r15d
jle    11b0 <main+0x70>
lea    0x0(,%r15,4),%rdx
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <memcpy@plt>
jmp    11b0 <main+0x70>
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 i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [20 x i32]
%6 = alloca [20 x i32]
store i32 0, i32* %1
store i32 1, i32* %4
%7 = 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 %8
8: ; preds = %17, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
br label %17
17: ; preds = %12
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %8
20: ; preds = %8
br label %21
21: ; preds = %78, %20
store i32 0, i32* %4
store i32 0, i32* %3
br label %22
22: ; preds = %34, %21
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 1, i32* %4
br label %37
33: ; preds = %26
br label %34
34: ; preds = %33
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %22
37: ; preds = %32, %22
store i32 0, i32* %3
br label %38
38: ; preds = %53, %37
%39 = load i32, i32* %3
%40 = load i32, i32* %2
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %56
42: ; preds = %38
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %52
50: ; preds = %42
%51 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50, %48
br label %53
53: ; preds = %52
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %38
56: ; preds = %38
%57 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%58 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 0
%59 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%60 = load i32, i32* %2
%61 = call i32 @next_generation(i32* %58, i32* %59, i32 %60)
store i32 0, i32* %3
br label %62
62: ; preds = %74, %56
%63 = load i32, i32* %3
%64 = load i32, i32* %2
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %77
66: ; preds = %62
%67 = load i32, i32* %3
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = load i32, i32* %3
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %72
store i32 %70, i32* %73
br label %74
74: ; preds = %66
%75 = load i32, i32* %3
%76 = add nsw i32 %75, 1
store i32 %76, i32* %3
br label %62
77: ; preds = %62
br label %78
78: ; preds = %77
%79 = load i32, i32* %4
%80 = icmp eq i32 %79, 1
br i1 %80, label %21, label %81
81: ; preds = %78
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 = bitcast [20 x i32]* %2 to i8*
%4 = alloca [20 x i32]
%5 = bitcast [20 x i32]* %4 to i8*
%6 = bitcast i32* %1 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 %15, label %10
10: ; preds = %15, %0
%11 = phi i32 [ %8, %0 ], [ %20, %15 ]
%12 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
br label %23
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%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)
%19 = add nuw nsw i64 %16, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %15, label %10
23: ; preds = %10, %64
%24 = phi i32 [ %11, %10 ], [ %59, %64 ]
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %54
26: ; preds = %23
%27 = zext i32 %24 to i64
%28 = zext i32 %24 to i64
%29 = load i32, i32* %14
%30 = icmp eq i32 %29, 1
br i1 %30, label %41, label %31
31: ; preds = %26, %34
%32 = phi i64 [ %38, %34 ], [ 1, %26 ]
%33 = icmp eq i64 %32, %28
br i1 %33, label %39, label %34
34: ; preds = %31
%35 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %32
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 1
%38 = add nuw nsw i64 %32, 1
br i1 %37, label %39, label %31
39: ; preds = %31, %34
%40 = icmp ult i64 %32, %27
br label %41
41: ; preds = %39, %26
%42 = phi i1 [ true, %26 ], [ %40, %39 ]
br i1 %25, label %43, label %54
43: ; preds = %41, %43
%44 = phi i64 [ %50, %43 ], [ 0, %41 ]
%45 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 1
%48 = select i1 %47, i32 42, i32 46
%49 = call i32 @putchar(i32 %48)
%50 = add nuw nsw i64 %44, 1
%51 = load i32, i32* %1
%52 = sext i32 %51 to i64
%53 = icmp slt i64 %50, %52
br i1 %53, label %43, label %54
54: ; preds = %43, %23, %41
%55 = phi i1 [ %42, %41 ], [ false, %23 ], [ %42, %43 ]
%56 = call i32 @putchar(i32 10)
%57 = load i32, i32* %1
%58 = call i32 @next_generation(i32* %12, i32* %13, i32 %57)
%59 = load i32, i32* %1
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %54
%62 = zext i32 %59 to i64
%63 = shl nuw nsw i64 %62, 2
br label %64
64: ; preds = %61, %54
br i1 %55, label %23, label %65
65: ; preds = %64
ret i32 0
}