#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 long uint32_t;

/* Variables and functions */
scalar_t__ ERANGE;
long LONG_MAX;
long LONG_MIN;
scalar_t__ errno;
int /*<<< orphan*/ fprint_err(char *, char *, ...);
int /*<<< orphan*/ print_err(char *);
int /*<<< orphan*/ strerror(scalar_t__);
long strtoul(char *, char **, int);
extern int unsigned_value(char *prefix, char *cmd, char *arg, int base,
                          uint32_t *value) {
  char *ptr;
  long val;
  errno = 0;
  val = strtoul(arg, &ptr, base);
  if (errno) {
    print_err("### ");
    if (prefix != NULL)
      fprint_err("%s: ", prefix);
    if (errno == ERANGE && val == 0)
      fprint_err(
          "String cannot be converted to (long) unsigned integer in %s %s\n",
          cmd, arg);
    else if (errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
      fprint_err("Number is too big (overflows) in %s %s\n", cmd, arg);
    else
      fprint_err("Cannot read number in %s %s (%s)\n", cmd, arg,
                 strerror(errno));
    return 1;
  }
  if (ptr[0] != '\0') {
    print_err("### ");
    if (prefix != NULL)
      fprint_err("%s: ", prefix);
    if (ptr - arg == 0)
      fprint_err("Argument to %s should be a number, in %s %s\n", cmd, cmd,
                 arg);
    else
      fprint_err("Unexpected characters ('%s') after the %.*s in %s %s\n", ptr,
                 (int)(ptr - arg), arg, cmd, arg);
    return 1;
  }
  *value = val;
  return 0;
}


x86 assembly (clang, -O0):
<unsigned_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    0x2e66(%rip),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    -0x38(%rbp),%rsi
call   1050 <strtoul@plt>
mov    %rax,-0x40(%rbp)
mov    0x2e44(%rip),%rax
cmpq   $0x0,(%rax)
je     129c <unsigned_value+0x15c>
lea    0xe6b(%rip),%rdi
call   1040 <print_err@plt>
cmpq   $0x0,-0x10(%rbp)
je     11b7 <unsigned_value+0x77>
mov    -0x10(%rbp),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%rax
mov    0x2e18(%rip),%rcx
cmp    (%rcx),%rax
jne    11f7 <unsigned_value+0xb7>
cmpq   $0x0,-0x40(%rbp)
jne    11f7 <unsigned_value+0xb7>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
jmp    1290 <unsigned_value+0x150>
mov    0x2dca(%rip),%rax
mov    (%rax),%rax
mov    0x2dd8(%rip),%rcx
cmp    (%rcx),%rax
jne    1254 <unsigned_value+0x114>
mov    -0x40(%rbp),%rax
mov    0x2db4(%rip),%rcx
cmp    (%rcx),%rax
je     1239 <unsigned_value+0xf9>
mov    -0x40(%rbp),%rax
mov    0x2db8(%rip),%rcx
cmp    (%rcx),%rax
jne    1254 <unsigned_value+0x114>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
jmp    128b <unsigned_value+0x14b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d5d(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    %eax,%ecx
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
jmp    1290 <unsigned_value+0x150>
movl   $0x1,-0x4(%rbp)
jmp    1352 <unsigned_value+0x212>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1340 <unsigned_value+0x200>
lea    0xd4d(%rip),%rdi
call   1040 <print_err@plt>
cmpq   $0x0,-0x10(%rbp)
je     12d5 <unsigned_value+0x195>
mov    -0x10(%rbp),%rsi
lea    0xd37(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x0,%rax
jne    1309 <unsigned_value+0x1c9>
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
jmp    1334 <unsigned_value+0x1f4>
mov    -0x38(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
movl   $0x1,-0x4(%rbp)
jmp    1352 <unsigned_value+0x212>
mov    -0x40(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unsigned_value>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbx
mov    0x2e6a(%rip),%rbp
movq   $0x0,0x0(%rbp)
mov    %rsp,%rsi
mov    %rdx,%rdi
mov    %ecx,%edx
call   1050 <strtoul@plt>
mov    %rax,%r12
cmpq   $0x0,0x0(%rbp)
je     11c3 <unsigned_value+0x83>
lea    0xe7c(%rip),%rdi
call   1040 <print_err@plt>
test   %rbx,%rbx
je     119f <unsigned_value+0x5f>
lea    0xe70(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprint_err@plt>
mov    0x0(%rbp),%rdi
mov    0x2e36(%rip),%rax
mov    (%rax),%rax
cmp    %rax,%rdi
jne    121b <unsigned_value+0xdb>
test   %r12,%r12
jne    121b <unsigned_value+0xdb>
lea    0xe4c(%rip),%rdi
jmp    127c <unsigned_value+0x13c>
mov    %r13,%rbp
mov    (%rsp),%r13
cmpb   $0x0,0x0(%r13)
je     1255 <unsigned_value+0x115>
lea    0xe24(%rip),%rdi
call   1040 <print_err@plt>
test   %rbx,%rbx
je     11f7 <unsigned_value+0xb7>
lea    0xe18(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprint_err@plt>
mov    %r13,%rdx
sub    %r15,%rdx
je     125c <unsigned_value+0x11c>
lea    0xebb(%rip),%rdi
mov    %r13,%rsi
mov    %r15,%rcx
mov    %rbp,%r8
mov    %r15,%r9
xor    %eax,%eax
call   1030 <fprint_err@plt>
jmp    1289 <unsigned_value+0x149>
cmp    %rax,%rdi
jne    1238 <unsigned_value+0xf8>
mov    0x2da9(%rip),%rax
cmp    (%rax),%r12
je     1275 <unsigned_value+0x135>
mov    0x2db5(%rip),%rax
cmp    (%rax),%r12
je     1275 <unsigned_value+0x135>
call   1060 <strerror@plt>
lea    0xe2e(%rip),%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <fprint_err@plt>
jmp    1289 <unsigned_value+0x149>
mov    %r12,(%r14)
xor    %eax,%eax
jmp    128e <unsigned_value+0x14e>
lea    0xe31(%rip),%rdi
mov    %rbp,%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <fprint_err@plt>
jmp    1289 <unsigned_value+0x149>
lea    0xdce(%rip),%rdi
mov    %r13,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <fprint_err@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [5 x i8] c"### \00"
@.str.1 = [5 x i8] c"%s: \00"
@ERANGE = global i64 0
@.str.2 = [64 x i8] c"String cannot be converted to (long) unsigned integer in %s %s\0A\00"
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str.3 = [40 x i8] c"Number is too big (overflows) in %s %s\0A\00"
@.str.4 = [34 x i8] c"Cannot read number in %s %s (%s)\0A\00"
@.str.5 = [45 x i8] c"Argument to %s should be a number, in %s %s\0A\00"
@.str.6 = [54 x i8] c"Unexpected characters ('%s') after the %.*s in %s %s\0A\00"
define i32 @unsigned_value(i8* %0, i8* %1, i8* %2, i32 %3, i64* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i64*
%12 = alloca i8*
%13 = alloca i64
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i64* %4, i64** %11
store i64 0, i64* @errno
%14 = load i8*, i8** %9
%15 = load i32, i32* %10
%16 = call i64 @strtoul(i8* %14, i8** %12, i32 %15)
store i64 %16, i64* %13
%17 = load i64, i64* @errno
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %61
19: ; preds = %5
%20 = call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%21 = load i8*, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %7
%25 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %23, %19
%27 = load i64, i64* @errno
%28 = load i64, i64* @ERANGE
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load i64, i64* %13
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i8*, i8** %8
%35 = load i8*, i8** %9
%36 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %35)
br label %60
37: ; preds = %30, %26
%38 = load i64, i64* @errno
%39 = load i64, i64* @ERANGE
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %53
41: ; preds = %37
%42 = load i64, i64* %13
%43 = load i64, i64* @LONG_MAX
%44 = icmp eq i64 %42, %43
br i1 %44, label %49, label %45
45: ; preds = %41
%46 = load i64, i64* %13
%47 = load i64, i64* @LONG_MIN
%48 = icmp eq i64 %46, %47
br i1 %48, label %49, label %53
49: ; preds = %45, %41
%50 = load i8*, i8** %8
%51 = load i8*, i8** %9
%52 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %50, i8* %51)
br label %59
53: ; preds = %45, %37
%54 = load i8*, i8** %8
%55 = load i8*, i8** %9
%56 = load i64, i64* @errno
%57 = call i32 @strerror(i64 %56)
%58 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %54, i8* %55, i32 %57)
br label %59
59: ; preds = %53, %49
br label %60
60: ; preds = %59, %33
store i32 1, i32* %6
br label %102
61: ; preds = %5
%62 = load i8*, i8** %12
%63 = getelementptr inbounds i8, i8* %62, i64 0
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %99
67: ; preds = %61
%68 = call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%69 = load i8*, i8** %7
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = load i8*, i8** %7
%73 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %72)
br label %74
74: ; preds = %71, %67
%75 = load i8*, i8** %12
%76 = load i8*, i8** %9
%77 = ptrtoint i8* %75 to i64
%78 = ptrtoint i8* %76 to i64
%79 = sub i64 %77, %78
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %86
81: ; preds = %74
%82 = load i8*, i8** %8
%83 = load i8*, i8** %8
%84 = load i8*, i8** %9
%85 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* %82, i8* %83, i8* %84)
br label %98
86: ; preds = %74
%87 = load i8*, i8** %12
%88 = load i8*, i8** %12
%89 = load i8*, i8** %9
%90 = ptrtoint i8* %88 to i64
%91 = ptrtoint i8* %89 to i64
%92 = sub i64 %90, %91
%93 = trunc i64 %92 to i32
%94 = load i8*, i8** %9
%95 = load i8*, i8** %8
%96 = load i8*, i8** %9
%97 = call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i8* %87, i32 %93, i8* %94, i8* %95, i8* %96)
br label %98
98: ; preds = %86, %81
store i32 1, i32* %6
br label %102
99: ; preds = %61
%100 = load i64, i64* %13
%101 = load i64*, i64** %11
store i64 %100, i64* %101
store i32 0, i32* %6
br label %102
102: ; preds = %99, %98, %60
%103 = load i32, i32* %6
ret i32 %103
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [5 x i8] c"### \00"
@.str.1 = [5 x i8] c"%s: \00"
@ERANGE = global i64 0
@.str.2 = [64 x i8] c"String cannot be converted to (long) unsigned integer in %s %s\0A\00"
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str.3 = [40 x i8] c"Number is too big (overflows) in %s %s\0A\00"
@.str.4 = [34 x i8] c"Cannot read number in %s %s (%s)\0A\00"
@.str.5 = [45 x i8] c"Argument to %s should be a number, in %s %s\0A\00"
@.str.6 = [54 x i8] c"Unexpected characters ('%s') after the %.*s in %s %s\0A\00"
define i32 @unsigned_value(i8* %0, i8* %1, i8* %2, i32 %3, i64* nocapture writeonly %4) {
%6 = alloca i8*
%7 = bitcast i8** %6 to i8*
store i64 0, i64* @errno
%8 = call i64 @strtoul(i8* %2, i8** %6, i32 %3)
%9 = load i64, i64* @errno
%10 = icmp eq i64 %9, 0
br i1 %10, label %36, label %11
11: ; preds = %5
%12 = tail call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i8* %0, null
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %16
16: ; preds = %14, %11
%17 = load i64, i64* @errno
%18 = load i64, i64* @ERANGE
%19 = icmp eq i64 %17, %18
%20 = icmp eq i64 %8, 0
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %2)
br label %56
24: ; preds = %16
br i1 %19, label %25, label %33
25: ; preds = %24
%26 = load i64, i64* @LONG_MAX
%27 = icmp eq i64 %8, %26
%28 = load i64, i64* @LONG_MIN
%29 = icmp eq i64 %8, %28
%30 = select i1 %27, i1 true, i1 %29
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %2)
br label %56
33: ; preds = %25, %24
%34 = tail call i32 @strerror(i64 %17)
%35 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %2, i32 %34)
br label %56
36: ; preds = %5
%37 = load i8*, i8** %6
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %55, label %40
40: ; preds = %36
%41 = tail call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%42 = icmp eq i8* %0, null
br i1 %42, label %45, label %43
43: ; preds = %40
%44 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %45
45: ; preds = %43, %40
%46 = ptrtoint i8* %37 to i64
%47 = ptrtoint i8* %2 to i64
%48 = sub i64 %46, %47
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %45
%51 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* %1, i8* %2)
br label %56
52: ; preds = %45
%53 = trunc i64 %48 to i32
%54 = tail call i32 (i8*, i8*, ...) @fprint_err(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i8* %37, i32 %53, i8* %2, i8* %1, i8* %2)
br label %56
55: ; preds = %36
store i64 %8, i64* %4
br label %56
56: ; preds = %50, %52, %22, %33, %31, %55
%57 = phi i32 [ 0, %55 ], [ 1, %31 ], [ 1, %33 ], [ 1, %22 ], [ 1, %52 ], [ 1, %50 ]
ret i32 %57
}