#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 */
struct expr {
  int dummy;
};

/* Variables and functions */
int isxdigit(char const);
int find_hex(const char *remain, struct expr *e) {
  if (remain[0] == '0' && remain[1] == 'x' && isxdigit(remain[2]))
    return 1;
  return isxdigit(*remain);
}


x86 assembly (clang, -O0):
<find_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1163 <find_hex+0x53>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
jne    1163 <find_hex+0x53>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <isxdigit@plt>
cmp    $0x0,%eax
je     1163 <find_hex+0x53>
movl   $0x1,-0x4(%rbp)
jmp    1172 <find_hex+0x62>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isxdigit@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_hex>:
push   %rbx
mov    (%rdi),%al
cmp    $0x30,%al
jne    1138 <find_hex+0x28>
mov    %rdi,%rbx
mov    $0x30,%al
cmpb   $0x78,0x1(%rdi)
jne    1138 <find_hex+0x28>
movsbl 0x2(%rbx),%edi
call   1030 <isxdigit@plt>
test   %eax,%eax
je     1136 <find_hex+0x26>
mov    $0x1,%eax
pop    %rbx
ret
mov    (%rbx),%al
movsbl %al,%edi
pop    %rbx
jmp    1030 <isxdigit@plt>

LLVM IR (-O0):
%struct.expr = type { i32 }
define i32 @find_hex(i8* %0, %struct.expr* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.expr*
store i8* %0, i8** %4
store %struct.expr* %1, %struct.expr** %5
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 48
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 120
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8, i8* %19
%21 = call i32 @isxdigit(i8 signext %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 1, i32* %3
br label %28
24: ; preds = %17, %11, %2
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = call i32 @isxdigit(i8 signext %26)
store i32 %27, i32* %3
br label %28
28: ; preds = %24, %23
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.expr = type { i32 }
define i32 @find_hex(i8* nocapture %0, %struct.expr* nocapture readnone %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 48
br i1 %4, label %5, label %16
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 120
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = tail call i32 @isxdigit(i8 signext %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i8, i8* %0
br label %16
16: ; preds = %14, %5, %2
%17 = phi i8 [ %15, %14 ], [ 48, %5 ], [ %3, %2 ]
%18 = tail call i32 @isxdigit(i8 signext %17)
br label %19
19: ; preds = %9, %16
%20 = phi i32 [ %18, %16 ], [ 1, %9 ]
ret i32 %20
}