#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*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_RED;
int /*<<< orphan*/ COLOR_WHITE;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ initializeField(int *);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printField(int *, int *);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ updateField(int *, int *);
int main(void) {
  initscr();
  cbreak();
  noecho();
  keypad(stdscr, TRUE);
  curs_set(0);
  start_color();
  init_pair(1, COLOR_WHITE, COLOR_BLACK);
  init_pair(2, COLOR_RED, COLOR_BLACK);
  int cells[25 * 80];
  int cellBuffer[25 * 80];
  initializeField(cells);
  for (int row = 0; row < 25; row++) {
    for (int col = 0; col < 80; col++) {
      cellBuffer[row * 80 + col] = 0;
    }
  }
  while (1) {
    printField(cells, cellBuffer);
    updateField(cells, cellBuffer);
    getch();
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3ea0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <initscr@plt>
mov    $0x0,%al
call   1040 <cbreak@plt>
mov    $0x0,%al
call   10c0 <noecho@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
call   1060 <keypad@plt>
xor    %edi,%edi
call   10d0 <curs_set@plt>
mov    $0x0,%al
call   1080 <start_color@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%esi
mov    0x2dcc(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1050 <init_pair@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
mov    0x2db0(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1050 <init_pair@plt>
lea    -0x1f50(%rbp),%rdi
call   10b0 <initializeField@plt>
movl   $0x0,-0x3e94(%rbp)
cmpl   $0x19,-0x3e94(%rbp)
jge    12b5 <main+0x105>
movl   $0x0,-0x3e98(%rbp)
cmpl   $0x50,-0x3e98(%rbp)
jge    129c <main+0xec>
imul   $0x50,-0x3e94(%rbp),%eax
add    -0x3e98(%rbp),%eax
cltq
movl   $0x0,-0x3e90(%rbp,%rax,4)
mov    -0x3e98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3e98(%rbp)
jmp    1261 <main+0xb1>
jmp    12a1 <main+0xf1>
mov    -0x3e94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3e94(%rbp)
jmp    124a <main+0x9a>
jmp    12ba <main+0x10a>
lea    -0x1f50(%rbp),%rdi
lea    -0x3e90(%rbp),%rsi
call   1090 <printField@plt>
lea    -0x1f50(%rbp),%rdi
lea    -0x3e90(%rbp),%rsi
call   1030 <updateField@plt>
mov    $0x0,%al
call   10a0 <getch@plt>
jmp    12ba <main+0x10a>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e88,%rsp
xor    %eax,%eax
call   1070 <initscr@plt>
xor    %eax,%eax
call   1040 <cbreak@plt>
xor    %eax,%eax
call   10d0 <noecho@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
call   1060 <keypad@plt>
xor    %edi,%edi
call   10e0 <curs_set@plt>
xor    %eax,%eax
call   1080 <start_color@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
mov    0x2dc4(%rip),%rbx
mov    (%rbx),%edx
mov    $0x1,%edi
call   1050 <init_pair@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x2,%edi
call   1050 <init_pair@plt>
lea    0x1f40(%rsp),%r14
mov    %r14,%rdi
call   10c0 <initializeField@plt>
mov    %rsp,%rbx
mov    $0x1f40,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <memset@plt>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   10a0 <printField@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <updateField@plt>
xor    %eax,%eax
call   10b0 <getch@plt>
jmp    1260 <main+0xa0>

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@COLOR_WHITE = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_RED = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2000 x i32]
%3 = alloca [2000 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @initscr()
%7 = call i32 (...) @cbreak()
%8 = call i32 (...) @noecho()
%9 = load i32, i32* @stdscr
%10 = load i32, i32* @TRUE
%11 = call i32 @keypad(i32 %9, i32 %10)
%12 = call i32 @curs_set(i32 0)
%13 = call i32 (...) @start_color()
%14 = load i32, i32* @COLOR_WHITE
%15 = load i32, i32* @COLOR_BLACK
%16 = call i32 @init_pair(i32 1, i32 %14, i32 %15)
%17 = load i32, i32* @COLOR_RED
%18 = load i32, i32* @COLOR_BLACK
%19 = call i32 @init_pair(i32 2, i32 %17, i32 %18)
%20 = getelementptr inbounds [2000 x i32], [2000 x i32]* %2, i64 0, i64 0
%21 = call i32 @initializeField(i32* %20)
store i32 0, i32* %4
br label %22
22: ; preds = %40, %0
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 25
br i1 %24, label %25, label %43
25: ; preds = %22
store i32 0, i32* %5
br label %26
26: ; preds = %36, %25
%27 = load i32, i32* %5
%28 = icmp slt i32 %27, 80
br i1 %28, label %29, label %39
29: ; preds = %26
%30 = load i32, i32* %4
%31 = mul nsw i32 %30, 80
%32 = load i32, i32* %5
%33 = add nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [2000 x i32], [2000 x i32]* %3, i64 0, i64 %34
store i32 0, i32* %35
br label %36
36: ; preds = %29
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %26
39: ; preds = %26
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %22
43: ; preds = %22
br label %44
44: ; preds = %43, %44
%45 = getelementptr inbounds [2000 x i32], [2000 x i32]* %2, i64 0, i64 0
%46 = getelementptr inbounds [2000 x i32], [2000 x i32]* %3, i64 0, i64 0
%47 = call i32 @printField(i32* %45, i32* %46)
%48 = getelementptr inbounds [2000 x i32], [2000 x i32]* %2, i64 0, i64 0
%49 = getelementptr inbounds [2000 x i32], [2000 x i32]* %3, i64 0, i64 0
%50 = call i32 @updateField(i32* %48, i32* %49)
%51 = call i32 (...) @getch()
br label %44
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@COLOR_WHITE = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_RED = global i32 0
define i32 @main() {
%1 = alloca [2000 x i32]
%2 = alloca [2000 x i32]
%3 = bitcast [2000 x i32]* %2 to i8*
%4 = tail call i32 (...) @initscr()
%5 = tail call i32 (...) @cbreak()
%6 = tail call i32 (...) @noecho()
%7 = load i32, i32* @stdscr
%8 = load i32, i32* @TRUE
%9 = tail call i32 @keypad(i32 %7, i32 %8)
%10 = tail call i32 @curs_set(i32 0)
%11 = tail call i32 (...) @start_color()
%12 = load i32, i32* @COLOR_WHITE
%13 = load i32, i32* @COLOR_BLACK
%14 = tail call i32 @init_pair(i32 1, i32 %12, i32 %13)
%15 = load i32, i32* @COLOR_RED
%16 = load i32, i32* @COLOR_BLACK
%17 = tail call i32 @init_pair(i32 2, i32 %15, i32 %16)
%18 = bitcast [2000 x i32]* %1 to i8*
%19 = getelementptr inbounds [2000 x i32], [2000 x i32]* %1, i64 0, i64 0
%20 = call i32 @initializeField(i32* %19)
%21 = getelementptr inbounds [2000 x i32], [2000 x i32]* %2, i64 0, i64 0
br label %22
22: ; preds = %0, %22
%23 = call i32 @printField(i32* %19, i32* %21)
%24 = call i32 @updateField(i32* %19, i32* %21)
%25 = call i32 (...) @getch()
br label %22
}