#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 HEM(uint8_t A, uint8_t B) {
  uint8_t R0 = ((A & (0x1)) | (((B & (0x4)) >> 1))) *
               ((((A & (0x4)) >> 2)) | ((B & (0x1)) << 1));
  uint8_t R1 = ((((A & (0x2)) >> 1)) | ((B & (0x8)) >> 2)) *
               ((((A & (0x8)) >> 3)) | (B & (0x2)));
  return R0 | (R1 << 4);
}


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

x86 assembly (clang, -O2):
<HEM>:
mov    %edi,%eax
and    $0x1,%eax
mov    %esi,%ecx
shr    %ecx
and    $0x2,%ecx
or     %eax,%ecx
mov    %edi,%eax
shr    $0x2,%eax
and    $0x1,%eax
mov    %esi,%edx
and    $0x1,%edx
lea    (%rax,%rdx,2),%edx
imul   %ecx,%edx
mov    %edi,%eax
shr    %eax
and    $0x1,%eax
mov    %esi,%ecx
shr    $0x2,%ecx
and    $0x2,%ecx
or     %eax,%ecx
shr    $0x3,%edi
and    $0x1,%edi
and    $0x2,%esi
lea    (%rsi,%rdi,1),%eax
imul   %ecx,%eax
shl    $0x4,%eax
or     %edx,%eax
ret

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

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