#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 scan_for_uintN(char const *, int, unsigned long long *, char const **);
int str_2_uint(const char *_str, unsigned int *ret_, const char **end_) {
  unsigned long long ret;
  const char *end;
  int N = sizeof(unsigned int) * 8;
  int b_err = scan_for_uintN(_str, N, &ret, &end);
  if (ret_) {
    *ret_ = (unsigned int)ret;
  }
  if (end_) {
    *end_ = end;
  }
  return b_err;
}


x86 assembly (clang, -O0):
<str_2_uint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x20,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <scan_for_uintN@plt>
mov    %eax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1159 <str_2_uint+0x49>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     116f <str_2_uint+0x5f>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_2_uint>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    $0x20,%esi
call   1030 <scan_for_uintN@plt>
test   %rbx,%rbx
je     113c <str_2_uint+0x2c>
mov    0x10(%rsp),%ecx
mov    %ecx,(%rbx)
test   %r14,%r14
je     1149 <str_2_uint+0x39>
mov    0x8(%rsp),%rcx
mov    %rcx,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @str_2_uint(i8* %0, i32* writeonly %1, i8** writeonly %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = bitcast i64* %4 to i8*
%7 = bitcast i8** %5 to i8*
%8 = call i32 @scan_for_uintN(i8* %0, i32 32, i64* %4, i8** %5)
%9 = icmp eq i32* %1, null
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i64, i64* %4
%12 = trunc i64 %11 to i32
store i32 %12, i32* %1
br label %13
13: ; preds = %10, %3
%14 = icmp eq i8** %2, null
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = load i8*, i8** %5
store i8* %16, i8** %2
br label %17
17: ; preds = %15, %13
ret i32 %8
}