unsigned char q0(unsigned char x) {
  static const unsigned char t0[16] = {0x8, 0x1, 0x7, 0xD, 0x6, 0xF, 0x3, 0x2,
                                       0x0, 0xB, 0x5, 0x9, 0xE, 0xC, 0xA, 0x4};
  static const unsigned char t1[16] = {0xE, 0xC, 0xB, 0x8, 0x1, 0x2, 0x3, 0x5,
                                       0xF, 0x4, 0xA, 0x6, 0x7, 0x0, 0x9, 0xD};
  static const unsigned char t2[16] = {0xB, 0xA, 0x5, 0xE, 0x6, 0xD, 0x9, 0x0,
                                       0xC, 0x8, 0xF, 0x3, 0x2, 0x4, 0x7, 0x1};
  static const unsigned char t3[16] = {0xD, 0x7, 0xF, 0x4, 0x1, 0x2, 0x6, 0xE,
                                       0x9, 0xB, 0x3, 0x0, 0x8, 0x5, 0xC, 0xA};
  unsigned char a0 = x / 16;
  unsigned char b0 = x % 16;
  unsigned char a1 = a0 ^ b0;
  unsigned char b1 = a0 ^ (((b0) >> 1) | (((b0)&1) << 3)) ^ ((8 * a0) % 16);
  unsigned char a2 = t0[a1];
  unsigned char b2 = t1[b1];
  unsigned char a3 = a2 ^ b2;
  unsigned char b3 = a2 ^ (((b2) >> 1) | (((b2)&1) << 3)) ^ ((8 * a2) % 16);
  unsigned char a4 = t2[a3];
  unsigned char b4 = t3[b3];
  unsigned char y = 16 * b4 + a4;
  return y;
}


x86 assembly (clang, -O0):
<q0>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %al,-0x2(%rbp)
movzbl -0x1(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x3(%rbp)
movzbl -0x2(%rbp),%eax
movzbl -0x3(%rbp),%ecx
xor    %ecx,%eax
mov    %al,-0x4(%rbp)
movzbl -0x2(%rbp),%eax
movzbl -0x3(%rbp),%ecx
sar    $0x1,%ecx
movzbl -0x3(%rbp),%edx
and    $0x1,%edx
shl    $0x3,%edx
or     %edx,%ecx
xor    %ecx,%eax
mov    %eax,-0x14(%rbp)
movzbl -0x2(%rbp),%eax
shl    $0x3,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%eax
xor    %edx,%eax
mov    %al,-0x5(%rbp)
movzbl -0x4(%rbp),%eax
mov    %eax,%ecx
lea    0xe89(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x6(%rbp)
movzbl -0x5(%rbp),%eax
mov    %eax,%ecx
lea    0xe86(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x7(%rbp)
movzbl -0x6(%rbp),%eax
movzbl -0x7(%rbp),%ecx
xor    %ecx,%eax
mov    %al,-0x8(%rbp)
movzbl -0x6(%rbp),%eax
movzbl -0x7(%rbp),%ecx
sar    $0x1,%ecx
movzbl -0x7(%rbp),%edx
and    $0x1,%edx
shl    $0x3,%edx
or     %edx,%ecx
xor    %ecx,%eax
mov    %eax,-0x10(%rbp)
movzbl -0x6(%rbp),%eax
shl    $0x3,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%eax
xor    %edx,%eax
mov    %al,-0x9(%rbp)
movzbl -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0xe43(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0xa(%rbp)
movzbl -0x9(%rbp),%eax
mov    %eax,%ecx
lea    0xe40(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0xb(%rbp)
movzbl -0xb(%rbp),%eax
shl    $0x4,%eax
movzbl -0xa(%rbp),%ecx
add    %ecx,%eax
mov    %al,-0xc(%rbp)
movzbl -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<q0>:
mov    %edi,%eax
shr    $0x4,%al
mov    %edi,%ecx
and    $0xf,%cl
shr    %dil
and    $0x8,%dil
xor    %al,%dil
xor    %cl,%al
mov    %ecx,%edx
shr    %dl
shl    $0x3,%cl
and    $0x8,%cl
or     %dl,%cl
xor    %cl,%dil
movzbl %al,%eax
lea    0xed1(%rip),%rcx
mov    (%rax,%rcx,1),%sil
movzbl %dil,%ecx
lea    0xed2(%rip),%rdx
mov    (%rcx,%rdx,1),%cl
mov    %ecx,%edx
xor    %sil,%dl
mov    %ecx,%eax
shr    %al
shl    $0x3,%cl
and    $0x8,%cl
or     %al,%cl
lea    0x0(,%rsi,8),%eax
and    $0x8,%al
xor    %sil,%al
xor    %cl,%al
movzbl %dl,%ecx
lea    0xeb6(%rip),%rdx
movzbl %al,%eax
lea    0xebc(%rip),%rsi
mov    (%rax,%rsi,1),%al
shl    $0x4,%al
add    (%rcx,%rdx,1),%al
ret

LLVM IR (-O0):
@q0.t0 = internal constant [16 x i8] c"\08\01\07\0D\06\0F\03\02\00\0B\05\09\0E\0C\0A\04"
@q0.t1 = internal constant [16 x i8] c"\0E\0C\0B\08\01\02\03\05\0F\04\0A\06\07\00\09\0D"
@q0.t2 = internal constant [16 x i8] c"\0B\0A\05\0E\06\0D\09\00\0C\08\0F\03\02\04\07\01"
@q0.t3 = internal constant [16 x i8] c"\0D\07\0F\04\01\02\06\0E\09\0B\03\00\08\05\0C\0A"
define zeroext i8 @q0(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
store i8 %0, i8* %2
%14 = load i8, i8* %2
%15 = zext i8 %14 to i32
%16 = sdiv i32 %15, 16
%17 = trunc i32 %16 to i8
store i8 %17, i8* %3
%18 = load i8, i8* %2
%19 = zext i8 %18 to i32
%20 = srem i32 %19, 16
%21 = trunc i32 %20 to i8
store i8 %21, i8* %4
%22 = load i8, i8* %3
%23 = zext i8 %22 to i32
%24 = load i8, i8* %4
%25 = zext i8 %24 to i32
%26 = xor i32 %23, %25
%27 = trunc i32 %26 to i8
store i8 %27, i8* %5
%28 = load i8, i8* %3
%29 = zext i8 %28 to i32
%30 = load i8, i8* %4
%31 = zext i8 %30 to i32
%32 = ashr i32 %31, 1
%33 = load i8, i8* %4
%34 = zext i8 %33 to i32
%35 = and i32 %34, 1
%36 = shl i32 %35, 3
%37 = or i32 %32, %36
%38 = xor i32 %29, %37
%39 = load i8, i8* %3
%40 = zext i8 %39 to i32
%41 = mul nsw i32 8, %40
%42 = srem i32 %41, 16
%43 = xor i32 %38, %42
%44 = trunc i32 %43 to i8
store i8 %44, i8* %6
%45 = load i8, i8* %5
%46 = zext i8 %45 to i64
%47 = getelementptr inbounds [16 x i8], [16 x i8]* @q0.t0, i64 0, i64 %46
%48 = load i8, i8* %47
store i8 %48, i8* %7
%49 = load i8, i8* %6
%50 = zext i8 %49 to i64
%51 = getelementptr inbounds [16 x i8], [16 x i8]* @q0.t1, i64 0, i64 %50
%52 = load i8, i8* %51
store i8 %52, i8* %8
%53 = load i8, i8* %7
%54 = zext i8 %53 to i32
%55 = load i8, i8* %8
%56 = zext i8 %55 to i32
%57 = xor i32 %54, %56
%58 = trunc i32 %57 to i8
store i8 %58, i8* %9
%59 = load i8, i8* %7
%60 = zext i8 %59 to i32
%61 = load i8, i8* %8
%62 = zext i8 %61 to i32
%63 = ashr i32 %62, 1
%64 = load i8, i8* %8
%65 = zext i8 %64 to i32
%66 = and i32 %65, 1
%67 = shl i32 %66, 3
%68 = or i32 %63, %67
%69 = xor i32 %60, %68
%70 = load i8, i8* %7
%71 = zext i8 %70 to i32
%72 = mul nsw i32 8, %71
%73 = srem i32 %72, 16
%74 = xor i32 %69, %73
%75 = trunc i32 %74 to i8
store i8 %75, i8* %10
%76 = load i8, i8* %9
%77 = zext i8 %76 to i64
%78 = getelementptr inbounds [16 x i8], [16 x i8]* @q0.t2, i64 0, i64 %77
%79 = load i8, i8* %78
store i8 %79, i8* %11
%80 = load i8, i8* %10
%81 = zext i8 %80 to i64
%82 = getelementptr inbounds [16 x i8], [16 x i8]* @q0.t3, i64 0, i64 %81
%83 = load i8, i8* %82
store i8 %83, i8* %12
%84 = load i8, i8* %12
%85 = zext i8 %84 to i32
%86 = mul nsw i32 16, %85
%87 = load i8, i8* %11
%88 = zext i8 %87 to i32
%89 = add nsw i32 %86, %88
%90 = trunc i32 %89 to i8
store i8 %90, i8* %13
%91 = load i8, i8* %13
ret i8 %91
}

LLVM IR (-O2):
@q0.t0 = internal unnamed_addr constant [16 x i8] c"\08\01\07\0D\06\0F\03\02\00\0B\05\09\0E\0C\0A\04"
@q0.t1 = internal unnamed_addr constant [16 x i8] c"\0E\0C\0B\08\01\02\03\05\0F\04\0A\06\07\00\09\0D"
@q0.t2 = internal unnamed_addr constant [16 x i8] c"\0B\0A\05\0E\06\0D\09\00\0C\08\0F\03\02\04\07\01"
@q0.t3 = internal unnamed_addr constant [16 x i8] c"\0D\07\0F\04\01\02\06\0E\09\0B\03\00\08\05\0C\0A"
define zeroext i8 @q0(i8 zeroext %0) {
%2 = lshr i8 %0, 4
%3 = and i8 %0, 15
%4 = xor i8 %2, %3
%5 = lshr i8 %3, 1
%6 = shl nuw nsw i8 %3, 3
%7 = and i8 %6, 8
%8 = or i8 %7, %5
%9 = shl nuw nsw i8 %2, 3
%10 = and i8 %9, 8
%11 = xor i8 %10, %2
%12 = xor i8 %11, %8
%13 = zext i8 %4 to i64
%14 = getelementptr inbounds [16 x i8], [16 x i8]* @q0.t0, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %12 to i64
%17 = getelementptr inbounds [16 x i8], [16 x i8]* @q0.t1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = xor i8 %18, %15
%20 = lshr i8 %18, 1
%21 = shl i8 %18, 3
%22 = and i8 %21, 8
%23 = or i8 %22, %20
%24 = shl i8 %15, 3
%25 = and i8 %24, 8
%26 = xor i8 %25, %15
%27 = xor i8 %26, %23
%28 = zext i8 %19 to i64
%29 = getelementptr inbounds [16 x i8], [16 x i8]* @q0.t2, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = zext i8 %27 to i64
%32 = getelementptr inbounds [16 x i8], [16 x i8]* @q0.t3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = shl i8 %33, 4
%35 = add i8 %34, %30
ret i8 %35
}