#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_9__ TYPE_2__;
typedef struct TYPE_8__ TYPE_1__;

/* Type definitions */
struct TYPE_8__ {
  int /*<<< orphan*/ default_colormap;
};
typedef TYPE_1__ xcb_screen_t;
struct TYPE_9__ {
  int /*<<< orphan*/ pixel;
  int /*<<< orphan*/ exact_blue;
  int /*<<< orphan*/ exact_green;
  int /*<<< orphan*/ exact_red;
};
typedef TYPE_2__ xcb_lookup_color_reply_t;
typedef int /*<<< orphan*/ xcb_lookup_color_cookie_t;
typedef int /*<<< orphan*/ xcb_connection_t;
typedef TYPE_2__ xcb_alloc_color_reply_t;
typedef int /*<<< orphan*/ xcb_alloc_color_cookie_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ free(TYPE_2__ *);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ xcb_alloc_color(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, int /*<<< orphan*/,
                                   int /*<<< orphan*/);
TYPE_2__ *xcb_alloc_color_reply(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_lookup_color(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                    int /*<<< orphan*/, char const *);
TYPE_2__ *xcb_lookup_color_reply(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                 int /*<<< orphan*/ *);
void lookup_color(xcb_connection_t *c, xcb_screen_t *screen, const char *color,
                  uint32_t *pixel) {
  xcb_lookup_color_cookie_t cookie;
  xcb_lookup_color_reply_t *r;
  xcb_alloc_color_cookie_t acookie;
  xcb_alloc_color_reply_t *ar;
  cookie = xcb_lookup_color(c, screen->default_colormap, strlen(color), color);
  r = xcb_lookup_color_reply(c, cookie, NULL);
  acookie = xcb_alloc_color(c, screen->default_colormap, r->exact_red,
                            r->exact_green, r->exact_blue);
  free(r);
  ar = xcb_alloc_color_reply(c, acookie, NULL);
  *pixel = ar->pixel;
  free(ar);
}


x86 assembly (clang, -O0):
<lookup_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    %eax,%edx
mov    -0x18(%rbp),%rcx
call   1080 <xcb_lookup_color@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <xcb_lookup_color_reply@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%rax
mov    0xc(%rax),%edx
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%r8d
call   1060 <xcb_alloc_color@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <xcb_alloc_color_reply@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup_color>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r15
mov    (%rsi),%ebp
mov    %rdx,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1080 <xcb_lookup_color@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1070 <xcb_lookup_color_reply@plt>
mov    %rax,%rbx
mov    (%r12),%esi
mov    0xc(%rax),%edx
mov    0x4(%rax),%r8d
mov    0x8(%rax),%ecx
mov    %r15,%rdi
call   1060 <xcb_alloc_color@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1050 <xcb_alloc_color_reply@plt>
mov    (%rax),%ecx
mov    %ecx,(%r14)
mov    %rax,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_9__ = type { i32, i32, i32, i32 }
define void @lookup_color(i32* %0, %struct.TYPE_8__* %1, i8* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca %struct.TYPE_8__*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca %struct.TYPE_9__*
%11 = alloca i32
%12 = alloca %struct.TYPE_9__*
store i32* %0, i32** %5
store %struct.TYPE_8__* %1, %struct.TYPE_8__** %6
store i8* %2, i8** %7
store i32* %3, i32** %8
%13 = load i32*, i32** %5
%14 = load %struct.TYPE_8__*, %struct.TYPE_8__** %6
%15 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = load i8*, i8** %7
%18 = call i32 @strlen(i8* %17)
%19 = load i8*, i8** %7
%20 = call i32 @xcb_lookup_color(i32* %13, i32 %16, i32 %18, i8* %19)
store i32 %20, i32* %9
%21 = load i32*, i32** %5
%22 = load i32, i32* %9
%23 = call %struct.TYPE_9__* @xcb_lookup_color_reply(i32* %21, i32 %22, i32* null)
store %struct.TYPE_9__* %23, %struct.TYPE_9__** %10
%24 = load i32*, i32** %5
%25 = load %struct.TYPE_8__*, %struct.TYPE_8__** %6
%26 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = load %struct.TYPE_9__*, %struct.TYPE_9__** %10
%29 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %28, i32 0, i32 3
%30 = load i32, i32* %29
%31 = load %struct.TYPE_9__*, %struct.TYPE_9__** %10
%32 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %31, i32 0, i32 2
%33 = load i32, i32* %32
%34 = load %struct.TYPE_9__*, %struct.TYPE_9__** %10
%35 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %34, i32 0, i32 1
%36 = load i32, i32* %35
%37 = call i32 @xcb_alloc_color(i32* %24, i32 %27, i32 %30, i32 %33, i32 %36)
store i32 %37, i32* %11
%38 = load %struct.TYPE_9__*, %struct.TYPE_9__** %10
%39 = call i32 @free(%struct.TYPE_9__* %38)
%40 = load i32*, i32** %5
%41 = load i32, i32* %11
%42 = call %struct.TYPE_9__* @xcb_alloc_color_reply(i32* %40, i32 %41, i32* null)
store %struct.TYPE_9__* %42, %struct.TYPE_9__** %12
%43 = load %struct.TYPE_9__*, %struct.TYPE_9__** %12
%44 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %43, i32 0, i32 0
%45 = load i32, i32* %44
%46 = load i32*, i32** %8
store i32 %45, i32* %46
%47 = load %struct.TYPE_9__*, %struct.TYPE_9__** %12
%48 = call i32 @free(%struct.TYPE_9__* %47)
ret void
}

LLVM IR (-O2):
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_9__ = type { i32, i32, i32, i32 }
define void @lookup_color(i32* %0, %struct.TYPE_8__* nocapture %1, i8* %2, i32* nocapture writeonly %3) {
%5 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = tail call i32 @strlen(i8* %2)
%8 = tail call i32 @xcb_lookup_color(i32* %0, i32 %6, i32 %7, i8* %2)
%9 = tail call %struct.TYPE_9__* @xcb_lookup_color_reply(i32* %0, i32 %8, i32* null)
%10 = load i32, i32* %5
%11 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %9, i64 0, i32 3
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %9, i64 0, i32 2
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %9, i64 0, i32 1
%16 = load i32, i32* %15
%17 = tail call i32 @xcb_alloc_color(i32* %0, i32 %10, i32 %12, i32 %14, i32 %16)
%18 = tail call i32 @free(%struct.TYPE_9__* %9)
%19 = tail call %struct.TYPE_9__* @xcb_alloc_color_reply(i32* %0, i32 %17, i32* null)
%20 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i64 0, i32 0
%21 = load i32, i32* %20
store i32 %21, i32* %3
%22 = tail call i32 @free(%struct.TYPE_9__* %19)
ret void
}