#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 */
typedef int uint8_t;

/* Variables and functions */
uint8_t HEA(uint8_t A, uint8_t B) {
  uint8_t S0 = ((B & (0x8)) >> 3) + (A & (0x1));
  uint8_t S1 = ((B & (0x4)) >> 2) + ((A & (0x2)) >> 1);
  uint8_t S2 = ((B & (0x2)) >> 1) + ((A & (0x4)) >> 2);
  uint8_t S3 = (B & (0x1)) + ((A & (0x8)) >> 3);
  return S0 | (S1 << 2) | (S2 << 4) | (S3 << 6);
}


x86 assembly (clang, -O0):
<HEA>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x8,%eax
sar    $0x3,%eax
mov    -0x4(%rbp),%ecx
and    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0x4,%eax
sar    $0x2,%eax
mov    -0x4(%rbp),%ecx
and    $0x2,%ecx
sar    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0x2,%eax
sar    $0x1,%eax
mov    -0x4(%rbp),%ecx
and    $0x4,%ecx
sar    $0x2,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
mov    -0x4(%rbp),%ecx
and    $0x8,%ecx
sar    $0x3,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
or     %ecx,%eax
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%ecx
shl    $0x6,%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<HEA>:
mov    %esi,%eax
shr    $0x3,%eax
and    $0x1,%eax
mov    %edi,%r8d
and    $0x1,%r8d
add    %eax,%r8d
mov    %esi,%eax
shr    %eax
and    $0x1,%eax
mov    %edi,%edx
shr    $0x2,%edx
and    $0x1,%edx
add    %eax,%edx
mov    %esi,%ecx
and    $0x1,%ecx
mov    %edi,%eax
shr    $0x3,%eax
and    $0x1,%eax
add    %ecx,%eax
and    $0x2,%edi
and    $0x4,%esi
lea    (%rsi,%rdi,2),%ecx
or     %r8d,%ecx
shl    $0x4,%edx
or     %ecx,%edx
shl    $0x6,%eax
or     %edx,%eax
ret

LLVM IR (-O0):
define i32 @HEA(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = and i32 %9, 8
%11 = ashr i32 %10, 3
%12 = load i32, i32* %3
%13 = and i32 %12, 1
%14 = add nsw i32 %11, %13
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = and i32 %15, 4
%17 = ashr i32 %16, 2
%18 = load i32, i32* %3
%19 = and i32 %18, 2
%20 = ashr i32 %19, 1
%21 = add nsw i32 %17, %20
store i32 %21, i32* %6
%22 = load i32, i32* %4
%23 = and i32 %22, 2
%24 = ashr i32 %23, 1
%25 = load i32, i32* %3
%26 = and i32 %25, 4
%27 = ashr i32 %26, 2
%28 = add nsw i32 %24, %27
store i32 %28, i32* %7
%29 = load i32, i32* %4
%30 = and i32 %29, 1
%31 = load i32, i32* %3
%32 = and i32 %31, 8
%33 = ashr i32 %32, 3
%34 = add nsw i32 %30, %33
store i32 %34, i32* %8
%35 = load i32, i32* %5
%36 = load i32, i32* %6
%37 = shl i32 %36, 2
%38 = or i32 %35, %37
%39 = load i32, i32* %7
%40 = shl i32 %39, 4
%41 = or i32 %38, %40
%42 = load i32, i32* %8
%43 = shl i32 %42, 6
%44 = or i32 %41, %43
ret i32 %44
}

LLVM IR (-O2):
define i32 @HEA(i32 %0, i32 %1) {
%3 = lshr i32 %1, 3
%4 = and i32 %3, 1
%5 = and i32 %0, 1
%6 = add nuw nsw i32 %4, %5
%7 = lshr i32 %1, 1
%8 = and i32 %7, 1
%9 = lshr i32 %0, 2
%10 = and i32 %9, 1
%11 = add nuw nsw i32 %8, %10
%12 = and i32 %1, 1
%13 = lshr i32 %0, 3
%14 = and i32 %13, 1
%15 = add nuw nsw i32 %12, %14
%16 = shl i32 %0, 1
%17 = and i32 %16, 4
%18 = and i32 %1, 4
%19 = add nuw nsw i32 %18, %17
%20 = or i32 %6, %19
%21 = shl nuw nsw i32 %11, 4
%22 = or i32 %20, %21
%23 = shl nuw nsw i32 %15, 6
%24 = or i32 %22, %23
ret i32 %24
}