#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*/ printf(char *);
unsigned char char2byte(char input) {
  if ((input >= '0') & (input <= '9'))
    return input - '0';
  if ((input >= 'A') & (input <= 'F'))
    return input - 'A' + 10;
  printf("Warning! Processing illegal hexadecimal digit.\n");
  return 0;
}


x86 assembly (clang, -O0):
<char2byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x30,%eax
setge  %al
and    $0x1,%al
movzbl %al,%eax
movsbl -0x2(%rbp),%ecx
cmp    $0x39,%ecx
setle  %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1157 <char2byte+0x47>
movsbl -0x2(%rbp),%eax
sub    $0x30,%eax
mov    %al,-0x1(%rbp)
jmp    11a3 <char2byte+0x93>
movsbl -0x2(%rbp),%eax
cmp    $0x41,%eax
setge  %al
and    $0x1,%al
movzbl %al,%eax
movsbl -0x2(%rbp),%ecx
cmp    $0x46,%ecx
setle  %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1193 <char2byte+0x83>
movsbl -0x2(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %al,-0x1(%rbp)
jmp    11a3 <char2byte+0x93>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char2byte>:
lea    -0x30(%rdi),%eax
cmp    $0xa,%al
jb     1138 <char2byte+0x28>
lea    -0x41(%rdi),%eax
cmp    $0x5,%al
ja     1125 <char2byte+0x15>
add    $0xc9,%dil
mov    %edi,%eax
ret
push   %rax
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Warning! Processing illegal hexadecimal digit.\0A\00"
define zeroext i8 @char2byte(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp sge i32 %5, 48
%7 = zext i1 %6 to i32
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp sle i32 %9, 57
%11 = zext i1 %10 to i32
%12 = and i32 %7, %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = sub nsw i32 %16, 48
%18 = trunc i32 %17 to i8
store i8 %18, i8* %2
br label %38
19: ; preds = %1
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp sge i32 %21, 65
%23 = zext i1 %22 to i32
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp sle i32 %25, 70
%27 = zext i1 %26 to i32
%28 = and i32 %23, %27
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %19
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
%33 = sub nsw i32 %32, 65
%34 = add nsw i32 %33, 10
%35 = trunc i32 %34 to i8
store i8 %35, i8* %2
br label %38
36: ; preds = %19
%37 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %2
br label %38
38: ; preds = %36, %30, %14
%39 = load i8, i8* %2
ret i8 %39
}

LLVM IR (-O2):
@str = [47 x i8] c"Warning! Processing illegal hexadecimal digit.\00"
define zeroext i8 @char2byte(i8 signext %0) {
%2 = add i8 %0, -48
%3 = icmp ult i8 %2, 10
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = add i8 %0, -65
%6 = icmp ult i8 %5, 6
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = add nsw i8 %0, -55
br label %11
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %1, %9, %7
%12 = phi i8 [ %8, %7 ], [ 0, %9 ], [ %2, %1 ]
ret i8 %12
}