#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 */
scalar_t__ can_change_color();
short find_color_name(char const *);
int /*<<< orphan*/ init_color(short, short const, short const, short const);
int /*<<< orphan*/ theme_parse_error(int const, char *);
int new_colordef(const int line_num, const char *name, const short red,
                 const short green, const short blue,
                 const int errors_are_fatal) {
  short color = find_color_name(name);
  if (color == -1) {
    if (errors_are_fatal)
      theme_parse_error(line_num, "bad color name");
    return 0;
  }
  if (can_change_color())
    init_color(color, red, green, blue);
  return 1;
}


x86 assembly (clang, -O0):
<new_colordef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8w,%ax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %dx,-0x12(%rbp)
mov    %cx,-0x14(%rbp)
mov    %ax,-0x16(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <find_color_name@plt>
mov    %ax,-0x1e(%rbp)
movswl -0x1e(%rbp),%eax
cmp    $0xffffffff,%eax
jne    11a2 <new_colordef+0x62>
cmpl   $0x0,-0x1c(%rbp)
je     1196 <new_colordef+0x56>
mov    -0x8(%rbp),%edi
lea    0xe6f(%rip),%rsi
call   1030 <theme_parse_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <new_colordef+0x98>
mov    $0x0,%al
call   1060 <can_change_color@plt>
cmp    $0x0,%rax
je     11d1 <new_colordef+0x91>
mov    -0x1e(%rbp),%dx
mov    -0x12(%rbp),%cx
mov    -0x14(%rbp),%ax
movswl %dx,%edi
movswl %cx,%esi
movswl %ax,%edx
movswl -0x16(%rbp),%ecx
call   1040 <init_color@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_colordef>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%ebx
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %edi,%r13d
mov    %rsi,%rdi
call   1050 <find_color_name@plt>
cmp    $0xffff,%ax
je     1194 <new_colordef+0x54>
mov    %eax,%ebp
mov    %ebx,%r14d
xor    %eax,%eax
call   1060 <can_change_color@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     11aa <new_colordef+0x6a>
movswl %bp,%edi
movswl %r12w,%esi
movswl %r15w,%edx
movswl %r14w,%ecx
call   1040 <init_color@plt>
jmp    11aa <new_colordef+0x6a>
xor    %ebx,%ebx
test   %r14d,%r14d
je     11aa <new_colordef+0x6a>
lea    0xe5e(%rip),%rsi
mov    %r13d,%edi
call   1030 <theme_parse_error@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"bad color name\00"
define i32 @new_colordef(i32 %0, i8* %1, i16 signext %2, i16 signext %3, i16 signext %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i16
%11 = alloca i16
%12 = alloca i16
%13 = alloca i32
%14 = alloca i16
store i32 %0, i32* %8
store i8* %1, i8** %9
store i16 %2, i16* %10
store i16 %3, i16* %11
store i16 %4, i16* %12
store i32 %5, i32* %13
%15 = load i8*, i8** %9
%16 = call signext i16 @find_color_name(i8* %15)
store i16 %16, i16* %14
%17 = load i16, i16* %14
%18 = sext i16 %17 to i32
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %27
20: ; preds = %6
%21 = load i32, i32* %13
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %8
%25 = call i32 @theme_parse_error(i32 %24, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %23, %20
store i32 0, i32* %7
br label %37
27: ; preds = %6
%28 = call i64 (...) @can_change_color()
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = load i16, i16* %14
%32 = load i16, i16* %10
%33 = load i16, i16* %11
%34 = load i16, i16* %12
%35 = call i32 @init_color(i16 signext %31, i16 signext %32, i16 signext %33, i16 signext %34)
br label %36
36: ; preds = %30, %27
store i32 1, i32* %7
br label %37
37: ; preds = %36, %26
%38 = load i32, i32* %7
ret i32 %38
}

LLVM IR (-O2):
@.str = [15 x i8] c"bad color name\00"
define i32 @new_colordef(i32 %0, i8* %1, i16 signext %2, i16 signext %3, i16 signext %4, i32 %5) {
%7 = tail call signext i16 @find_color_name(i8* %1)
%8 = icmp eq i16 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = icmp eq i32 %5, 0
br i1 %10, label %18, label %11
11: ; preds = %9
%12 = tail call i32 @theme_parse_error(i32 %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %18
13: ; preds = %6
%14 = tail call i64 (...) @can_change_color()
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @init_color(i16 signext %7, i16 signext %2, i16 signext %3, i16 signext %4)
br label %18
18: ; preds = %13, %16, %9, %11
%19 = phi i32 [ 0, %11 ], [ 0, %9 ], [ 1, %16 ], [ 1, %13 ]
ret i32 %19
}