#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 count_neighbouts_ones(int *, int, int, int);
int nth_position(int, int);
int /*<<< orphan*/ set_bit(int *, int, int);
void start_game(int src[], int copy[], size_t size) {
  int neighboursCount = 0;
  int currentRow, currentCol;
  for (currentRow = 0; currentRow < size; currentRow++) {
    for (currentCol = 0; currentCol < size; currentCol++) {
      neighboursCount = count_neighbouts_ones(copy, 10, currentRow, currentCol);
      if ((nth_position(copy[currentRow], currentCol)) == 1) {
        if (neighboursCount < 2 || neighboursCount > 3) {
          set_bit(&src[currentRow], currentCol, 0);
        }
      } else if (neighboursCount == 3) {
        set_bit(&src[currentRow], currentCol, 1);
      }
    }
  }
}


x86 assembly (clang, -O0):
<start_game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    122b <start_game+0xfb>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1218 <start_game+0xe8>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    $0xa,%esi
call   1040 <count_neighbouts_ones@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x24(%rbp),%esi
call   1050 <nth_position@plt>
cmp    $0x1,%eax
jne    11da <start_game+0xaa>
cmpl   $0x2,-0x1c(%rbp)
jl     11bc <start_game+0x8c>
cmpl   $0x3,-0x1c(%rbp)
jle    11d5 <start_game+0xa5>
mov    -0x8(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x24(%rbp),%esi
xor    %edx,%edx
call   1030 <set_bit@plt>
jmp    1205 <start_game+0xd5>
cmpl   $0x3,-0x1c(%rbp)
jne    1200 <start_game+0xd0>
mov    -0x8(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
call   1030 <set_bit@plt>
jmp    1205 <start_game+0xd5>
jmp    120a <start_game+0xda>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1167 <start_game+0x37>
jmp    121d <start_game+0xed>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <start_game+0x22>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_game>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %rdx,%rdx
je     11dd <start_game+0xad>
mov    %rdx,%r14
mov    %rsi,%r12
xor    %ebx,%ebx
jmp    1169 <start_game+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %r14,%rbx
je     11dd <start_game+0xad>
mov    (%rsp),%rax
lea    (%rax,%rbx,4),%r13
xor    %ebp,%ebp
jmp    1193 <start_game+0x63>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <set_bit@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
je     1160 <start_game+0x30>
mov    %r12,%rdi
mov    $0xa,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <count_neighbouts_ones@plt>
mov    %eax,%r15d
mov    (%r12,%rbx,4),%edi
mov    %ebp,%esi
call   1050 <nth_position@plt>
cmp    $0x1,%eax
jne    11d0 <start_game+0xa0>
add    $0xfffffffc,%r15d
xor    %edx,%edx
cmp    $0xfffffffe,%r15d
jb     1180 <start_game+0x50>
jmp    118a <start_game+0x5a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%edx
cmp    $0x3,%r15d
je     1180 <start_game+0x50>
jmp    118a <start_game+0x5a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @start_game(i32* %0, i32* %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %31, label %5
5: ; preds = %3, %28
%6 = phi i64 [ %29, %28 ], [ 0, %3 ]
%7 = getelementptr inbounds i32, i32* %1, i64 %6
%8 = getelementptr inbounds i32, i32* %0, i64 %6
%9 = trunc i64 %6 to i32
br label %10
10: ; preds = %5, %25
%11 = phi i64 [ 0, %5 ], [ %26, %25 ]
%12 = trunc i64 %11 to i32
%13 = tail call i32 @count_neighbouts_ones(i32* %1, i32 10, i32 %9, i32 %12)
%14 = load i32, i32* %7
%15 = tail call i32 @nth_position(i32 %14, i32 %12)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = add i32 %13, -4
%19 = icmp ult i32 %18, -2
br i1 %19, label %22, label %25
20: ; preds = %10
%21 = icmp eq i32 %13, 3
br i1 %21, label %22, label %25
22: ; preds = %20, %17
%23 = phi i32 [ 0, %17 ], [ 1, %20 ]
%24 = tail call i32 @set_bit(i32* %8, i32 %12, i32 %23)
br label %25
25: ; preds = %22, %17, %20
%26 = add nuw i64 %11, 1
%27 = icmp eq i64 %26, %2
br i1 %27, label %28, label %10
28: ; preds = %25
%29 = add nuw i64 %6, 1
%30 = icmp eq i64 %29, %2
br i1 %30, label %31, label %5
31: ; preds = %28, %3
ret void
}