#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*/ uint32_t;

/* Variables and functions */
int EINVAL;
scalar_t__ errno;
int /*<<< orphan*/ strtoul(char *, char **, int /*<<< orphan*/);
int ert_mapper_convert_to_uint32(char *string, uint32_t *value_rcv) {
  char *endptr = NULL;
  errno = 0;
  uint32_t value = (uint32_t)strtoul(string, &endptr, 0);
  if (errno != 0) {
    return -EINVAL;
  }
  if (endptr != NULL && (*endptr) != '\0') {
    return -EINVAL;
  }
  *value_rcv = value;
  return 0;
}


x86 assembly (clang, -O0):
<ert_mapper_convert_to_uint32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2eb1(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtoul@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e91(%rip),%rax
cmpq   $0x0,(%rax)
je     116c <ert_mapper_convert_to_uint32+0x5c>
xor    %eax,%eax
mov    0x2e76(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11aa <ert_mapper_convert_to_uint32+0x9a>
cmpq   $0x0,-0x20(%rbp)
je     119a <ert_mapper_convert_to_uint32+0x8a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119a <ert_mapper_convert_to_uint32+0x8a>
xor    %eax,%eax
mov    0x2e48(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11aa <ert_mapper_convert_to_uint32+0x9a>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ert_mapper_convert_to_uint32>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
movq   $0x0,0x8(%rsp)
mov    0x2eb5(%rip),%rbx
movq   $0x0,(%rbx)
lea    0x8(%rsp),%rsi
xor    %ebp,%ebp
xor    %edx,%edx
call   1030 <strtoul@plt>
cmpq   $0x0,(%rbx)
je     1151 <ert_mapper_convert_to_uint32+0x41>
mov    0x2e8b(%rip),%rax
sub    (%rax),%ebp
jmp    1172 <ert_mapper_convert_to_uint32+0x62>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     116d <ert_mapper_convert_to_uint32+0x5d>
cmpb   $0x0,(%rcx)
je     116d <ert_mapper_convert_to_uint32+0x5d>
mov    0x2e71(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
jmp    1172 <ert_mapper_convert_to_uint32+0x62>
mov    %eax,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@errno = global i64 0
@EINVAL = global i32 0
define i32 @ert_mapper_convert_to_uint32(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
store i64 0, i64* @errno
%5 = call i32 @strtoul(i8* %0, i8** %3, i32 0)
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @EINVAL
%10 = sub nsw i32 0, %9
br label %21
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = icmp eq i8* %12, null
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* @EINVAL
%19 = sub nsw i32 0, %18
br label %21
20: ; preds = %14, %11
store i32 %5, i32* %1
br label %21
21: ; preds = %20, %17, %8
%22 = phi i32 [ %10, %8 ], [ %19, %17 ], [ 0, %20 ]
ret i32 %22
}