#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*/ btp_skip_char(char const **, char);
scalar_t__ btp_skip_char_span(char const **, char *);
int btp_skip_hexadecimal_number(const char **input) {
  const char *local_input = *input;
  if (!btp_skip_char(&local_input, '0'))
    return 0;
  if (!btp_skip_char(&local_input, 'x'))
    return 0;
  int count = 2;
  count += btp_skip_char_span(&local_input, "abcdef0123456789");
  if (2 == count)
    return 0;
  *input = local_input;
  return count;
}


x86 assembly (clang, -O0):
<btp_skip_hexadecimal_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
mov    $0x30,%esi
call   1040 <btp_skip_char@plt>
cmp    $0x0,%eax
jne    115a <btp_skip_hexadecimal_number+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    11cc <btp_skip_hexadecimal_number+0xac>
lea    -0x18(%rbp),%rdi
mov    $0x78,%esi
call   1040 <btp_skip_char@plt>
cmp    $0x0,%eax
jne    117d <btp_skip_hexadecimal_number+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    11cc <btp_skip_hexadecimal_number+0xac>
movl   $0x2,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1030 <btp_skip_char_span@plt>
mov    %rax,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    $0x2,%eax
cmp    -0x1c(%rbp),%eax
jne    11bb <btp_skip_hexadecimal_number+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    11cc <btp_skip_hexadecimal_number+0xac>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<btp_skip_hexadecimal_number>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
mov    $0x30,%esi
call   1040 <btp_skip_char@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1170 <btp_skip_hexadecimal_number+0x50>
mov    %rsp,%rdi
mov    $0x78,%esi
call   1040 <btp_skip_char@plt>
test   %eax,%eax
je     1170 <btp_skip_hexadecimal_number+0x50>
lea    0xea8(%rip),%rsi
mov    %rsp,%rdi
call   1030 <btp_skip_char_span@plt>
test   %eax,%eax
je     1170 <btp_skip_hexadecimal_number+0x50>
add    $0x2,%eax
mov    (%rsp),%rcx
mov    %rcx,(%rbx)
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"abcdef0123456789\00"
define i32 @btp_skip_hexadecimal_number(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
store i8** %0, i8*** %3
%6 = load i8**, i8*** %3
%7 = load i8*, i8** %6
store i8* %7, i8** %4
%8 = call i32 @btp_skip_char(i8** %4, i8 signext 48)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 0, i32* %2
br label %28
11: ; preds = %1
%12 = call i32 @btp_skip_char(i8** %4, i8 signext 120)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %11
store i32 0, i32* %2
br label %28
15: ; preds = %11
store i32 2, i32* %5
%16 = call i64 @btp_skip_char_span(i8** %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = add nsw i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = icmp eq i32 2, %21
br i1 %22, label %23, label %24
23: ; preds = %15
store i32 0, i32* %2
br label %28
24: ; preds = %15
%25 = load i8*, i8** %4
%26 = load i8**, i8*** %3
store i8* %25, i8** %26
%27 = load i32, i32* %5
store i32 %27, i32* %2
br label %28
28: ; preds = %24, %23, %14, %10
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [17 x i8] c"abcdef0123456789\00"
define i32 @btp_skip_hexadecimal_number(i8** nocapture %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = load i8*, i8** %0
store i8* %4, i8** %2
%5 = call i32 @btp_skip_char(i8** %2, i8 signext 48)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %1
%8 = call i32 @btp_skip_char(i8** %2, i8 signext 120)
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = call i64 @btp_skip_char_span(i8** %2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%12 = trunc i64 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = add i32 %12, 2
%16 = load i8*, i8** %2
store i8* %16, i8** %0
br label %17
17: ; preds = %14, %10, %7, %1
%18 = phi i32 [ 0, %1 ], [ 0, %7 ], [ %15, %14 ], [ 0, %10 ]
ret i32 %18
}