#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 */
char *getItemName(void *context, size_t item) {
  switch (item) {
  case 0:
    return "user";
  case 1:
    return "nice";
  case 2:
    return "system";
  case 3:
    return "idle";
  };
  return NULL;
}


x86 assembly (clang, -O0):
<getItemName>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     1172 <getItemName+0x72>
mov    -0x20(%rbp),%rax
lea    0xed7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117a <getItemName+0x7a>
lea    0xecc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117a <getItemName+0x7a>
lea    0xec1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117a <getItemName+0x7a>
lea    0xeb8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117a <getItemName+0x7a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getItemName>:
cmp    $0x3,%rsi
ja     1115 <getItemName+0x15>
lea    0xf0b(%rip),%rcx
movslq (%rcx,%rsi,4),%rax
add    %rcx,%rax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [5 x i8] c"user\00"
@.str.1 = [5 x i8] c"nice\00"
@.str.2 = [7 x i8] c"system\00"
@.str.3 = [5 x i8] c"idle\00"
define i8* @getItemName(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%6 = load i64, i64* %5
switch i64 %6, label %11 [
i64 0, label %7
i64 1, label %8
i64 2, label %9
i64 3, label %10
]
7: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
br label %12
8: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %12
9: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %12
10: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %12
11: ; preds = %2
store i8* null, i8** %3
br label %12
12: ; preds = %11, %10, %9, %8, %7
%13 = load i8*, i8** %3
ret i8* %13
}

LLVM IR (-O2):
@.str = [5 x i8] c"user\00"
@.str.1 = [5 x i8] c"nice\00"
@.str.2 = [7 x i8] c"system\00"
@.str.3 = [5 x i8] c"idle\00"
@reltable.getItemName = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.getItemName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.getItemName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.getItemName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.getItemName to i64)) to i32)]
define i8* @getItemName(i8* nocapture readnone %0, i64 %1) {
%3 = icmp ult i64 %1, 4
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = shl i64 %1, 2
%6 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.getItemName to i8*), i64 %5)
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ null, %2 ]
ret i8* %8
}