#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*/ assert(int /*<<< orphan*/);
int esch_integer_convert_char(char ch) {
  if (ch >= '0' && ch <= '9') {
    return ch - '0';
  } else if (ch >= 'a' && ch <= 'f') {
    return 10 + (ch - 'a');
  } else if (ch >= 'A' && ch <= 'F') {
    return 10 + (ch - 'A');
  }
  assert(0);
  return 0;
}


x86 assembly (clang, -O0):
<esch_integer_convert_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     1147 <esch_integer_convert_char+0x37>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     1147 <esch_integer_convert_char+0x37>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11b7 <esch_integer_convert_char+0xa7>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     1173 <esch_integer_convert_char+0x63>
movsbl -0x5(%rbp),%eax
cmp    $0x66,%eax
jg     1173 <esch_integer_convert_char+0x63>
movsbl -0x5(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11b7 <esch_integer_convert_char+0xa7>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     119f <esch_integer_convert_char+0x8f>
movsbl -0x5(%rbp),%eax
cmp    $0x46,%eax
jg     119f <esch_integer_convert_char+0x8f>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11b7 <esch_integer_convert_char+0xa7>
jmp    11a4 <esch_integer_convert_char+0x94>
jmp    11a9 <esch_integer_convert_char+0x99>
xor    %edi,%edi
call   1030 <assert@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<esch_integer_convert_char>:
push   %rbx
mov    %edi,%ebx
lea    -0x30(%rbx),%eax
cmp    $0x9,%al
ja     111f <esch_integer_convert_char+0xf>
add    $0xffffffd0,%ebx
jmp    1140 <esch_integer_convert_char+0x30>
lea    -0x61(%rbx),%eax
cmp    $0x5,%al
ja     112b <esch_integer_convert_char+0x1b>
add    $0xffffffa9,%ebx
jmp    1140 <esch_integer_convert_char+0x30>
lea    -0x41(%rbx),%eax
cmp    $0x5,%al
ja     1137 <esch_integer_convert_char+0x27>
add    $0xffffffc9,%ebx
jmp    1140 <esch_integer_convert_char+0x30>
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <assert@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @esch_integer_convert_char(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add i8 %0, -48
%4 = icmp ult i8 %3, 10
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add nsw i32 %2, -48
br label %19
7: ; preds = %1
%8 = add i8 %0, -97
%9 = icmp ult i8 %8, 6
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = add nsw i32 %2, -87
br label %19
12: ; preds = %7
%13 = add i8 %0, -65
%14 = icmp ult i8 %13, 6
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = add nsw i32 %2, -55
br label %19
17: ; preds = %12
%18 = tail call i32 @assert(i32 0)
br label %19
19: ; preds = %17, %15, %10, %5
%20 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %16, %15 ], [ 0, %17 ]
ret i32 %20
}