#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*/ isalnum(char);
scalar_t__ islower(char);
scalar_t__ isupper(char);
int /*<<< orphan*/ printf(char *);
int get_Num(char ch) {
  if (!isalnum(ch)) {
    printf("Error Code!!\n");
    return -1;
  }
  if (isupper(ch)) {
    return ch - 'A' + 10;
  } else if (islower(ch)) {
    return ch - 'a' + 10;
  } else {
    return ch - '0';
  }
}


x86 assembly (clang, -O0):
<get_Num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1050 <isalnum@plt>
cmp    $0x0,%eax
jne    1178 <get_Num+0x38>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cc <get_Num+0x8c>
movsbl -0x5(%rbp),%edi
call   1060 <isupper@plt>
cmp    $0x0,%rax
je     119d <get_Num+0x5d>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <get_Num+0x8c>
movsbl -0x5(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     11c2 <get_Num+0x82>
movsbl -0x5(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <get_Num+0x8c>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_Num>:
push   %rbx
mov    %edi,%ebx
call   1050 <isalnum@plt>
test   %eax,%eax
je     1160 <get_Num+0x20>
movsbl %bl,%ebx
mov    %ebx,%edi
call   1060 <isupper@plt>
test   %rax,%rax
je     1173 <get_Num+0x33>
add    $0xffffffc9,%ebx
jmp    1187 <get_Num+0x47>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
jmp    1187 <get_Num+0x47>
mov    %ebx,%edi
call   1030 <islower@plt>
test   %rax,%rax
je     1184 <get_Num+0x44>
add    $0xffffffa9,%ebx
jmp    1187 <get_Num+0x47>
add    $0xffffffd0,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Error Code!!\0A\00"
define i32 @get_Num(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i32 @isalnum(i8 signext %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %31
9: ; preds = %1
%10 = load i8, i8* %3
%11 = call i64 @isupper(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = sub nsw i32 %15, 65
%17 = add nsw i32 %16, 10
store i32 %17, i32* %2
br label %31
18: ; preds = %9
%19 = load i8, i8* %3
%20 = call i64 @islower(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %18
%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* %2
br label %31
27: ; preds = %18
%28 = load i8, i8* %3
%29 = sext i8 %28 to i32
%30 = sub nsw i32 %29, 48
store i32 %30, i32* %2
br label %31
31: ; preds = %27, %22, %13, %7
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@str = [13 x i8] c"Error Code!!\00"
define i32 @get_Num(i8 signext %0) {
%2 = tail call i32 @isalnum(i8 signext %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %20
6: ; preds = %1
%7 = tail call i64 @isupper(i8 signext %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = sext i8 %0 to i32
%11 = add nsw i32 %10, -55
br label %20
12: ; preds = %6
%13 = tail call i64 @islower(i8 signext %0)
%14 = icmp eq i64 %13, 0
%15 = sext i8 %0 to i32
br i1 %14, label %18, label %16
16: ; preds = %12
%17 = add nsw i32 %15, -87
br label %20
18: ; preds = %12
%19 = add nsw i32 %15, -48
br label %20
20: ; preds = %18, %16, %9, %4
%21 = phi i32 [ %11, %9 ], [ %17, %16 ], [ %19, %18 ], [ -1, %4 ]
ret i32 %21
}