#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 atoi(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int get_hex_digit(char *d) {
  char c[2];
  c[0] = *d;
  c[1] = 0;
  if (!strcmp(c, "a") || !strcmp(c, "A"))
    return 10;
  if (!strcmp(c, "b") || !strcmp(c, "B"))
    return 11;
  if (!strcmp(c, "c") || !strcmp(c, "C"))
    return 12;
  if (!strcmp(c, "d") || !strcmp(c, "D"))
    return 13;
  if (!strcmp(c, "e") || !strcmp(c, "E"))
    return 14;
  if (!strcmp(c, "f") || !strcmp(c, "F"))
    return 15;
  return (atoi(c));
}


x86 assembly (clang, -O0):
<get_hex_digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x12(%rbp)
movb   $0x0,-0x11(%rbp)
lea    -0x12(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     116b <get_hex_digit+0x4b>
lea    -0x12(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1177 <get_hex_digit+0x57>
movl   $0xa,-0x4(%rbp)
jmp    12b9 <get_hex_digit+0x199>
lea    -0x12(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11a9 <get_hex_digit+0x89>
lea    -0x12(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11b5 <get_hex_digit+0x95>
movl   $0xb,-0x4(%rbp)
jmp    12b9 <get_hex_digit+0x199>
lea    -0x12(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11e7 <get_hex_digit+0xc7>
lea    -0x12(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11f3 <get_hex_digit+0xd3>
movl   $0xc,-0x4(%rbp)
jmp    12b9 <get_hex_digit+0x199>
lea    -0x12(%rbp),%rdi
lea    0xe0e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1225 <get_hex_digit+0x105>
lea    -0x12(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1231 <get_hex_digit+0x111>
movl   $0xd,-0x4(%rbp)
jmp    12b9 <get_hex_digit+0x199>
lea    -0x12(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1263 <get_hex_digit+0x143>
lea    -0x12(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    126f <get_hex_digit+0x14f>
movl   $0xe,-0x4(%rbp)
jmp    12b9 <get_hex_digit+0x199>
lea    -0x12(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     12a1 <get_hex_digit+0x181>
lea    -0x12(%rbp),%rdi
lea    0xd83(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    12ad <get_hex_digit+0x18d>
movl   $0xf,-0x4(%rbp)
jmp    12b9 <get_hex_digit+0x199>
lea    -0x12(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_hex_digit>:
push   %rax
mov    (%rdi),%al
mov    %al,0x6(%rsp)
movb   $0x0,0x7(%rsp)
mov    $0xa,%eax
cmpw   $0x61,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
cmpw   $0x41,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
mov    $0xb,%eax
cmpw   $0x62,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
cmpw   $0x42,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
mov    $0xc,%eax
cmpw   $0x63,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
cmpw   $0x43,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
mov    $0xd,%eax
cmpw   $0x64,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
cmpw   $0x44,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
mov    $0xe,%eax
cmpw   $0x65,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
cmpw   $0x45,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
mov    $0xf,%eax
cmpw   $0x66,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
cmpw   $0x46,0x6(%rsp)
je     11a4 <get_hex_digit+0x94>
lea    0x6(%rsp),%rdi
call   1030 <atoi@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"A\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [2 x i8] c"B\00"
@.str.4 = [2 x i8] c"c\00"
@.str.5 = [2 x i8] c"C\00"
@.str.6 = [2 x i8] c"d\00"
@.str.7 = [2 x i8] c"D\00"
@.str.8 = [2 x i8] c"e\00"
@.str.9 = [2 x i8] c"E\00"
@.str.10 = [2 x i8] c"f\00"
@.str.11 = [2 x i8] c"F\00"
define i32 @get_hex_digit(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [2 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
store i8 %6, i8* %7
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
store i8 0, i8* %8
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %12, %1
store i32 10, i32* %2
br label %65
17: ; preds = %12
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %21, %17
store i32 11, i32* %2
br label %65
26: ; preds = %21
%27 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %30, %26
store i32 12, i32* %2
br label %65
35: ; preds = %30
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %39, %35
store i32 13, i32* %2
br label %65
44: ; preds = %39
%45 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%50 = call i32 @strcmp(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%51 = icmp ne i32 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %48, %44
store i32 14, i32* %2
br label %65
53: ; preds = %48
%54 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%55 = call i32 @strcmp(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%59 = call i32 @strcmp(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%60 = icmp ne i32 %59, 0
br i1 %60, label %62, label %61
61: ; preds = %57, %53
store i32 15, i32* %2
br label %65
62: ; preds = %57
%63 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%64 = call i32 @atoi(i8* %63)
store i32 %64, i32* %2
br label %65
65: ; preds = %62, %61, %52, %43, %34, %25, %16
%66 = load i32, i32* %2
ret i32 %66
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"A\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [2 x i8] c"B\00"
@.str.4 = [2 x i8] c"c\00"
@.str.5 = [2 x i8] c"C\00"
@.str.6 = [2 x i8] c"d\00"
@.str.7 = [2 x i8] c"D\00"
@.str.8 = [2 x i8] c"e\00"
@.str.9 = [2 x i8] c"E\00"
@.str.10 = [2 x i8] c"f\00"
@.str.11 = [2 x i8] c"F\00"
define i32 @get_hex_digit(i8* nocapture %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
store i8 %4, i8* %3
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 0, i8* %5
%6 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i64 2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %43, label %8
8: ; preds = %1
%9 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i64 2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %43, label %11
11: ; preds = %8
%12 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64 2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %43, label %14
14: ; preds = %11
%15 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i64 2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %43, label %17
17: ; preds = %14
%18 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i64 2)
%19 = icmp eq i32 %18, 0
br i1 %19, label %43, label %20
20: ; preds = %17
%21 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i64 2)
%22 = icmp eq i32 %21, 0
br i1 %22, label %43, label %23
23: ; preds = %20
%24 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i64 2)
%25 = icmp eq i32 %24, 0
br i1 %25, label %43, label %26
26: ; preds = %23
%27 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i64 2)
%28 = icmp eq i32 %27, 0
br i1 %28, label %43, label %29
29: ; preds = %26
%30 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i64 2)
%31 = icmp eq i32 %30, 0
br i1 %31, label %43, label %32
32: ; preds = %29
%33 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i64 2)
%34 = icmp eq i32 %33, 0
br i1 %34, label %43, label %35
35: ; preds = %32
%36 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i64 2)
%37 = icmp eq i32 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %35
%39 = call i32 @bcmp(i8* dereferenceable(2) %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i64 2)
%40 = icmp eq i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %38
%42 = call i32 @atoi(i8* %3)
br label %43
43: ; preds = %35, %38, %29, %32, %23, %26, %17, %20, %11, %14, %1, %8, %41
%44 = phi i32 [ %42, %41 ], [ 10, %8 ], [ 10, %1 ], [ 11, %14 ], [ 11, %11 ], [ 12, %20 ], [ 12, %17 ], [ 13, %26 ], [ 13, %23 ], [ 14, %32 ], [ 14, %29 ], [ 15, %38 ], [ 15, %35 ]
ret i32 %44
}