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


x86 assembly (clang, -O0):
<Hexvalue>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xf,%eax
ja     11f8 <Hexvalue+0xf8>
mov    -0x10(%rbp),%rax
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x30,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x31,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x32,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x33,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x34,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x35,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x36,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x37,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x38,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x39,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x61,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x62,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x63,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x64,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x65,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x66,-0x8(%rbp)
jmp    11ff <Hexvalue+0xff>
movl   $0x30,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Hexvalue>:
add    $0xffffffff,%edi
mov    $0x30,%eax
cmp    $0xe,%edi
ja     111a <Hexvalue+0x1a>
movslq %edi,%rax
lea    0xee9(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

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

LLVM IR (-O2):
@switch.table.Hexvalue = [15 x i32] [i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 97, i32 98, i32 99, i32 100, i32 101, i32 102]
define i32 @Hexvalue(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -1
%4 = icmp ult i32 %3, 15
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [15 x i32], [15 x i32]* @switch.table.Hexvalue, i64 0, i64 %6
%8 = load i32, i32* %7
br label %9
9: ; preds = %5, %1
%10 = phi i32 [ 48, %1 ], [ %8, %5 ]
ret i32 %10
}