#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 fabs(int);
scalar_t__ fmod(int, int);
int isDiagonal(int src, int dest, int boardSize) {
  if (fmod(fabs(src - dest) / (boardSize + 1), 1) == 0 ||
      fmod(fabs(src - dest) / (boardSize - 1), 1) == 0) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<isDiagonal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1040 <fabs@plt>
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <fmod@plt>
cmp    $0x0,%rax
je     1185 <isDiagonal+0x65>
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1040 <fabs@plt>
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <fmod@plt>
cmp    $0x0,%rax
jne    1191 <isDiagonal+0x71>
movl   $0x1,-0x4(%rbp)
jmp    1198 <isDiagonal+0x78>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isDiagonal>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %edi,%ebp
sub    %esi,%ebp
mov    %ebp,%edi
call   1040 <fabs@plt>
lea    0x1(%r14),%ecx
cltd
idiv   %ecx
mov    $0x1,%ebx
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <fmod@plt>
test   %rax,%rax
je     1172 <isDiagonal+0x52>
mov    %ebp,%edi
call   1040 <fabs@plt>
add    $0xffffffff,%r14d
cltd
idiv   %r14d
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <fmod@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isDiagonal(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = sub nsw i32 %8, %9
%11 = call i32 @fabs(i32 %10)
%12 = load i32, i32* %7
%13 = add nsw i32 %12, 1
%14 = sdiv i32 %11, %13
%15 = call i64 @fmod(i32 %14, i32 1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %3
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = sub nsw i32 %18, %19
%21 = call i32 @fabs(i32 %20)
%22 = load i32, i32* %7
%23 = sub nsw i32 %22, 1
%24 = sdiv i32 %21, %23
%25 = call i64 @fmod(i32 %24, i32 1)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %17, %3
store i32 1, i32* %4
br label %29
28: ; preds = %17
store i32 0, i32* %4
br label %29
29: ; preds = %28, %27
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @isDiagonal(i32 %0, i32 %1, i32 %2) {
%4 = sub nsw i32 %0, %1
%5 = tail call i32 @fabs(i32 %4)
%6 = add nsw i32 %2, 1
%7 = sdiv i32 %5, %6
%8 = tail call i64 @fmod(i32 %7, i32 1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %3
%11 = tail call i32 @fabs(i32 %4)
%12 = add nsw i32 %2, -1
%13 = sdiv i32 %11, %12
%14 = tail call i64 @fmod(i32 %13, i32 1)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %10, %3
%18 = phi i32 [ 1, %3 ], [ %16, %10 ]
ret i32 %18
}