#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 *, ...);
int main() {
  const int size = 50;
  int old_cell[size];
  int new_cell[size];
  for (int i = 0; i < size; i++) {
    old_cell[i] = 0;
    new_cell[i] = 0;
  }
  old_cell[36] = 1;
  for (;;) {
    for (int i = 0; i < size; i++) {
      printf("%d", old_cell[i]);
    }
    printf("\n");
    for (int i = 1; i < size - 1; i++) {
      int number_of_neighbours =
          old_cell[i - 1] + old_cell[i] + old_cell[i + 1];
      switch (number_of_neighbours) {
      case 0:
      case 3:
        new_cell[i] = 0;
        break;
      case 1:
      case 2:
        new_cell[i] = 1;
        break;
      default:
        printf("This should never happen!\n");
        break;
      }
    }
    for (int i = 0; i < size; i++) {
      old_cell[i] = new_cell[i];
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x32,-0x8(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jge    116d <main+0x5d>
movslq -0x14(%rbp),%rax
movl   $0x0,-0xf0(%rbp,%rax,4)
movslq -0x14(%rbp),%rax
movl   $0x0,-0x1c0(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <main+0x27>
movl   $0x1,-0x60(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x32,-0x18(%rbp)
jge    11ac <main+0x9c>
movslq -0x18(%rbp),%rax
mov    -0xf0(%rbp,%rax,4),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117b <main+0x6b>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x31,-0x1c(%rbp)
jge    127c <main+0x16c>
movslq -0x1c(%rbp),%rcx
mov    %ecx,%eax
add    $0xffffffff,%eax
cltq
mov    -0xf0(%rbp,%rax,4),%eax
mov    -0xf0(%rbp,%rcx,4),%edx
mov    -0xec(%rbp,%rcx,4),%ecx
add    %edx,%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c4(%rbp)
test   %eax,%eax
je     1233 <main+0x123>
jmp    1208 <main+0xf8>
mov    -0x1c4(%rbp),%eax
add    $0xffffffff,%eax
sub    $0x2,%eax
jb     1247 <main+0x137>
jmp    121f <main+0x10f>
mov    -0x1c4(%rbp),%eax
sub    $0x3,%eax
jne    125b <main+0x14b>
jmp    1233 <main+0x123>
movslq -0x1c(%rbp),%rax
movl   $0x0,-0x1c0(%rbp,%rax,4)
jmp    1269 <main+0x159>
movslq -0x1c(%rbp),%rax
movl   $0x1,-0x1c0(%rbp,%rax,4)
jmp    1269 <main+0x159>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126e <main+0x15e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c1 <main+0xb1>
movl   $0x0,-0x24(%rbp)
cmpl   $0x32,-0x24(%rbp)
jge    12b1 <main+0x1a1>
movslq -0x24(%rbp),%rax
mov    -0x1c0(%rbp,%rax,4),%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0xf0(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1283 <main+0x173>
jmp    1174 <main+0x64>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x198,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0xc0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x180(%rsp)
movq   $0x0,0x190(%rsp)
movl   $0x1,0x90(%rsp)
lea    0xddb(%rip),%r12
lea    0xd0(%rsp),%r15
lea    0xdcf(%rip),%r13
jmp    1250 <main+0x110>
cs nopw 0x0(%rax,%rax,1)
mov    $0xc8,%edx
mov    %rsp,%rdi
mov    %r15,%rsi
call   1060 <memcpy@plt>
xor    %ebx,%ebx
mov    (%rsp,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x32,%rbx
jne    1252 <main+0x112>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%ebp
mov    0x4(%rsp),%r14d
xor    %ebx,%ebx
jmp    1295 <main+0x155>
nop
movl   $0x0,0xd4(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x30,%rbx
je     1240 <main+0x100>
mov    %ebp,%eax
mov    %r14d,%ebp
add    %r14d,%eax
mov    0x8(%rsp,%rbx,4),%r14d
lea    (%r14,%rax,1),%ecx
add    $0xffffffff,%ecx
add    %r14d,%eax
cmp    $0x2,%ecx
jb     12d0 <main+0x190>
cmp    $0x3,%eax
je     1280 <main+0x140>
test   %eax,%eax
je     1280 <main+0x140>
mov    %r13,%rdi
call   1040 <puts@plt>
jmp    128b <main+0x14b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movl   $0x1,0xd4(%rsp,%rbx,4)
jmp    128b <main+0x14b>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [27 x i8] c"This should never happen!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 50, i32* %2
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i32, i64 50
%11 = alloca i32, i64 50
store i32 0, i32* %4
br label %12
12: ; preds = %22, %0
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 50
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %10, i64 %17
store i32 0, i32* %18
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %11, i64 %20
store i32 0, i32* %21
br label %22
22: ; preds = %15
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %12
%26 = getelementptr inbounds i32, i32* %10, i64 36
store i32 1, i32* %26
br label %27
27: ; preds = %92, %25
store i32 0, i32* %5
br label %28
28: ; preds = %37, %27
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 50
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %10, i64 %33
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %31
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %28
40: ; preds = %28
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %42
42: ; preds = %74, %40
%43 = load i32, i32* %6
%44 = icmp slt i32 %43, 49
br i1 %44, label %45, label %77
45: ; preds = %42
%46 = load i32, i32* %6
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %10, i64 %48
%50 = load i32, i32* %49
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %10, i64 %52
%54 = load i32, i32* %53
%55 = add nsw i32 %50, %54
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %10, i64 %58
%60 = load i32, i32* %59
%61 = add nsw i32 %55, %60
store i32 %61, i32* %7
%62 = load i32, i32* %7
switch i32 %62, label %71 [
i32 0, label %63
i32 3, label %63
i32 1, label %67
i32 2, label %67
]
63: ; preds = %45, %45
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i32, i32* %11, i64 %65
store i32 0, i32* %66
br label %73
67: ; preds = %45, %45
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %11, i64 %69
store i32 1, i32* %70
br label %73
71: ; preds = %45
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %73
73: ; preds = %71, %67, %63
br label %74
74: ; preds = %73
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %42
77: ; preds = %42
store i32 0, i32* %8
br label %78
78: ; preds = %89, %77
%79 = load i32, i32* %8
%80 = icmp slt i32 %79, 50
br i1 %80, label %81, label %92
81: ; preds = %78
%82 = load i32, i32* %8
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %11, i64 %83
%85 = load i32, i32* %84
%86 = load i32, i32* %8
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %10, i64 %87
store i32 %85, i32* %88
br label %89
89: ; preds = %81
%90 = load i32, i32* %8
%91 = add nsw i32 %90, 1
store i32 %91, i32* %8
br label %78
92: ; preds = %78
br label %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [26 x i8] c"This should never happen!\00"
define i32 @main() {
%1 = alloca [50 x i32]
%2 = bitcast [50 x i32]* %1 to i8*
%3 = alloca [50 x i32]
%4 = bitcast [50 x i32]* %3 to i8*
%5 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 36
store i32 1, i32* %5
%6 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%7 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 1
br label %12
8: ; preds = %12
%9 = tail call i32 @putchar(i32 10)
%10 = load i32, i32* %6
%11 = load i32, i32* %7
br label %21
12: ; preds = %19, %0
%13 = phi i64 [ 0, %0 ], [ %20, %19 ]
%14 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, 50
br i1 %18, label %8, label %19
19: ; preds = %12, %38
%20 = phi i64 [ %17, %12 ], [ 0, %38 ]
br label %12
21: ; preds = %8, %36
%22 = phi i32 [ %11, %8 ], [ %28, %36 ]
%23 = phi i32 [ %10, %8 ], [ %22, %36 ]
%24 = phi i64 [ 1, %8 ], [ %26, %36 ]
%25 = add nsw i32 %22, %23
%26 = add nuw nsw i64 %24, 1
%27 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = add nsw i32 %25, %28
switch i32 %29, label %34 [
i32 0, label %30
i32 3, label %30
i32 1, label %32
i32 2, label %32
]
30: ; preds = %21, %21
%31 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %24
store i32 0, i32* %31
br label %36
32: ; preds = %21, %21
%33 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %24
store i32 1, i32* %33
br label %36
34: ; preds = %21
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %36
36: ; preds = %34, %32, %30
%37 = icmp eq i64 %26, 49
br i1 %37, label %38, label %21
38: ; preds = %36
br label %19
}