#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 */
typedef int uint8_t;

/* Variables and functions */
int COLOR_BLACK;
int COLOR_BLUE;
int COLOR_CYAN;
int COLOR_GREEN;
int COLOR_MAGENTA;
int COLOR_RED;
int COLOR_WHITE;
int COLOR_YELLOW;
uint8_t CharProp2Color(uint8_t value) {
  value &= 0x07;
  switch (value) {
  case 0x00:
    return COLOR_BLACK;
    break;
  case 0x01:
    return COLOR_BLUE;
    break;
  case 0x02:
    return COLOR_GREEN;
    break;
  case 0x03:
    return COLOR_CYAN;
    break;
  case 0x04:
    return COLOR_RED;
    break;
  case 0x05:
    return COLOR_MAGENTA;
    break;
  case 0x06:
    return COLOR_YELLOW;
    break;
  case 0x07:
    return COLOR_WHITE;
    break;
  }
  return COLOR_BLACK;
}


x86 assembly (clang, -O0):
<CharProp2Color>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x7,%rax
ja     11bd <CharProp2Color+0xbd>
mov    -0x10(%rbp),%rax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2eac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <CharProp2Color+0xc9>
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <CharProp2Color+0xc9>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <CharProp2Color+0xc9>
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <CharProp2Color+0xc9>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <CharProp2Color+0xc9>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <CharProp2Color+0xc9>
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <CharProp2Color+0xc9>
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <CharProp2Color+0xc9>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<CharProp2Color>:
and    $0x7,%edi
lea    0x2d06(%rip),%rax
mov    (%rax,%rdi,8),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
@COLOR_BLACK = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_CYAN = global i32 0
@COLOR_RED = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_WHITE = global i32 0
define i32 @CharProp2Color(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 7
store i32 %5, i32* %3
%6 = load i32, i32* %3
switch i32 %6, label %23 [
i32 0, label %7
i32 1, label %9
i32 2, label %11
i32 3, label %13
i32 4, label %15
i32 5, label %17
i32 6, label %19
i32 7, label %21
]
7: ; preds = %1
%8 = load i32, i32* @COLOR_BLACK
store i32 %8, i32* %2
br label %25
9: ; preds = %1
%10 = load i32, i32* @COLOR_BLUE
store i32 %10, i32* %2
br label %25
11: ; preds = %1
%12 = load i32, i32* @COLOR_GREEN
store i32 %12, i32* %2
br label %25
13: ; preds = %1
%14 = load i32, i32* @COLOR_CYAN
store i32 %14, i32* %2
br label %25
15: ; preds = %1
%16 = load i32, i32* @COLOR_RED
store i32 %16, i32* %2
br label %25
17: ; preds = %1
%18 = load i32, i32* @COLOR_MAGENTA
store i32 %18, i32* %2
br label %25
19: ; preds = %1
%20 = load i32, i32* @COLOR_YELLOW
store i32 %20, i32* %2
br label %25
21: ; preds = %1
%22 = load i32, i32* @COLOR_WHITE
store i32 %22, i32* %2
br label %25
23: ; preds = %1
%24 = load i32, i32* @COLOR_BLACK
store i32 %24, i32* %2
br label %25
25: ; preds = %23, %21, %19, %17, %15, %13, %11, %9, %7
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@COLOR_BLACK = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_CYAN = global i32 0
@COLOR_RED = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_WHITE = global i32 0
@switch.table.CharProp2Color = [8 x i32*] [i32* @COLOR_BLACK, i32* @COLOR_BLUE, i32* @COLOR_GREEN, i32* @COLOR_CYAN, i32* @COLOR_RED, i32* @COLOR_MAGENTA, i32* @COLOR_YELLOW, i32* @COLOR_WHITE]
define i32 @CharProp2Color(i32 %0) {
%2 = and i32 %0, 7
%3 = zext i32 %2 to i64
%4 = getelementptr inbounds [8 x i32*], [8 x i32*]* @switch.table.CharProp2Color, i64 0, i64 %3
%5 = load i32*, i32** %4
%6 = load i32, i32* %5
ret i32 %6
}