#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 gameover(int grid[COLS][LINES]) {
  int i;
  int j;
  int alive;
  alive = 0;
  for (i = 0; i < COLS; i++) {
    for (j = 0; j < LINES; j++) {
      if (grid[i][j] == 1)
        return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<gameover>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    0x2ed9(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2eb3(%rip),%rcx
cmp    (%rcx),%eax
jge    11a5 <gameover+0xa5>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%eax
jge    1192 <gameover+0x92>
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    117f <gameover+0x7f>
movl   $0x1,-0x4(%rbp)
jmp    11ac <gameover+0xac>
jmp    1184 <gameover+0x84>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <gameover+0x3c>
jmp    1197 <gameover+0x97>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <gameover+0x23>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gameover>:
mov    0x2ed9(%rip),%rax
mov    (%rax),%eax
test   %eax,%eax
jle    1167 <gameover+0x67>
mov    0x2ed4(%rip),%rcx
mov    (%rcx),%ecx
lea    0x0(,%rcx,4),%r8
xor    %esi,%esi
jmp    113c <gameover+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rsi
add    %r8,%rdi
cmp    %rax,%rsi
je     1167 <gameover+0x67>
test   %ecx,%ecx
jle    1130 <gameover+0x30>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpl   $0x1,(%rdi,%rdx,4)
je     1161 <gameover+0x61>
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1150 <gameover+0x50>
jmp    1130 <gameover+0x30>
mov    $0x1,%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@COLS = global i32 0
@LINES = global i32 0
define i32 @gameover(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
%7 = load i32, i32* @COLS
%8 = zext i32 %7 to i64
%9 = load i32, i32* @LINES
%10 = zext i32 %9 to i64
store i32 0, i32* %6
store i32 0, i32* %4
br label %11
11: ; preds = %37, %1
%12 = load i32, i32* %4
%13 = load i32, i32* @COLS
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %40
15: ; preds = %11
store i32 0, i32* %5
br label %16
16: ; preds = %33, %15
%17 = load i32, i32* %5
%18 = load i32, i32* @LINES
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = load i32*, i32** %3
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = mul nsw i64 %23, %10
%25 = getelementptr inbounds i32, i32* %21, i64 %24
%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 %32
31: ; preds = %20
store i32 1, i32* %2
br label %41
32: ; preds = %20
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %16
36: ; preds = %16
br label %37
37: ; preds = %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %11
40: ; preds = %11
store i32 0, i32* %2
br label %41
41: ; preds = %40, %31
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
@COLS = global i32 0
@LINES = global i32 0
define i32 @gameover(i32* nocapture %0) {
%2 = load i32, i32* @LINES
%3 = zext i32 %2 to i64
%4 = load i32, i32* @COLS
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %25
6: ; preds = %1
%7 = icmp sgt i32 %2, 0
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %6, %22
%10 = phi i64 [ 0, %6 ], [ %23, %22 ]
br i1 %7, label %11, label %22
11: ; preds = %9
%12 = mul nuw nsw i64 %10, %3
%13 = getelementptr inbounds i32, i32* %0, i64 %12
br label %16
14: ; preds = %16
%15 = icmp eq i64 %21, %3
br i1 %15, label %22, label %16
16: ; preds = %11, %14
%17 = phi i64 [ 0, %11 ], [ %21, %14 ]
%18 = getelementptr inbounds i32, i32* %13, i64 %17
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 1
%21 = add nuw nsw i64 %17, 1
br i1 %20, label %25, label %14
22: ; preds = %14, %9
%23 = add nuw nsw i64 %10, 1
%24 = icmp eq i64 %23, %8
br i1 %24, label %25, label %9
25: ; preds = %22, %16, %1
%26 = phi i32 [ 0, %1 ], [ 1, %16 ], [ 0, %22 ]
ret i32 %26
}