#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ stderr;
char hexdig(char c) {
  char ochar = 0;
  if (c >= '0' && c <= '9') {
    ochar = (c - '0');
    return ochar;
  }
  if (c >= 'a' && c <= 'f') {
    ochar = (c - 'a') + 10;
    return ochar;
  }
  if (c >= 'A' && c <= 'F') {
    ochar = (c - 'A') + 10;
    return ochar;
  }
  fprintf(stderr,
          "Translating from uri: "
          "A supposed hexadecimal input character is "
          "not 0-9 or a-f or A-F, it is (shown as hex here): %x\n",
          c);
  return ochar;
}


x86 assembly (clang, -O0):
<hexdig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movb   $0x0,-0x3(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x30,%eax
jl     1151 <hexdig+0x41>
movsbl -0x2(%rbp),%eax
cmp    $0x39,%eax
jg     1151 <hexdig+0x41>
movsbl -0x2(%rbp),%eax
sub    $0x30,%eax
mov    %al,-0x3(%rbp)
mov    -0x3(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11d4 <hexdig+0xc4>
movsbl -0x2(%rbp),%eax
cmp    $0x61,%eax
jl     1183 <hexdig+0x73>
movsbl -0x2(%rbp),%eax
cmp    $0x66,%eax
jg     1183 <hexdig+0x73>
movsbl -0x2(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %al,-0x3(%rbp)
mov    -0x3(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11d4 <hexdig+0xc4>
movsbl -0x2(%rbp),%eax
cmp    $0x41,%eax
jl     11b5 <hexdig+0xa5>
movsbl -0x2(%rbp),%eax
cmp    $0x46,%eax
jg     11b5 <hexdig+0xa5>
movsbl -0x2(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %al,-0x3(%rbp)
mov    -0x3(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11d4 <hexdig+0xc4>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
movsbl -0x2(%rbp),%edx
call   1030 <fprintf@plt>
mov    -0x3(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdig>:
lea    -0x30(%rdi),%eax
cmp    $0xa,%al
jb     1155 <hexdig+0x45>
lea    -0x61(%rdi),%eax
cmp    $0x5,%al
ja     1125 <hexdig+0x15>
add    $0xa9,%dil
mov    %edi,%eax
ret
lea    -0x41(%rdi),%eax
cmp    $0x5,%al
ja     1133 <hexdig+0x23>
add    $0xc9,%dil
mov    %edi,%eax
ret
push   %rax
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
movsbl %dil,%edx
lea    0xeb8(%rip),%rsi
mov    %eax,%edi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [118 x i8] c"Translating from uri: A supposed hexadecimal input character is not 0-9 or a-f or A-F, it is (shown as hex here): %x\0A\00"
define signext i8 @hexdig(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
store i8 %0, i8* %3
store i8 0, i8* %4
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
%7 = icmp sge i32 %6, 48
br i1 %7, label %8, label %18
8: ; preds = %1
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp sle i32 %10, 57
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = sub nsw i32 %14, 48
%16 = trunc i32 %15 to i8
store i8 %16, i8* %4
%17 = load i8, i8* %4
store i8 %17, i8* %2
br label %53
18: ; preds = %8, %1
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp sge i32 %20, 97
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = icmp sle i32 %24, 102
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = load i8, i8* %3
%28 = sext i8 %27 to i32
%29 = sub nsw i32 %28, 97
%30 = add nsw i32 %29, 10
%31 = trunc i32 %30 to i8
store i8 %31, i8* %4
%32 = load i8, i8* %4
store i8 %32, i8* %2
br label %53
33: ; preds = %22, %18
%34 = load i8, i8* %3
%35 = sext i8 %34 to i32
%36 = icmp sge i32 %35, 65
br i1 %36, label %37, label %48
37: ; preds = %33
%38 = load i8, i8* %3
%39 = sext i8 %38 to i32
%40 = icmp sle i32 %39, 70
br i1 %40, label %41, label %48
41: ; preds = %37
%42 = load i8, i8* %3
%43 = sext i8 %42 to i32
%44 = sub nsw i32 %43, 65
%45 = add nsw i32 %44, 10
%46 = trunc i32 %45 to i8
store i8 %46, i8* %4
%47 = load i8, i8* %4
store i8 %47, i8* %2
br label %53
48: ; preds = %37, %33
%49 = load i32, i32* @stderr
%50 = load i8, i8* %3
%51 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([118 x i8], [118 x i8]* @.str, i64 0, i64 0), i8 signext %50)
%52 = load i8, i8* %4
store i8 %52, i8* %2
br label %53
53: ; preds = %48, %41, %26, %12
%54 = load i8, i8* %2
ret i8 %54
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [118 x i8] c"Translating from uri: A supposed hexadecimal input character is not 0-9 or a-f or A-F, it is (shown as hex here): %x\0A\00"
define signext i8 @hexdig(i8 signext %0) {
%2 = add i8 %0, -48
%3 = icmp ult i8 %2, 10
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = add i8 %0, -97
%6 = icmp ult i8 %5, 6
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = add nsw i8 %0, -87
br label %17
9: ; preds = %4
%10 = add i8 %0, -65
%11 = icmp ult i8 %10, 6
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = add nsw i8 %0, -55
br label %17
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([118 x i8], [118 x i8]* @.str, i64 0, i64 0), i8 signext %0)
br label %17
17: ; preds = %1, %14, %12, %7
%18 = phi i8 [ %8, %7 ], [ %13, %12 ], [ 0, %14 ], [ %2, %1 ]
ret i8 %18
}