#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_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ XImage;
struct TYPE_4__ {
  int /*<<< orphan*/ pixel;
};
typedef TYPE_1__ XColor;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ AllPlanes;
int /*<<< orphan*/ DefaultColormap(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ XFree(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XGetImage(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                              int, int, int, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ XGetPixel(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/);
int /*<<< orphan*/ XQueryColor(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               TYPE_1__ *);
int /*<<< orphan*/ XYPixmap;
void mouse_pixel_color(Display *display, int x, int y, XColor *color) {
  XImage *image;
  image = XGetImage(display, DefaultRootWindow(display), x, y, 1, 1, AllPlanes,
                    XYPixmap);
  color->pixel = XGetPixel(image, 0, 0);
  XFree(image);
  XQueryColor(display, DefaultColormap(display, DefaultScreen(display)), color);
}


x86 assembly (clang, -O0):
<mouse_pixel_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <DefaultRootWindow@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    0x2e2e(%rip),%rax
mov    (%rax),%r10d
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    $0x1,%r9d
mov    %r9d,%r8d
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1090 <XGetImage@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <XGetPixel@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
call   1050 <XFree@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <DefaultScreen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1060 <DefaultColormap@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%rdx
call   1070 <XQueryColor@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mouse_pixel_color>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbx
call   1040 <DefaultRootWindow@plt>
mov    0x2e48(%rip),%rcx
mov    (%rcx),%r10d
mov    0x2e46(%rip),%rcx
mov    (%rcx),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    $0x1,%r8d
mov    $0x1,%r9d
push   %rbp
push   %r10
call   1090 <XGetImage@plt>
add    $0x10,%rsp
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <XGetPixel@plt>
mov    %eax,(%r14)
mov    %rbp,%rdi
call   1050 <XFree@plt>
mov    %rbx,%rdi
call   1080 <DefaultScreen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <DefaultColormap@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <XQueryColor@plt>

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32 }
@AllPlanes = global i32 0
@XYPixmap = global i32 0
define void @mouse_pixel_color(i32* %0, i32 %1, i32 %2, %struct.TYPE_4__* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.TYPE_4__*
%9 = alloca i32*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store %struct.TYPE_4__* %3, %struct.TYPE_4__** %8
%10 = load i32*, i32** %5
%11 = load i32*, i32** %5
%12 = call i32 @DefaultRootWindow(i32* %11)
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = load i32, i32* @AllPlanes
%16 = load i32, i32* @XYPixmap
%17 = call i32* @XGetImage(i32* %10, i32 %12, i32 %13, i32 %14, i32 1, i32 1, i32 %15, i32 %16)
store i32* %17, i32** %9
%18 = load i32*, i32** %9
%19 = call i32 @XGetPixel(i32* %18, i32 0, i32 0)
%20 = load %struct.TYPE_4__*, %struct.TYPE_4__** %8
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %20, i32 0, i32 0
store i32 %19, i32* %21
%22 = load i32*, i32** %9
%23 = call i32 @XFree(i32* %22)
%24 = load i32*, i32** %5
%25 = load i32*, i32** %5
%26 = load i32*, i32** %5
%27 = call i32 @DefaultScreen(i32* %26)
%28 = call i32 @DefaultColormap(i32* %25, i32 %27)
%29 = load %struct.TYPE_4__*, %struct.TYPE_4__** %8
%30 = call i32 @XQueryColor(i32* %24, i32 %28, %struct.TYPE_4__* %29)
ret void
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32 }
@AllPlanes = global i32 0
@XYPixmap = global i32 0
define void @mouse_pixel_color(i32* %0, i32 %1, i32 %2, %struct.TYPE_4__* %3) {
%5 = tail call i32 @DefaultRootWindow(i32* %0)
%6 = load i32, i32* @AllPlanes
%7 = load i32, i32* @XYPixmap
%8 = tail call i32* @XGetImage(i32* %0, i32 %5, i32 %1, i32 %2, i32 1, i32 1, i32 %6, i32 %7)
%9 = tail call i32 @XGetPixel(i32* %8, i32 0, i32 0)
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 0
store i32 %9, i32* %10
%11 = tail call i32 @XFree(i32* %8)
%12 = tail call i32 @DefaultScreen(i32* %0)
%13 = tail call i32 @DefaultColormap(i32* %0, i32 %12)
%14 = tail call i32 @XQueryColor(i32* %0, i32 %13, %struct.TYPE_4__* %3)
ret void
}