char *StreamTypeName(int type) {
  switch (type) {
  case 0:
    return ("waveform");
  case 1:
    return ("spike");
  case 2:
    return ("reserved");
  case 999:
    return ("none");
  default:
    return ("*INVALID*");
  }
}


x86 assembly (clang, -O0):
<StreamTypeName>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     114f <StreamTypeName+0x4f>
jmp    111a <StreamTypeName+0x1a>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     115f <StreamTypeName+0x5f>
jmp    112b <StreamTypeName+0x2b>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     116f <StreamTypeName+0x6f>
jmp    113c <StreamTypeName+0x3c>
mov    -0x10(%rbp),%eax
sub    $0x3e7,%eax
je     117f <StreamTypeName+0x7f>
jmp    118f <StreamTypeName+0x8f>
lea    0xeaa(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119a <StreamTypeName+0x9a>
lea    0xea3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119a <StreamTypeName+0x9a>
lea    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119a <StreamTypeName+0x9a>
lea    0xe92(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119a <StreamTypeName+0x9a>
lea    0xe87(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<StreamTypeName>:
cmp    $0x1,%edi
jg     1116 <StreamTypeName+0x16>
test   %edi,%edi
je     1133 <StreamTypeName+0x33>
cmp    $0x1,%edi
jne    112b <StreamTypeName+0x2b>
lea    0xef4(%rip),%rax
ret
cmp    $0x2,%edi
je     113b <StreamTypeName+0x3b>
cmp    $0x3e7,%edi
jne    112b <StreamTypeName+0x2b>
lea    0xeee(%rip),%rax
ret
lea    0xeeb(%rip),%rax
ret
lea    0xec6(%rip),%rax
ret
lea    0xecd(%rip),%rax
ret

LLVM IR (-O0):
@.str = [9 x i8] c"waveform\00"
@.str.1 = [6 x i8] c"spike\00"
@.str.2 = [9 x i8] c"reserved\00"
@.str.3 = [5 x i8] c"none\00"
@.str.4 = [10 x i8] c"*INVALID*\00"
define i8* @StreamTypeName(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %9 [
i32 0, label %5
i32 1, label %6
i32 2, label %7
i32 999, label %8
]
5: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %2
br label %10
6: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %10
7: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %10
8: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %10
9: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %10
10: ; preds = %9, %8, %7, %6, %5
%11 = load i8*, i8** %2
ret i8* %11
}

LLVM IR (-O2):
@.str = [9 x i8] c"waveform\00"
@.str.1 = [6 x i8] c"spike\00"
@.str.2 = [9 x i8] c"reserved\00"
@.str.3 = [5 x i8] c"none\00"
@.str.4 = [10 x i8] c"*INVALID*\00"
define i8* @StreamTypeName(i32 %0) {
switch i32 %0, label %5 [
i32 0, label %6
i32 1, label %2
i32 2, label %3
i32 999, label %4
]
2: ; preds = %1
br label %6
3: ; preds = %1
br label %6
4: ; preds = %1
br label %6
5: ; preds = %1
br label %6
6: ; preds = %1, %5, %4, %3, %2
%7 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %7
}