#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 */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *gui_color_get_custom(char *);
char *gui_nick_find_color_name(char const *, char const *);
char *strdup(char const *);
char *gui_nick_find_color(const char *nickname, const char *colors) {
  char *color;
  const char *ptr_result;
  color = gui_nick_find_color_name(nickname, colors);
  ptr_result = gui_color_get_custom(color);
  if (color)
    free(color);
  return (ptr_result) ? strdup(ptr_result) : NULL;
}


x86 assembly (clang, -O0):
<gui_nick_find_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <gui_nick_find_color_name@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <gui_color_get_custom@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1182 <gui_nick_find_color+0x42>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x20(%rbp)
je     119f <gui_nick_find_color+0x5f>
mov    -0x20(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x28(%rbp)
jmp    11aa <gui_nick_find_color+0x6a>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    11aa <gui_nick_find_color+0x6a>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_nick_find_color>:
push   %r14
push   %rbx
push   %rax
call   1060 <gui_nick_find_color_name@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <gui_color_get_custom@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     1164 <gui_nick_find_color+0x24>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     1178 <gui_nick_find_color+0x38>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <strdup@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @gui_nick_find_color(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i8* @gui_nick_find_color_name(i8* %7, i8* %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = call i8* @gui_color_get_custom(i8* %10)
store i8* %11, i8** %6
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = call i32 @free(i8* %15)
br label %17
17: ; preds = %14, %2
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i8*, i8** %6
%22 = call i8* @strdup(i8* %21)
br label %24
23: ; preds = %17
br label %24
24: ; preds = %23, %20
%25 = phi i8* [ %22, %20 ], [ null, %23 ]
ret i8* %25
}

LLVM IR (-O2):
define noalias i8* @gui_nick_find_color(i8* %0, i8* %1) {
%3 = tail call i8* @gui_nick_find_color_name(i8* %0, i8* %1)
%4 = tail call i8* @gui_color_get_custom(i8* %3)
%5 = icmp eq i8* %3, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @free(i8* %3)
br label %8
8: ; preds = %6, %2
%9 = icmp eq i8* %4, null
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i8* @strdup(i8* %4)
br label %12
12: ; preds = %8, %10
%13 = phi i8* [ %11, %10 ], [ null, %8 ]
ret i8* %13
}