#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 */
scalar_t__ isalnum(int);
int strlen(char *);
int isxdigit(int c) {
  char hexmap[] = "0123456789ABCDEFabcdef";
  if (isalnum(c))
    for (int i = 0; i < strlen(hexmap); ++i)
      if (c == hexmap[i])
        return 1;
  return 0;
}


x86 assembly (clang, -O0):
<isxdigit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec9(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xec3(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xebb(%rip),%al
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
je     11cb <isxdigit+0xab>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11c6 <isxdigit+0xa6>
mov    -0x8(%rbp),%eax
movslq -0x24(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11b3 <isxdigit+0x93>
movl   $0x1,-0x4(%rbp)
jmp    11d2 <isxdigit+0xb2>
jmp    11b8 <isxdigit+0x98>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1177 <isxdigit+0x57>
jmp    11cb <isxdigit+0xab>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isxdigit>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
movaps 0xecf(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x66656463626146,%rax
mov    %rax,0xf(%rsp)
call   1040 <isalnum@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1194 <isxdigit+0x74>
mov    %rsp,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1194 <isxdigit+0x74>
xor    %ebp,%ebp
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbp,1),%eax
cmp    %ebx,%eax
je     118f <isxdigit+0x6f>
add    $0x1,%rbp
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1170 <isxdigit+0x50>
xor    %ebp,%ebp
jmp    1194 <isxdigit+0x74>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.isxdigit.hexmap = [23 x i8] c"0123456789ABCDEFabcdef\00"
define i32 @isxdigit(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [23 x i8]
%5 = alloca i32
store i32 %0, i32* %3
%6 = bitcast [23 x i8]* %4 to i8*
%7 = load i32, i32* %3
%8 = call i64 @isalnum(i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %30
10: ; preds = %1
store i32 0, i32* %5
br label %11
11: ; preds = %26, %10
%12 = load i32, i32* %5
%13 = getelementptr inbounds [23 x i8], [23 x i8]* %4, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %29
16: ; preds = %11
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [23 x i8], [23 x i8]* %4, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %17, %22
br i1 %23, label %24, label %25
24: ; preds = %16
store i32 1, i32* %2
br label %31
25: ; preds = %16
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %11
29: ; preds = %11
br label %30
30: ; preds = %29, %1
store i32 0, i32* %2
br label %31
31: ; preds = %30, %24
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@__const.isxdigit.hexmap = [23 x i8] c"0123456789ABCDEFabcdef\00"
define i32 @isxdigit(i32 %0) {
%2 = alloca [23 x i8]
%3 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @isalnum(i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %20, label %6
6: ; preds = %1
%7 = call i32 @strlen(i8* %3)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %13, label %20
9: ; preds = %13
%10 = call i32 @strlen(i8* %3)
%11 = sext i32 %10 to i64
%12 = icmp slt i64 %19, %11
br i1 %12, label %13, label %20
13: ; preds = %6, %9
%14 = phi i64 [ %19, %9 ], [ 0, %6 ]
%15 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, %0
%19 = add nuw nsw i64 %14, 1
br i1 %18, label %20, label %9
20: ; preds = %13, %9, %6, %1
%21 = phi i32 [ 0, %1 ], [ 0, %6 ], [ 1, %13 ], [ 0, %9 ]
ret i32 %21
}