#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 */
struct board {
  int dummy;
};

/* Variables and functions */
int banko_board_mask(struct board const *);
int cmp_boards(const void *xp, const void *yp) {
  const struct board *x = xp;
  const struct board *y = yp;
  int xmask = banko_board_mask(x);
  int ymask = banko_board_mask(y);
  if (xmask < ymask) {
    return -1;
  } else if (ymask < xmask) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<cmp_boards>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <banko_board_mask@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <banko_board_mask@plt>
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1160 <cmp_boards+0x50>
movl   $0xffffffff,-0x4(%rbp)
jmp    117f <cmp_boards+0x6f>
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1178 <cmp_boards+0x68>
movl   $0x1,-0x4(%rbp)
jmp    117f <cmp_boards+0x6f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp_boards>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1030 <banko_board_mask@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <banko_board_mask@plt>
xor    %ecx,%ecx
cmp    %ebp,%eax
setl   %cl
mov    $0xffffffff,%eax
cmovle %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.board = type { i32 }
define i32 @cmp_boards(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.board*
%7 = alloca %struct.board*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to %struct.board*
store %struct.board* %11, %struct.board** %6
%12 = load i8*, i8** %5
%13 = bitcast i8* %12 to %struct.board*
store %struct.board* %13, %struct.board** %7
%14 = load %struct.board*, %struct.board** %6
%15 = call i32 @banko_board_mask(%struct.board* %14)
store i32 %15, i32* %8
%16 = load %struct.board*, %struct.board** %7
%17 = call i32 @banko_board_mask(%struct.board* %16)
store i32 %17, i32* %9
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %2
store i32 -1, i32* %3
br label %28
22: ; preds = %2
%23 = load i32, i32* %9
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 1, i32* %3
br label %28
27: ; preds = %22
store i32 0, i32* %3
br label %28
28: ; preds = %27, %26, %21
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.board = type { i32 }
define i32 @cmp_boards(i8* %0, i8* %1) {
%3 = bitcast i8* %0 to %struct.board*
%4 = bitcast i8* %1 to %struct.board*
%5 = tail call i32 @banko_board_mask(%struct.board* %3)
%6 = tail call i32 @banko_board_mask(%struct.board* %4)
%7 = icmp slt i32 %5, %6
%8 = icmp slt i32 %6, %5
%9 = zext i1 %8 to i32
%10 = select i1 %7, i32 -1, i32 %9
ret i32 %10
}