const char *discsim_error_message(int err) {
  const char *ret = "Unknown error";
  switch (err) {
  case -1:
    ret = "Memory allocation failure";
    break;
  case -9:
    ret = "Dimension must be 1 or 2";
    break;
  case -2:
    ret = "Bad pixel size";
    break;
  case -3:
    ret = "Out of int map nodes";
    break;
  case -4:
    ret = "Out of set map nodes";
    break;
  case -5:
    ret = "Out of avl set nodes";
  case -6:
    ret = "Out of individuals";
    break;
  case -7:
    ret = "AVL tree operation failed";
    break;
  case -8:
    ret = "max occupancy exceeded";
    break;
  case -10:
    ret = "event radius too large";
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<discsim_error_message>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
lea    0xf1a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     11d1 <discsim_error_message+0xd1>
mov    -0x18(%rbp),%rax
lea    0xece(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef4(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d1 <discsim_error_message+0xd1>
lea    0xefe(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d1 <discsim_error_message+0xd1>
lea    0xf07(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d1 <discsim_error_message+0xd1>
lea    0xf06(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d1 <discsim_error_message+0xd1>
lea    0xf0b(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d1 <discsim_error_message+0xd1>
lea    0xf10(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xf1a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d1 <discsim_error_message+0xd1>
lea    0xf1d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d1 <discsim_error_message+0xd1>
lea    0xf27(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11d1 <discsim_error_message+0xd1>
lea    0xf2e(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<discsim_error_message>:
cmp    $0xfffffff6,%edi
jb     111a <discsim_error_message+0x1a>
add    $0xa,%edi
movslq %edi,%rax
lea    0xfc6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xedf(%rip),%rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Unknown error\00"
@.str.1 = [26 x i8] c"Memory allocation failure\00"
@.str.2 = [25 x i8] c"Dimension must be 1 or 2\00"
@.str.3 = [15 x i8] c"Bad pixel size\00"
@.str.4 = [21 x i8] c"Out of int map nodes\00"
@.str.5 = [21 x i8] c"Out of set map nodes\00"
@.str.6 = [21 x i8] c"Out of avl set nodes\00"
@.str.7 = [19 x i8] c"Out of individuals\00"
@.str.8 = [26 x i8] c"AVL tree operation failed\00"
@.str.9 = [23 x i8] c"max occupancy exceeded\00"
@.str.10 = [23 x i8] c"event radius too large\00"
define i8* @discsim_error_message(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i32, i32* %2
switch i32 %4, label %15 [
i32 -1, label %5
i32 -9, label %6
i32 -2, label %7
i32 -3, label %8
i32 -4, label %9
i32 -5, label %10
i32 -6, label %11
i32 -7, label %12
i32 -8, label %13
i32 -10, label %14
]
5: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %15
6: ; preds = %1
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %15
7: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %15
8: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %15
9: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %15
10: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %11
11: ; preds = %1, %10
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %15
12: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %15
13: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %15
14: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %15
15: ; preds = %1, %14, %13, %12, %11, %9, %8, %7, %6, %5
%16 = load i8*, i8** %3
ret i8* %16
}

LLVM IR (-O2):
@.str = [14 x i8] c"Unknown error\00"
@.str.1 = [26 x i8] c"Memory allocation failure\00"
@.str.2 = [25 x i8] c"Dimension must be 1 or 2\00"
@.str.3 = [15 x i8] c"Bad pixel size\00"
@.str.4 = [21 x i8] c"Out of int map nodes\00"
@.str.5 = [21 x i8] c"Out of set map nodes\00"
@.str.7 = [19 x i8] c"Out of individuals\00"
@.str.8 = [26 x i8] c"AVL tree operation failed\00"
@.str.9 = [23 x i8] c"max occupancy exceeded\00"
@.str.10 = [23 x i8] c"event radius too large\00"
@reltable.discsim_error_message = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.10 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.discsim_error_message to i64)) to i32)]
define i8* @discsim_error_message(i32 %0) {
%2 = icmp ugt i32 %0, -11
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = add i32 %0, 10
%5 = sext i32 %4 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.discsim_error_message to i8*), i64 %6)
br label %8
8: ; preds = %3, %1
%9 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %1 ], [ %7, %3 ]
ret i8* %9
}