void HEX_PS2(char b1, char b2) {
  volatile int *HEX3_HEX0_ptr = (int *)0x10000020;
  unsigned char seven_seg_decode_table[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D,
                                            0x7D, 0x07, 0x7F, 0x67, 0x77, 0x7C,
                                            0x39, 0x5E, 0x79, 0x71};
  unsigned char hex_segs[] = {0, 0, 0, 0};
  unsigned int shift_buffer, nibble;
  unsigned char code;
  int i;
  shift_buffer = (b1 << 8) | b2;
  for (i = 0; i < 4; ++i) {
    nibble = shift_buffer & 0x0000000F;
    code = seven_seg_decode_table[nibble];
    hex_segs[i] = code;
    shift_buffer = shift_buffer >> 4;
  }
  *(HEX3_HEX0_ptr) = *(int *)(hex_segs);
}


x86 assembly (clang, -O0):
<HEX_PS2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
mov    $0x10000020,%eax
mov    %rax,-0x10(%rbp)
mov    0xecc(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec9(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x24(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
movsbl -0x1(%rbp),%eax
shl    $0x8,%eax
movsbl -0x2(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    11a9 <HEX_PS2+0x99>
mov    -0x28(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x20(%rbp,%rax,1),%al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x24(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
shr    $0x4,%eax
mov    %eax,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116a <HEX_PS2+0x5a>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HEX_PS2>:
shl    $0x8,%edi
or     %esi,%edi
mov    %esi,%eax
and    $0xf,%eax
lea    0xeef(%rip),%rcx
movzbl (%rax,%rcx,1),%eax
shr    $0x4,%esi
and    $0xf,%esi
movzbl (%rsi,%rcx,1),%edx
mov    %edi,%esi
shr    $0x8,%esi
and    $0xf,%esi
movzbl (%rsi,%rcx,1),%esi
shr    $0xc,%edi
and    $0xf,%edi
movzbl (%rdi,%rcx,1),%ecx
shl    $0x18,%ecx
shl    $0x10,%esi
or     %ecx,%esi
shl    $0x8,%edx
or     %esi,%edx
or     %eax,%edx
mov    %edx,0x10000020
ret

LLVM IR (-O0):
@__const.HEX_PS2.seven_seg_decode_table = [16 x i8] c"?\06[Ofm}\07\7Fgw|9^yq"
define void @HEX_PS2(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32*
%6 = alloca [16 x i8]
%7 = alloca [4 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
store i32* inttoptr (i64 268435488 to i32*), i32** %5
%12 = bitcast [16 x i8]* %6 to i8*
%13 = bitcast [4 x i8]* %7 to i8*
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = shl i32 %15, 8
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = or i32 %16, %18
store i32 %19, i32* %8
store i32 0, i32* %11
br label %20
20: ; preds = %36, %2
%21 = load i32, i32* %11
%22 = icmp slt i32 %21, 4
br i1 %22, label %23, label %39
23: ; preds = %20
%24 = load i32, i32* %8
%25 = and i32 %24, 15
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 %27
%29 = load i8, i8* %28
store i8 %29, i8* %10
%30 = load i8, i8* %10
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 %32
store i8 %30, i8* %33
%34 = load i32, i32* %8
%35 = lshr i32 %34, 4
store i32 %35, i32* %8
br label %36
36: ; preds = %23
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
store i32 %38, i32* %11
br label %20
39: ; preds = %20
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%41 = bitcast i8* %40 to i32*
%42 = load i32, i32* %41
%43 = load i32*, i32** %5
store volatile i32 %42, i32* %43
ret void
}

LLVM IR (-O2):
@__const.HEX_PS2.seven_seg_decode_table = [16 x i8] c"?\06[Ofm}\07\7Fgw|9^yq"
define void @HEX_PS2(i8 signext %0, i8 signext %1) {
%3 = sext i8 %0 to i32
%4 = shl nsw i32 %3, 8
%5 = sext i8 %1 to i32
%6 = or i32 %4, %5
%7 = and i32 %5, 15
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.HEX_PS2.seven_seg_decode_table, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = lshr i32 %5, 4
%12 = and i32 %11, 15
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.HEX_PS2.seven_seg_decode_table, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = lshr i32 %6, 8
%17 = and i32 %16, 15
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.HEX_PS2.seven_seg_decode_table, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = lshr i32 %6, 12
%22 = and i32 %21, 15
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.HEX_PS2.seven_seg_decode_table, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = shl nuw i32 %26, 24
%28 = zext i8 %20 to i32
%29 = shl nuw nsw i32 %28, 16
%30 = or i32 %27, %29
%31 = zext i8 %15 to i32
%32 = shl nuw nsw i32 %31, 8
%33 = or i32 %30, %32
%34 = zext i8 %10 to i32
%35 = or i32 %33, %34
store volatile i32 %35, i32* inttoptr (i64 268435488 to i32*)
ret void
}