#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 COLS;
int LINES;
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
scalar_t__ gameover(int **);
int /*<<< orphan*/ init_life(int **);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printgrid(int **);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ run_life(int **);
int /*<<< orphan*/ usleep(int);
int main(void) {
  initscr();
  noecho();
  noecho();
  curs_set(0);
  int grid[COLS][LINES];
  init_life(grid);
  printgrid(grid);
  for (;;) {
    run_life(grid);
    printgrid(grid);
    refresh();
    if (gameover(grid) == 0)
      break;
    usleep(50000);
  }
  refresh();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
mov    %al,-0x2d(%rbp)
call   1030 <initscr@plt>
mov    -0x2d(%rbp),%al
call   10a0 <noecho@plt>
mov    -0x2d(%rbp),%al
call   10a0 <noecho@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <curs_set@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,%rdx
imul   %rax,%rdx
lea    0xf(,%rdx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rdi
sub    %rdx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
call   1040 <init_life@plt>
mov    -0x28(%rbp),%rdi
call   1060 <printgrid@plt>
mov    -0x28(%rbp),%rdi
call   1090 <run_life@plt>
mov    -0x28(%rbp),%rdi
call   1060 <printgrid@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    -0x28(%rbp),%rdi
call   1050 <gameover@plt>
cmp    $0x0,%rax
jne    1256 <main+0xb6>
jmp    1265 <main+0xc5>
mov    $0xc350,%edi
call   10c0 <usleep@plt>
jmp    1225 <main+0x85>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    $0x0,%al
call   1080 <endwin@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <initscr@plt>
xor    %eax,%eax
call   10a0 <noecho@plt>
xor    %eax,%eax
call   10a0 <noecho@plt>
xor    %edi,%edi
call   10b0 <curs_set@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    0x2e16(%rip),%rcx
mov    (%rcx),%ecx
imul   %rax,%rcx
lea    0xf(,%rcx,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1040 <init_life@plt>
mov    %rbx,%rdi
call   1060 <printgrid@plt>
nopl   (%rax)
mov    %rbx,%rdi
call   1090 <run_life@plt>
mov    %rbx,%rdi
call   1060 <printgrid@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
mov    %rbx,%rdi
call   1050 <gameover@plt>
test   %rax,%rax
je     1230 <main+0x90>
mov    $0xc350,%edi
call   10c0 <usleep@plt>
jmp    1200 <main+0x60>
xor    %eax,%eax
call   1070 <refresh@plt>
xor    %eax,%eax
call   1080 <endwin@plt>
xor    %eax,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@COLS = global i32 0
@LINES = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32 (...) @initscr()
%6 = call i32 (...) @noecho()
%7 = call i32 (...) @noecho()
%8 = call i32 @curs_set(i32 0)
%9 = load i32, i32* @COLS
%10 = zext i32 %9 to i64
%11 = load i32, i32* @LINES
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %2
%14 = mul nuw i64 %10, %12
%15 = alloca i32, i64 %14
store i64 %10, i64* %3
store i64 %12, i64* %4
%16 = bitcast i32* %15 to i32**
%17 = call i32 @init_life(i32** %16)
%18 = bitcast i32* %15 to i32**
%19 = call i32 @printgrid(i32** %18)
br label %20
20: ; preds = %30, %0
%21 = bitcast i32* %15 to i32**
%22 = call i32 @run_life(i32** %21)
%23 = bitcast i32* %15 to i32**
%24 = call i32 @printgrid(i32** %23)
%25 = call i32 (...) @refresh()
%26 = bitcast i32* %15 to i32**
%27 = call i64 @gameover(i32** %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %20
br label %32
30: ; preds = %20
%31 = call i32 @usleep(i32 50000)
br label %20
32: ; preds = %29
%33 = call i32 (...) @refresh()
%34 = call i32 (...) @endwin()
store i32 0, i32* %1
%35 = load i8*, i8** %2
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@COLS = global i32 0
@LINES = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @noecho()
%3 = tail call i32 (...) @noecho()
%4 = tail call i32 @curs_set(i32 0)
%5 = load i32, i32* @COLS
%6 = zext i32 %5 to i64
%7 = load i32, i32* @LINES
%8 = zext i32 %7 to i64
%9 = mul nuw i64 %8, %6
%10 = alloca i32, i64 %9
%11 = bitcast i32* %10 to i32**
%12 = call i32 @init_life(i32** %11)
%13 = call i32 @printgrid(i32** %11)
%14 = call i32 @run_life(i32** %11)
%15 = call i32 @printgrid(i32** %11)
%16 = call i32 (...) @refresh()
%17 = call i64 @gameover(i32** %11)
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %0, %19
%20 = call i32 @usleep(i32 50000)
%21 = call i32 @run_life(i32** %11)
%22 = call i32 @printgrid(i32** %11)
%23 = call i32 (...) @refresh()
%24 = call i64 @gameover(i32** %11)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %19
26: ; preds = %19, %0
%27 = call i32 (...) @refresh()
%28 = call i32 (...) @endwin()
ret i32 0
}