#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 /*<<< orphan*/ assert(int);
int chess_file(int);
int chess_rank(int);
bool chess_square_border(int square) {
  int file, rank;
  assert(square >= 0 && square <= 63);
  file = chess_file(square);
  rank = chess_rank(square);
  return ((file == 0) || (file == 7) || (rank == 0) || (rank == 7));
}


x86 assembly (clang, -O0):
<chess_square_border>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0xd(%rbp)
jl     1154 <chess_square_border+0x24>
cmpl   $0x3f,-0x4(%rbp)
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%edi
call   1050 <chess_file@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <chess_rank@plt>
mov    %eax,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0xe(%rbp)
je     11ae <chess_square_border+0x7e>
mov    $0x1,%al
cmpl   $0x7,-0x8(%rbp)
mov    %al,-0xe(%rbp)
je     11ae <chess_square_border+0x7e>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xe(%rbp)
je     11ae <chess_square_border+0x7e>
cmpl   $0x7,-0xc(%rbp)
sete   %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chess_square_border>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x40,%ebp
setb   %dil
call   1030 <assert@plt>
mov    %ebp,%edi
call   1050 <chess_file@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <chess_rank@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
je     116f <chess_square_border+0x3f>
test   %ebx,%ebx
je     116f <chess_square_border+0x3f>
cmp    $0x7,%ebx
je     116f <chess_square_border+0x3f>
xor    %eax,%eax
cmp    $0x7,%ecx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @chess_square_border(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 63
br label %10
10: ; preds = %7, %1
%11 = phi i1 [ false, %1 ], [ %9, %7 ]
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @chess_file(i32 %14)
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = call i32 @chess_rank(i32 %16)
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %10
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 7
br i1 %22, label %29, label %23
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 7
br label %29
29: ; preds = %26, %23, %20, %10
%30 = phi i1 [ true, %23 ], [ true, %20 ], [ true, %10 ], [ %28, %26 ]
%31 = zext i1 %30 to i32
ret i32 %31
}

LLVM IR (-O2):
define i32 @chess_square_border(i32 %0) {
%2 = icmp ult i32 %0, 64
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @chess_file(i32 %0)
%6 = tail call i32 @chess_rank(i32 %0)
%7 = freeze i32 %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %1
switch i32 %5, label %10 [
i32 7, label %13
i32 0, label %13
]
10: ; preds = %9
%11 = icmp eq i32 %7, 7
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %9, %9, %1, %10
%14 = phi i32 [ 1, %9 ], [ %12, %10 ], [ 1, %1 ], [ 1, %9 ]
ret i32 %14
}