#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 */
scalar_t__ collisionSnake(int, int, int **, int, int);
int collisionDetection(int snakeXY[][310], int consoleWidth, int consoleHeight,
                       int snakeLength) {
  int colision = 0;
  if ((snakeXY[0][0] == 1) || (snakeXY[1][0] == 1) ||
      (snakeXY[0][0] == consoleWidth) || (snakeXY[1][0] == consoleHeight - 4))
    colision = 1;
  else if (collisionSnake(snakeXY[0][0], snakeXY[1][0], snakeXY, snakeLength,
                          1))
    colision = 1;
  return (colision);
}


x86 assembly (clang, -O0):
<collisionDetection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x1,(%rax)
je     1171 <collisionDetection+0x61>
mov    -0x8(%rbp),%rax
cmpl   $0x1,0x4d8(%rax)
je     1171 <collisionDetection+0x61>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
je     1171 <collisionDetection+0x61>
mov    -0x8(%rbp),%rax
mov    0x4d8(%rax),%eax
mov    -0x10(%rbp),%ecx
sub    $0x4,%ecx
cmp    %ecx,%eax
jne    117d <collisionDetection+0x6d>
movl   $0x1,-0x18(%rbp)
jmp    11b5 <collisionDetection+0xa5>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x4d8(%rax),%esi
mov    -0x8(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    $0x1,%r8d
call   1030 <collisionSnake@plt>
cmp    $0x0,%rax
je     11b0 <collisionDetection+0xa0>
movl   $0x1,-0x18(%rbp)
jmp    11b5 <collisionDetection+0xa5>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<collisionDetection>:
push   %rax
mov    %rdi,%r8
mov    (%rdi),%edi
mov    $0x1,%eax
cmp    $0x1,%edi
je     1154 <collisionDetection+0x44>
mov    %esi,%r9d
mov    0x4d8(%r8),%esi
cmp    $0x1,%esi
je     1154 <collisionDetection+0x44>
cmp    %r9d,%edi
je     1154 <collisionDetection+0x44>
add    $0xfffffffc,%edx
cmp    %edx,%esi
je     1154 <collisionDetection+0x44>
mov    %r8,%rdx
mov    $0x1,%r8d
call   1030 <collisionSnake@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rcx
ret

LLVM IR (-O0):
define i32 @collisionDetection([310 x i32]* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [310 x i32]*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store [310 x i32]* %0, [310 x i32]** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
%10 = load [310 x i32]*, [310 x i32]** %5
%11 = getelementptr inbounds [310 x i32], [310 x i32]* %10, i64 0
%12 = getelementptr inbounds [310 x i32], [310 x i32]* %11, i64 0, i64 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 1
br i1 %14, label %36, label %15
15: ; preds = %4
%16 = load [310 x i32]*, [310 x i32]** %5
%17 = getelementptr inbounds [310 x i32], [310 x i32]* %16, i64 1
%18 = getelementptr inbounds [310 x i32], [310 x i32]* %17, i64 0, i64 0
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 1
br i1 %20, label %36, label %21
21: ; preds = %15
%22 = load [310 x i32]*, [310 x i32]** %5
%23 = getelementptr inbounds [310 x i32], [310 x i32]* %22, i64 0
%24 = getelementptr inbounds [310 x i32], [310 x i32]* %23, i64 0, i64 0
%25 = load i32, i32* %24
%26 = load i32, i32* %6
%27 = icmp eq i32 %25, %26
br i1 %27, label %36, label %28
28: ; preds = %21
%29 = load [310 x i32]*, [310 x i32]** %5
%30 = getelementptr inbounds [310 x i32], [310 x i32]* %29, i64 1
%31 = getelementptr inbounds [310 x i32], [310 x i32]* %30, i64 0, i64 0
%32 = load i32, i32* %31
%33 = load i32, i32* %7
%34 = sub nsw i32 %33, 4
%35 = icmp eq i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %28, %21, %15, %4
store i32 1, i32* %9
br label %53
37: ; preds = %28
%38 = load [310 x i32]*, [310 x i32]** %5
%39 = getelementptr inbounds [310 x i32], [310 x i32]* %38, i64 0
%40 = getelementptr inbounds [310 x i32], [310 x i32]* %39, i64 0, i64 0
%41 = load i32, i32* %40
%42 = load [310 x i32]*, [310 x i32]** %5
%43 = getelementptr inbounds [310 x i32], [310 x i32]* %42, i64 1
%44 = getelementptr inbounds [310 x i32], [310 x i32]* %43, i64 0, i64 0
%45 = load i32, i32* %44
%46 = load [310 x i32]*, [310 x i32]** %5
%47 = bitcast [310 x i32]* %46 to i32**
%48 = load i32, i32* %8
%49 = call i64 @collisionSnake(i32 %41, i32 %45, i32** %47, i32 %48, i32 1)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %37
store i32 1, i32* %9
br label %52
52: ; preds = %51, %37
br label %53
53: ; preds = %52, %36
%54 = load i32, i32* %9
ret i32 %54
}

LLVM IR (-O2):
define i32 @collisionDetection([310 x i32]* %0, i32 %1, i32 %2, i32 %3) {
%5 = getelementptr inbounds [310 x i32], [310 x i32]* %0, i64 0, i64 0
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 1
br i1 %7, label %22, label %8
8: ; preds = %4
%9 = getelementptr inbounds [310 x i32], [310 x i32]* %0, i64 1, i64 0
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 1
%12 = icmp eq i32 %6, %1
%13 = select i1 %11, i1 true, i1 %12
%14 = add nsw i32 %2, -4
%15 = icmp eq i32 %10, %14
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %22, label %17
17: ; preds = %8
%18 = bitcast [310 x i32]* %0 to i32**
%19 = tail call i64 @collisionSnake(i32 %6, i32 %10, i32** %18, i32 %3, i32 1)
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %17, %4, %8
%23 = phi i32 [ 1, %8 ], [ 1, %4 ], [ %21, %17 ]
ret i32 %23
}