#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*/ new_colordef(int const, char *, short, short, short,
                                int const);
int parse_rgb_color_value(int const, int const);
scalar_t__ strcmp(char *, char *);
char *strtok(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ theme_parse_error(int const, char *);
int parse_theme_colordef(const int line_num, const int errors_are_fatal) {
  char *name;
  char *tmp;
  short red, green, blue;
  if (!(name = strtok(NULL, " \t"))) {
    if (errors_are_fatal)
      theme_parse_error(line_num, "expected color name");
    return 0;
  }
  if (!(tmp = strtok(NULL, " \t")) || strcmp(tmp, "=")) {
    if (errors_are_fatal)
      theme_parse_error(line_num, "expected '='");
    return 0;
  }
  if ((red = parse_rgb_color_value(line_num, errors_are_fatal) == -1) ||
      (green = parse_rgb_color_value(line_num, errors_are_fatal)) == -1 ||
      (blue = parse_rgb_color_value(line_num, errors_are_fatal)) == -1)
    return 0;
  if (!new_colordef(line_num, name, red, green, blue, errors_are_fatal))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<parse_theme_colordef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe97(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a1 <parse_theme_colordef+0x51>
cmpl   $0x0,-0xc(%rbp)
je     1195 <parse_theme_colordef+0x45>
mov    -0x8(%rbp),%edi
lea    0xe73(%rip),%rsi
call   1030 <theme_parse_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a2 <parse_theme_colordef+0x152>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe54(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11d9 <parse_theme_colordef+0x89>
mov    -0x20(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11fe <parse_theme_colordef+0xae>
cmpl   $0x0,-0xc(%rbp)
je     11f2 <parse_theme_colordef+0xa2>
mov    -0x8(%rbp),%edi
lea    0xe2c(%rip),%rsi
call   1030 <theme_parse_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a2 <parse_theme_colordef+0x152>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <parse_rgb_color_value@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %ax,-0x22(%rbp)
cwtl
cmp    $0x0,%eax
jne    1254 <parse_theme_colordef+0x104>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <parse_rgb_color_value@plt>
mov    %ax,-0x24(%rbp)
cwtl
cmp    $0xffffffff,%eax
je     1254 <parse_theme_colordef+0x104>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <parse_rgb_color_value@plt>
mov    %ax,-0x26(%rbp)
cwtl
cmp    $0xffffffff,%eax
jne    1260 <parse_theme_colordef+0x110>
movl   $0x0,-0x4(%rbp)
jmp    12a2 <parse_theme_colordef+0x152>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x22(%rbp),%dx
mov    -0x24(%rbp),%cx
mov    -0x26(%rbp),%ax
mov    -0xc(%rbp),%r9d
movswl %dx,%edx
movswl %cx,%ecx
movswl %ax,%r8d
call   1050 <new_colordef@plt>
cmp    $0x0,%eax
jne    129b <parse_theme_colordef+0x14b>
movl   $0x0,-0x4(%rbp)
jmp    12a2 <parse_theme_colordef+0x152>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_theme_colordef>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
lea    0xe98(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <strtok@plt>
test   %rax,%rax
je     11b0 <parse_theme_colordef+0x60>
mov    %rax,%rbp
lea    0xe80(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <strtok@plt>
test   %rax,%rax
je     11a2 <parse_theme_colordef+0x52>
lea    0xe82(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d5 <parse_theme_colordef+0x85>
test   %r15d,%r15d
je     11c4 <parse_theme_colordef+0x74>
lea    0xe6b(%rip),%rsi
jmp    11bc <parse_theme_colordef+0x6c>
test   %r15d,%r15d
je     11c4 <parse_theme_colordef+0x74>
lea    0xe47(%rip),%rsi
mov    %r14d,%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
mov    %r14d,%edi
mov    %r15d,%esi
call   1070 <parse_rgb_color_value@plt>
xor    %ebx,%ebx
xor    %r13d,%r13d
cmp    $0xffffffff,%eax
sete   %al
je     11c4 <parse_theme_colordef+0x74>
mov    %al,0x7(%rsp)
mov    %r14d,%edi
mov    %r15d,%esi
call   1070 <parse_rgb_color_value@plt>
mov    %eax,%r12d
cmp    $0xffff,%r12w
je     11c4 <parse_theme_colordef+0x74>
mov    %r14d,%edi
mov    %r15d,%esi
call   1070 <parse_rgb_color_value@plt>
cmp    $0xffff,%ax
je     11c4 <parse_theme_colordef+0x74>
mov    0x7(%rsp),%cl
mov    %cl,%r13b
movzwl %r13w,%edx
movswl %r12w,%ecx
movswl %ax,%r8d
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %r15d,%r9d
call   1050 <new_colordef@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
jmp    11c4 <parse_theme_colordef+0x74>

LLVM IR (-O0):
@.str = [3 x i8] c" \09\00"
@.str.1 = [20 x i8] c"expected color name\00"
@.str.2 = [2 x i8] c"=\00"
@.str.3 = [13 x i8] c"expected '='\00"
define i32 @parse_theme_colordef(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i16
%9 = alloca i16
%10 = alloca i16
store i32 %0, i32* %4
store i32 %1, i32* %5
%11 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %20, label %13
13: ; preds = %2
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %4
%18 = call i32 @theme_parse_error(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %16, %13
store i32 0, i32* %3
br label %69
20: ; preds = %2
%21 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %23, %20
%28 = load i32, i32* %5
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %4
%32 = call i32 @theme_parse_error(i32 %31, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %30, %27
store i32 0, i32* %3
br label %69
34: ; preds = %23
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = call i32 @parse_rgb_color_value(i32 %35, i32 %36)
%38 = icmp eq i32 %37, -1
%39 = zext i1 %38 to i32
%40 = trunc i32 %39 to i16
store i16 %40, i16* %8
%41 = sext i16 %40 to i32
%42 = icmp ne i32 %41, 0
br i1 %42, label %57, label %43
43: ; preds = %34
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = call i32 @parse_rgb_color_value(i32 %44, i32 %45)
%47 = trunc i32 %46 to i16
store i16 %47, i16* %9
%48 = sext i16 %47 to i32
%49 = icmp eq i32 %48, -1
br i1 %49, label %57, label %50
50: ; preds = %43
%51 = load i32, i32* %4
%52 = load i32, i32* %5
%53 = call i32 @parse_rgb_color_value(i32 %51, i32 %52)
%54 = trunc i32 %53 to i16
store i16 %54, i16* %10
%55 = sext i16 %54 to i32
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %58
57: ; preds = %50, %43, %34
store i32 0, i32* %3
br label %69
58: ; preds = %50
%59 = load i32, i32* %4
%60 = load i8*, i8** %6
%61 = load i16, i16* %8
%62 = load i16, i16* %9
%63 = load i16, i16* %10
%64 = load i32, i32* %5
%65 = call i32 @new_colordef(i32 %59, i8* %60, i16 signext %61, i16 signext %62, i16 signext %63, i32 %64)
%66 = icmp ne i32 %65, 0
br i1 %66, label %68, label %67
67: ; preds = %58
store i32 0, i32* %3
br label %69
68: ; preds = %58
store i32 1, i32* %3
br label %69
69: ; preds = %68, %67, %57, %33, %19
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
@.str.1 = [20 x i8] c"expected color name\00"
@.str.2 = [2 x i8] c"=\00"
@.str.3 = [13 x i8] c"expected '='\00"
define i32 @parse_theme_colordef(i32 %0, i32 %1) {
%3 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = icmp eq i32 %1, 0
br i1 %6, label %37, label %7
7: ; preds = %5
%8 = tail call i32 @theme_parse_error(i32 %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %37
9: ; preds = %2
%10 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12, %9
%16 = icmp eq i32 %1, 0
br i1 %16, label %37, label %17
17: ; preds = %15
%18 = tail call i32 @theme_parse_error(i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %37
19: ; preds = %12
%20 = tail call i32 @parse_rgb_color_value(i32 %0, i32 %1)
%21 = icmp eq i32 %20, -1
%22 = zext i1 %21 to i16
br i1 %21, label %37, label %23
23: ; preds = %19
%24 = tail call i32 @parse_rgb_color_value(i32 %0, i32 %1)
%25 = trunc i32 %24 to i16
%26 = and i32 %24, 65535
%27 = icmp eq i32 %26, 65535
br i1 %27, label %37, label %28
28: ; preds = %23
%29 = tail call i32 @parse_rgb_color_value(i32 %0, i32 %1)
%30 = and i32 %29, 65535
%31 = icmp eq i32 %30, 65535
br i1 %31, label %37, label %32
32: ; preds = %28
%33 = trunc i32 %29 to i16
%34 = tail call i32 @new_colordef(i32 %0, i8* %3, i16 signext %22, i16 signext %25, i16 signext %33, i32 %1)
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i32
br label %37
37: ; preds = %32, %19, %23, %28, %15, %17, %5, %7
%38 = phi i32 [ 0, %7 ], [ 0, %5 ], [ 0, %17 ], [ 0, %15 ], [ 0, %28 ], [ 0, %23 ], [ 0, %19 ], [ %36, %32 ]
ret i32 %38
}