#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*/ scanf(char *, int *);
int main() {
  int n, length;
  int in[20];
  int out[20];
  scanf("%d", &length);
  if (length > 20 || length < 0) {
    return 0;
  }
  for (n = 0; n < length; n++) {
    scanf("%d", &in[n]);
  }
  next_generation(in, out, length);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x14,-0xc(%rbp)
jg     1156 <main+0x36>
cmpl   $0x0,-0xc(%rbp)
jge    1162 <main+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <main+0x98>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119e <main+0x7e>
movslq -0x8(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe75(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <main+0x49>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <next_generation@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xb0,%rsp
lea    0xecd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x14,%eax
ja     1190 <main+0x70>
test   %eax,%eax
je     117f <main+0x5f>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xea8(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rdx
add    $0x4,%r15
cmp    %rdx,%rbx
jl     1160 <main+0x40>
jmp    1181 <main+0x61>
xor    %edx,%edx
lea    0x10(%rsp),%rdi
lea    0x60(%rsp),%rsi
call   1030 <next_generation@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i32]
%5 = alloca [20 x 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* %3)
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 20
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %0
store i32 0, i32* %1
br label %31
13: ; preds = %9
store i32 0, i32* %2
br label %14
14: ; preds = %23, %13
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %14
26: ; preds = %14
%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* %3
%30 = call i32 @next_generation(i32* %27, i32* %28, i32 %29)
store i32 0, i32* %1
br label %31
31: ; preds = %26, %12
%32 = load i32, i32* %1
ret i32 %32
}

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 ugt i32 %8, 20
br i1 %9, label %25, label %10
10: ; preds = %0
%11 = icmp eq i32 %8, 0
br i1 %11, label %20, label %12
12: ; preds = %10, %12
%13 = phi i64 [ %16, %12 ], [ 0, %10 ]
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %10
%21 = phi i32 [ 0, %10 ], [ %17, %12 ]
%22 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%23 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%24 = call i32 @next_generation(i32* %22, i32* %23, i32 %21)
br label %25
25: ; preds = %0, %20
ret i32 0
}