int Hex2Int(char A, char B) {
  int liczba = 0;
  int j;
  char tablicaHex[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
                         '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  for (j = 0; j < 16; j++) {
    if (A == tablicaHex[j])
      liczba = liczba + 16 * j;
    if (B == tablicaHex[j])
      liczba = liczba + j;
  }
  return liczba;
}


x86 assembly (clang, -O0):
<Hex2Int>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movl   $0x0,-0x8(%rbp)
mov    0xee2(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xedf(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    1192 <Hex2Int+0x92>
movsbl -0x1(%rbp),%eax
movslq -0xc(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    1161 <Hex2Int+0x61>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x4,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
movsbl -0x2(%rbp),%eax
movslq -0xc(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    117f <Hex2Int+0x7f>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1184 <Hex2Int+0x84>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <Hex2Int+0x34>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Hex2Int>:
xor    %eax,%eax
cmp    $0x31,%dil
sete   %al
shl    $0x4,%eax
xor    %ecx,%ecx
cmp    $0x31,%sil
sete   %cl
or     %eax,%ecx
xor    %eax,%eax
cmp    $0x32,%dil
sete   %al
shl    $0x5,%eax
or     %ecx,%eax
xor    %ecx,%ecx
cmp    $0x32,%sil
sete   %cl
lea    (%rax,%rcx,2),%ecx
mov    %esi,%eax
shl    $0x8,%eax
movzbl %dil,%edx
or     %eax,%edx
movd   %edx,%xmm0
pxor   %xmm1,%xmm1
punpcklbw %xmm1,%xmm0
pshuflw $0x0,%xmm0,%xmm1
pshufd $0x0,%xmm1,%xmm1
pshufd $0x0,%xmm0,%xmm0
pshuflw $0x0,%xmm0,%xmm0
pshufhw $0x54,%xmm0,%xmm0
packuswb %xmm0,%xmm1
pcmpeqb 0xe93(%rip),%xmm1
movdqa %xmm1,%xmm2
punpcklbw %xmm2,%xmm2
movdqa %xmm2,%xmm0
punpckhwd %xmm0,%xmm0
punpckhbw %xmm1,%xmm1
movdqa %xmm1,%xmm3
punpckhwd %xmm3,%xmm3
punpcklwd %xmm2,%xmm2
punpcklwd %xmm1,%xmm1
pand   0xe77(%rip),%xmm1
pand   0xe7f(%rip),%xmm2
pand   0xe87(%rip),%xmm3
pand   0xe8f(%rip),%xmm0
paddd  %xmm1,%xmm2
paddd  %xmm3,%xmm0
paddd  %xmm2,%xmm0
movd   %esi,%xmm1
punpcklbw %xmm1,%xmm1
pshuflw $0x0,%xmm1,%xmm1
pcmpeqb 0xe7e(%rip),%xmm1
punpcklbw %xmm1,%xmm1
movdqa %xmm1,%xmm2
punpckhwd %xmm1,%xmm1
pand   0xe7a(%rip),%xmm1
punpcklwd %xmm2,%xmm2
pand   0xe7e(%rip),%xmm2
paddd  %xmm1,%xmm2
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%eax
pshufd $0xee,%xmm2,%xmm0
paddd  %xmm2,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edx
lea    (%rax,%rdx,1),%edi
cmp    $0x45,%sil
lea    0xe(%rax,%rdx,1),%edx
cmovne %edi,%edx
lea    0xf(%rdx),%eax
cmp    $0x46,%sil
cmovne %edx,%eax
add    %ecx,%eax
ret

LLVM IR (-O0):
@__const.Hex2Int.tablicaHex = [16 x i8] c"0123456789ABCDEF"
define i32 @Hex2Int(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca [16 x i8]
store i8 %0, i8* %3
store i8 %1, i8* %4
store i32 0, i32* %5
%8 = bitcast [16 x i8]* %7 to i8*
store i32 0, i32* %6
br label %9
9: ; preds = %40, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 16
br i1 %11, label %12, label %43
12: ; preds = %9
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %14, %19
br i1 %20, label %21, label %26
21: ; preds = %12
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = mul nsw i32 16, %23
%25 = add nsw i32 %22, %24
store i32 %25, i32* %5
br label %26
26: ; preds = %21, %12
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %28, %33
br i1 %34, label %35, label %39
35: ; preds = %26
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = add nsw i32 %36, %37
store i32 %38, i32* %5
br label %39
39: ; preds = %35, %26
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %9
43: ; preds = %9
%44 = load i32, i32* %5
ret i32 %44
}

LLVM IR (-O2):
define i32 @Hex2Int(i8 signext %0, i8 signext %1) {
%3 = icmp eq i8 %0, 49
%4 = select i1 %3, i32 16, i32 0
%5 = icmp eq i8 %1, 49
%6 = zext i1 %5 to i32
%7 = or i32 %4, %6
%8 = icmp eq i8 %0, 50
%9 = select i1 %8, i32 32, i32 0
%10 = or i32 %9, %7
%11 = icmp eq i8 %1, 50
%12 = select i1 %11, i32 2, i32 0
%13 = or i32 %10, %12
%14 = insertelement <16 x i8> poison, i8 %0, i64 0
%15 = insertelement <16 x i8> %14, i8 %1, i64 1
%16 = shufflevector <16 x i8> %15, <16 x i8> poison, <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1>
%17 = icmp eq <16 x i8> %16, <i8 70, i8 69, i8 68, i8 67, i8 66, i8 65, i8 57, i8 56, i8 55, i8 54, i8 53, i8 52, i8 51, i8 51, i8 52, i8 53>
%18 = select <16 x i1> %17, <16 x i32> <i32 240, i32 224, i32 208, i32 192, i32 176, i32 160, i32 144, i32 128, i32 112, i32 96, i32 80, i32 64, i32 48, i32 3, i32 4, i32 5>, <16 x i32> zeroinitializer
%19 = insertelement <8 x i8> poison, i8 %1, i64 0
%20 = shufflevector <8 x i8> %19, <8 x i8> poison, <8 x i32> zeroinitializer
%21 = icmp eq <8 x i8> %20, <i8 54, i8 55, i8 56, i8 57, i8 65, i8 66, i8 67, i8 68>
%22 = select <8 x i1> %21, <8 x i32> <i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13>, <8 x i32> zeroinitializer
%23 = icmp eq i8 %1, 69
%24 = select i1 %23, i32 14, i32 0
%25 = icmp eq i8 %1, 70
%26 = select i1 %25, i32 15, i32 0
%27 = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %18)
%28 = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %22)
%29 = add nsw i32 %27, %28
%30 = add nsw i32 %29, %24
%31 = add nsw i32 %30, %26
%32 = add nuw nsw i32 %31, %13
ret i32 %32
}