#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*/ isHexaDigit(char const);
char getCharFromUnicode(char const *str) {
  unsigned int i;
  for (i = 0; i < 4; ++i)
    if (!isHexaDigit(str[i]))
      return '\0';
  return '?';
}


x86 assembly (clang, -O0):
<getCharFromUnicode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jae    1162 <getCharFromUnicode+0x52>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <isHexaDigit@plt>
cmp    $0x0,%eax
jne    114f <getCharFromUnicode+0x3f>
movb   $0x0,-0x1(%rbp)
jmp    1166 <getCharFromUnicode+0x56>
jmp    1154 <getCharFromUnicode+0x44>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <getCharFromUnicode+0x13>
movb   $0x3f,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCharFromUnicode>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <isHexaDigit@plt>
test   %eax,%eax
je     1151 <getCharFromUnicode+0x41>
movsbl 0x1(%rbx),%edi
call   1030 <isHexaDigit@plt>
test   %eax,%eax
je     1151 <getCharFromUnicode+0x41>
movsbl 0x2(%rbx),%edi
call   1030 <isHexaDigit@plt>
test   %eax,%eax
je     1151 <getCharFromUnicode+0x41>
movsbl 0x3(%rbx),%edi
call   1030 <isHexaDigit@plt>
mov    %eax,%ecx
test   %eax,%eax
mov    $0x3f,%eax
cmove  %ecx,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @getCharFromUnicode(i8* %0) {
%2 = alloca i8
%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 ult i32 %6, 4
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = call i32 @isHexaDigit(i8 signext %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %8
store i8 0, i8* %2
br label %22
17: ; preds = %8
br label %18
18: ; preds = %17
%19 = load i32, i32* %4
%20 = add i32 %19, 1
store i32 %20, i32* %4
br label %5
21: ; preds = %5
store i8 63, i8* %2
br label %22
22: ; preds = %21, %16
%23 = load i8, i8* %2
ret i8 %23
}

LLVM IR (-O2):
define signext i8 @getCharFromUnicode(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @isHexaDigit(i8 signext %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 @isHexaDigit(i8 signext %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 @isHexaDigit(i8 signext %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 @isHexaDigit(i8 signext %17)
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i8 0, i8 63
br label %21
21: ; preds = %15, %10, %5, %1
%22 = phi i8 [ 0, %1 ], [ 0, %5 ], [ 0, %10 ], [ %20, %15 ]
ret i8 %22
}