#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*/ strncpy(char *, char *, int);
int state_to_color(char *colorDest, char state) {
  switch (state) {
  case 'o':
    strncpy(colorDest, "#FF0000", 7);
    break;
  case 'f':
    strncpy(colorDest, "#FFFFFF", 7);
    break;
  case 'O':
  case 'F':
    strncpy(colorDest, "#00FF00", 7);
    break;
  default:
    strncpy(colorDest, "#131313", 7);
    return 0;
    break;
  }
  return 1;
}


x86 assembly (clang, -O0):
<state_to_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x46,%eax
je     119e <state_to_color+0x8e>
jmp    1137 <state_to_color+0x27>
mov    -0x18(%rbp),%eax
sub    $0x4f,%eax
je     119e <state_to_color+0x8e>
jmp    1148 <state_to_color+0x38>
mov    -0x18(%rbp),%eax
sub    $0x66,%eax
je     1184 <state_to_color+0x74>
jmp    1159 <state_to_color+0x49>
mov    -0x18(%rbp),%eax
sub    $0x6f,%eax
jne    11b8 <state_to_color+0xa8>
jmp    116a <state_to_color+0x5a>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
jmp    11d9 <state_to_color+0xc9>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
jmp    11d9 <state_to_color+0xc9>
mov    -0x10(%rbp),%rdi
lea    0xe67(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
jmp    11d9 <state_to_color+0xc9>
mov    -0x10(%rbp),%rdi
lea    0xe55(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <state_to_color+0xd0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<state_to_color>:
push   %rbx
mov    $0x1,%ebx
cmp    $0x65,%esi
jg     112e <state_to_color+0x1e>
cmp    $0x46,%esi
je     1125 <state_to_color+0x15>
cmp    $0x4f,%esi
jne    1141 <state_to_color+0x31>
lea    0xee4(%rip),%rsi
jmp    1153 <state_to_color+0x43>
cmp    $0x6f,%esi
je     114c <state_to_color+0x3c>
cmp    $0x66,%esi
jne    1141 <state_to_color+0x31>
lea    0xec9(%rip),%rsi
jmp    1153 <state_to_color+0x43>
xor    %ebx,%ebx
lea    0xece(%rip),%rsi
jmp    1153 <state_to_color+0x43>
lea    0xead(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"#FF0000\00"
@.str.1 = [8 x i8] c"#FFFFFF\00"
@.str.2 = [8 x i8] c"FF00\00"
@.str.3 = [8 x i8] c"\00"
define i32 @state_to_color(i8* %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %4
store i8 %1, i8* %5
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %17 [
i32 111, label %8
i32 102, label %11
i32 79, label %14
i32 70, label %14
]
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @strncpy(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
br label %20
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i32 @strncpy(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
br label %20
14: ; preds = %2, %2
%15 = load i8*, i8** %4
%16 = call i32 @strncpy(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
br label %20
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i32 @strncpy(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
store i32 0, i32* %3
br label %21
20: ; preds = %14, %11, %8
store i32 1, i32* %3
br label %21
21: ; preds = %20, %17
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [8 x i8] c"#FF0000\00"
@.str.1 = [8 x i8] c"#FFFFFF\00"
@.str.2 = [8 x i8] c"FF00\00"
@.str.3 = [8 x i8] c"\00"
define i32 @state_to_color(i8* %0, i8 signext %1) {
%3 = sext i8 %1 to i32
switch i32 %3, label %6 [
i32 111, label %7
i32 102, label %4
i32 79, label %5
i32 70, label %5
]
4: ; preds = %2
br label %7
5: ; preds = %2, %2
br label %7
6: ; preds = %2
br label %7
7: ; preds = %2, %4, %5, %6
%8 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = phi i32 [ 1, %4 ], [ 1, %5 ], [ 0, %6 ], [ 1, %2 ]
%10 = tail call i32 @strncpy(i8* %0, i8* %8, i32 7)
ret i32 %9
}