unsigned short int transform_hex(char a) {
  unsigned short int aa;
  switch (a) {
  case 'a':
    aa = 10;
    break;
  case 'b':
    aa = 11;
    break;
  case 'c':
    aa = 12;
    break;
  case 'd':
    aa = 13;
    break;
  case 'e':
    aa = 14;
    break;
  case 'f':
    aa = 15;
    break;
  case '0':
    aa = 0;
    break;
  case '1':
    aa = 1;
    break;
  case '2':
    aa = 2;
    break;
  case '3':
    aa = 3;
    break;
  case '4':
    aa = 4;
    break;
  case '5':
    aa = 5;
    break;
  case '6':
    aa = 6;
    break;
  case '7':
    aa = 7;
    break;
  case '8':
    aa = 8;
    break;
  case '9':
    aa = 9;
    break;
  }
  return (aa);
}


x86 assembly (clang, -O0):
<transform_hex>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x36,%eax
ja     11df <transform_hex+0xdf>
mov    -0x10(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movw   $0xa,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0xb,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0xc,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0xd,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0xe,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0xf,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x0,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x1,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x2,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x3,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x4,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x5,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x6,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x7,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x8,-0x4(%rbp)
jmp    11df <transform_hex+0xdf>
movw   $0x9,-0x4(%rbp)
movzwl -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<transform_hex>:
mov    $0xa,%ax
add    $0xffffffd0,%edi
cmp    $0x36,%edi
ja     1146 <transform_hex+0x46>
lea    0xeed(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
xor    %eax,%eax
ret
mov    $0x1,%ax
ret
mov    $0x2,%ax
ret
mov    $0x3,%ax
ret
mov    $0x4,%ax
ret
mov    $0x5,%ax
ret
mov    $0x6,%ax
ret
mov    $0x7,%ax
ret
mov    $0x9,%ax
ret
mov    $0xb,%ax
ret
mov    $0xc,%ax
ret
mov    $0xd,%ax
ret
mov    $0xe,%ax
ret
mov    $0xf,%ax
ret
mov    $0x8,%ax
ret

LLVM IR (-O0):
define zeroext i16 @transform_hex(i8 signext %0) {
%2 = alloca i8
%3 = alloca i16
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
switch i32 %5, label %22 [
i32 97, label %6
i32 98, label %7
i32 99, label %8
i32 100, label %9
i32 101, label %10
i32 102, label %11
i32 48, label %12
i32 49, label %13
i32 50, label %14
i32 51, label %15
i32 52, label %16
i32 53, label %17
i32 54, label %18
i32 55, label %19
i32 56, label %20
i32 57, label %21
]
6: ; preds = %1
store i16 10, i16* %3
br label %22
7: ; preds = %1
store i16 11, i16* %3
br label %22
8: ; preds = %1
store i16 12, i16* %3
br label %22
9: ; preds = %1
store i16 13, i16* %3
br label %22
10: ; preds = %1
store i16 14, i16* %3
br label %22
11: ; preds = %1
store i16 15, i16* %3
br label %22
12: ; preds = %1
store i16 0, i16* %3
br label %22
13: ; preds = %1
store i16 1, i16* %3
br label %22
14: ; preds = %1
store i16 2, i16* %3
br label %22
15: ; preds = %1
store i16 3, i16* %3
br label %22
16: ; preds = %1
store i16 4, i16* %3
br label %22
17: ; preds = %1
store i16 5, i16* %3
br label %22
18: ; preds = %1
store i16 6, i16* %3
br label %22
19: ; preds = %1
store i16 7, i16* %3
br label %22
20: ; preds = %1
store i16 8, i16* %3
br label %22
21: ; preds = %1
store i16 9, i16* %3
br label %22
22: ; preds = %1, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%23 = load i16, i16* %3
ret i16 %23
}

LLVM IR (-O2):
define zeroext i16 @transform_hex(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %18 [
i32 57, label %17
i32 98, label %3
i32 99, label %4
i32 100, label %5
i32 101, label %6
i32 102, label %7
i32 48, label %8
i32 49, label %9
i32 50, label %10
i32 51, label %11
i32 52, label %12
i32 53, label %13
i32 54, label %14
i32 55, label %15
i32 56, label %16
]
3: ; preds = %1
br label %18
4: ; preds = %1
br label %18
5: ; preds = %1
br label %18
6: ; preds = %1
br label %18
7: ; preds = %1
br label %18
8: ; preds = %1
br label %18
9: ; preds = %1
br label %18
10: ; preds = %1
br label %18
11: ; preds = %1
br label %18
12: ; preds = %1
br label %18
13: ; preds = %1
br label %18
14: ; preds = %1
br label %18
15: ; preds = %1
br label %18
16: ; preds = %1
br label %18
17: ; preds = %1
br label %18
18: ; preds = %1, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3
%19 = phi i16 [ 9, %17 ], [ 8, %16 ], [ 7, %15 ], [ 6, %14 ], [ 5, %13 ], [ 4, %12 ], [ 3, %11 ], [ 2, %10 ], [ 1, %9 ], [ 0, %8 ], [ 15, %7 ], [ 14, %6 ], [ 13, %5 ], [ 12, %4 ], [ 11, %3 ], [ 10, %1 ]
ret i16 %19
}