#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 */
scalar_t__ is_alive(int *, int);
int /*<<< orphan*/ next_generation(int *, int *, int);
int /*<<< orphan*/ print_generation(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[20], b[20], c, l;
  scanf("%d", &c);
  if (c <= 0) {
    return 0;
  } else if (c > 20) {
    c = 20;
  }
  l = c;
  while (c > 0) {
    scanf("%d", &a[l - c]);
    c--;
  }
  print_generation(a, l);
  if (is_alive(a, l)) {
    while (c < 999 && is_alive(b, l))
      ;
    {
      c = c + 1;
      next_generation(a, b, l);
      print_generation(b, l);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0xb4(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0xb4(%rbp)
jg     117e <main+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    12a6 <main+0x166>
cmpl   $0x14,-0xb4(%rbp)
jle    1195 <main+0x55>
movl   $0x14,-0xb4(%rbp)
jmp    119a <main+0x5a>
mov    -0xb4(%rbp),%eax
mov    %eax,-0xb8(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jle    11ec <main+0xac>
mov    -0xb8(%rbp),%eax
sub    -0xb4(%rbp),%eax
cltq
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2d(%rip),%rdi
call   1060 <scanf@plt>
mov    -0xb4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xb4(%rbp)
jmp    11a6 <main+0x66>
lea    -0x60(%rbp),%rdi
mov    -0xb8(%rbp),%esi
call   1050 <print_generation@plt>
lea    -0x60(%rbp),%rdi
mov    -0xb8(%rbp),%esi
call   1040 <is_alive@plt>
cmp    $0x0,%rax
je     129f <main+0x15f>
jmp    1219 <main+0xd9>
xor    %eax,%eax
cmpl   $0x3e7,-0xb4(%rbp)
mov    %al,-0xb9(%rbp)
jge    1250 <main+0x110>
lea    -0xb0(%rbp),%rdi
mov    -0xb8(%rbp),%esi
call   1040 <is_alive@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xb9(%rbp)
mov    -0xb9(%rbp),%al
test   $0x1,%al
jne    1263 <main+0x123>
jmp    1268 <main+0x128>
jmp    1219 <main+0xd9>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0xb8(%rbp),%edx
call   1030 <next_generation@plt>
lea    -0xb0(%rbp),%rdi
mov    -0xb8(%rbp),%esi
call   1050 <print_generation@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
lea    0xeaf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    1230 <main+0xf0>
cmp    $0x15,%ebx
jb     1179 <main+0x39>
movl   $0x14,0xc(%rsp)
mov    $0x14,%ebx
lea    0xe80(%rip),%r14
mov    %ebx,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
lea    (%rsp,%rax,4),%rsi
add    $0x10,%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
mov    0xc(%rsp),%ecx
lea    -0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
cmp    $0x1,%ecx
jg     1190 <main+0x50>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <print_generation@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <is_alive@plt>
test   %rax,%rax
je     1230 <main+0xf0>
mov    0xc(%rsp),%ecx
cmp    $0x3e6,%ecx
jg     120b <main+0xcb>
lea    0x60(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <is_alive@plt>
mov    0xc(%rsp),%ecx
test   %rax,%rax
je     120b <main+0xcb>
cmp    $0x3e7,%ecx
jl     11f0 <main+0xb0>
add    $0x1,%ecx
mov    %ecx,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0x60(%rsp),%r14
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <next_generation@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <print_generation@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca [20 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 0, i32* %1
br label %60
10: ; preds = %0
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 20
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 20, i32* %4
br label %14
14: ; preds = %13, %10
br label %15
15: ; preds = %14
%16 = load i32, i32* %4
store i32 %16, i32* %5
br label %17
17: ; preds = %20, %15
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = sub nsw i32 %21, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
%27 = load i32, i32* %4
%28 = add nsw i32 %27, -1
store i32 %28, i32* %4
br label %17
29: ; preds = %17
%30 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%31 = load i32, i32* %5
%32 = call i32 @print_generation(i32* %30, i32 %31)
%33 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%34 = load i32, i32* %5
%35 = call i64 @is_alive(i32* %33, i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %59
37: ; preds = %29
br label %38
38: ; preds = %48, %37
%39 = load i32, i32* %4
%40 = icmp slt i32 %39, 999
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%43 = load i32, i32* %5
%44 = call i64 @is_alive(i32* %42, i32 %43)
%45 = icmp ne i64 %44, 0
br label %46
46: ; preds = %41, %38
%47 = phi i1 [ false, %38 ], [ %45, %41 ]
br i1 %47, label %48, label %49
48: ; preds = %46
br label %38
49: ; preds = %46
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
%52 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%53 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%54 = load i32, i32* %5
%55 = call i32 @next_generation(i32* %52, i32* %53, i32 %54)
%56 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%57 = load i32, i32* %5
%58 = call i32 @print_generation(i32* %56, i32 %57)
br label %59
59: ; preds = %49, %29
store i32 0, i32* %1
br label %60
60: ; preds = %59, %9
%61 = load i32, i32* %1
ret i32 %61
}

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 slt i32 %8, 1
br i1 %9, label %46, label %10
10: ; preds = %0
%11 = icmp ugt i32 %8, 20
br i1 %11, label %12, label %13
12: ; preds = %10
store i32 20, i32* %3
br label %13
13: ; preds = %12, %10
%14 = phi i32 [ %8, %10 ], [ 20, %12 ]
br label %15
15: ; preds = %13, %15
%16 = phi i32 [ %22, %15 ], [ %14, %13 ]
%17 = sub nsw i32 %14, %16
%18 = sext i32 %17 to i64
%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 = load i32, i32* %3
%22 = add nsw i32 %21, -1
store i32 %22, i32* %3
%23 = icmp sgt i32 %21, 1
br i1 %23, label %15, label %24
24: ; preds = %15
%25 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%26 = call i32 @print_generation(i32* %25, i32 %14)
%27 = call i64 @is_alive(i32* %25, i32 %14)
%28 = icmp eq i64 %27, 0
br i1 %28, label %46, label %29
29: ; preds = %24
%30 = load i32, i32* %3
%31 = icmp slt i32 %30, 999
br i1 %31, label %32, label %40
32: ; preds = %29
%33 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
br label %34
34: ; preds = %32, %34
%35 = call i64 @is_alive(i32* %33, i32 %14)
%36 = icmp ne i64 %35, 0
%37 = load i32, i32* %3
%38 = icmp slt i32 %37, 999
%39 = select i1 %36, i1 %38, i1 false
br i1 %39, label %34, label %40
40: ; preds = %34, %29
%41 = phi i32 [ %30, %29 ], [ %37, %34 ]
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
%43 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%44 = call i32 @next_generation(i32* %25, i32* %43, i32 %14)
%45 = call i32 @print_generation(i32* %43, i32 %14)
br label %46
46: ; preds = %24, %40, %0
ret i32 0
}