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

/* Type definitions */
struct TYPE_6__ {
  int /*<<< orphan*/ pixel;
};
typedef TYPE_1__ XColor;
typedef int /*<<< orphan*/ Window;
typedef scalar_t__ Pixmap;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Cursor;
typedef int /*<<< orphan*/ Colormap;

/* Variables and functions */
int /*<<< orphan*/ DefaultColormap(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ DefaultScreen(int /*<<< orphan*/ *);
scalar_t__ None;
int /*<<< orphan*/ XAllocNamedColor(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                    char *, TYPE_1__ *, TYPE_1__ *);
scalar_t__ XCreateBitmapFromData(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                 char *, int, int);
int /*<<< orphan*/ XCreatePixmapCursor(int /*<<< orphan*/ *, scalar_t__,
                                       scalar_t__, TYPE_1__ *, TYPE_1__ *,
                                       int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XDefineCursor(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ XFreeColors(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ XFreeCursor(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XFreePixmap(int /*<<< orphan*/ *, scalar_t__);
void hide_ptr(Display *d, Window win) {
  Pixmap bm;
  Cursor ptr;
  Colormap cmap;
  XColor black, dummy;
  static char empty[] = {0, 0, 0, 0, 0, 0, 0, 0};
  cmap = DefaultColormap(d, DefaultScreen(d));
  XAllocNamedColor(d, cmap, "black", &black, &dummy);
  bm = XCreateBitmapFromData(d, win, empty, 8, 8);
  ptr = XCreatePixmapCursor(d, bm, bm, &black, &black, 0, 0);
  XDefineCursor(d, win, ptr);
  XFreeCursor(d, ptr);
  if (bm != None)
    XFreePixmap(d, bm);
  XFreeColors(d, cmap, &black.pixel, 1, 0);
}


x86 assembly (clang, -O0):
<hide_ptr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <DefaultScreen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1090 <DefaultColormap@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
lea    0xe34(%rip),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1080 <XAllocNamedColor@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0x2e89(%rip),%rdx
mov    $0x8,%r8d
mov    %r8d,%ecx
call   1050 <XCreateBitmapFromData@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%r8
xor    %r9d,%r9d
mov    %r8,%rcx
movl   $0x0,(%rsp)
call   1060 <XCreatePixmapCursor@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1070 <XDefineCursor@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <XFreeCursor@plt>
mov    -0x18(%rbp),%rax
mov    0x2da4(%rip),%rcx
cmp    (%rcx),%rax
je     125a <hide_ptr+0xca>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <XFreePixmap@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
lea    -0x28(%rbp),%rdx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <XFreeColors@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hide_ptr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r15d
mov    %rdi,%rbx
call   10b0 <DefaultScreen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1090 <DefaultColormap@plt>
mov    %eax,%r14d
lea    0xe43(%rip),%rdx
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r12,%rcx
call   1080 <XAllocNamedColor@plt>
lea    0x2e95(%rip),%rdx
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x8,%ecx
mov    $0x8,%r8d
call   1050 <XCreateBitmapFromData@plt>
mov    %rax,%r13
movl   $0x0,(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %rax,%rdx
mov    %r12,%rcx
mov    %r12,%r8
xor    %r9d,%r9d
call   1060 <XCreatePixmapCursor@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %eax,%edx
call   1070 <XDefineCursor@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10a0 <XFreeCursor@plt>
mov    0x2db6(%rip),%rax
cmp    (%rax),%r13
je     1242 <hide_ptr+0xb2>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <XFreePixmap@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <XFreeColors@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32 }
@hide_ptr.empty = internal global [8 x i8] zeroinitializer
@.str = [6 x i8] c"black\00"
@None = global i64 0
define void @hide_ptr(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.TYPE_6__
%9 = alloca %struct.TYPE_6__
store i32* %0, i32** %3
store i32 %1, i32* %4
%10 = load i32*, i32** %3
%11 = load i32*, i32** %3
%12 = call i32 @DefaultScreen(i32* %11)
%13 = call i32 @DefaultColormap(i32* %10, i32 %12)
store i32 %13, i32* %7
%14 = load i32*, i32** %3
%15 = load i32, i32* %7
%16 = call i32 @XAllocNamedColor(i32* %14, i32 %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.TYPE_6__* %8, %struct.TYPE_6__* %9)
%17 = load i32*, i32** %3
%18 = load i32, i32* %4
%19 = call i64 @XCreateBitmapFromData(i32* %17, i32 %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @hide_ptr.empty, i64 0, i64 0), i32 8, i32 8)
store i64 %19, i64* %5
%20 = load i32*, i32** %3
%21 = load i64, i64* %5
%22 = load i64, i64* %5
%23 = call i32 @XCreatePixmapCursor(i32* %20, i64 %21, i64 %22, %struct.TYPE_6__* %8, %struct.TYPE_6__* %8, i32 0, i32 0)
store i32 %23, i32* %6
%24 = load i32*, i32** %3
%25 = load i32, i32* %4
%26 = load i32, i32* %6
%27 = call i32 @XDefineCursor(i32* %24, i32 %25, i32 %26)
%28 = load i32*, i32** %3
%29 = load i32, i32* %6
%30 = call i32 @XFreeCursor(i32* %28, i32 %29)
%31 = load i64, i64* %5
%32 = load i64, i64* @None
%33 = icmp ne i64 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %2
%35 = load i32*, i32** %3
%36 = load i64, i64* %5
%37 = call i32 @XFreePixmap(i32* %35, i64 %36)
br label %38
38: ; preds = %34, %2
%39 = load i32*, i32** %3
%40 = load i32, i32* %7
%41 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %8, i32 0, i32 0
%42 = call i32 @XFreeColors(i32* %39, i32 %40, i32* %41, i32 1, i32 0)
ret void
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32 }
@hide_ptr.empty = internal global [8 x i8] zeroinitializer
@.str = [6 x i8] c"black\00"
@None = global i64 0
define void @hide_ptr(i32* %0, i32 %1) {
%3 = alloca %struct.TYPE_6__
%4 = alloca %struct.TYPE_6__
%5 = bitcast %struct.TYPE_6__* %3 to i8*
%6 = bitcast %struct.TYPE_6__* %4 to i8*
%7 = tail call i32 @DefaultScreen(i32* %0)
%8 = tail call i32 @DefaultColormap(i32* %0, i32 %7)
%9 = call i32 @XAllocNamedColor(i32* %0, i32 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.TYPE_6__* %3, %struct.TYPE_6__* %4)
%10 = call i64 @XCreateBitmapFromData(i32* %0, i32 %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @hide_ptr.empty, i64 0, i64 0), i32 8, i32 8)
%11 = call i32 @XCreatePixmapCursor(i32* %0, i64 %10, i64 %10, %struct.TYPE_6__* %3, %struct.TYPE_6__* %3, i32 0, i32 0)
%12 = call i32 @XDefineCursor(i32* %0, i32 %1, i32 %11)
%13 = call i32 @XFreeCursor(i32* %0, i32 %11)
%14 = load i64, i64* @None
%15 = icmp eq i64 %10, %14
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = call i32 @XFreePixmap(i32* %0, i64 %10)
br label %18
18: ; preds = %16, %2
%19 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 0
%20 = call i32 @XFreeColors(i32* %0, i32 %8, i32* %19, i32 1, i32 0)
ret void
}