#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int current[20];
  int next[20];
  int lenth, count;
  printf(" Enter number of cells: \n");
  scanf("%d", &lenth);
  for (count = 0; count < lenth; count++) {
    printf(" Enter Cell (0 for dead 1 for alive):  \n");
    scanf("%d", &current[count]);
  }
  next_generation(current, next, &lenth);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0xb4(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    11bb <main+0x8b>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
movslq -0xb8(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe78(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    116b <main+0x3b>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0xb4(%rbp),%rdx
call   1030 <next_generation@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb8,%rsp
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11a5 <main+0x75>
lea    0x10(%rsp),%r12
xor    %ebx,%ebx
lea    0xeac(%rip),%r14
lea    0xe89(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     1180 <main+0x50>
lea    0x10(%rsp),%rdi
lea    0x60(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1030 <next_generation@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c" Enter number of cells: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [41 x i8] c" Enter Cell (0 for dead 1 for alive): \0A\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 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 0, i32* %5
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %12
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %8
21: ; preds = %8
%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* %4)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [25 x i8] c" Enter number of cells: \00"
@str.3 = [40 x i8] c" Enter Cell (0 for dead 1 for alive): \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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %0, %11
%12 = phi i64 [ %16, %11 ], [ 0, %0 ]
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.3, i64 0, i64 0))
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %12
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %12, 1
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %11, label %20
20: ; preds = %11, %0
%21 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%22 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%23 = call i32 @next_generation(i32* %21, i32* %22, i32* %3)
ret i32 0
}