#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 */
scalar_t__ isspace(char const);
int scan_for_uint64_npre(char const *, unsigned int, unsigned long long,
                         unsigned long long *, char const **);
int scan_for_uint64_pre(const char *_str, unsigned long long max,
                        unsigned long long *ret_, const char **end_) {
  unsigned int base = 10;
  while (isspace(*_str)) {
    ++_str;
  }
  if (*_str == '0') {
    unsigned int n = *(_str + 1);
    if (n == 'x' || n == 'X') {
      base = 16;
      _str += 2;
    } else if (n == 'b' || n == 'B') {
      base = 2;
      _str += 2;
    } else {
      base = 8;
    }
  }
  return scan_for_uint64_npre(_str, base, max, ret_, end_);
}


x86 assembly (clang, -O0):
<scan_for_uint64_pre>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0xa,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1166 <scan_for_uint64_pre+0x46>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113f <scan_for_uint64_pre+0x1f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    11ea <scan_for_uint64_pre+0xca>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x78,-0x28(%rbp)
je     1195 <scan_for_uint64_pre+0x75>
cmpl   $0x58,-0x28(%rbp)
jne    11ad <scan_for_uint64_pre+0x8d>
movl   $0x10,-0x24(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    11e5 <scan_for_uint64_pre+0xc5>
cmpl   $0x62,-0x28(%rbp)
je     11c1 <scan_for_uint64_pre+0xa1>
cmpl   $0x42,-0x28(%rbp)
jne    11d9 <scan_for_uint64_pre+0xb9>
movl   $0x2,-0x24(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    11e0 <scan_for_uint64_pre+0xc0>
movl   $0x8,-0x24(%rbp)
jmp    11e5 <scan_for_uint64_pre+0xc5>
jmp    11ea <scan_for_uint64_pre+0xca>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1040 <scan_for_uint64_npre@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_for_uint64_pre>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isspace@plt>
test   %rax,%rax
jne    1140 <scan_for_uint64_pre+0x20>
mov    $0xa,%esi
cmpb   $0x30,(%rbx)
jne    1188 <scan_for_uint64_pre+0x68>
mov    0x1(%rbx),%al
and    $0xdf,%al
cmp    $0x58,%al
jne    1170 <scan_for_uint64_pre+0x50>
add    $0x2,%rbx
mov    $0x10,%esi
jmp    1188 <scan_for_uint64_pre+0x68>
xor    %ecx,%ecx
cmp    $0x42,%al
sete   %cl
mov    $0x2,%eax
mov    $0x8,%esi
cmove  %eax,%esi
lea    (%rbx,%rcx,2),%rbx
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <scan_for_uint64_npre@plt>

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

LLVM IR (-O2):
define i32 @scan_for_uint64_pre(i8* %0, i64 %1, i64* %2, i8** %3) {
br label %5
5: ; preds = %5, %4
%6 = phi i8* [ %0, %4 ], [ %10, %5 ]
%7 = load i8, i8* %6
%8 = tail call i64 @isspace(i8 signext %7)
%9 = icmp eq i64 %8, 0
%10 = getelementptr inbounds i8, i8* %6, i64 1
br i1 %9, label %11, label %5
11: ; preds = %5
%12 = load i8, i8* %6
%13 = icmp eq i8 %12, 48
br i1 %13, label %14, label %25
14: ; preds = %11
%15 = load i8, i8* %10
%16 = and i8 %15, -33
%17 = icmp eq i8 %16, 88
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = getelementptr inbounds i8, i8* %6, i64 2
br label %25
20: ; preds = %14
%21 = icmp eq i8 %16, 66
%22 = select i1 %21, i32 2, i32 8
%23 = select i1 %21, i64 2, i64 0
%24 = getelementptr i8, i8* %6, i64 %23
br label %25
25: ; preds = %20, %18, %11
%26 = phi i32 [ 10, %11 ], [ 16, %18 ], [ %22, %20 ]
%27 = phi i8* [ %6, %11 ], [ %19, %18 ], [ %24, %20 ]
%28 = tail call i32 @scan_for_uint64_npre(i8* %27, i32 %26, i64 %1, i64* %2, i8** %3)
ret i32 %28
}