#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ red;
  scalar_t__ green;
  scalar_t__ blue;
};
typedef TYPE_1__ XColor;

/* Variables and functions */
int pgx_cmp_xcolor(const void *va, const void *vb) {
  XColor *ca = (XColor *)va;
  XColor *cb = (XColor *)vb;
  if (ca->red < cb->red)
    return -1;
  else if (ca->red > cb->red)
    return 1;
  if (ca->green < cb->green)
    return -1;
  else if (ca->green > cb->green)
    return 1;
  if (ca->blue < cb->blue)
    return -1;
  else if (ca->blue > cb->blue)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<pgx_cmp_xcolor>:
push   %rbp
mov    %rsp,%rbp
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),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%rax
jge    113c <pgx_cmp_xcolor+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fa <pgx_cmp_xcolor+0xfa>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%rax
jle    115c <pgx_cmp_xcolor+0x5c>
movl   $0x1,-0x4(%rbp)
jmp    11fa <pgx_cmp_xcolor+0xfa>
jmp    1161 <pgx_cmp_xcolor+0x61>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    0x8(%rcx),%rax
jge    1183 <pgx_cmp_xcolor+0x83>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fa <pgx_cmp_xcolor+0xfa>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    0x8(%rcx),%rax
jle    11a5 <pgx_cmp_xcolor+0xa5>
movl   $0x1,-0x4(%rbp)
jmp    11fa <pgx_cmp_xcolor+0xfa>
jmp    11aa <pgx_cmp_xcolor+0xaa>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    0x10(%rcx),%rax
jge    11cc <pgx_cmp_xcolor+0xcc>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fa <pgx_cmp_xcolor+0xfa>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x28(%rbp),%rcx
cmp    0x10(%rcx),%rax
jle    11ee <pgx_cmp_xcolor+0xee>
movl   $0x1,-0x4(%rbp)
jmp    11fa <pgx_cmp_xcolor+0xfa>
jmp    11f3 <pgx_cmp_xcolor+0xf3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pgx_cmp_xcolor>:
mov    (%rsi),%rax
cmp    %rax,(%rdi)
jge    110e <pgx_cmp_xcolor+0xe>
mov    $0xffffffff,%eax
ret
mov    $0x1,%eax
jg     113c <pgx_cmp_xcolor+0x3c>
mov    0x8(%rsi),%rcx
cmp    %rcx,0x8(%rdi)
jge    1125 <pgx_cmp_xcolor+0x25>
mov    $0xffffffff,%eax
ret
jg     113c <pgx_cmp_xcolor+0x3c>
mov    0x10(%rsi),%rcx
mov    $0xffffffff,%eax
cmp    %rcx,0x10(%rdi)
jl     113c <pgx_cmp_xcolor+0x3c>
setg   %al
movzbl %al,%eax
ret

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

LLVM IR (-O2):
define i32 @pgx_cmp_xcolor(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i64*
%4 = load i64, i64* %3
%5 = bitcast i8* %1 to i64*
%6 = load i64, i64* %5
%7 = icmp slt i64 %4, %6
br i1 %7, label %31, label %8
8: ; preds = %2
%9 = icmp sgt i64 %4, %6
br i1 %9, label %31, label %10
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %0, i64 8
%12 = bitcast i8* %11 to i64*
%13 = load i64, i64* %12
%14 = getelementptr inbounds i8, i8* %1, i64 8
%15 = bitcast i8* %14 to i64*
%16 = load i64, i64* %15
%17 = icmp slt i64 %13, %16
br i1 %17, label %31, label %18
18: ; preds = %10
%19 = icmp sgt i64 %13, %16
br i1 %19, label %31, label %20
20: ; preds = %18
%21 = getelementptr inbounds i8, i8* %0, i64 16
%22 = bitcast i8* %21 to i64*
%23 = load i64, i64* %22
%24 = getelementptr inbounds i8, i8* %1, i64 16
%25 = bitcast i8* %24 to i64*
%26 = load i64, i64* %25
%27 = icmp slt i64 %23, %26
br i1 %27, label %31, label %28
28: ; preds = %20
%29 = icmp sgt i64 %23, %26
%30 = zext i1 %29 to i32
br label %31
31: ; preds = %28, %20, %18, %10, %8, %2
%32 = phi i32 [ -1, %2 ], [ 1, %8 ], [ -1, %10 ], [ 1, %18 ], [ -1, %20 ], [ %30, %28 ]
ret i32 %32
}