#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_strtobytes(char *, unsigned long long *);
void test_mx_strtobytes(void) {
  unsigned long long int l;
  assert(mx_strtobytes("123B", &l) == 0);
  assert(l == 123);
  assert(mx_strtobytes("2M", &l) == 0);
  assert(l == 2 * 1024 * 1024);
  assert(mx_strtobytes("1M1024k", &l) == 0);
  assert(l == 2 * 1024 * 1024);
  assert(mx_strtobytes("1024k1024K", &l) == 0);
  assert(l == 2 * 1024 * 1024);
  assert(mx_strtobytes("-1", &l) == -ERANGE);
  assert(mx_strtobytes(" -1", &l) == -ERANGE);
  assert(mx_strtobytes("2.5M", &l) == -EINVAL);
  assert(mx_strtobytes("123", &l) == -EINVAL);
  assert(mx_strtobytes("0123", &l) == -EINVAL);
  assert(mx_strtobytes("1.2", &l) == -EINVAL);
  assert(mx_strtobytes("1,2", &l) == -EINVAL);
  assert(mx_strtobytes("test", &l) == -EINVAL);
}


x86 assembly (clang, -O0):
<test_mx_strtobytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@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    0xea4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x200000,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe72(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x200000,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe45(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x200000,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xe1c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
xor    %ecx,%ecx
mov    0x2dd6(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xdf1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
xor    %ecx,%ecx
mov    0x2dac(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xdcb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
xor    %ecx,%ecx
mov    0x2d72(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xda7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
xor    %ecx,%ecx
mov    0x2d48(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xd7c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
xor    %ecx,%ecx
mov    0x2d1e(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xd57(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
xor    %ecx,%ecx
mov    0x2cf4(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xd31(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
xor    %ecx,%ecx
mov    0x2cca(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    0xd0b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <mx_strtobytes@plt>
xor    %ecx,%ecx
mov    0x2ca0(%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_strtobytes>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1040 <mx_strtobytes@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    0xeab(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpq   $0x200000,(%rsp)
sete   %dil
call   1030 <assert@plt>
lea    0xe7f(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpq   $0x200000,(%rsp)
sete   %dil
call   1030 <assert@plt>
lea    0xe58(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpq   $0x200000,(%rsp)
sete   %dil
call   1030 <assert@plt>
lea    0xe35(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
mov    0x2df2(%rip),%rbx
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xe11(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xdf9(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
mov    0x2da3(%rip),%rbx
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xddc(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xdbf(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xda8(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xd90(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@plt>
xor    %edi,%edi
add    (%rbx),%eax
sete   %dil
call   1030 <assert@plt>
lea    0xd78(%rip),%rdi
mov    %r14,%rsi
call   1040 <mx_strtobytes@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 = [5 x i8] c"123B\00"
@.str.1 = [3 x i8] c"2M\00"
@.str.2 = [8 x i8] c"1M1024k\00"
@.str.3 = [11 x i8] c"1024k1024K\00"
@.str.4 = [3 x i8] c"-1\00"
@ERANGE = global i32 0
@.str.5 = [4 x i8] c" -1\00"
@.str.6 = [5 x i8] c"2.5M\00"
@EINVAL = global i32 0
@.str.7 = [4 x i8] c"123\00"
@.str.8 = [5 x i8] c"0123\00"
@.str.9 = [4 x i8] c"1.2\00"
@.str.10 = [4 x i8] c"1,2\00"
@.str.11 = [5 x i8] c"test\00"
define void @test_mx_strtobytes() {
%1 = alloca i64
%2 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([5 x i8], [5 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_strtobytes(i8* getelementptr inbounds ([3 x i8], [3 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, 2097152
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([8 x i8], [8 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, 2097152
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([11 x i8], [11 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, 2097152
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64* %1)
%35 = load i32, i32* @ERANGE
%36 = sub nsw i32 0, %35
%37 = icmp eq i32 %34, %36
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64* %1)
%41 = load i32, i32* @ERANGE
%42 = sub nsw i32 0, %41
%43 = icmp eq i32 %40, %42
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64* %1)
%47 = load i32, i32* @EINVAL
%48 = sub nsw i32 0, %47
%49 = icmp eq i32 %46, %48
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i64* %1)
%53 = load i32, i32* @EINVAL
%54 = sub nsw i32 0, %53
%55 = icmp eq i32 %52, %54
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i64* %1)
%59 = load i32, i32* @EINVAL
%60 = sub nsw i32 0, %59
%61 = icmp eq i32 %58, %60
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i64* %1)
%65 = load i32, i32* @EINVAL
%66 = sub nsw i32 0, %65
%67 = icmp eq i32 %64, %66
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i64* %1)
%71 = load i32, i32* @EINVAL
%72 = sub nsw i32 0, %71
%73 = icmp eq i32 %70, %72
%74 = zext i1 %73 to i32
%75 = call i32 @assert(i32 %74)
%76 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i64* %1)
%77 = load i32, i32* @EINVAL
%78 = sub nsw i32 0, %77
%79 = icmp eq i32 %76, %78
%80 = zext i1 %79 to i32
%81 = call i32 @assert(i32 %80)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"123B\00"
@.str.1 = [3 x i8] c"2M\00"
@.str.2 = [8 x i8] c"1M1024k\00"
@.str.3 = [11 x i8] c"1024k1024K\00"
@.str.4 = [3 x i8] c"-1\00"
@ERANGE = global i32 0
@.str.5 = [4 x i8] c" -1\00"
@.str.6 = [5 x i8] c"2.5M\00"
@EINVAL = global i32 0
@.str.7 = [4 x i8] c"123\00"
@.str.8 = [5 x i8] c"0123\00"
@.str.9 = [4 x i8] c"1.2\00"
@.str.10 = [4 x i8] c"1,2\00"
@.str.11 = [5 x i8] c"test\00"
define void @test_mx_strtobytes() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([5 x i8], [5 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_strtobytes(i8* getelementptr inbounds ([3 x i8], [3 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, 2097152
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([8 x i8], [8 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, 2097152
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([11 x i8], [11 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, 2097152
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64* %1)
%36 = load i32, i32* @ERANGE
%37 = sub nsw i32 0, %36
%38 = icmp eq i32 %35, %37
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64* %1)
%42 = load i32, i32* @ERANGE
%43 = sub nsw i32 0, %42
%44 = icmp eq i32 %41, %43
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64* %1)
%48 = load i32, i32* @EINVAL
%49 = sub nsw i32 0, %48
%50 = icmp eq i32 %47, %49
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i64* %1)
%54 = load i32, i32* @EINVAL
%55 = sub nsw i32 0, %54
%56 = icmp eq i32 %53, %55
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i64* %1)
%60 = load i32, i32* @EINVAL
%61 = sub nsw i32 0, %60
%62 = icmp eq i32 %59, %61
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i64* %1)
%66 = load i32, i32* @EINVAL
%67 = sub nsw i32 0, %66
%68 = icmp eq i32 %65, %67
%69 = zext i1 %68 to i32
%70 = call i32 @assert(i32 %69)
%71 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i64* %1)
%72 = load i32, i32* @EINVAL
%73 = sub nsw i32 0, %72
%74 = icmp eq i32 %71, %73
%75 = zext i1 %74 to i32
%76 = call i32 @assert(i32 %75)
%77 = call i32 @mx_strtobytes(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i64* %1)
%78 = load i32, i32* @EINVAL
%79 = sub nsw i32 0, %78
%80 = icmp eq i32 %77, %79
%81 = zext i1 %80 to i32
%82 = call i32 @assert(i32 %81)
ret void
}