#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__ {
  unsigned long pixel;
  int /*<<< orphan*/ blue;
  int /*<<< orphan*/ green;
  int /*<<< orphan*/ red;
};
typedef TYPE_1__ XColor;
typedef int Status;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Colormap;

/* Variables and functions */
int /*<<< orphan*/ RWcell(int /*<<< orphan*/ *, int /*<<< orphan*/, TYPE_1__ *,
                          TYPE_1__ *, unsigned long *);
int /*<<< orphan*/ XAllocColor(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               TYPE_1__ *);
int /*<<< orphan*/ XFreeColors(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               unsigned long *, int, unsigned long);
int /*<<< orphan*/ free_cells(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              unsigned long *, int, int);
Status ROorRWcell(Display *dpy, Colormap cmap, unsigned long pixels[],
                  int npixels, XColor *color, unsigned long p) {
  unsigned long pixel;
  XColor request;
  pixel = color->pixel;
  request.red = color->red;
  request.green = color->green;
  request.blue = color->blue;
  XFreeColors(dpy, cmap, &pixel, 1, (unsigned long)0);
  if (!XAllocColor(dpy, cmap, color) ||
      (color->pixel != pixel &&
       (!RWcell(dpy, cmap, color, &request, &pixel)))) {
    free_cells(dpy, cmap, pixels, npixels, (int)p);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ROorRWcell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x40(%rbp),%rdx
mov    $0x1,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <XFreeColors@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1030 <XAllocColor@plt>
cmp    $0x0,%eax
je     11ec <ROorRWcell+0xac>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
cmp    -0x40(%rbp),%rax
je     1212 <ROorRWcell+0xd2>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%rdx
lea    -0x58(%rbp),%rcx
lea    -0x40(%rbp),%r8
call   1060 <RWcell@plt>
cmp    $0x0,%eax
jne    1212 <ROorRWcell+0xd2>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %eax,%r8d
call   1050 <free_cells@plt>
movl   $0x0,-0x4(%rbp)
jmp    1219 <ROorRWcell+0xd9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ROorRWcell>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,%rbp
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %esi,%r13d
mov    %rdi,%rbx
mov    (%r8),%rax
mov    %rax,(%rsp)
mov    0x10(%r8),%eax
mov    %eax,0x20(%rsp)
mov    0xc(%r8),%eax
mov    %eax,0x1c(%rsp)
mov    0x8(%r8),%eax
mov    %eax,0x18(%rsp)
mov    %rsp,%rdx
mov    $0x1,%r14d
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1040 <XFreeColors@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %rbp,%rdx
call   1030 <XAllocColor@plt>
test   %eax,%eax
je     11cd <ROorRWcell+0x8d>
mov    0x0(%rbp),%rax
cmp    (%rsp),%rax
je     11e6 <ROorRWcell+0xa6>
lea    0x10(%rsp),%rcx
mov    %rsp,%r8
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %rbp,%rdx
call   1060 <RWcell@plt>
test   %eax,%eax
jne    11e6 <ROorRWcell+0xa6>
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    0x8(%rsp),%r8
call   1050 <free_cells@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i64, i32, i32, i32 }
define i32 @ROorRWcell(i32* %0, i32 %1, i64* %2, i32 %3, %struct.TYPE_6__* %4, i64 %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i64*
%11 = alloca i32
%12 = alloca %struct.TYPE_6__*
%13 = alloca i64
%14 = alloca i64
%15 = alloca %struct.TYPE_6__
store i32* %0, i32** %8
store i32 %1, i32* %9
store i64* %2, i64** %10
store i32 %3, i32* %11
store %struct.TYPE_6__* %4, %struct.TYPE_6__** %12
store i64 %5, i64* %13
%16 = load %struct.TYPE_6__*, %struct.TYPE_6__** %12
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 0
%18 = load i64, i64* %17
store i64 %18, i64* %14
%19 = load %struct.TYPE_6__*, %struct.TYPE_6__** %12
%20 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %19, i32 0, i32 3
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %15, i32 0, i32 3
store i32 %21, i32* %22
%23 = load %struct.TYPE_6__*, %struct.TYPE_6__** %12
%24 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %23, i32 0, i32 2
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %15, i32 0, i32 2
store i32 %25, i32* %26
%27 = load %struct.TYPE_6__*, %struct.TYPE_6__** %12
%28 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %27, i32 0, i32 1
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %15, i32 0, i32 1
store i32 %29, i32* %30
%31 = load i32*, i32** %8
%32 = load i32, i32* %9
%33 = call i32 @XFreeColors(i32* %31, i32 %32, i64* %14, i32 1, i64 0)
%34 = load i32*, i32** %8
%35 = load i32, i32* %9
%36 = load %struct.TYPE_6__*, %struct.TYPE_6__** %12
%37 = call i32 @XAllocColor(i32* %34, i32 %35, %struct.TYPE_6__* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %51
39: ; preds = %6
%40 = load %struct.TYPE_6__*, %struct.TYPE_6__** %12
%41 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %40, i32 0, i32 0
%42 = load i64, i64* %41
%43 = load i64, i64* %14
%44 = icmp ne i64 %42, %43
br i1 %44, label %45, label %59
45: ; preds = %39
%46 = load i32*, i32** %8
%47 = load i32, i32* %9
%48 = load %struct.TYPE_6__*, %struct.TYPE_6__** %12
%49 = call i32 @RWcell(i32* %46, i32 %47, %struct.TYPE_6__* %48, %struct.TYPE_6__* %15, i64* %14)
%50 = icmp ne i32 %49, 0
br i1 %50, label %59, label %51
51: ; preds = %45, %6
%52 = load i32*, i32** %8
%53 = load i32, i32* %9
%54 = load i64*, i64** %10
%55 = load i32, i32* %11
%56 = load i64, i64* %13
%57 = trunc i64 %56 to i32
%58 = call i32 @free_cells(i32* %52, i32 %53, i64* %54, i32 %55, i32 %57)
store i32 0, i32* %7
br label %60
59: ; preds = %45, %39
store i32 1, i32* %7
br label %60
60: ; preds = %59, %51
%61 = load i32, i32* %7
ret i32 %61
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i64, i32, i32, i32 }
define i32 @ROorRWcell(i32* %0, i32 %1, i64* %2, i32 %3, %struct.TYPE_6__* %4, i64 %5) {
%7 = alloca i64
%8 = alloca %struct.TYPE_6__
%9 = bitcast i64* %7 to i8*
%10 = bitcast %struct.TYPE_6__* %8 to i8*
%11 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %4, i64 0, i32 0
%12 = load i64, i64* %11
store i64 %12, i64* %7
%13 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %4, i64 0, i32 3
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %8, i64 0, i32 3
store i32 %14, i32* %15
%16 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %4, i64 0, i32 2
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %8, i64 0, i32 2
store i32 %17, i32* %18
%19 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %4, i64 0, i32 1
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %8, i64 0, i32 1
store i32 %20, i32* %21
%22 = call i32 @XFreeColors(i32* %0, i32 %1, i64* %7, i32 1, i64 0)
%23 = call i32 @XAllocColor(i32* %0, i32 %1, %struct.TYPE_6__* %4)
%24 = icmp eq i32 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %6
%26 = load i64, i64* %11
%27 = load i64, i64* %7
%28 = icmp eq i64 %26, %27
br i1 %28, label %35, label %29
29: ; preds = %25
%30 = call i32 @RWcell(i32* %0, i32 %1, %struct.TYPE_6__* %4, %struct.TYPE_6__* %8, i64* %7)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29, %6
%33 = trunc i64 %5 to i32
%34 = call i32 @free_cells(i32* %0, i32 %1, i64* %2, i32 %3, i32 %33)
br label %35
35: ; preds = %25, %29, %32
%36 = phi i32 [ 0, %32 ], [ 1, %29 ], [ 1, %25 ]
ret i32 %36
}