void htoi(c) {
  if (c != '0' && c != 'x' && c != 'X') {
    if (c > 96 && c < 103)
      printf("%d ", (c - 87));
    else if (c > 64 && c < 71)
      printf("%d ", (c - 55));
    else
      printf("%c ", c);
  }
}


x86 assembly (clang, -O0):
<htoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x30,-0x4(%rbp)
je     11ae <htoi+0x9e>
cmpl   $0x78,-0x4(%rbp)
je     11ae <htoi+0x9e>
cmpl   $0x58,-0x4(%rbp)
je     11ae <htoi+0x9e>
cmpl   $0x60,-0x4(%rbp)
jle    1166 <htoi+0x56>
cmpl   $0x67,-0x4(%rbp)
jge    1166 <htoi+0x56>
mov    -0x4(%rbp),%esi
sub    $0x57,%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a9 <htoi+0x99>
cmpl   $0x40,-0x4(%rbp)
jle    1193 <htoi+0x83>
cmpl   $0x47,-0x4(%rbp)
jge    1193 <htoi+0x83>
mov    -0x4(%rbp),%esi
sub    $0x37,%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a4 <htoi+0x94>
mov    -0x4(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a9 <htoi+0x99>
jmp    11ae <htoi+0x9e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<htoi>:
cmp    $0x30,%edi
je     1121 <htoi+0x11>
mov    %edi,%esi
cmp    $0x58,%edi
je     1121 <htoi+0x11>
cmp    $0x78,%esi
jne    1122 <htoi+0x12>
ret
lea    -0x61(%rsi),%eax
cmp    $0x5,%eax
ja     112f <htoi+0x1f>
add    $0xffffffa9,%esi
jmp    113a <htoi+0x2a>
lea    -0x41(%rsi),%eax
cmp    $0x5,%eax
ja     1148 <htoi+0x38>
add    $0xffffffc9,%esi
lea    0xebf(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [4 x i8] c"%c \00"
define void @htoi(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 48
br i1 %4, label %5, label %36
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 120
br i1 %7, label %8, label %36
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 88
br i1 %10, label %11, label %36
11: ; preds = %8
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 96
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 103
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, 87
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %35
21: ; preds = %14, %11
%22 = load i32, i32* %2
%23 = icmp sgt i32 %22, 64
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load i32, i32* %2
%26 = icmp slt i32 %25, 71
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* %2
%29 = sub nsw i32 %28, 55
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
br label %34
31: ; preds = %24, %21
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %27
br label %35
35: ; preds = %34, %17
br label %36
36: ; preds = %35, %8, %5, %1
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [4 x i8] c"%c \00"
define void @htoi(i32 %0) {
switch i32 %0, label %2 [
i32 120, label %16
i32 88, label %16
i32 48, label %16
]
2: ; preds = %1
%3 = add i32 %0, -97
%4 = icmp ult i32 %3, 6
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = add nsw i32 %0, -87
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %16
8: ; preds = %2
%9 = add i32 %0, -65
%10 = icmp ult i32 %9, 6
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = add nsw i32 %0, -55
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %16
14: ; preds = %8
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %16
16: ; preds = %1, %1, %1, %5, %14, %11
ret void
}