#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 length, current[20], next[20], count = 0;
  scanf("%d", &length);
  while (length > 20 || length < 0)
    scanf("%d", &length);
  while (count != length) {
    scanf("%d", &current[count]);
    count++;
  }
  next_generation(current, next, length);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xb4(%rbp)
lea    0xebd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x14,-0x8(%rbp)
mov    %al,-0xb5(%rbp)
jg     116b <main+0x4b>
cmpl   $0x0,-0x8(%rbp)
setl   %al
mov    %al,-0xb5(%rbp)
mov    -0xb5(%rbp),%al
test   $0x1,%al
jne    117e <main+0x5e>
jmp    1193 <main+0x73>
lea    0xe7b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    114c <main+0x2c>
jmp    1198 <main+0x78>
mov    -0xb4(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11d9 <main+0xb9>
movslq -0xb4(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe40(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1198 <main+0x78>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <next_generation@plt>
xor    %eax,%eax
add    $0xc0,%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    $0x15,%eax
jb     1174 <main+0x54>
lea    0xeb3(%rip),%r14
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x14,%eax
ja     1160 <main+0x40>
test   %eax,%eax
je     11ae <main+0x8e>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe7a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbx
mov    0xc(%rsp),%edx
add    $0x4,%r15
cmp    %rdx,%rbx
jne    1190 <main+0x70>
jmp    11b0 <main+0x90>
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 [20 x i32]
%4 = alloca [20 x i32]
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 20
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br label %13
13: ; preds = %10, %7
%14 = phi i1 [ true, %7 ], [ %12, %10 ]
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
17: ; preds = %13
br label %18
18: ; preds = %22, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %2
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [20 x i32], [20 x i32]* %3, 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* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %18
29: ; preds = %18
%30 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%31 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%32 = load i32, i32* %2
%33 = call i32 @next_generation(i32* %30, i32* %31, i32 %32)
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 = 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 %13, label %10
10: ; preds = %13, %0
%11 = phi i32 [ %8, %0 ], [ %15, %13 ]
%12 = icmp eq i32 %11, 0
br i1 %12, label %25, label %17
13: ; preds = %0, %13
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp ugt i32 %15, 20
br i1 %16, label %13, label %10
17: ; preds = %10, %17
%18 = phi i64 [ %21, %17 ], [ 0, %10 ]
%19 = getelementptr inbounds [20 x i32], [20 x i32]* %2, 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 = add nuw i64 %18, 1
%22 = load i32, i32* %1
%23 = zext i32 %22 to i64
%24 = icmp eq i64 %21, %23
br i1 %24, label %25, label %17
25: ; preds = %17, %10
%26 = phi i32 [ 0, %10 ], [ %22, %17 ]
%27 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%28 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%29 = call i32 @next_generation(i32* %27, i32* %28, i32 %26)
ret i32 0
}