#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 *decode_cc(unsigned short, int);
int /*<<< orphan*/ printf(char *, ...);
void cc_session(int cc) {
  switch (cc) {
  case 0x81:
    printf("ActivateSession: No session slots available from BMC\n");
    break;
  case 0x82:
    printf("ActivateSession: No sessions available for this user\n");
    break;
  case 0x83:
    printf("ActivateSession: No sessions for this user/privilege\n");
    break;
  case 0x84:
    printf("ActivateSession: Session sequence number out of range\n");
    break;
  case 0x85:
    printf("ActivateSession: Invalid session ID in request\n");
    break;
  case 0x86:
    printf("ActivateSession: Privilege level exceeds user/channel limit\n");
    break;
  default:
    printf("%s\n", decode_cc((unsigned short)0, cc));
    break;
  }
  return;
}


x86 assembly (clang, -O0):
<cc_session>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff7f,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     11c8 <cc_session+0xa8>
mov    -0x10(%rbp),%rax
lea    0xeb3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <cc_session+0xc3>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <cc_session+0xc3>
lea    0xf01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <cc_session+0xc3>
lea    0xf24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <cc_session+0xc3>
lea    0xf48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <cc_session+0xc3>
lea    0xf65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <cc_session+0xc3>
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1040 <decode_cc@plt>
mov    %rax,%rsi
lea    0xf82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cc_session>:
push   %rax
mov    %edi,%esi
lea    -0x81(%rsi),%eax
cmp    $0x6,%eax
jae    1144 <cc_session+0x24>
cltq
lea    0x1009(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %edi,%edi
call   1040 <decode_cc@plt>
mov    %rax,%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [54 x i8] c"ActivateSession: No session slots available from BMC\0A\00"
@.str.1 = [54 x i8] c"ActivateSession: No sessions available for this user\0A\00"
@.str.2 = [54 x i8] c"ActivateSession: No sessions for this user/privilege\0A\00"
@.str.3 = [55 x i8] c"ActivateSession: Session sequence number out of range\0A\00"
@.str.4 = [48 x i8] c"ActivateSession: Invalid session ID in request\0A\00"
@.str.5 = [61 x i8] c"ActivateSession: Privilege level exceeds user/channel limit\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
define void @cc_session(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %16 [
i32 129, label %4
i32 130, label %6
i32 131, label %8
i32 132, label %10
i32 133, label %12
i32 134, label %14
]
4: ; preds = %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
br label %20
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %20
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %20
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0))
br label %20
12: ; preds = %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %20
14: ; preds = %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
br label %20
16: ; preds = %1
%17 = load i32, i32* %2
%18 = call i8* @decode_cc(i16 zeroext 0, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %14, %12, %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@str = [60 x i8] c"ActivateSession: Privilege level exceeds user/channel limit\00"
@str.7 = [47 x i8] c"ActivateSession: Invalid session ID in request\00"
@str.8 = [54 x i8] c"ActivateSession: Session sequence number out of range\00"
@str.9 = [53 x i8] c"ActivateSession: No sessions for this user/privilege\00"
@str.10 = [53 x i8] c"ActivateSession: No sessions available for this user\00"
@str.11 = [53 x i8] c"ActivateSession: No session slots available from BMC\00"
@reltable.cc_session = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([53 x i8]* @str.11 to i64), i64 ptrtoint ([6 x i32]* @reltable.cc_session to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([53 x i8]* @str.10 to i64), i64 ptrtoint ([6 x i32]* @reltable.cc_session to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([53 x i8]* @str.9 to i64), i64 ptrtoint ([6 x i32]* @reltable.cc_session to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([54 x i8]* @str.8 to i64), i64 ptrtoint ([6 x i32]* @reltable.cc_session to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([47 x i8]* @str.7 to i64), i64 ptrtoint ([6 x i32]* @reltable.cc_session to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([60 x i8]* @str to i64), i64 ptrtoint ([6 x i32]* @reltable.cc_session to i64)) to i32)]
define void @cc_session(i32 %0) {
%2 = add i32 %0, -129
%3 = icmp ult i32 %2, 6
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i8* @decode_cc(i16 zeroext 0, i32 %0)
br label %10
6: ; preds = %1
%7 = sext i32 %2 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.cc_session to i8*), i64 %8)
br label %10
10: ; preds = %6, %4
%11 = phi i8* [ %5, %4 ], [ %9, %6 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
ret void
}