#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 */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
scalar_t__ errno;
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ strtoull(char const *, char **, int /*<<< orphan*/);
uint64_t *parse_number64(const char *argv) {
  uint64_t *n = malloc(sizeof(*n));
  char *endptr;
  if (!argv)
    return NULL;
  errno = 0;
  *n = strtoull(argv, &endptr, 0);
  if (errno || *endptr != '\0')
    return NULL;
  return n;
}


x86 assembly (clang, -O0):
<parse_number64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1152 <parse_number64+0x32>
movq   $0x0,-0x8(%rbp)
jmp    11ad <parse_number64+0x8d>
mov    0x2e87(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtoull@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2e62(%rip),%rax
cmpq   $0x0,(%rax)
jne    1198 <parse_number64+0x78>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a5 <parse_number64+0x85>
movq   $0x0,-0x8(%rbp)
jmp    11ad <parse_number64+0x8d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_number64>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x4,%edi
call   1040 <malloc@plt>
test   %rbx,%rbx
je     1176 <parse_number64+0x56>
mov    %rax,%r14
mov    0x2e9c(%rip),%r12
movq   $0x0,(%r12)
mov    %rsp,%rsi
xor    %r15d,%r15d
mov    %rbx,%rdi
xor    %edx,%edx
call   1030 <strtoull@plt>
mov    %eax,(%r14)
cmpq   $0x0,(%r12)
jne    1179 <parse_number64+0x59>
mov    (%rsp),%rax
xor    %r15d,%r15d
cmpb   $0x0,(%rax)
cmove  %r14,%r15
jmp    1179 <parse_number64+0x59>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@errno = global i64 0
define noalias i32* @parse_number64(i8* %0) {
%2 = alloca i8*
%3 = tail call i32* @malloc(i32 4)
%4 = bitcast i8** %2 to i8*
%5 = icmp eq i8* %0, null
br i1 %5, label %15, label %6
6: ; preds = %1
store i64 0, i64* @errno
%7 = call i32 @strtoull(i8* %0, i8** %2, i32 0)
store i32 %7, i32* %3
%8 = load i64, i64* @errno
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
%14 = select i1 %13, i32* %3, i32* null
br label %15
15: ; preds = %10, %6, %1
%16 = phi i32* [ null, %1 ], [ null, %6 ], [ %14, %10 ]
ret i32* %16
}