#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[20], next[20], count, length;
  for (count = 0; count < 20; count++) {
    current[count] = next[count] = 0;
  }
  do {
    scanf("%d", &length);
  } while (length < 0 || length > 20);
  for (count = 0; count < length; count++) {
    scanf("%d", &current[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)
cmpl   $0x14,-0xb4(%rbp)
jge    117e <main+0x5e>
movslq -0xb4(%rbp),%rax
movl   $0x0,-0xb0(%rbp,%rax,4)
movslq -0xb4(%rbp),%rax
movl   $0x0,-0x60(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    113c <main+0x1c>
jmp    1183 <main+0x63>
lea    0xe76(%rip),%rdi
lea    -0xb8(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0xb8(%rbp)
mov    %al,-0xb9(%rbp)
jl     11bb <main+0x9b>
cmpl   $0x14,-0xb8(%rbp)
setg   %al
mov    %al,-0xb9(%rbp)
mov    -0xb9(%rbp),%al
test   $0x1,%al
jne    1183 <main+0x63>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xb8(%rbp),%eax
jge    1217 <main+0xf7>
movslq -0xb4(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe02(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    11d3 <main+0xb3>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0xb8(%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
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
lea    0xe8f(%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     1180 <main+0x60>
test   %eax,%eax
je     11cf <main+0xaf>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe5a(%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     11b0 <main+0x90>
jmp    11d1 <main+0xb1>
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 [20 x i32]
%3 = alloca [20 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %11
store i32 0, i32* %12
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %14
store i32 0, i32* %15
br label %16
16: ; preds = %9
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
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* %5)
br label %22
22: ; preds = %20
%23 = load i32, i32* %5
%24 = icmp slt i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %5
%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* %4
br label %31
31: ; preds = %40, %30
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %43
35: ; preds = %31
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [20 x i32], [20 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* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %31
43: ; preds = %31
%44 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%45 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%46 = load i32, i32* %5
%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 [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = alloca [20 x i32]
%4 = bitcast [20 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 [20 x i32], [20 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 [20 x i32], [20 x i32]* %1, i64 0, i64 0
%24 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%25 = call i32 @next_generation(i32* %23, i32* %24, i32 %22)
ret i32 0
}