#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*/ printf(char *);
void next_generation(int *number, int *lenght) {
  int counter = 0, number_zero = 2, previous[20], new_generation_number = 0;
  printf("\n.");
  for (counter = 1; counter < *lenght; counter++) {
    if (number[counter] == 0)
      printf(".");
    if (number[counter] == 1)
      printf("*");
  }
  do {
    for (counter = 0; counter < *lenght; counter++)
      previous[counter] = number[counter];
    number_zero = 2;
    printf("\n.");
    for (counter = 1; counter < *lenght - 1; counter++) {
      if ((previous[counter - 1] == 0 && previous[counter + 1] == 1) ||
          (previous[counter - 1] == 1 && previous[counter + 1] == 0)) {
        number[counter] = 1;
        printf("*");
      } else {
        number[counter] = 0;
        number_zero++;
        printf(".");
      }
    }
    new_generation_number++;
    printf(".");
  } while ((number_zero < *lenght) || new_generation_number == 1000);
}


x86 assembly (clang, -O0):
<next_generation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
movl   $0x0,-0x74(%rbp)
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    11a9 <next_generation+0x99>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1178 <next_generation+0x68>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    1196 <next_generation+0x86>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
jmp    119b <next_generation+0x8b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <next_generation+0x3b>
jmp    11ae <next_generation+0x9e>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    11e5 <next_generation+0xd5>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b5 <next_generation+0xa5>
movl   $0x2,-0x18(%rbp)
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12b6 <next_generation+0x1a6>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
cmpl   $0x0,-0x70(%rbp,%rax,4)
jne    1239 <next_generation+0x129>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
cmpl   $0x1,-0x70(%rbp,%rax,4)
je     125f <next_generation+0x14f>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
cmpl   $0x1,-0x70(%rbp,%rax,4)
jne    127f <next_generation+0x16f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
cmpl   $0x0,-0x70(%rbp,%rax,4)
jne    127f <next_generation+0x16f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
lea    0xd8e(%rip),%rdi
call   1030 <printf@plt>
jmp    12a3 <next_generation+0x193>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
lea    0xd63(%rip),%rdi
call   1030 <printf@plt>
jmp    12a8 <next_generation+0x198>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ff <next_generation+0xef>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
lea    0xd3b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rdx
mov    $0x1,%al
cmp    (%rdx),%ecx
mov    %al,-0x75(%rbp)
jl     12ec <next_generation+0x1dc>
cmpl   $0x3e8,-0x74(%rbp)
sete   %al
mov    %al,-0x75(%rbp)
mov    -0x75(%rbp),%al
test   $0x1,%al
jne    11ae <next_generation+0x9e>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_generation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
mov    (%rbx),%eax
cmp    $0x2,%eax
jl     119f <next_generation+0x6f>
mov    $0x1,%ebp
jmp    116c <next_generation+0x3c>
xchg   %ax,%ax
add    $0x1,%rbp
movslq (%rbx),%rax
cmp    %rax,%rbp
jge    119f <next_generation+0x6f>
mov    (%r14,%rbp,4),%eax
test   %eax,%eax
je     1180 <next_generation+0x50>
cmp    $0x1,%eax
jne    1160 <next_generation+0x30>
jmp    1193 <next_generation+0x63>
nopl   0x0(%rax,%rax,1)
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    (%r14,%rbp,4),%eax
cmp    $0x1,%eax
jne    1160 <next_generation+0x30>
mov    $0x2a,%edi
call   1030 <putchar@plt>
jmp    1160 <next_generation+0x30>
xor    %r13d,%r13d
lea    0xe57(%rip),%r12
nopl   0x0(%rax)
test   %eax,%eax
jle    11c5 <next_generation+0x95>
mov    %eax,%edx
shl    $0x2,%rdx
mov    %rsp,%rdi
mov    %r14,%rsi
call   1050 <memcpy@plt>
mov    %r12,%rdi
call   1040 <printf@plt>
mov    $0x2,%ebp
cmpl   $0x3,(%rbx)
jl     1250 <next_generation+0x120>
mov    $0x2,%ebp
mov    $0x1,%r15d
jmp    121d <next_generation+0xed>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpl   $0x0,0x4(%rsp,%r15,4)
je     1233 <next_generation+0x103>
movl   $0x0,(%r14,%r15,4)
add    $0x1,%ebp
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
movslq (%rbx),%rax
add    $0xffffffffffffffff,%rax
cmp    %rax,%r15
jge    1250 <next_generation+0x120>
mov    -0x4(%rsp,%r15,4),%eax
cmp    $0x1,%eax
je     11f0 <next_generation+0xc0>
test   %eax,%eax
jne    11f8 <next_generation+0xc8>
cmpl   $0x1,0x4(%rsp,%r15,4)
jne    11f8 <next_generation+0xc8>
movl   $0x1,(%r14,%r15,4)
mov    $0x2a,%edi
jmp    1208 <next_generation+0xd8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r13d
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    (%rbx),%eax
cmp    %eax,%ebp
jl     11b0 <next_generation+0x80>
cmp    $0x3e8,%r13d
je     11b0 <next_generation+0x80>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0A.\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [2 x i8] c"*\00"
define void @next_generation(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [20 x i32]
%8 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
store i32 2, i32* %6
store i32 0, i32* %8
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %10
10: ; preds = %34, %2
%11 = load i32, i32* %5
%12 = load i32*, i32** %4
%13 = load i32, i32* %12
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %37
15: ; preds = %10
%16 = load i32*, i32** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %15
%25 = load i32*, i32** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31, %24
br label %34
34: ; preds = %33
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %10
37: ; preds = %10
br label %38
38: ; preds = %122, %37
store i32 0, i32* %5
br label %39
39: ; preds = %53, %38
%40 = load i32, i32* %5
%41 = load i32*, i32** %4
%42 = load i32, i32* %41
%43 = icmp slt i32 %40, %42
br i1 %43, label %44, label %56
44: ; preds = %39
%45 = load i32*, i32** %3
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 %51
store i32 %49, i32* %52
br label %53
53: ; preds = %44
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 1
store i32 %55, i32* %5
br label %39
56: ; preds = %39
store i32 2, i32* %6
%57 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %58
58: ; preds = %107, %56
%59 = load i32, i32* %5
%60 = load i32*, i32** %4
%61 = load i32, i32* %60
%62 = sub nsw i32 %61, 1
%63 = icmp slt i32 %59, %62
br i1 %63, label %64, label %110
64: ; preds = %58
%65 = load i32, i32* %5
%66 = sub nsw i32 %65, 1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %78
71: ; preds = %64
%72 = load i32, i32* %5
%73 = add nsw i32 %72, 1
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 %74
%76 = load i32, i32* %75
%77 = icmp eq i32 %76, 1
br i1 %77, label %92, label %78
78: ; preds = %71, %64
%79 = load i32, i32* %5
%80 = sub nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 %81
%83 = load i32, i32* %82
%84 = icmp eq i32 %83, 1
br i1 %84, label %85, label %98
85: ; preds = %78
%86 = load i32, i32* %5
%87 = add nsw i32 %86, 1
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 %88
%90 = load i32, i32* %89
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %98
92: ; preds = %85, %71
%93 = load i32*, i32** %3
%94 = load i32, i32* %5
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i32, i32* %93, i64 %95
store i32 1, i32* %96
%97 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %106
98: ; preds = %85, %78
%99 = load i32*, i32** %3
%100 = load i32, i32* %5
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i32, i32* %99, i64 %101
store i32 0, i32* %102
%103 = load i32, i32* %6
%104 = add nsw i32 %103, 1
store i32 %104, i32* %6
%105 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %106
106: ; preds = %98, %92
br label %107
107: ; preds = %106
%108 = load i32, i32* %5
%109 = add nsw i32 %108, 1
store i32 %109, i32* %5
br label %58
110: ; preds = %58
%111 = load i32, i32* %8
%112 = add nsw i32 %111, 1
store i32 %112, i32* %8
%113 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %114
114: ; preds = %110
%115 = load i32, i32* %6
%116 = load i32*, i32** %4
%117 = load i32, i32* %116
%118 = icmp slt i32 %115, %117
br i1 %118, label %122, label %119
119: ; preds = %114
%120 = load i32, i32* %8
%121 = icmp eq i32 %120, 1000
br label %122
122: ; preds = %119, %114
%123 = phi i1 [ true, %114 ], [ %121, %119 ]
br i1 %123, label %38, label %124
124: ; preds = %122
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0A.\00"
define void @next_generation(i32* nocapture %0, i32* nocapture %1) {
%3 = bitcast i32* %0 to i8*
%4 = alloca [20 x i32]
%5 = bitcast [20 x i32]* %4 to i8*
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %27
9: ; preds = %2, %22
%10 = phi i64 [ %23, %22 ], [ 1, %2 ]
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 @putchar(i32 46)
%16 = load i32, i32* %11
br label %17
17: ; preds = %14, %9
%18 = phi i32 [ %16, %14 ], [ %12, %9 ]
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @putchar(i32 42)
br label %22
22: ; preds = %17, %20
%23 = add nuw nsw i64 %10, 1
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %9, label %27
27: ; preds = %22, %2
%28 = phi i32 [ %7, %2 ], [ %24, %22 ]
br label %29
29: ; preds = %27, %70
%30 = phi i32 [ %74, %70 ], [ %28, %27 ]
%31 = phi i32 [ %72, %70 ], [ 0, %27 ]
%32 = icmp sgt i32 %30, 0
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = zext i32 %30 to i64
%35 = shl nuw nsw i64 %34, 2
br label %36
36: ; preds = %33, %29
%37 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%38 = load i32, i32* %1
%39 = icmp sgt i32 %38, 2
br i1 %39, label %40, label %70
40: ; preds = %36, %61
%41 = phi i64 [ %65, %61 ], [ 1, %36 ]
%42 = phi i32 [ %63, %61 ], [ 2, %36 ]
%43 = add nsw i64 %41, -1
%44 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %43
%45 = load i32, i32* %44
switch i32 %45, label %58 [
i32 0, label %46
i32 1, label %51
]
46: ; preds = %40
%47 = add nuw nsw i64 %41, 1
%48 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = icmp eq i32 %49, 1
br i1 %50, label %56, label %58
51: ; preds = %40
%52 = add nuw nsw i64 %41, 1
%53 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %51, %46
%57 = getelementptr inbounds i32, i32* %0, i64 %41
store i32 1, i32* %57
br label %61
58: ; preds = %40, %46, %51
%59 = getelementptr inbounds i32, i32* %0, i64 %41
store i32 0, i32* %59
%60 = add nsw i32 %42, 1
br label %61
61: ; preds = %56, %58
%62 = phi i32 [ 42, %56 ], [ 46, %58 ]
%63 = phi i32 [ %42, %56 ], [ %60, %58 ]
%64 = tail call i32 @putchar(i32 %62)
%65 = add nuw nsw i64 %41, 1
%66 = load i32, i32* %1
%67 = add nsw i32 %66, -1
%68 = sext i32 %67 to i64
%69 = icmp slt i64 %65, %68
br i1 %69, label %40, label %70
70: ; preds = %61, %36
%71 = phi i32 [ 2, %36 ], [ %63, %61 ]
%72 = add nuw nsw i32 %31, 1
%73 = tail call i32 @putchar(i32 46)
%74 = load i32, i32* %1
%75 = icmp slt i32 %71, %74
%76 = icmp eq i32 %72, 1000
%77 = select i1 %75, i1 true, i1 %76
br i1 %77, label %29, label %78
78: ; preds = %70
ret void
}