unsigned char McbGetSBoxNibble(unsigned char sbox, unsigned int idxSBox) {
  static unsigned char tblSBox[8][4][16] = {
      {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7},
       {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8},
       {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0},
       {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}},
      {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10},
       {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5},
       {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15},
       {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}},
      {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8},
       {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1},
       {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7},
       {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}},
      {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15},
       {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9},
       {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4},
       {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}},
      {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9},
       {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6},
       {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14},
       {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}},
      {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11},
       {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8},
       {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6},
       {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}},
      {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1},
       {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6},
       {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2},
       {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}},
      {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7},
       {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2},
       {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8},
       {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}}};
  unsigned char row, col, nibble;
  row = ((sbox & 0x20) >> 4) | (sbox & 0x01);
  col = ((sbox & 0x1E) >> 1);
  nibble = tblSBox[idxSBox][row][col];
  return nibble;
}


x86 assembly (clang, -O0):
<McbGetSBoxNibble>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
and    $0x20,%eax
sar    $0x4,%eax
movzbl -0x1(%rbp),%ecx
and    $0x1,%ecx
or     %ecx,%eax
mov    %al,-0x9(%rbp)
movzbl -0x1(%rbp),%eax
and    $0x1e,%eax
sar    $0x1,%eax
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0x2ef4(%rip),%rax
shl    $0x6,%rcx
add    %rcx,%rax
movzbl -0x9(%rbp),%ecx
shl    $0x4,%rcx
add    %rcx,%rax
movzbl -0xa(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0xb(%rbp)
movzbl -0xb(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<McbGetSBoxNibble>:
mov    %edi,%eax
shr    $0x4,%al
and    $0x2,%al
mov    %edi,%ecx
and    $0x1,%cl
or     %al,%cl
shr    %dil
and    $0xf,%dil
mov    %esi,%eax
movzbl %cl,%ecx
movzbl %dil,%edx
shl    $0x6,%rax
lea    0xed7(%rip),%rsi
add    %rax,%rsi
shl    $0x4,%rcx
add    %rsi,%rcx
mov    (%rdx,%rcx,1),%al
ret

LLVM IR (-O0):
@McbGetSBoxNibble.tblSBox = internal global [8 x [4 x [16 x i8]]] [[4 x [16 x i8]] [[16 x i8] c"\0E\04\0D\01\02\0F\0B\08\03\0A\06\0C\05\09\00\07", [16 x i8] c"\00\0F\07\04\0E\02\0D\01\0A\06\0C\0B\09\05\03\08", [16 x i8] c"\04\01\0E\08\0D\06\02\0B\0F\0C\09\07\03\0A\05\00", [16 x i8] c"\0F\0C\08\02\04\09\01\07\05\0B\03\0E\0A\00\06\0D"], [4 x [16 x i8]] [[16 x i8] c"\0F\01\08\0E\06\0B\03\04\09\07\02\0D\0C\00\05\0A", [16 x i8] c"\03\0D\04\07\0F\02\08\0E\0C\00\01\0A\06\09\0B\05", [16 x i8] c"\00\0E\07\0B\0A\04\0D\01\05\08\0C\06\09\03\02\0F", [16 x i8] c"\0D\08\0A\01\03\0F\04\02\0B\06\07\0C\00\05\0E\09"], [4 x [16 x i8]] [[16 x i8] c"\0A\00\09\0E\06\03\0F\05\01\0D\0C\07\0B\04\02\08", [16 x i8] c"\0D\07\00\09\03\04\06\0A\02\08\05\0E\0C\0B\0F\01", [16 x i8] c"\0D\06\04\09\08\0F\03\00\0B\01\02\0C\05\0A\0E\07", [16 x i8] c"\01\0A\0D\00\06\09\08\07\04\0F\0E\03\0B\05\02\0C"], [4 x [16 x i8]] [[16 x i8] c"\07\0D\0E\03\00\06\09\0A\01\02\08\05\0B\0C\04\0F", [16 x i8] c"\0D\08\0B\05\06\0F\00\03\04\07\02\0C\01\0A\0E\09", [16 x i8] c"\0A\06\09\00\0C\0B\07\0D\0F\01\03\0E\05\02\08\04", [16 x i8] c"\03\0F\00\06\0A\01\0D\08\09\04\05\0B\0C\07\02\0E"], [4 x [16 x i8]] [[16 x i8] c"\02\0C\04\01\07\0A\0B\06\08\05\03\0F\0D\00\0E\09", [16 x i8] c"\0E\0B\02\0C\04\07\0D\01\05\00\0F\0A\03\09\08\06", [16 x i8] c"\04\02\01\0B\0A\0D\07\08\0F\09\0C\05\06\03\00\0E", [16 x i8] c"\0B\08\0C\07\01\0E\02\0D\06\0F\00\09\0A\04\05\03"], [4 x [16 x i8]] [[16 x i8] c"\0C\01\0A\0F\09\02\06\08\00\0D\03\04\0E\07\05\0B", [16 x i8] c"\0A\0F\04\02\07\0C\09\05\06\01\0D\0E\00\0B\03\08", [16 x i8] c"\09\0E\0F\05\02\08\0C\03\07\00\04\0A\01\0D\0B\06", [16 x i8] c"\04\03\02\0C\09\05\0F\0A\0B\0E\01\07\06\00\08\0D"], [4 x [16 x i8]] [[16 x i8] c"\04\0B\02\0E\0F\00\08\0D\03\0C\09\07\05\0A\06\01", [16 x i8] c"\0D\00\0B\07\04\09\01\0A\0E\03\05\0C\02\0F\08\06", [16 x i8] c"\01\04\0B\0D\0C\03\07\0E\0A\0F\06\08\00\05\09\02", [16 x i8] c"\06\0B\0D\08\01\04\0A\07\09\05\00\0F\0E\02\03\0C"], [4 x [16 x i8]] [[16 x i8] c"\0D\02\08\04\06\0F\0B\01\0A\09\03\0E\05\00\0C\07", [16 x i8] c"\01\0F\0D\08\0A\03\07\04\0C\05\06\0B\00\0E\09\02", [16 x i8] c"\07\0B\04\01\09\0C\0E\02\00\06\0A\0D\0F\03\05\08", [16 x i8] c"\02\01\0E\07\04\0A\08\0D\0F\0C\09\00\03\05\06\0B"]]
define zeroext i8 @McbGetSBoxNibble(i8 zeroext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
store i8 %0, i8* %3
store i32 %1, i32* %4
%8 = load i8, i8* %3
%9 = zext i8 %8 to i32
%10 = and i32 %9, 32
%11 = ashr i32 %10, 4
%12 = load i8, i8* %3
%13 = zext i8 %12 to i32
%14 = and i32 %13, 1
%15 = or i32 %11, %14
%16 = trunc i32 %15 to i8
store i8 %16, i8* %5
%17 = load i8, i8* %3
%18 = zext i8 %17 to i32
%19 = and i32 %18, 30
%20 = ashr i32 %19, 1
%21 = trunc i32 %20 to i8
store i8 %21, i8* %6
%22 = load i32, i32* %4
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [8 x [4 x [16 x i8]]], [8 x [4 x [16 x i8]]]* @McbGetSBoxNibble.tblSBox, i64 0, i64 %23
%25 = load i8, i8* %5
%26 = zext i8 %25 to i64
%27 = getelementptr inbounds [4 x [16 x i8]], [4 x [16 x i8]]* %24, i64 0, i64 %26
%28 = load i8, i8* %6
%29 = zext i8 %28 to i64
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %27, i64 0, i64 %29
%31 = load i8, i8* %30
store i8 %31, i8* %7
%32 = load i8, i8* %7
ret i8 %32
}

LLVM IR (-O2):
@McbGetSBoxNibble.tblSBox = internal unnamed_addr constant [8 x [4 x [16 x i8]]] [[4 x [16 x i8]] [[16 x i8] c"\0E\04\0D\01\02\0F\0B\08\03\0A\06\0C\05\09\00\07", [16 x i8] c"\00\0F\07\04\0E\02\0D\01\0A\06\0C\0B\09\05\03\08", [16 x i8] c"\04\01\0E\08\0D\06\02\0B\0F\0C\09\07\03\0A\05\00", [16 x i8] c"\0F\0C\08\02\04\09\01\07\05\0B\03\0E\0A\00\06\0D"], [4 x [16 x i8]] [[16 x i8] c"\0F\01\08\0E\06\0B\03\04\09\07\02\0D\0C\00\05\0A", [16 x i8] c"\03\0D\04\07\0F\02\08\0E\0C\00\01\0A\06\09\0B\05", [16 x i8] c"\00\0E\07\0B\0A\04\0D\01\05\08\0C\06\09\03\02\0F", [16 x i8] c"\0D\08\0A\01\03\0F\04\02\0B\06\07\0C\00\05\0E\09"], [4 x [16 x i8]] [[16 x i8] c"\0A\00\09\0E\06\03\0F\05\01\0D\0C\07\0B\04\02\08", [16 x i8] c"\0D\07\00\09\03\04\06\0A\02\08\05\0E\0C\0B\0F\01", [16 x i8] c"\0D\06\04\09\08\0F\03\00\0B\01\02\0C\05\0A\0E\07", [16 x i8] c"\01\0A\0D\00\06\09\08\07\04\0F\0E\03\0B\05\02\0C"], [4 x [16 x i8]] [[16 x i8] c"\07\0D\0E\03\00\06\09\0A\01\02\08\05\0B\0C\04\0F", [16 x i8] c"\0D\08\0B\05\06\0F\00\03\04\07\02\0C\01\0A\0E\09", [16 x i8] c"\0A\06\09\00\0C\0B\07\0D\0F\01\03\0E\05\02\08\04", [16 x i8] c"\03\0F\00\06\0A\01\0D\08\09\04\05\0B\0C\07\02\0E"], [4 x [16 x i8]] [[16 x i8] c"\02\0C\04\01\07\0A\0B\06\08\05\03\0F\0D\00\0E\09", [16 x i8] c"\0E\0B\02\0C\04\07\0D\01\05\00\0F\0A\03\09\08\06", [16 x i8] c"\04\02\01\0B\0A\0D\07\08\0F\09\0C\05\06\03\00\0E", [16 x i8] c"\0B\08\0C\07\01\0E\02\0D\06\0F\00\09\0A\04\05\03"], [4 x [16 x i8]] [[16 x i8] c"\0C\01\0A\0F\09\02\06\08\00\0D\03\04\0E\07\05\0B", [16 x i8] c"\0A\0F\04\02\07\0C\09\05\06\01\0D\0E\00\0B\03\08", [16 x i8] c"\09\0E\0F\05\02\08\0C\03\07\00\04\0A\01\0D\0B\06", [16 x i8] c"\04\03\02\0C\09\05\0F\0A\0B\0E\01\07\06\00\08\0D"], [4 x [16 x i8]] [[16 x i8] c"\04\0B\02\0E\0F\00\08\0D\03\0C\09\07\05\0A\06\01", [16 x i8] c"\0D\00\0B\07\04\09\01\0A\0E\03\05\0C\02\0F\08\06", [16 x i8] c"\01\04\0B\0D\0C\03\07\0E\0A\0F\06\08\00\05\09\02", [16 x i8] c"\06\0B\0D\08\01\04\0A\07\09\05\00\0F\0E\02\03\0C"], [4 x [16 x i8]] [[16 x i8] c"\0D\02\08\04\06\0F\0B\01\0A\09\03\0E\05\00\0C\07", [16 x i8] c"\01\0F\0D\08\0A\03\07\04\0C\05\06\0B\00\0E\09\02", [16 x i8] c"\07\0B\04\01\09\0C\0E\02\00\06\0A\0D\0F\03\05\08", [16 x i8] c"\02\01\0E\07\04\0A\08\0D\0F\0C\09\00\03\05\06\0B"]]
define zeroext i8 @McbGetSBoxNibble(i8 zeroext %0, i32 %1) {
%3 = lshr i8 %0, 4
%4 = and i8 %3, 2
%5 = and i8 %0, 1
%6 = or i8 %4, %5
%7 = lshr i8 %0, 1
%8 = and i8 %7, 15
%9 = zext i32 %1 to i64
%10 = zext i8 %6 to i64
%11 = zext i8 %8 to i64
%12 = getelementptr inbounds [8 x [4 x [16 x i8]]], [8 x [4 x [16 x i8]]]* @McbGetSBoxNibble.tblSBox, i64 0, i64 %9, i64 %10, i64 %11
%13 = load i8, i8* %12
ret i8 %13
}