#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*/ strcpy(char *, char *);
void pick_colour(int colour, char colour_code[]) {
  switch (colour) {
  case 0:
    strcpy(colour_code, "ffffff");
    break;
  case 1:
    strcpy(colour_code, "00ffff");
    break;
  case 2:
    strcpy(colour_code, "0000ff");
    break;
  case 3:
    strcpy(colour_code, "ff00ff");
    break;
  case 4:
    strcpy(colour_code, "ff0000");
    break;
  case 5:
    strcpy(colour_code, "ffff00");
    break;
  case 6:
    strcpy(colour_code, "00ff00");
    break;
  default:
    strcpy(colour_code, "000000");
    break;
  }
}


x86 assembly (clang, -O0):
<pick_colour>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x6,%rax
ja     11d7 <pick_colour+0xc7>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xecd(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11e7 <pick_colour+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11e7 <pick_colour+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11e7 <pick_colour+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11e7 <pick_colour+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11e7 <pick_colour+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11e7 <pick_colour+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11e7 <pick_colour+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pick_colour>:
mov    %rsi,%rax
cmp    $0x6,%edi
ja     1131 <pick_colour+0x21>
movslq %edi,%rcx
lea    0xf16(%rip),%rdx
movslq (%rdx,%rcx,4),%rsi
add    %rdx,%rsi
mov    %rax,%rdi
jmp    1030 <strcpy@plt>
lea    0xef9(%rip),%rsi
mov    %rax,%rdi
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"ffffff\00"
@.str.1 = [7 x i8] c"00ffff\00"
@.str.2 = [7 x i8] c"0000ff\00"
@.str.3 = [7 x i8] c"ff00ff\00"
@.str.4 = [7 x i8] c"ff0000\00"
@.str.5 = [7 x i8] c"ffff00\00"
@.str.6 = [7 x i8] c"00ff00\00"
@.str.7 = [7 x i8] c"000000\00"
define void @pick_colour(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
switch i32 %5, label %27 [
i32 0, label %6
i32 1, label %9
i32 2, label %12
i32 3, label %15
i32 4, label %18
i32 5, label %21
i32 6, label %24
]
6: ; preds = %2
%7 = load i8*, i8** %4
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %30
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %30
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %30
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %30
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %30
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %30
24: ; preds = %2
%25 = load i8*, i8** %4
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %30
27: ; preds = %2
%28 = load i8*, i8** %4
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %30
30: ; preds = %27, %24, %21, %18, %15, %12, %9, %6
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"ffffff\00"
@.str.1 = [7 x i8] c"00ffff\00"
@.str.2 = [7 x i8] c"0000ff\00"
@.str.3 = [7 x i8] c"ff00ff\00"
@.str.4 = [7 x i8] c"ff0000\00"
@.str.5 = [7 x i8] c"ffff00\00"
@.str.6 = [7 x i8] c"00ff00\00"
@.str.7 = [7 x i8] c"000000\00"
@reltable.pick_colour = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.pick_colour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.pick_colour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.pick_colour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.pick_colour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.pick_colour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.pick_colour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.pick_colour to i64)) to i32)]
define void @pick_colour(i32 %0, i8* %1) {
%3 = icmp ult i32 %0, 7
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = sext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.pick_colour to i8*), i64 %6)
br label %8
8: ; preds = %2, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %2 ]
%10 = tail call i32 @strcpy(i8* %1, i8* %9)
ret void
}