char *getWriteError(int error) {
  static char *WriteError[] = {
      "Cannot connect to control process", "Offset seek error",
      "Cannot write to control process", "Unknown error"};
  switch (error) {
  case -1:
    return WriteError[0];
    break;
  case -2:
    return WriteError[1];
    break;
  case -3:
    return WriteError[2];
    break;
  default:
    return WriteError[3];
    break;
  }
}


x86 assembly (clang, -O0):
<getWriteError>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0xfffffffd,%eax
je     115d <getWriteError+0x5d>
jmp    111b <getWriteError+0x1b>
mov    -0x10(%rbp),%eax
sub    $0xfffffffe,%eax
je     114d <getWriteError+0x4d>
jmp    112c <getWriteError+0x2c>
mov    -0x10(%rbp),%eax
sub    $0xffffffff,%eax
jne    116d <getWriteError+0x6d>
jmp    113d <getWriteError+0x3d>
mov    0x2eec(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1178 <getWriteError+0x78>
mov    0x2ee4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1178 <getWriteError+0x78>
mov    0x2edc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1178 <getWriteError+0x78>
mov    0x2ed4(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getWriteError>:
cmp    $0xfffffffd,%edi
jb     111a <getWriteError+0x1a>
add    $0x3,%edi
movslq %edi,%rax
lea    0xf52(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xf33(%rip),%rax
ret

LLVM IR (-O0):
@getWriteError.WriteError = internal global [4 x i8*] [i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0)]
@.str = [34 x i8] c"Cannot connect to control process\00"
@.str.1 = [18 x i8] c"Offset seek error\00"
@.str.2 = [32 x i8] c"Cannot write to control process\00"
@.str.3 = [14 x i8] c"Unknown error\00"
define i8* @getWriteError(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %11 [
i32 -1, label %5
i32 -2, label %7
i32 -3, label %9
]
5: ; preds = %1
%6 = load i8*, i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @getWriteError.WriteError, i64 0, i64 0)
store i8* %6, i8** %2
br label %13
7: ; preds = %1
%8 = load i8*, i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @getWriteError.WriteError, i64 0, i64 1)
store i8* %8, i8** %2
br label %13
9: ; preds = %1
%10 = load i8*, i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @getWriteError.WriteError, i64 0, i64 2)
store i8* %10, i8** %2
br label %13
11: ; preds = %1
%12 = load i8*, i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @getWriteError.WriteError, i64 0, i64 3)
store i8* %12, i8** %2
br label %13
13: ; preds = %11, %9, %7, %5
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@.str = [34 x i8] c"Cannot connect to control process\00"
@.str.1 = [18 x i8] c"Offset seek error\00"
@.str.2 = [32 x i8] c"Cannot write to control process\00"
@.str.3 = [14 x i8] c"Unknown error\00"
@reltable.getWriteError = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([32 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.getWriteError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.getWriteError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.getWriteError to i64)) to i32)]
define i8* @getWriteError(i32 %0) {
%2 = icmp ugt i32 %0, -4
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = add i32 %0, 3
%5 = sext i32 %4 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.getWriteError to i8*), i64 %6)
br label %8
8: ; preds = %1, %3
%9 = phi i8* [ %7, %3 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), %1 ]
ret i8* %9
}