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 "fork() failed";
  case (0x13):
    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    $0x13,%rax
ja     117c <stress_session_error+0x7c>
mov    -0x18(%rbp),%rax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf1d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <stress_session_error+0x8c>
lea    0xf15(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <stress_session_error+0x8c>
lea    0xf15(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <stress_session_error+0x8c>
lea    0xf15(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <stress_session_error+0x8c>
lea    0xf13(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <stress_session_error+0x8c>
jmp    1181 <stress_session_error+0x81>
lea    0xf0f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<stress_session_error>:
cmp    $0x13,%edi
ja     1126 <stress_session_error+0x26>
lea    0xf44(%rip),%rax
mov    %edi,%ecx
lea    0xeeb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf33(%rip),%rax
ret
lea    0xf6a(%rip),%rax
ret
lea    0xf33(%rip),%rax
ret
lea    0xf3b(%rip),%rax
ret
lea    0xf41(%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 = [14 x i8] c"fork() failed\00"
@.str.4 = [17 x i8] c"waitpid() failed\00"
@.str.5 = [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 %10 [
i32 0, label %5
i32 16, label %6
i32 17, label %7
i32 18, label %8
i32 19, label %9
]
5: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
br label %12
6: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %12
7: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %12
8: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %12
9: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %12
10: ; preds = %1
br label %11
11: ; preds = %10
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %12
12: ; preds = %11, %9, %8, %7, %6, %5
%13 = load i8*, i8** %2
ret i8* %13
}

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 = [14 x i8] c"fork() failed\00"
@.str.4 = [17 x i8] c"waitpid() failed\00"
@.str.5 = [16 x i8] c"unknown failure\00"
define i8* @stress_session_error(i32 %0) {
switch i32 %0, label %6 [
i32 0, label %7
i32 16, label %2
i32 17, label %3
i32 18, label %4
i32 19, label %5
]
2: ; preds = %1
br label %7
3: ; preds = %1
br label %7
4: ; preds = %1
br label %7
5: ; preds = %1
br label %7
6: ; preds = %1
br label %7
7: ; preds = %1, %6, %5, %4, %3, %2
%8 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([14 x i8], [14 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* %8
}