#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 */
float bg(char);
int strlen(char *);
int checkPosHex(char *hex) {
  int len = strlen(hex);
  for (int i = 0; i < len; i++) {
    if (hex[i] >= '0' && hex[i] <= '9')
      continue;
    if (bg(hex[i]) >= 'A' && bg(hex[i]) <= 'F')
      continue;
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkPosHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e0 <checkPosHex+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     117a <checkPosHex+0x5a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jg     117a <checkPosHex+0x5a>
jmp    11d2 <checkPosHex+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <bg@plt>
movss  0xe6d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11c6 <checkPosHex+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <bg@plt>
movaps %xmm0,%xmm1
movss  0xe4c(%rip),%xmm0
ucomiss %xmm1,%xmm0
jb     11c6 <checkPosHex+0xa6>
jmp    11d2 <checkPosHex+0xb2>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <checkPosHex+0xc7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113f <checkPosHex+0x1f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkPosHex>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
call   1040 <strlen@plt>
test   %eax,%eax
jle    11a2 <checkPosHex+0x82>
mov    %eax,%r14d
mov    %r14,%r15
neg    %r15
mov    $0x1,%bpl
mov    $0x1,%ebx
jmp    1169 <checkPosHex+0x49>
nopw   0x0(%rax,%rax,1)
cmp    %r14,%rbx
setb   %bpl
lea    (%r15,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
je     11a4 <checkPosHex+0x84>
movzbl -0x1(%r12,%rbx,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0xa,%cl
jb     1150 <checkPosHex+0x30>
movsbl %al,%edi
call   1030 <bg@plt>
ucomiss 0xe7a(%rip),%xmm0
jb     11a4 <checkPosHex+0x84>
movsbl -0x1(%r12,%rbx,1),%edi
call   1030 <bg@plt>
movss  0xe69(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1150 <checkPosHex+0x30>
jmp    11a4 <checkPosHex+0x84>
xor    %ebp,%ebp
not    %bpl
movzbl %bpl,%eax
and    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkPosHex(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %47, %1
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %50
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp sge i32 %18, 48
br i1 %19, label %20, label %29
20: ; preds = %12
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp sle i32 %26, 57
br i1 %27, label %28, label %29
28: ; preds = %20
br label %47
29: ; preds = %20, %12
%30 = load i8*, i8** %3
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = call float @bg(i8 signext %34)
%36 = fcmp oge float %35, 6.500000e+01
br i1 %36, label %37, label %46
37: ; preds = %29
%38 = load i8*, i8** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = call float @bg(i8 signext %42)
%44 = fcmp ole float %43, 7.000000e+01
br i1 %44, label %45, label %46
45: ; preds = %37
br label %47
46: ; preds = %37, %29
store i32 0, i32* %2
br label %51
47: ; preds = %45, %28
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %8
50: ; preds = %8
store i32 1, i32* %2
br label %51
51: ; preds = %50, %46
%52 = load i32, i32* %2
ret i32 %52
}

LLVM IR (-O2):
define i32 @checkPosHex(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %25
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %4, %21
%8 = phi i64 [ 0, %4 ], [ %22, %21 ]
%9 = phi i1 [ true, %4 ], [ %23, %21 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %8
%11 = load i8, i8* %10
%12 = add i8 %11, -48
%13 = icmp ult i8 %12, 10
br i1 %13, label %21, label %14
14: ; preds = %7
%15 = tail call float @bg(i8 signext %11)
%16 = fcmp ult float %15, 6.500000e+01
br i1 %16, label %25, label %17
17: ; preds = %14
%18 = load i8, i8* %10
%19 = tail call float @bg(i8 signext %18)
%20 = fcmp ugt float %19, 7.000000e+01
br i1 %20, label %25, label %21
21: ; preds = %7, %17
%22 = add nuw nsw i64 %8, 1
%23 = icmp ult i64 %22, %5
%24 = icmp eq i64 %22, %6
br i1 %24, label %25, label %7
25: ; preds = %21, %17, %14, %1
%26 = phi i1 [ false, %1 ], [ %9, %14 ], [ %9, %17 ], [ %23, %21 ]
%27 = xor i1 %26, true
%28 = zext i1 %27 to i32
ret i32 %28
}