#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 phaseNumToName(int phase, char *name) {
  switch (phase) {
  case 0:
    strcpy(name, "Action");
    break;
  case 1:
    strcpy(name, "Buy");
    break;
  case 2:
    strcpy(name, "Cleanup");
    break;
  }
}


x86 assembly (clang, -O0):
<phaseNumToName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1154 <phaseNumToName+0x44>
jmp    1132 <phaseNumToName+0x22>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1169 <phaseNumToName+0x59>
jmp    1143 <phaseNumToName+0x33>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     117e <phaseNumToName+0x6e>
jmp    118e <phaseNumToName+0x7e>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    118e <phaseNumToName+0x7e>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcpy@plt>
jmp    118e <phaseNumToName+0x7e>
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<phaseNumToName>:
cmp    $0x2,%edi
ja     1131 <phaseNumToName+0x21>
movslq %edi,%rax
lea    0xef5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
jmp    1030 <strcpy@plt>
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Action\00"
@.str.1 = [4 x i8] c"Buy\00"
@.str.2 = [8 x i8] c"Cleanup\00"
define void @phaseNumToName(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 %15 [
i32 0, label %6
i32 1, label %9
i32 2, label %12
]
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 %15
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %15
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %2, %12, %9, %6
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Action\00"
@.str.1 = [4 x i8] c"Buy\00"
@.str.2 = [8 x i8] c"Cleanup\00"
@reltable.phaseNumToName = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.phaseNumToName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.phaseNumToName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.phaseNumToName to i64)) to i32)]
define void @phaseNumToName(i32 %0, i8* %1) {
%3 = icmp ult i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = sext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.phaseNumToName to i8*), i64 %6)
%8 = tail call i32 @strcpy(i8* %1, i8* %7)
br label %9
9: ; preds = %2, %4
ret void
}