#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 */
char COLOR_PAIR(int);
int countNeighbors(int *, int, int);
int /*<<< orphan*/ mvaddch(int, int, char);
int /*<<< orphan*/ refresh();
void printField(int *cells) {
  int neighbors = 0;
  for (int row = 0; row < 25; row++) {
    for (int col = 0; col < 80; col++) {
      mvaddch(row, col, ' ');
    }
  }
  for (int row = 0; row < 25; row++) {
    for (int col = 0; col < 80; col++) {
      neighbors = countNeighbors(cells, row, col);
      if (cells[row * 80 + col] == 1) {
        mvaddch(row, col, '*' | COLOR_PAIR(2));
      }
    }
  }
  refresh();
}


x86 assembly (clang, -O0):
<printField>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x19,-0x10(%rbp)
jge    11a6 <printField+0x66>
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    1193 <printField+0x53>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x20,%edx
call   1060 <mvaddch@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <printField+0x2b>
jmp    1198 <printField+0x58>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115a <printField+0x1a>
movl   $0x0,-0x18(%rbp)
cmpl   $0x19,-0x18(%rbp)
jge    1242 <printField+0x102>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x50,-0x1c(%rbp)
jge    122f <printField+0xef>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <countNeighbors@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x50,-0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    121c <printField+0xdc>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x2,%edi
call   1030 <COLOR_PAIR@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
movsbl %al,%eax
or     $0x2a,%eax
movsbl %al,%edx
call   1060 <mvaddch@plt>
jmp    1221 <printField+0xe1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11be <printField+0x7e>
jmp    1234 <printField+0xf4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ad <printField+0x6d>
mov    $0x0,%al
call   1040 <refresh@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printField>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x20,%edx
call   1060 <mvaddch@plt>
add    $0x1,%ebp
cmp    $0x50,%ebp
jne    1160 <printField+0x20>
add    $0x1,%ebx
cmp    $0x19,%ebx
jne    1150 <printField+0x10>
xor    %r15d,%r15d
mov    %r14,%rbp
jmp    11a1 <printField+0x61>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15
add    $0x140,%rbp
cmp    $0x19,%r15
je     11e9 <printField+0xa9>
xor    %ebx,%ebx
jmp    11ba <printField+0x7a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    $0x50,%rbx
je     1190 <printField+0x50>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
call   1050 <countNeighbors@plt>
cmpl   $0x1,0x0(%rbp,%rbx,4)
jne    11b0 <printField+0x70>
mov    $0x2,%edi
call   1030 <COLOR_PAIR@plt>
or     $0x2a,%al
movsbl %al,%edx
mov    %r15d,%edi
mov    %ebx,%esi
call   1060 <mvaddch@plt>
jmp    11b0 <printField+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <refresh@plt>

LLVM IR (-O0):
define void @printField(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %23, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 25
br i1 %10, label %11, label %26
11: ; preds = %8
store i32 0, i32* %5
br label %12
12: ; preds = %19, %11
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 80
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32 @mvaddch(i32 %16, i32 %17, i8 signext 32)
br label %19
19: ; preds = %15
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %12
22: ; preds = %12
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %8
26: ; preds = %8
store i32 0, i32* %6
br label %27
27: ; preds = %61, %26
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 25
br i1 %29, label %30, label %64
30: ; preds = %27
store i32 0, i32* %7
br label %31
31: ; preds = %57, %30
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 80
br i1 %33, label %34, label %60
34: ; preds = %31
%35 = load i32*, i32** %2
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = call i32 @countNeighbors(i32* %35, i32 %36, i32 %37)
store i32 %38, i32* %3
%39 = load i32*, i32** %2
%40 = load i32, i32* %6
%41 = mul nsw i32 %40, 80
%42 = load i32, i32* %7
%43 = add nsw i32 %41, %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %39, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %56
48: ; preds = %34
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = call signext i8 @COLOR_PAIR(i32 2)
%52 = sext i8 %51 to i32
%53 = or i32 42, %52
%54 = trunc i32 %53 to i8
%55 = call i32 @mvaddch(i32 %49, i32 %50, i8 signext %54)
br label %56
56: ; preds = %48, %34
br label %57
57: ; preds = %56
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
br label %31
60: ; preds = %31
br label %61
61: ; preds = %60
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %27
64: ; preds = %27
%65 = call i32 (...) @refresh()
ret void
}

LLVM IR (-O2):
define void @printField(i32* %0) {
br label %2
2: ; preds = %1, %4
%3 = phi i32 [ 0, %1 ], [ %5, %4 ]
br label %7
4: ; preds = %7
%5 = add nuw nsw i32 %3, 1
%6 = icmp eq i32 %5, 25
br i1 %6, label %12, label %2
7: ; preds = %2, %7
%8 = phi i32 [ 0, %2 ], [ %10, %7 ]
%9 = tail call i32 @mvaddch(i32 %3, i32 %8, i8 signext 32)
%10 = add nuw nsw i32 %8, 1
%11 = icmp eq i32 %10, 80
br i1 %11, label %4, label %7
12: ; preds = %4, %18
%13 = phi i64 [ %19, %18 ], [ 0, %4 ]
%14 = mul nuw nsw i64 %13, 80
%15 = trunc i64 %13 to i32
br label %21
16: ; preds = %18
%17 = tail call i32 (...) @refresh()
ret void
18: ; preds = %33
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, 25
br i1 %20, label %16, label %12
21: ; preds = %12, %33
%22 = phi i64 [ 0, %12 ], [ %34, %33 ]
%23 = trunc i64 %22 to i32
%24 = tail call i32 @countNeighbors(i32* %0, i32 %15, i32 %23)
%25 = add nuw nsw i64 %22, %14
%26 = getelementptr inbounds i32, i32* %0, i64 %25
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %33
29: ; preds = %21
%30 = tail call signext i8 @COLOR_PAIR(i32 2)
%31 = or i8 %30, 42
%32 = tail call i32 @mvaddch(i32 %15, i32 %23, i8 signext %31)
br label %33
33: ; preds = %21, %29
%34 = add nuw nsw i64 %22, 1
%35 = icmp eq i64 %34, 80
br i1 %35, label %18, label %21
}