#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
char fcitx_utils_tolower(char);
int to_hex_digit(char hi, char lo) {
  hi = fcitx_utils_tolower(hi);
  lo = fcitx_utils_tolower(lo);
  int dhi = 0, dlo = 0;
  if (hi >= '0' && hi <= '9') {
    dhi = hi - '0';
  } else {
    dhi = hi - 'a' + 10;
  }
  if (lo >= '0' && lo <= '9') {
    dlo = lo - '0';
  } else {
    dlo = lo - 'a' + 10;
  }
  return dhi * 16 + dlo;
}


x86 assembly (clang, -O0):
<to_hex_digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <fcitx_utils_tolower@plt>
mov    %al,-0x1(%rbp)
movsbl -0x2(%rbp),%edi
call   1030 <fcitx_utils_tolower@plt>
mov    %al,-0x2(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x30,%eax
jl     1173 <to_hex_digit+0x63>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
jg     1173 <to_hex_digit+0x63>
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <to_hex_digit+0x70>
movsbl -0x1(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x30,%eax
jl     11a9 <to_hex_digit+0x99>
movsbl -0x2(%rbp),%eax
cmp    $0x39,%eax
jg     11a9 <to_hex_digit+0x99>
movsbl -0x2(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
jmp    11b6 <to_hex_digit+0xa6>
movsbl -0x2(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
add    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_hex_digit>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1030 <fcitx_utils_tolower@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <fcitx_utils_tolower@plt>
movsbl %bl,%ecx
lea    -0x30(%rcx),%edx
lea    -0x57(%rcx),%esi
add    $0xffffffd0,%ecx
cmp    $0xa,%dl
cmovae %esi,%ecx
movsbl %al,%eax
lea    -0x30(%rax),%edx
lea    -0x57(%rax),%esi
add    $0xffffffd0,%eax
cmp    $0xa,%dl
cmovae %esi,%eax
shl    $0x4,%ecx
add    %eax,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @to_hex_digit(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
%7 = load i8, i8* %3
%8 = call signext i8 @fcitx_utils_tolower(i8 signext %7)
store i8 %8, i8* %3
%9 = load i8, i8* %4
%10 = call signext i8 @fcitx_utils_tolower(i8 signext %9)
store i8 %10, i8* %4
store i32 0, i32* %5
store i32 0, i32* %6
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp sge i32 %12, 48
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp sle i32 %16, 57
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = sub nsw i32 %20, 48
store i32 %21, i32* %5
br label %27
22: ; preds = %14, %2
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = sub nsw i32 %24, 97
%26 = add nsw i32 %25, 10
store i32 %26, i32* %5
br label %27
27: ; preds = %22, %18
%28 = load i8, i8* %4
%29 = sext i8 %28 to i32
%30 = icmp sge i32 %29, 48
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load i8, i8* %4
%33 = sext i8 %32 to i32
%34 = icmp sle i32 %33, 57
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i8, i8* %4
%37 = sext i8 %36 to i32
%38 = sub nsw i32 %37, 48
store i32 %38, i32* %6
br label %44
39: ; preds = %31, %27
%40 = load i8, i8* %4
%41 = sext i8 %40 to i32
%42 = sub nsw i32 %41, 97
%43 = add nsw i32 %42, 10
store i32 %43, i32* %6
br label %44
44: ; preds = %39, %35
%45 = load i32, i32* %5
%46 = mul nsw i32 %45, 16
%47 = load i32, i32* %6
%48 = add nsw i32 %46, %47
ret i32 %48
}

LLVM IR (-O2):
define i32 @to_hex_digit(i8 signext %0, i8 signext %1) {
%3 = tail call signext i8 @fcitx_utils_tolower(i8 signext %0)
%4 = tail call signext i8 @fcitx_utils_tolower(i8 signext %1)
%5 = sext i8 %3 to i32
%6 = add i8 %3, -48
%7 = icmp ult i8 %6, 10
%8 = select i1 %7, i32 -48, i32 -87
%9 = add nsw i32 %8, %5
%10 = sext i8 %4 to i32
%11 = add i8 %4, -48
%12 = icmp ult i8 %11, 10
%13 = select i1 %12, i32 -48, i32 -87
%14 = add nsw i32 %13, %10
%15 = shl nsw i32 %9, 4
%16 = add nsw i32 %14, %15
ret i32 %16
}