char *stress_session_error(int err) {
  switch (err) {
  case (0x00):
    return "success";
  case (0x10):
    return "setsid() failed";
  case (0x11):
    return "getsid() failed";
  case (0x12):
    return "getsid() returned incorrect session id";
  case (0x13):
    return "fork() failed";
  case (0x14):
    return "waitpid() failed";
  default:
    break;
  }
  return "unknown failure";
}


x86 assembly (clang, -O0):
<stress_session_error>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x14,%rax
ja     118c <stress_session_error+0x8c>
mov    -0x18(%rbp),%rax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf21(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <stress_session_error+0x9c>
lea    0xf19(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <stress_session_error+0x9c>
lea    0xf19(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <stress_session_error+0x9c>
lea    0xf19(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <stress_session_error+0x9c>
lea    0xf30(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <stress_session_error+0x9c>
lea    0xf2e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <stress_session_error+0x9c>
jmp    1191 <stress_session_error+0x91>
lea    0xf2a(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<stress_session_error>:
cmp    $0x14,%edi
ja     1126 <stress_session_error+0x26>
lea    0xf48(%rip),%rax
mov    %edi,%ecx
lea    0xeeb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf37(%rip),%rax
ret
lea    0xf95(%rip),%rax
ret
lea    0xf37(%rip),%rax
ret
lea    0xf3f(%rip),%rax
ret
lea    0xf5e(%rip),%rax
ret
lea    0xf64(%rip),%rax
ret

LLVM IR (-O0):
@.str = [8 x i8] c"success\00"
@.str.1 = [16 x i8] c"setsid() failed\00"
@.str.2 = [16 x i8] c"getsid() failed\00"
@.str.3 = [39 x i8] c"getsid() returned incorrect session id\00"
@.str.4 = [14 x i8] c"fork() failed\00"
@.str.5 = [17 x i8] c"waitpid() failed\00"
@.str.6 = [16 x i8] c"unknown failure\00"
define i8* @stress_session_error(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %11 [
i32 0, label %5
i32 16, label %6
i32 17, label %7
i32 18, label %8
i32 19, label %9
i32 20, label %10
]
5: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
br label %13
6: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %13
7: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %13
8: ; preds = %1
store i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %13
9: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %13
10: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %13
11: ; preds = %1
br label %12
12: ; preds = %11
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %13
13: ; preds = %12, %10, %9, %8, %7, %6, %5
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@.str = [8 x i8] c"success\00"
@.str.1 = [16 x i8] c"setsid() failed\00"
@.str.2 = [16 x i8] c"getsid() failed\00"
@.str.3 = [39 x i8] c"getsid() returned incorrect session id\00"
@.str.4 = [14 x i8] c"fork() failed\00"
@.str.5 = [17 x i8] c"waitpid() failed\00"
@.str.6 = [16 x i8] c"unknown failure\00"
define i8* @stress_session_error(i32 %0) {
switch i32 %0, label %7 [
i32 0, label %8
i32 16, label %2
i32 17, label %3
i32 18, label %4
i32 19, label %5
i32 20, label %6
]
2: ; preds = %1
br label %8
3: ; preds = %1
br label %8
4: ; preds = %1
br label %8
5: ; preds = %1
br label %8
6: ; preds = %1
br label %8
7: ; preds = %1
br label %8
8: ; preds = %1, %7, %6, %5, %4, %3, %2
%9 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %9
}