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


x86 assembly (clang, -O0):
<iscsiAuthClientTextToNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1171 <iscsiAuthClientTextToNumber+0x61>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
je     1152 <iscsiAuthClientTextToNumber+0x42>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x58,%eax
jne    1171 <iscsiAuthClientTextToNumber+0x61>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strtoul@plt>
mov    %rax,-0x28(%rbp)
jmp    1187 <iscsiAuthClientTextToNumber+0x77>
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     11be <iscsiAuthClientTextToNumber+0xae>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11be <iscsiAuthClientTextToNumber+0xae>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11c5 <iscsiAuthClientTextToNumber+0xb5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @iscsiAuthClientTextToNumber(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
}