#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*/ isxdigit(unsigned char);
int jsonIs4Hex(const char *z) {
  int i;
  for (i = 0; i < 4; i++)
    if (!isxdigit((unsigned char)(z[i])))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<jsonIs4Hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1166 <jsonIs4Hex+0x56>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <isxdigit@plt>
cmp    $0x0,%eax
jne    1153 <jsonIs4Hex+0x43>
movl   $0x0,-0x4(%rbp)
jmp    116d <jsonIs4Hex+0x5d>
jmp    1158 <jsonIs4Hex+0x48>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <jsonIs4Hex+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jsonIs4Hex>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
movzbl (%rdi),%edi
call   1030 <isxdigit@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     114f <jsonIs4Hex+0x3f>
movzbl 0x1(%rbx),%edi
call   1030 <isxdigit@plt>
test   %eax,%eax
je     114f <jsonIs4Hex+0x3f>
movzbl 0x2(%rbx),%edi
call   1030 <isxdigit@plt>
test   %eax,%eax
je     114f <jsonIs4Hex+0x3f>
movzbl 0x3(%rbx),%edi
call   1030 <isxdigit@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @jsonIs4Hex(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %18, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 4
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = call i32 @isxdigit(i8 zeroext %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %8
store i32 0, i32* %2
br label %22
17: ; preds = %8
br label %18
18: ; preds = %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %5
21: ; preds = %5
store i32 1, i32* %2
br label %22
22: ; preds = %21, %16
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @jsonIs4Hex(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @isxdigit(i8 zeroext %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = tail call i32 @isxdigit(i8 zeroext %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = load i8, i8* %11
%13 = tail call i32 @isxdigit(i8 zeroext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %10
%16 = getelementptr inbounds i8, i8* %0, i64 3
%17 = load i8, i8* %16
%18 = tail call i32 @isxdigit(i8 zeroext %17)
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %15, %10, %5, %1
%22 = phi i32 [ 0, %1 ], [ 0, %5 ], [ 0, %10 ], [ %20, %15 ]
ret i32 %22
}