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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xb8(%rbp)
movl   $0x0,-0xbc(%rbp)
movl   $0x0,-0xc0(%rbp)
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
lea    0xe80(%rip),%rdi
lea    -0xb4(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0xb4(%rbp)
mov    %al,-0xc1(%rbp)
jle    11b4 <main+0x74>
cmpl   $0x14,-0xb4(%rbp)
setge  %al
mov    %al,-0xc1(%rbp)
mov    -0xc1(%rbp),%al
test   $0x1,%al
jne    1170 <main+0x30>
mov    $0x0,%al
call   1050 <getchar@plt>
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    1262 <main+0x122>
movslq -0xb8(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe05(%rip),%rdi
call   1060 <scanf@plt>
cmp    $0x0,%rax
jne    1219 <main+0xd9>
movl   $0x0,-0x4(%rbp)
jmp    13da <main+0x29a>
movslq -0xb8(%rbp),%rax
cmpl   $0x0,-0x60(%rbp,%rax,4)
je     1249 <main+0x109>
movslq -0xb8(%rbp),%rax
cmpl   $0x1,-0x60(%rbp,%rax,4)
je     1249 <main+0x109>
movl   $0x0,-0x4(%rbp)
jmp    13da <main+0x29a>
jmp    124e <main+0x10e>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    11d3 <main+0x93>
lea    0xd9d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    12d2 <main+0x192>
movslq -0xb8(%rbp),%rax
cmpl   $0x0,-0x60(%rbp,%rax,4)
jne    12ad <main+0x16d>
lea    0xd65(%rip),%rdi
call   1040 <printf@plt>
jmp    12b9 <main+0x179>
lea    0xd56(%rip),%rdi
call   1040 <printf@plt>
jmp    12be <main+0x17e>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    1278 <main+0x138>
lea    0xd2d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0xb4(%rbp),%edx
call   1030 <next_generation@plt>
movl   $0x0,-0xbc(%rbp)
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    1371 <main+0x231>
movslq -0xb8(%rbp),%rax
cmpl   $0x0,-0x60(%rbp,%rax,4)
jne    134c <main+0x20c>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
lea    0xcc6(%rip),%rdi
call   1040 <printf@plt>
jmp    1358 <main+0x218>
lea    0xcb7(%rip),%rdi
call   1040 <printf@plt>
jmp    135d <main+0x21d>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    1308 <main+0x1c8>
lea    0xc8e(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
mov    -0xbc(%rbp),%ecx
xor    %eax,%eax
cmp    -0xb4(%rbp),%ecx
mov    %al,-0xc2(%rbp)
je     13b9 <main+0x279>
cmpl   $0x3e8,-0xc0(%rbp)
setl   %al
mov    %al,-0xc2(%rbp)
mov    -0xc2(%rbp),%al
test   $0x1,%al
jne    12de <main+0x19e>
lea    0xc38(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb0,%rsp
lea    0xe9a(%rip),%r14
lea    0xe96(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffec,%eax
cmp    $0xffffffed,%eax
jb     1180 <main+0x30>
xor    %eax,%eax
call   1060 <getchar@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ef <main+0x9f>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe48(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
test   %rax,%rax
je     12c3 <main+0x173>
cmpl   $0x2,(%rbx)
jae    12c3 <main+0x173>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11c0 <main+0x70>
mov    $0xa,%edi
call   1040 <putchar@plt>
cmpl   $0x0,0xc(%rsp)
jle    1234 <main+0xe4>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
cmpl   $0x0,0x10(%rsp,%rbx,4)
sete   %al
lea    0x2a(,%rax,4),%edi
call   1040 <putchar@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1210 <main+0xc0>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %r12d,%r12d
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%r14
lea    0x60(%rsp),%r15
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <next_generation@plt>
cmpl   $0x0,0xc(%rsp)
mov    $0x0,%ebp
jle    1296 <main+0x146>
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
cmpl   $0x0,0x10(%rsp,%rbx,4)
sete   %al
lea    0x2a(,%rax,4),%edi
add    %eax,%ebp
call   1040 <putchar@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1270 <main+0x120>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0xc(%rsp),%edx
cmp    %edx,%ebp
je     12b9 <main+0x169>
lea    0x1(%r12),%eax
cmp    $0x3e7,%r12d
mov    %eax,%r12d
jb     1250 <main+0x100>
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"n=\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [2 x i8] c"*\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* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %17, %0
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %11
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp sle i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 20
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ true, %11 ], [ %16, %14 ]
br i1 %18, label %8, label %19
19: ; preds = %17
%20 = call i32 (...) @getchar()
store i32 0, i32* %5
br label %21
21: ; preds = %46, %19
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %49
25: ; preds = %21
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %27
%29 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
store i32 0, i32* %1
br label %111
32: ; preds = %25
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %32
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = icmp ne i32 %42, 1
br i1 %43, label %44, label %45
44: ; preds = %38
store i32 0, i32* %1
br label %111
45: ; preds = %38, %32
br label %46
46: ; preds = %45
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
br label %21
49: ; preds = %21
%50 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %51
51: ; preds = %66, %49
%52 = load i32, i32* %5
%53 = load i32, i32* %4
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %69
55: ; preds = %51
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %55
%62 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %65
63: ; preds = %55
%64 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
br label %66
66: ; preds = %65
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 1
store i32 %68, i32* %5
br label %51
69: ; preds = %51
%70 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %71
71: ; preds = %107, %69
%72 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%73 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%74 = load i32, i32* %4
%75 = call i32 @next_generation(i32* %72, i32* %73, i32 %74)
store i32 0, i32* %6
store i32 0, i32* %5
br label %76
76: ; preds = %93, %71
%77 = load i32, i32* %5
%78 = load i32, i32* %4
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %96
80: ; preds = %76
%81 = load i32, i32* %5
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %82
%84 = load i32, i32* %83
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %90
86: ; preds = %80
%87 = load i32, i32* %6
%88 = add nsw i32 %87, 1
store i32 %88, i32* %6
%89 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %92
90: ; preds = %80
%91 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %92
92: ; preds = %90, %86
br label %93
93: ; preds = %92
%94 = load i32, i32* %5
%95 = add nsw i32 %94, 1
store i32 %95, i32* %5
br label %76
96: ; preds = %76
%97 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%98 = load i32, i32* %7
%99 = add nsw i32 %98, 1
store i32 %99, i32* %7
br label %100
100: ; preds = %96
%101 = load i32, i32* %6
%102 = load i32, i32* %4
%103 = icmp ne i32 %101, %102
br i1 %103, label %104, label %107
104: ; preds = %100
%105 = load i32, i32* %7
%106 = icmp slt i32 %105, 1000
br label %107
107: ; preds = %104, %100
%108 = phi i1 [ false, %100 ], [ %106, %104 ]
br i1 %108, label %71, label %109
109: ; preds = %107
%110 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %111
111: ; preds = %109, %44, %31
%112 = load i32, i32* %1
ret i32 %112
}

LLVM IR (-O2):
@.str = [3 x i8] c"n=\00"
@.str.1 = [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*
br label %7
7: ; preds = %7, %0
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = add i32 %10, -20
%12 = icmp ult i32 %11, -19
br i1 %12, label %7, label %13
13: ; preds = %7
%14 = call i32 (...) @getchar()
%15 = load i32, i32* %3
%16 = icmp sgt i32 %15, 0
br i1 %16, label %21, label %30
17: ; preds = %26
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %29, %19
br i1 %20, label %21, label %30
21: ; preds = %13, %17
%22 = phi i64 [ %29, %17 ], [ 0, %13 ]
%23 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %22
%24 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %80, label %26
26: ; preds = %21
%27 = load i32, i32* %23
%28 = icmp ult i32 %27, 2
%29 = add nuw nsw i64 %22, 1
br i1 %28, label %17, label %80
30: ; preds = %17, %13
%31 = call i32 @putchar(i32 10)
%32 = load i32, i32* %3
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %30, %34
%35 = phi i64 [ %41, %34 ], [ 0, %30 ]
%36 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 0
%39 = select i1 %38, i32 46, i32 42
%40 = call i32 @putchar(i32 %39)
%41 = add nuw nsw i64 %35, 1
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %41, %43
br i1 %44, label %34, label %45
45: ; preds = %34, %30
%46 = call i32 @putchar(i32 10)
%47 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%48 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%49 = load i32, i32* %3
br label %50
50: ; preds = %70, %45
%51 = phi i32 [ %49, %45 ], [ %74, %70 ]
%52 = phi i32 [ 0, %45 ], [ %73, %70 ]
%53 = call i32 @next_generation(i32* %47, i32* %48, i32 %51)
%54 = load i32, i32* %3
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %70
56: ; preds = %50, %56
%57 = phi i64 [ %66, %56 ], [ 0, %50 ]
%58 = phi i32 [ %64, %56 ], [ 0, %50 ]
%59 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %57
%60 = load i32, i32* %59
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i32 46, i32 42
%63 = zext i1 %61 to i32
%64 = add nuw nsw i32 %58, %63
%65 = call i32 @putchar(i32 %62)
%66 = add nuw nsw i64 %57, 1
%67 = load i32, i32* %3
%68 = sext i32 %67 to i64
%69 = icmp slt i64 %66, %68
br i1 %69, label %56, label %70
70: ; preds = %56, %50
%71 = phi i32 [ 0, %50 ], [ %64, %56 ]
%72 = call i32 @putchar(i32 10)
%73 = add nuw nsw i32 %52, 1
%74 = load i32, i32* %3
%75 = icmp ne i32 %71, %74
%76 = icmp ult i32 %52, 999
%77 = select i1 %75, i1 %76, i1 false
br i1 %77, label %50, label %78
78: ; preds = %70
%79 = call i32 @putchar(i32 10)
br label %80
80: ; preds = %26, %21, %78
ret i32 0
}