#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 */
int /*<<< orphan*/ dod_exit(char *, char const *);
scalar_t__ errno;
int /*<<< orphan*/ *strchr(char const *, char);
unsigned long long strtoull(char const *, char **, int /*<<< orphan*/);
unsigned long long dod_strtoull(char const *s) {
  if (strchr(s, '-') != NULL)
    dod_exit("opt:integer must be non-negative:<%s>", s);
  char *p;
  errno = 0;
  unsigned long long i = strtoull(s, &p, 0);
  if ((errno != 0) || p[0])
    dod_exit("dod:invalid integer:<%s>", s);
  return i;
}


x86 assembly (clang, -O0):
<dod_strtoull>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2d,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1164 <dod_strtoull+0x34>
mov    -0x8(%rbp),%rsi
lea    0xea1(%rip),%rdi
call   1030 <dod_exit@plt>
mov    0x2e75(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1050 <strtoull@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e54(%rip),%rax
cmpq   $0x0,(%rax)
jne    11a6 <dod_strtoull+0x76>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b6 <dod_strtoull+0x86>
mov    -0x8(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1030 <dod_exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dod_strtoull>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    $0x2d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     115a <dod_strtoull+0x2a>
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
call   1030 <dod_exit@plt>
mov    0x2e7f(%rip),%r15
movq   $0x0,(%r15)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <strtoull@plt>
mov    %rax,%r14
cmpq   $0x0,(%r15)
jne    118a <dod_strtoull+0x5a>
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1199 <dod_strtoull+0x69>
lea    0xe95(%rip),%rdi
mov    %rbx,%rsi
call   1030 <dod_exit@plt>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [38 x i8] c"opt:integer must be non-negative:<%s>\00"
@errno = global i64 0
@.str.1 = [25 x i8] c"dod:invalid integer:<%s>\00"
define i64 @dod_strtoull(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @strchr(i8* %5, i8 signext 45)
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @dod_exit(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %8, %1
store i64 0, i64* @errno
%12 = load i8*, i8** %2
%13 = call i64 @strtoull(i8* %12, i8** %3, i32 0)
store i64 %13, i64* %4
%14 = load i64, i64* @errno
%15 = icmp ne i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16, %11
%23 = load i8*, i8** %2
%24 = call i32 @dod_exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %22, %16
%26 = load i64, i64* %4
ret i64 %26
}

LLVM IR (-O2):
@.str = [38 x i8] c"opt:integer must be non-negative:<%s>\00"
@errno = global i64 0
@.str.1 = [25 x i8] c"dod:invalid integer:<%s>\00"
define i64 @dod_strtoull(i8* %0) {
%2 = alloca i8*
%3 = tail call i32* @strchr(i8* %0, i8 signext 45)
%4 = icmp eq i32* %3, null
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @dod_exit(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %7
7: ; preds = %5, %1
%8 = bitcast i8** %2 to i8*
store i64 0, i64* @errno
%9 = call i64 @strtoull(i8* %0, i8** %2, i32 0)
%10 = load i64, i64* @errno
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12, %7
%17 = tail call i32 @dod_exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %18
18: ; preds = %16, %12
ret i64 %9
}