#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 */
struct TYPE_4__ {
  unsigned long pixel;
};
typedef TYPE_1__ XColor;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Colormap;

/* Variables and functions */
unsigned long WhitePixel(int /*<<< orphan*/ *, int);
int XAllocNamedColor(int /*<<< orphan*/ *, int /*<<< orphan*/, char const *,
                     TYPE_1__ *, TYPE_1__ *);
unsigned long get_pixel(Display *dpy, int screen, Colormap cmap,
                        const char *colorstr) {
  XColor exact_fg, screen_fg;
  unsigned long pixel;
  int rc;
  rc = XAllocNamedColor(dpy, cmap, colorstr, &screen_fg, &exact_fg);
  if (rc > 0) {
    pixel = screen_fg.pixel;
  } else {
    pixel = WhitePixel(dpy, screen);
  }
  return pixel;
}


x86 assembly (clang, -O0):
<get_pixel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1040 <XAllocNamedColor@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jle    1168 <get_pixel+0x48>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1178 <get_pixel+0x58>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <WhitePixel@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pixel>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x8(%rsp),%rax
lea    0x10(%rsp),%r8
mov    %edx,%esi
mov    %rcx,%rdx
mov    %rax,%rcx
call   1040 <XAllocNamedColor@plt>
test   %eax,%eax
jle    114d <get_pixel+0x2d>
mov    0x8(%rsp),%rax
jmp    1157 <get_pixel+0x37>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <WhitePixel@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i64 }
define i64 @get_pixel(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca %struct.TYPE_4__
%10 = alloca %struct.TYPE_4__
%11 = alloca i64
%12 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%13 = load i32*, i32** %5
%14 = load i32, i32* %7
%15 = load i8*, i8** %8
%16 = call i32 @XAllocNamedColor(i32* %13, i32 %14, i8* %15, %struct.TYPE_4__* %10, %struct.TYPE_4__* %9)
store i32 %16, i32* %12
%17 = load i32, i32* %12
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %4
%20 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %10, i32 0, i32 0
%21 = load i64, i64* %20
store i64 %21, i64* %11
br label %26
22: ; preds = %4
%23 = load i32*, i32** %5
%24 = load i32, i32* %6
%25 = call i64 @WhitePixel(i32* %23, i32 %24)
store i64 %25, i64* %11
br label %26
26: ; preds = %22, %19
%27 = load i64, i64* %11
ret i64 %27
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i64 }
define i64 @get_pixel(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca %struct.TYPE_4__
%6 = alloca %struct.TYPE_4__
%7 = bitcast %struct.TYPE_4__* %5 to i8*
%8 = bitcast %struct.TYPE_4__* %6 to i8*
%9 = call i32 @XAllocNamedColor(i32* %0, i32 %2, i8* %3, %struct.TYPE_4__* %6, %struct.TYPE_4__* %5)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %6, i64 0, i32 0
%13 = load i64, i64* %12
br label %16
14: ; preds = %4
%15 = call i64 @WhitePixel(i32* %0, i32 %1)
br label %16
16: ; preds = %14, %11
%17 = phi i64 [ %13, %11 ], [ %15, %14 ]
ret i64 %17
}