#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 isOn(unsigned long long, int, int);
alive_Neighbours(unsigned long long M, int i, int j) {
  int ans = 0;
  for (int k = -1; (-1 > 2 ? k >= 2 : k < 2); (-1 > 2 ? --k : ++k))
    for (int l = -1; (-1 > 2 ? l >= 2 : l < 2); (-1 > 2 ? --l : ++l))
      ans += isOn(M, i + k, j + l);
  return ans - isOn(M, i, j);
}


x86 assembly (clang, -O0):
<alive_Neighbours>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jge    1187 <alive_Neighbours+0x77>
movl   $0xffffffff,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1174 <alive_Neighbours+0x64>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    -0x18(%rbp),%esi
mov    -0x10(%rbp),%edx
add    -0x1c(%rbp),%edx
call   1030 <isOn@plt>
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <alive_Neighbours+0x31>
jmp    1179 <alive_Neighbours+0x69>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1130 <alive_Neighbours+0x20>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <isOn@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alive_Neighbours>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r13
lea    -0x1(%r14),%edx
mov    %edx,0x4(%rsp)
lea    -0x1(%r15),%ebp
mov    %ebp,%esi
call   1030 <isOn@plt>
mov    %eax,%ebx
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <isOn@plt>
mov    %eax,%r12d
add    %ebx,%r12d
lea    0x1(%r14),%edx
mov    %edx,(%rsp)
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <isOn@plt>
mov    %eax,%ebp
add    %r12d,%ebp
mov    %r13,%rdi
mov    %r15d,%esi
mov    0x4(%rsp),%edx
call   1030 <isOn@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1030 <isOn@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%edx
call   1030 <isOn@plt>
mov    %eax,%ebx
add    %ebp,%ebx
lea    0x1(%r15),%r12d
mov    %r13,%rdi
mov    %r12d,%esi
mov    0x4(%rsp),%edx
call   1030 <isOn@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1030 <isOn@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r13,%rdi
mov    %r12d,%esi
mov    (%rsp),%edx
call   1030 <isOn@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1030 <isOn@plt>
sub    %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @alive_Neighbours(i64 %0, i32 %1, i32 %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i64 %0, i64* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 -1, i32* %8
br label %10
10: ; preds = %32, %3
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %35
13: ; preds = %10
store i32 -1, i32* %9
br label %14
14: ; preds = %28, %13
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = load i64, i64* %4
%19 = load i32, i32* %5
%20 = load i32, i32* %8
%21 = add nsw i32 %19, %20
%22 = load i32, i32* %6
%23 = load i32, i32* %9
%24 = add nsw i32 %22, %23
%25 = call i32 @isOn(i64 %18, i32 %21, i32 %24)
%26 = load i32, i32* %7
%27 = add nsw i32 %26, %25
store i32 %27, i32* %7
br label %28
28: ; preds = %17
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
br label %14
31: ; preds = %14
br label %32
32: ; preds = %31
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %10
35: ; preds = %10
%36 = load i32, i32* %7
%37 = load i64, i64* %4
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = call i32 @isOn(i64 %37, i32 %38, i32 %39)
%41 = sub nsw i32 %36, %40
ret i32 %41
}

LLVM IR (-O2):
define i32 @alive_Neighbours(i64 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %2, -1
%5 = add nsw i32 %1, -1
%6 = tail call i32 @isOn(i64 %0, i32 %5, i32 %4)
%7 = tail call i32 @isOn(i64 %0, i32 %5, i32 %2)
%8 = add nsw i32 %7, %6
%9 = add nsw i32 %2, 1
%10 = tail call i32 @isOn(i64 %0, i32 %5, i32 %9)
%11 = add nsw i32 %10, %8
%12 = tail call i32 @isOn(i64 %0, i32 %1, i32 %4)
%13 = add nsw i32 %12, %11
%14 = tail call i32 @isOn(i64 %0, i32 %1, i32 %2)
%15 = add nsw i32 %14, %13
%16 = tail call i32 @isOn(i64 %0, i32 %1, i32 %9)
%17 = add nsw i32 %16, %15
%18 = add nsw i32 %1, 1
%19 = tail call i32 @isOn(i64 %0, i32 %18, i32 %4)
%20 = add nsw i32 %19, %17
%21 = tail call i32 @isOn(i64 %0, i32 %18, i32 %2)
%22 = add nsw i32 %21, %20
%23 = tail call i32 @isOn(i64 %0, i32 %18, i32 %9)
%24 = add nsw i32 %23, %22
%25 = tail call i32 @isOn(i64 %0, i32 %1, i32 %2)
%26 = sub nsw i32 %24, %25
ret i32 %26
}