#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*/ EINVAL;
int /*<<< orphan*/ ERANGE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ mx_strtoull(char *, unsigned long long *);
void test_mx_strtoull(void) {
  unsigned long long int l;
  assert(mx_strtoull("123", &l) == 0);
  assert(l == 123);
  assert(mx_strtoull("0173", &l) == 0);
  assert(l == 123);
  assert(mx_strtoull("0x007b", &l) == 0);
  assert(l == 123);
  assert(mx_strtoull("0x00000000000000000000000000000007b", &l) == 0);
  assert(l == 123);
  assert(mx_strtoull("0x007B", &l) == 0);
  assert(l == 123);
  assert(mx_strtoull("-127", &l) == -ERANGE);
  assert(mx_strtoull(" -128", &l) == -ERANGE);
  assert(mx_strtoull("0888", &l) == -EINVAL);
  assert(mx_strtoull("1.2", &l) == -EINVAL);
  assert(mx_strtoull("1,2", &l) == -EINVAL);
  assert(mx_strtoull("test", &l) == -EINVAL);
}


x86 assembly (clang, -O0):
<test_mx_strtoull>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x7b,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xea3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x7b,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe76(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x7b,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe4b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x7b,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe3d(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x7b,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe12(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
xor    %ecx,%ecx
mov    0x2dad(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xded(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
xor    %ecx,%ecx
mov    0x2d83(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xdc9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
xor    %ecx,%ecx
mov    0x2d49(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xda4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
xor    %ecx,%ecx
mov    0x2d1f(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xd7e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
xor    %ecx,%ecx
mov    0x2cf5(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xd58(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtoull@plt>
xor    %ecx,%ecx
mov    0x2ccb(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mx_strtoull>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpq   $0x7b,(%rsp)
sete   %dil
call   1030 <assert@plt>
lea    0xeaa(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpq   $0x7b,(%rsp)
sete   %dil
call   1030 <assert@plt>
lea    0xe83(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpq   $0x7b,(%rsp)
sete   %dil
call   1030 <assert@plt>
lea    0xe5e(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpq   $0x7b,(%rsp)
sete   %dil
call   1030 <assert@plt>
lea    0xe56(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpq   $0x7b,(%rsp)
sete   %dil
call   1030 <assert@plt>
lea    0xe31(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
mov    0x2dcf(%rip),%rbx
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xe13(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xdfd(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
mov    0x2d80(%rip),%rbx
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xddf(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xdc7(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xdaf(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtoull@plt>
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"123\00"
@.str.1 = [5 x i8] c"0173\00"
@.str.2 = [7 x i8] c"0x007b\00"
@.str.3 = [36 x i8] c"0x00000000000000000000000000000007b\00"
@.str.4 = [7 x i8] c"0x007B\00"
@.str.5 = [5 x i8] c"-127\00"
@ERANGE = global i32 0
@.str.6 = [6 x i8] c" -128\00"
@.str.7 = [5 x i8] c"0888\00"
@EINVAL = global i32 0
@.str.8 = [4 x i8] c"1.2\00"
@.str.9 = [4 x i8] c"1,2\00"
@.str.10 = [5 x i8] c"test\00"
define void @test_mx_strtoull() {
%1 = alloca i64
%2 = call i32 @mx_strtoull(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%3 = icmp eq i32 %2, 0
%4 = zext i1 %3 to i32
%5 = call i32 @assert(i32 %4)
%6 = load i64, i64* %1
%7 = icmp eq i64 %6, 123
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @mx_strtoull(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i64, i64* %1
%15 = icmp eq i64 %14, 123
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @mx_strtoull(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i64, i64* %1
%23 = icmp eq i64 %22, 123
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @mx_strtoull(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64* %1)
%27 = icmp eq i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i64, i64* %1
%31 = icmp eq i64 %30, 123
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = call i32 @mx_strtoull(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64* %1)
%35 = icmp eq i32 %34, 0
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i64, i64* %1
%39 = icmp eq i64 %38, 123
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = call i32 @mx_strtoull(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64* %1)
%43 = load i32, i32* @ERANGE
%44 = sub nsw i32 0, %43
%45 = icmp eq i32 %42, %44
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = call i32 @mx_strtoull(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64* %1)
%49 = load i32, i32* @ERANGE
%50 = sub nsw i32 0, %49
%51 = icmp eq i32 %48, %50
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = call i32 @mx_strtoull(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i64* %1)
%55 = load i32, i32* @EINVAL
%56 = sub nsw i32 0, %55
%57 = icmp eq i32 %54, %56
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = call i32 @mx_strtoull(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i64* %1)
%61 = load i32, i32* @EINVAL
%62 = sub nsw i32 0, %61
%63 = icmp eq i32 %60, %62
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = call i32 @mx_strtoull(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i64* %1)
%67 = load i32, i32* @EINVAL
%68 = sub nsw i32 0, %67
%69 = icmp eq i32 %66, %68
%70 = zext i1 %69 to i32
%71 = call i32 @assert(i32 %70)
%72 = call i32 @mx_strtoull(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i64* %1)
%73 = load i32, i32* @EINVAL
%74 = sub nsw i32 0, %73
%75 = icmp eq i32 %72, %74
%76 = zext i1 %75 to i32
%77 = call i32 @assert(i32 %76)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"123\00"
@.str.1 = [5 x i8] c"0173\00"
@.str.2 = [7 x i8] c"0x007b\00"
@.str.3 = [36 x i8] c"0x00000000000000000000000000000007b\00"
@.str.4 = [7 x i8] c"0x007B\00"
@.str.5 = [5 x i8] c"-127\00"
@ERANGE = global i32 0
@.str.6 = [6 x i8] c" -128\00"
@.str.7 = [5 x i8] c"0888\00"
@EINVAL = global i32 0
@.str.8 = [4 x i8] c"1.2\00"
@.str.9 = [4 x i8] c"1,2\00"
@.str.10 = [5 x i8] c"test\00"
define void @test_mx_strtoull() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @mx_strtoull(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = load i64, i64* %1
%8 = icmp eq i64 %7, 123
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @mx_strtoull(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i64, i64* %1
%16 = icmp eq i64 %15, 123
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @mx_strtoull(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i64, i64* %1
%24 = icmp eq i64 %23, 123
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i32 @mx_strtoull(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64* %1)
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i64, i64* %1
%32 = icmp eq i64 %31, 123
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = call i32 @mx_strtoull(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64* %1)
%36 = icmp eq i32 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i64, i64* %1
%40 = icmp eq i64 %39, 123
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = call i32 @mx_strtoull(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64* %1)
%44 = load i32, i32* @ERANGE
%45 = sub nsw i32 0, %44
%46 = icmp eq i32 %43, %45
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = call i32 @mx_strtoull(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64* %1)
%50 = load i32, i32* @ERANGE
%51 = sub nsw i32 0, %50
%52 = icmp eq i32 %49, %51
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = call i32 @mx_strtoull(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i64* %1)
%56 = load i32, i32* @EINVAL
%57 = sub nsw i32 0, %56
%58 = icmp eq i32 %55, %57
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = call i32 @mx_strtoull(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i64* %1)
%62 = load i32, i32* @EINVAL
%63 = sub nsw i32 0, %62
%64 = icmp eq i32 %61, %63
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = call i32 @mx_strtoull(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i64* %1)
%68 = load i32, i32* @EINVAL
%69 = sub nsw i32 0, %68
%70 = icmp eq i32 %67, %69
%71 = zext i1 %70 to i32
%72 = call i32 @assert(i32 %71)
%73 = call i32 @mx_strtoull(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i64* %1)
%74 = load i32, i32* @EINVAL
%75 = sub nsw i32 0, %74
%76 = icmp eq i32 %73, %75
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
ret void
}