#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 */
unsigned long strtoul(char const *, char **, int);
int acl_text_to_number(const char *text, unsigned long *num) {
  char *end;
  unsigned long number = *num;
  if (text[0] == '0' && (text[1] == 'x' || text[1] == 'X'))
    number = strtoul(text + 2, &end, 16);
  else
    number = strtoul(text, &end, 10);
  if (*text != '\0' && *end == '\0') {
    *num = number;
    return 0;
  } else
    return 1;
}


x86 assembly (clang, -O0):
<acl_text_to_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    117c <acl_text_to_number+0x6c>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
je     115d <acl_text_to_number+0x4d>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x58,%eax
jne    117c <acl_text_to_number+0x6c>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strtoul@plt>
mov    %rax,-0x28(%rbp)
jmp    1192 <acl_text_to_number+0x82>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c9 <acl_text_to_number+0xb9>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c9 <acl_text_to_number+0xb9>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11d0 <acl_text_to_number+0xc0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acl_text_to_number>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
cmpb   $0x30,(%rdi)
jne    1136 <acl_text_to_number+0x26>
mov    0x1(%rbx),%al
or     $0x20,%al
cmp    $0x78,%al
jne    1136 <acl_text_to_number+0x26>
lea    0x2(%rbx),%rdi
mov    %rsp,%rsi
mov    $0x10,%edx
jmp    1141 <acl_text_to_number+0x31>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    $0x1,%ecx
cmpb   $0x0,(%rbx)
je     115e <acl_text_to_number+0x4e>
mov    (%rsp),%rdx
cmpb   $0x0,(%rdx)
jne    115e <acl_text_to_number+0x4e>
mov    %rax,(%r14)
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @acl_text_to_number(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i64* %1, i64** %5
%8 = load i64*, i64** %5
%9 = load i64, i64* %8
store i64 %9, i64* %7
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 48
br i1 %14, label %15, label %31
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 120
br i1 %20, label %27, label %21
21: ; preds = %15
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 88
br i1 %26, label %27, label %31
27: ; preds = %21, %15
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 2
%30 = call i64 @strtoul(i8* %29, i8** %6, i32 16)
store i64 %30, i64* %7
br label %34
31: ; preds = %21, %2
%32 = load i8*, i8** %4
%33 = call i64 @strtoul(i8* %32, i8** %6, i32 10)
store i64 %33, i64* %7
br label %34
34: ; preds = %31, %27
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %47
39: ; preds = %34
%40 = load i8*, i8** %6
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load i64, i64* %7
%46 = load i64*, i64** %5
store i64 %45, i64* %46
store i32 0, i32* %3
br label %48
47: ; preds = %39, %34
store i32 1, i32* %3
br label %48
48: ; preds = %47, %44
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
define i32 @acl_text_to_number(i8* %0, i64* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 48
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
switch i8 %9, label %13 [
i8 120, label %10
i8 88, label %10
]
10: ; preds = %7, %7
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = call i64 @strtoul(i8* %11, i8** %3, i32 16)
br label %15
13: ; preds = %7, %2
%14 = call i64 @strtoul(i8* %0, i8** %3, i32 10)
br label %15
15: ; preds = %13, %10
%16 = phi i64 [ %12, %10 ], [ %14, %13 ]
%17 = load i8, i8* %0
%18 = icmp eq i8 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i64 %16, i64* %1
br label %24
24: ; preds = %15, %19, %23
%25 = phi i32 [ 0, %23 ], [ 1, %19 ], [ 1, %15 ]
ret i32 %25
}