#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);
short 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;
  }
  red = parse_rgb_color_value(line_num, errors_are_fatal);
  green = parse_rgb_color_value(line_num, errors_are_fatal);
  blue = parse_rgb_color_value(line_num, errors_are_fatal);
  if (red == -1 || green == -1 || blue == -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    12a0 <parse_theme_colordef+0x150>
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    12a0 <parse_theme_colordef+0x150>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <parse_rgb_color_value@plt>
mov    %ax,-0x22(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <parse_rgb_color_value@plt>
mov    %ax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <parse_rgb_color_value@plt>
mov    %ax,-0x26(%rbp)
movswl -0x22(%rbp),%eax
cmp    $0xffffffff,%eax
je     1252 <parse_theme_colordef+0x102>
movswl -0x24(%rbp),%eax
cmp    $0xffffffff,%eax
je     1252 <parse_theme_colordef+0x102>
movswl -0x26(%rbp),%eax
cmp    $0xffffffff,%eax
jne    125e <parse_theme_colordef+0x10e>
movl   $0x0,-0x4(%rbp)
jmp    12a0 <parse_theme_colordef+0x150>
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    1299 <parse_theme_colordef+0x149>
movl   $0x0,-0x4(%rbp)
jmp    12a0 <parse_theme_colordef+0x150>
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>
mov    %eax,%r12d
mov    %r14d,%edi
mov    %r15d,%esi
call   1070 <parse_rgb_color_value@plt>
mov    %eax,%r13d
mov    %r14d,%edi
mov    %r15d,%esi
call   1070 <parse_rgb_color_value@plt>
xor    %ebx,%ebx
cmp    $0xffff,%r12w
je     11c4 <parse_theme_colordef+0x74>
cmp    $0xffff,%r13w
je     11c4 <parse_theme_colordef+0x74>
cmp    $0xffff,%ax
je     11c4 <parse_theme_colordef+0x74>
movswl %r12w,%edx
movswl %r13w,%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 %67
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 %67
34: ; preds = %23
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = call signext i16 @parse_rgb_color_value(i32 %35, i32 %36)
store i16 %37, i16* %8
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = call signext i16 @parse_rgb_color_value(i32 %38, i32 %39)
store i16 %40, i16* %9
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = call signext i16 @parse_rgb_color_value(i32 %41, i32 %42)
store i16 %43, i16* %10
%44 = load i16, i16* %8
%45 = sext i16 %44 to i32
%46 = icmp eq i32 %45, -1
br i1 %46, label %55, label %47
47: ; preds = %34
%48 = load i16, i16* %9
%49 = sext i16 %48 to i32
%50 = icmp eq i32 %49, -1
br i1 %50, label %55, label %51
51: ; preds = %47
%52 = load i16, i16* %10
%53 = sext i16 %52 to i32
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %56
55: ; preds = %51, %47, %34
store i32 0, i32* %3
br label %67
56: ; preds = %51
%57 = load i32, i32* %4
%58 = load i8*, i8** %6
%59 = load i16, i16* %8
%60 = load i16, i16* %9
%61 = load i16, i16* %10
%62 = load i32, i32* %5
%63 = call i32 @new_colordef(i32 %57, i8* %58, i16 signext %59, i16 signext %60, i16 signext %61, i32 %62)
%64 = icmp ne i32 %63, 0
br i1 %64, label %66, label %65
65: ; preds = %56
store i32 0, i32* %3
br label %67
66: ; preds = %56
store i32 1, i32* %3
br label %67
67: ; preds = %66, %65, %55, %33, %19
%68 = load i32, i32* %3
ret i32 %68
}

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 %32, 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 %32
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 %32, 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 %32
19: ; preds = %12
%20 = tail call signext i16 @parse_rgb_color_value(i32 %0, i32 %1)
%21 = tail call signext i16 @parse_rgb_color_value(i32 %0, i32 %1)
%22 = tail call signext i16 @parse_rgb_color_value(i32 %0, i32 %1)
%23 = icmp eq i16 %20, -1
%24 = icmp eq i16 %21, -1
%25 = select i1 %23, i1 true, i1 %24
%26 = icmp eq i16 %22, -1
%27 = select i1 %25, i1 true, i1 %26
br i1 %27, label %32, label %28
28: ; preds = %19
%29 = tail call i32 @new_colordef(i32 %0, i8* %3, i16 signext %20, i16 signext %21, i16 signext %22, i32 %1)
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i32
br label %32
32: ; preds = %28, %19, %15, %17, %5, %7
%33 = phi i32 [ 0, %7 ], [ 0, %5 ], [ 0, %17 ], [ 0, %15 ], [ 0, %19 ], [ %31, %28 ]
ret i32 %33
}