#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 int _parse_integer(char const *, unsigned int, unsigned long long *);
char *_parse_integer_fixup_radix(char const *, unsigned int *);
unsigned long long simple_strtoull(const char *cp, char **endp,
                                   unsigned int base) {
  unsigned long long result;
  unsigned int rv;
  cp = _parse_integer_fixup_radix(cp, &base);
  rv = _parse_integer(cp, base, &result);
  cp += (rv & ~(1U << 31));
  if (endp)
    *endp = (char *)cp;
  return result;
}


x86 assembly (clang, -O0):
<simple_strtoull>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <_parse_integer_fixup_radix@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   1040 <_parse_integer@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
and    $0x7fffffff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1183 <simple_strtoull+0x63>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_strtoull>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edx,0xc(%rsp)
lea    0xc(%rsp),%rsi
call   1030 <_parse_integer_fixup_radix@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
call   1040 <_parse_integer@plt>
test   %r14,%r14
je     115c <simple_strtoull+0x3c>
and    $0x7fffffff,%eax
add    %rax,%rbx
mov    %rbx,(%r14)
mov    0x10(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @simple_strtoull(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i8* @_parse_integer_fixup_radix(i8* %9, i32* %6)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = load i32, i32* %6
%13 = call i32 @_parse_integer(i8* %11, i32 %12, i64* %7)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = and i32 %14, 2147483647
%16 = load i8*, i8** %4
%17 = zext i32 %15 to i64
%18 = getelementptr inbounds i8, i8* %16, i64 %17
store i8* %18, i8** %4
%19 = load i8**, i8*** %5
%20 = icmp ne i8** %19, null
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = load i8*, i8** %4
%23 = load i8**, i8*** %5
store i8* %22, i8** %23
br label %24
24: ; preds = %21, %3
%25 = load i64, i64* %7
ret i64 %25
}

LLVM IR (-O2):
define i64 @simple_strtoull(i8* %0, i8** writeonly %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64
store i32 %2, i32* %4
%6 = bitcast i64* %5 to i8*
%7 = call i8* @_parse_integer_fixup_radix(i8* %0, i32* %4)
%8 = load i32, i32* %4
%9 = call i32 @_parse_integer(i8* %7, i32 %8, i64* %5)
%10 = icmp eq i8** %1, null
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = and i32 %9, 2147483647
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %7, i64 %13
store i8* %14, i8** %1
br label %15
15: ; preds = %11, %3
%16 = load i64, i64* %5
ret i64 %16
}