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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc8(%rbp)
movl   $0x0,-0xc8(%rbp)
cmpl   $0x17,-0xc8(%rbp)
jge    1188 <main+0x68>
movslq -0xc8(%rbp),%rax
movl   $0x0,-0xc0(%rbp,%rax,4)
movslq -0xc8(%rbp),%rax
movl   $0x0,-0x60(%rbp,%rax,4)
mov    -0xc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8(%rbp)
jmp    1146 <main+0x26>
jmp    118d <main+0x6d>
lea    0xe6c(%rip),%rdi
lea    -0xc4(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0xc4(%rbp)
mov    %al,-0xc9(%rbp)
jl     11c5 <main+0xa5>
cmpl   $0x14,-0xc4(%rbp)
setg   %al
mov    %al,-0xc9(%rbp)
mov    -0xc9(%rbp),%al
test   $0x1,%al
jne    118d <main+0x6d>
movl   $0x0,-0xc8(%rbp)
mov    -0xc8(%rbp),%eax
cmp    -0xc4(%rbp),%eax
jge    1221 <main+0x101>
movslq -0xc8(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdf8(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8(%rbp)
jmp    11dd <main+0xbd>
lea    -0x60(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
mov    -0xc4(%rbp),%edx
call   1030 <next_generation@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xb0(%rsp)
movups %xmm0,0xbc(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movups %xmm0,0x5c(%rsp)
lea    0xe7f(%rip),%r14
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x14,%eax
ja     1190 <main+0x70>
test   %eax,%eax
je     11df <main+0xbf>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe4a(%rip),%r14
cs nopw 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     11c0 <main+0xa0>
jmp    11e1 <main+0xc1>
xor    %edx,%edx
lea    0x10(%rsp),%rdi
lea    0x70(%rsp),%rsi
call   1030 <next_generation@plt>
xor    %eax,%eax
add    $0xd0,%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 [23 x i32]
%3 = alloca [23 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %5
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 23
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [23 x i32], [23 x i32]* %3, i64 0, i64 %11
store i32 0, i32* %12
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [23 x i32], [23 x i32]* %2, i64 0, i64 %14
store i32 0, i32* %15
br label %16
16: ; preds = %9
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %6
19: ; preds = %6
br label %20
20: ; preds = %28, %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %22
22: ; preds = %20
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 20
br label %28
28: ; preds = %25, %22
%29 = phi i1 [ true, %22 ], [ %27, %25 ]
br i1 %29, label %20, label %30
30: ; preds = %28
store i32 0, i32* %5
br label %31
31: ; preds = %40, %30
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %43
35: ; preds = %31
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [23 x i32], [23 x i32]* %2, i64 0, i64 %37
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %38)
br label %40
40: ; preds = %35
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %31
43: ; preds = %31
%44 = getelementptr inbounds [23 x i32], [23 x i32]* %2, i64 0, i64 0
%45 = getelementptr inbounds [23 x i32], [23 x i32]* %3, i64 0, i64 0
%46 = load i32, i32* %4
%47 = call i32 @next_generation(i32* %44, i32* %45, i32 %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [23 x i32]
%2 = bitcast [23 x i32]* %1 to i8*
%3 = alloca [23 x i32]
%4 = bitcast [23 x i32]* %3 to i8*
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
br label %7
7: ; preds = %0, %7
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%9 = load i32, i32* %5
%10 = icmp ugt i32 %9, 20
br i1 %10, label %7, label %11
11: ; preds = %7
%12 = icmp eq i32 %9, 0
br i1 %12, label %21, label %13
13: ; preds = %11, %13
%14 = phi i64 [ %17, %13 ], [ 0, %11 ]
%15 = getelementptr inbounds [23 x i32], [23 x i32]* %1, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = add nuw nsw i64 %14, 1
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %13, label %21
21: ; preds = %13, %11
%22 = phi i32 [ 0, %11 ], [ %18, %13 ]
%23 = getelementptr inbounds [23 x i32], [23 x i32]* %1, i64 0, i64 0
%24 = getelementptr inbounds [23 x i32], [23 x i32]* %3, i64 0, i64 0
%25 = call i32 @next_generation(i32* %23, i32* %24, i32 %22)
ret i32 0
}