#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_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int red_max;
  int red_mult;
  int /*<<< orphan*/ colormap;
  scalar_t__ base_pixel;
};
typedef TYPE_1__ XStandardColormap;
struct TYPE_6__ {
  scalar_t__ blue;
  scalar_t__ green;
  scalar_t__ pixel;
};
typedef TYPE_2__ XColor;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ XQueryColor(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               TYPE_2__ *);
int IsGray(Display *dpy, XStandardColormap *stdmap) {
  XColor color;
  color.pixel = stdmap->base_pixel + (stdmap->red_max * stdmap->red_mult);
  XQueryColor(dpy, stdmap->colormap, &color);
  return (color.green || color.blue);
}


x86 assembly (clang, -O0):
<IsGray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
mov    -0x10(%rbp),%rdx
imul   0x4(%rdx),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%esi
lea    -0x28(%rbp),%rdx
call   1030 <XQueryColor@plt>
mov    $0x1,%al
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x29(%rbp)
jne    116f <IsGray+0x5f>
cmpq   $0x0,-0x28(%rbp)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsGray>:
sub    $0x18,%rsp
movslq (%rsi),%rax
movslq 0x4(%rsi),%rcx
imul   %rax,%rcx
add    0x10(%rsi),%rcx
mov    %rcx,0x10(%rsp)
mov    0x8(%rsi),%esi
mov    %rsp,%rdx
call   1030 <XQueryColor@plt>
mov    0x8(%rsp),%rcx
xor    %eax,%eax
or     (%rsp),%rcx
setne  %al
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i32, i32, i64 }
%struct.TYPE_6__ = type { i64, i64, i64 }
define i32 @IsGray(i32* %0, %struct.TYPE_5__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_5__*
%5 = alloca %struct.TYPE_6__
store i32* %0, i32** %3
store %struct.TYPE_5__* %1, %struct.TYPE_5__** %4
%6 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 3
%8 = load i64, i64* %7
%9 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = mul nsw i32 %11, %14
%16 = sext i32 %15 to i64
%17 = add nsw i64 %8, %16
%18 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 2
store i64 %17, i64* %18
%19 = load i32*, i32** %3
%20 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 2
%22 = load i32, i32* %21
%23 = call i32 @XQueryColor(i32* %19, i32 %22, %struct.TYPE_6__* %5)
%24 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 1
%25 = load i64, i64* %24
%26 = icmp ne i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %2
%28 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %5, i32 0, i32 0
%29 = load i64, i64* %28
%30 = icmp ne i64 %29, 0
br label %31
31: ; preds = %27, %2
%32 = phi i1 [ true, %2 ], [ %30, %27 ]
%33 = zext i1 %32 to i32
ret i32 %33
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i32, i32, i64 }
%struct.TYPE_6__ = type { i64, i64, i64 }
define i32 @IsGray(i32* %0, %struct.TYPE_5__* nocapture %1) {
%3 = alloca %struct.TYPE_6__
%4 = bitcast %struct.TYPE_6__* %3 to i8*
%5 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 3
%6 = load i64, i64* %5
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, %8
%12 = sext i32 %11 to i64
%13 = add nsw i64 %6, %12
%14 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 2
store i64 %13, i64* %14
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 2
%16 = load i32, i32* %15
%17 = call i32 @XQueryColor(i32* %0, i32 %16, %struct.TYPE_6__* %3)
%18 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 1
%19 = load i64, i64* %18
%20 = icmp ne i64 %19, 0
%21 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %3, i64 0, i32 0
%22 = load i64, i64* %21
%23 = icmp ne i64 %22, 0
%24 = select i1 %20, i1 true, i1 %23
%25 = zext i1 %24 to i32
ret i32 %25
}