#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 */
char getchar();
int /*<<< orphan*/ next_generation(int *, int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int current[50], next[50];
  int n, i, j, alive;
  char c;
  do {
    scanf("%d", &n);
    c = getchar();
  } while (n < 0 || n > 20);
  for (i = 0; i < n; i++) {
    c = getchar();
    current[i] = c - '0';
    next[i] = current[i];
    c = getchar();
  }
  for (j = 0; j < 1000; j++) {
    alive = 0;
    for (i = 0; i < n; i++) {
      current[i] = next[i];
      if (next[i] == 1) {
        printf("*");
        alive = 1;
      } else if (next[i] == 0)
        printf(".");
    }
    printf("\n");
    if (!alive)
      break;
    next_generation(current, next, n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1b1(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x1a4(%rbp)
mov    %al,-0x1b2(%rbp)
jl     1197 <main+0x57>
cmpl   $0x14,-0x1a4(%rbp)
setg   %al
mov    %al,-0x1b2(%rbp)
mov    -0x1b2(%rbp),%al
test   $0x1,%al
jne    1152 <main+0x12>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    1223 <main+0xe3>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1b1(%rbp)
movsbl -0x1b1(%rbp),%ecx
sub    $0x30,%ecx
movslq -0x1a8(%rbp),%rax
mov    %ecx,-0xd0(%rbp,%rax,4)
movslq -0x1a8(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%ecx
movslq -0x1a8(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1b1(%rbp)
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11af <main+0x6f>
movl   $0x0,-0x1ac(%rbp)
cmpl   $0x3e8,-0x1ac(%rbp)
jge    1339 <main+0x1f9>
movl   $0x0,-0x1b0(%rbp)
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    12ee <main+0x1ae>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1a8(%rbp),%rax
mov    %ecx,-0xd0(%rbp,%rax,4)
movslq -0x1a8(%rbp),%rax
cmpl   $0x1,-0x1a0(%rbp,%rax,4)
01
jne    12af <main+0x16f>
lea    0xd68(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x1b0(%rbp)
jmp    12d5 <main+0x195>
movslq -0x1a8(%rbp),%rax
cmpl   $0x0,-0x1a0(%rbp,%rax,4)
jne    12d0 <main+0x190>
lea    0xd3a(%rip),%rdi
call   1040 <printf@plt>
jmp    12d5 <main+0x195>
jmp    12da <main+0x19a>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    1251 <main+0x111>
lea    0xd12(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x1b0(%rbp)
jne    130c <main+0x1cc>
jmp    1339 <main+0x1f9>
lea    -0xd0(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
mov    -0x1a4(%rbp),%edx
call   1030 <next_generation@plt>
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    122d <main+0xed>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1b0,%rsp
lea    0xeaa(%rip),%r14
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0xc(%rsp),%eax
cmp    $0x14,%eax
ja     1160 <main+0x20>
test   %eax,%eax
je     11cb <main+0x8b>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%eax
add    $0xffffffd0,%eax
mov    %eax,0xe0(%rsp,%rbx,4)
mov    %eax,0x10(%rsp,%rbx,4)
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1190 <main+0x50>
test   %eax,%eax
setg   %al
test   %al,%al
jne    11d5 <main+0x95>
jmp    1275 <main+0x135>
xor    %eax,%eax
test   %al,%al
je     1275 <main+0x135>
xor    %r12d,%r12d
lea    0xe0(%rsp),%r14
lea    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    121a <main+0xda>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2a,%edi
mov    %eax,%ebp
call   1040 <putchar@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jge    1240 <main+0x100>
mov    0x10(%rsp,%rbx,4),%eax
mov    %eax,0xe0(%rsp,%rbx,4)
cmp    $0x1,%eax
je     1200 <main+0xc0>
test   %eax,%eax
jne    120c <main+0xcc>
mov    $0x2e,%edi
jmp    1207 <main+0xc7>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1040 <putchar@plt>
test   %ebp,%ebp
je     127f <main+0x13f>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <next_generation@plt>
add    $0x1,%r12d
cmp    $0x3e8,%r12d
je     127f <main+0x13f>
cmpl   $0x0,0xc(%rsp)
jg     11f0 <main+0xb0>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x1b0,%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 [50 x i32]
%3 = alloca [50 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %1
br label %9
9: ; preds = %18, %0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%11 = call signext i8 (...) @getchar()
store i8 %11, i8* %8
br label %12
12: ; preds = %9
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 20
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ true, %12 ], [ %17, %15 ]
br i1 %19, label %9, label %20
20: ; preds = %18
store i32 0, i32* %5
br label %21
21: ; preds = %41, %20
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %44
25: ; preds = %21
%26 = call signext i8 (...) @getchar()
store i8 %26, i8* %8
%27 = load i8, i8* %8
%28 = sext i8 %27 to i32
%29 = sub nsw i32 %28, 48
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %31
store i32 %29, i32* %32
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %38
store i32 %36, i32* %39
%40 = call signext i8 (...) @getchar()
store i8 %40, i8* %8
br label %41
41: ; preds = %25
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %21
44: ; preds = %21
store i32 0, i32* %6
br label %45
45: ; preds = %91, %44
%46 = load i32, i32* %6
%47 = icmp slt i32 %46, 1000
br i1 %47, label %48, label %94
48: ; preds = %45
store i32 0, i32* %7
store i32 0, i32* %5
br label %49
49: ; preds = %78, %48
%50 = load i32, i32* %5
%51 = load i32, i32* %4
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %81
53: ; preds = %49
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %59
store i32 %57, i32* %60
%61 = load i32, i32* %5
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = icmp eq i32 %64, 1
br i1 %65, label %66, label %68
66: ; preds = %53
%67 = 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 %77
68: ; preds = %53
%69 = load i32, i32* %5
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %68
%75 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %76
76: ; preds = %74, %68
br label %77
77: ; preds = %76, %66
br label %78
78: ; preds = %77
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 1
store i32 %80, i32* %5
br label %49
81: ; preds = %49
%82 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%83 = load i32, i32* %7
%84 = icmp ne i32 %83, 0
br i1 %84, label %86, label %85
85: ; preds = %81
br label %94
86: ; preds = %81
%87 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%88 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
%89 = load i32, i32* %4
%90 = call i32 @next_generation(i32* %87, i32* %88, i32 %89)
br label %91
91: ; preds = %86
%92 = load i32, i32* %6
%93 = add nsw i32 %92, 1
store i32 %93, i32* %6
br label %45
94: ; preds = %85, %45
ret i32 0
}

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