#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 */
typedef char uint8_t;

/* Variables and functions */
uint8_t zrpc_util_convertchartohexa(uint8_t *hexa, int *error) {
  if ((*hexa == '0') || (*hexa == '1') || (*hexa == '2') || (*hexa == '3') ||
      (*hexa == '4') || (*hexa == '5') || (*hexa == '6') || (*hexa == '7') ||
      (*hexa == '8') || (*hexa == '9'))
    return (uint8_t)(*hexa) - '0';
  if ((*hexa == 'a') || (*hexa == 'A'))
    return 0xa;
  if ((*hexa == 'b') || (*hexa == 'B'))
    return 0xb;
  if ((*hexa == 'c') || (*hexa == 'C'))
    return 0xc;
  if ((*hexa == 'd') || (*hexa == 'D'))
    return 0xd;
  if ((*hexa == 'e') || (*hexa == 'E'))
    return 0xe;
  if ((*hexa == 'f') || (*hexa == 'F'))
    return 0xf;
  *error = -1;
  return 0;
}


x86 assembly (clang, -O0):
<zrpc_util_convertchartohexa>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     11ac <zrpc_util_convertchartohexa+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
je     11ac <zrpc_util_convertchartohexa+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x32,%eax
je     11ac <zrpc_util_convertchartohexa+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x33,%eax
je     11ac <zrpc_util_convertchartohexa+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x34,%eax
je     11ac <zrpc_util_convertchartohexa+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x35,%eax
je     11ac <zrpc_util_convertchartohexa+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x36,%eax
je     11ac <zrpc_util_convertchartohexa+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x37,%eax
je     11ac <zrpc_util_convertchartohexa+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x38,%eax
je     11ac <zrpc_util_convertchartohexa+0xac>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jne    11be <zrpc_util_convertchartohexa+0xbe>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
mov    %al,-0x1(%rbp)
jmp    12c2 <zrpc_util_convertchartohexa+0x1c2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
je     11de <zrpc_util_convertchartohexa+0xde>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jne    11e7 <zrpc_util_convertchartohexa+0xe7>
movb   $0xa,-0x1(%rbp)
jmp    12c2 <zrpc_util_convertchartohexa+0x1c2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
je     1207 <zrpc_util_convertchartohexa+0x107>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x42,%eax
jne    1210 <zrpc_util_convertchartohexa+0x110>
movb   $0xb,-0x1(%rbp)
jmp    12c2 <zrpc_util_convertchartohexa+0x1c2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
je     1230 <zrpc_util_convertchartohexa+0x130>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x43,%eax
jne    1239 <zrpc_util_convertchartohexa+0x139>
movb   $0xc,-0x1(%rbp)
jmp    12c2 <zrpc_util_convertchartohexa+0x1c2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
je     1259 <zrpc_util_convertchartohexa+0x159>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x44,%eax
jne    1262 <zrpc_util_convertchartohexa+0x162>
movb   $0xd,-0x1(%rbp)
jmp    12c2 <zrpc_util_convertchartohexa+0x1c2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x65,%eax
je     1282 <zrpc_util_convertchartohexa+0x182>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x45,%eax
jne    128b <zrpc_util_convertchartohexa+0x18b>
movb   $0xe,-0x1(%rbp)
jmp    12c2 <zrpc_util_convertchartohexa+0x1c2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x66,%eax
je     12ab <zrpc_util_convertchartohexa+0x1ab>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x46,%eax
jne    12b4 <zrpc_util_convertchartohexa+0x1b4>
movb   $0xf,-0x1(%rbp)
jmp    12c2 <zrpc_util_convertchartohexa+0x1c2>
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<zrpc_util_convertchartohexa>:
mov    (%rdi),%al
add    $0xd0,%al
cmp    $0x37,%al
jae    111b <zrpc_util_convertchartohexa+0x1b>
movzbl %al,%ecx
movabs $0x7e0000007e03ff,%rdx
bt     %rcx,%rdx
jb     1124 <zrpc_util_convertchartohexa+0x24>
movl   $0xffffffff,(%rsi)
xor    %eax,%eax
ret
movsbq %al,%rax
lea    0xed1(%rip),%rcx
mov    (%rax,%rcx,1),%al
ret

LLVM IR (-O0):
define signext i8 @zrpc_util_convertchartohexa(i8* %0, i32* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 48
br i1 %9, label %55, label %10
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 49
br i1 %14, label %55, label %15
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 50
br i1 %19, label %55, label %20
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 51
br i1 %24, label %55, label %25
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 52
br i1 %29, label %55, label %30
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 53
br i1 %34, label %55, label %35
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 54
br i1 %39, label %55, label %40
40: ; preds = %35
%41 = load i8*, i8** %4
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 55
br i1 %44, label %55, label %45
45: ; preds = %40
%46 = load i8*, i8** %4
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 56
br i1 %49, label %55, label %50
50: ; preds = %45
%51 = load i8*, i8** %4
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 57
br i1 %54, label %55, label %61
55: ; preds = %50, %45, %40, %35, %30, %25, %20, %15, %10, %2
%56 = load i8*, i8** %4
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = sub nsw i32 %58, 48
%60 = trunc i32 %59 to i8
store i8 %60, i8* %3
br label %129
61: ; preds = %50
%62 = load i8*, i8** %4
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 97
br i1 %65, label %71, label %66
66: ; preds = %61
%67 = load i8*, i8** %4
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 65
br i1 %70, label %71, label %72
71: ; preds = %66, %61
store i8 10, i8* %3
br label %129
72: ; preds = %66
%73 = load i8*, i8** %4
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 98
br i1 %76, label %82, label %77
77: ; preds = %72
%78 = load i8*, i8** %4
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp eq i32 %80, 66
br i1 %81, label %82, label %83
82: ; preds = %77, %72
store i8 11, i8* %3
br label %129
83: ; preds = %77
%84 = load i8*, i8** %4
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 99
br i1 %87, label %93, label %88
88: ; preds = %83
%89 = load i8*, i8** %4
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = icmp eq i32 %91, 67
br i1 %92, label %93, label %94
93: ; preds = %88, %83
store i8 12, i8* %3
br label %129
94: ; preds = %88
%95 = load i8*, i8** %4
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp eq i32 %97, 100
br i1 %98, label %104, label %99
99: ; preds = %94
%100 = load i8*, i8** %4
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = icmp eq i32 %102, 68
br i1 %103, label %104, label %105
104: ; preds = %99, %94
store i8 13, i8* %3
br label %129
105: ; preds = %99
%106 = load i8*, i8** %4
%107 = load i8, i8* %106
%108 = sext i8 %107 to i32
%109 = icmp eq i32 %108, 101
br i1 %109, label %115, label %110
110: ; preds = %105
%111 = load i8*, i8** %4
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 69
br i1 %114, label %115, label %116
115: ; preds = %110, %105
store i8 14, i8* %3
br label %129
116: ; preds = %110
%117 = load i8*, i8** %4
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = icmp eq i32 %119, 102
br i1 %120, label %126, label %121
121: ; preds = %116
%122 = load i8*, i8** %4
%123 = load i8, i8* %122
%124 = sext i8 %123 to i32
%125 = icmp eq i32 %124, 70
br i1 %125, label %126, label %127
126: ; preds = %121, %116
store i8 15, i8* %3
br label %129
127: ; preds = %121
%128 = load i32*, i32** %5
store i32 -1, i32* %128
store i8 0, i8* %3
br label %129
129: ; preds = %127, %126, %115, %104, %93, %82, %71, %55
%130 = load i8, i8* %3
ret i8 %130
}

LLVM IR (-O2):
@switch.table.zrpc_util_convertchartohexa = [55 x i8] c"\00\01\02\03\04\05\06\07\08\09\00\00\00\00\00\00\00\0A\0B\0C\0D\0E\0F\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\0A\0B\0C\0D\0E\0F"
define signext i8 @zrpc_util_convertchartohexa(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = add i8 %3, -48
%5 = icmp ult i8 %4, 55
br i1 %5, label %7, label %6
6: ; preds = %7, %2
store i32 -1, i32* %1
br label %16
7: ; preds = %2
%8 = zext i8 %4 to i64
%9 = lshr i64 35465847073801215, %8
%10 = and i64 %9, 1
%11 = icmp eq i64 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %7
%13 = sext i8 %4 to i64
%14 = getelementptr inbounds [55 x i8], [55 x i8]* @switch.table.zrpc_util_convertchartohexa, i64 0, i64 %13
%15 = load i8, i8* %14
br label %16
16: ; preds = %12, %6
%17 = phi i8 [ 0, %6 ], [ %15, %12 ]
ret i8 %17
}