#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 COLOR_BLACK;
int COLOR_BLUE;
int COLOR_CYAN;
int COLOR_GREEN;
int COLOR_MAGENTA;
int COLOR_RED;
int COLOR_WHITE;
int COLOR_YELLOW;
int unix_convert(int color) {
  switch (color) {
  case 2:
    return COLOR_BLACK;
  case 3:
    return COLOR_RED;
  case 4:
    return COLOR_GREEN;
  case 5:
    return COLOR_YELLOW;
  case 6:
    return COLOR_BLUE;
  case 7:
    return COLOR_MAGENTA;
  case 8:
    return COLOR_CYAN;
  case 9:
    return COLOR_WHITE;
  }
  return 0;
}


x86 assembly (clang, -O0):
<unix_convert>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xfffffffe,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x7,%eax
ja     11b8 <unix_convert+0xb8>
mov    -0x10(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2eb1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <unix_convert+0xbf>
mov    0x2e60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <unix_convert+0xbf>
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <unix_convert+0xbf>
mov    0x2e4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <unix_convert+0xbf>
mov    0x2e35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <unix_convert+0xbf>
mov    0x2e3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <unix_convert+0xbf>
mov    0x2e43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <unix_convert+0xbf>
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <unix_convert+0xbf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<unix_convert>:
add    $0xfffffffe,%edi
cmp    $0x7,%edi
ja     1122 <unix_convert+0x22>
lea    0xef1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    0x2ec9(%rip),%rax
mov    (%rax),%eax
ret
xor    %eax,%eax
ret
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e78(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e58(%rip),%rax
mov    (%rax),%eax
ret

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

LLVM IR (-O2):
@COLOR_BLACK = global i32 0
@COLOR_RED = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_CYAN = global i32 0
@COLOR_WHITE = global i32 0
define i32 @unix_convert(i32 %0) {
switch i32 %0, label %18 [
i32 2, label %2
i32 3, label %4
i32 4, label %6
i32 5, label %8
i32 6, label %10
i32 7, label %12
i32 8, label %14
i32 9, label %16
]
2: ; preds = %1
%3 = load i32, i32* @COLOR_BLACK
br label %18
4: ; preds = %1
%5 = load i32, i32* @COLOR_RED
br label %18
6: ; preds = %1
%7 = load i32, i32* @COLOR_GREEN
br label %18
8: ; preds = %1
%9 = load i32, i32* @COLOR_YELLOW
br label %18
10: ; preds = %1
%11 = load i32, i32* @COLOR_BLUE
br label %18
12: ; preds = %1
%13 = load i32, i32* @COLOR_MAGENTA
br label %18
14: ; preds = %1
%15 = load i32, i32* @COLOR_CYAN
br label %18
16: ; preds = %1
%17 = load i32, i32* @COLOR_WHITE
br label %18
18: ; preds = %1, %16, %14, %12, %10, %8, %6, %4, %2
%19 = phi i32 [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ %3, %2 ], [ 0, %1 ]
ret i32 %19
}