#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 int32_t;

/* Variables and functions */
scalar_t__ EINVAL;
int /*<<< orphan*/ convFail(char const *, char *, char const *, char const *);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
unsigned long long strtoull(char const *, char **, int);
unsigned long long convUnsigned(const char *fname, const char *arg,
                                register int32_t flags, const char *name) {
  register unsigned long long res = 0;
  register int32_t base = 0;
  char *endptr = NULL;
  if (arg == NULL || *arg == '\0') {
    if (flags & 0x20) {
      fprintf(stderr, "\nNull or empty string.\n");
      return 0;
    } else {
      convFail(fname, "null or empty string", arg, name);
    }
  }
  base = (flags & 0x4) ? 10 : (flags & 0x10) ? 16 : (flags & 0x8) ? 8 : 0;
  errno = 0;
  res = strtoull(arg, &endptr, base);
  if (errno != 0) {
    if (flags & 0x20) {
      fprintf(stderr, "\nConversion convFailed.\n");
      return 0;
    } else {
      convFail(fname, "strtoll() convFailed", arg, name);
    }
  }
  if (*endptr != '\0') {
    if (flags & 0x20) {
      errno = EINVAL;
      fprintf(stderr, "\nNonnumeric characters.\n");
      return 0;
    } else {
      convFail(fname, "nonnumeric characters", arg, name);
    }
  }
  if ((flags & 0x2) && res <= 0) {
    if (flags & 0x20) {
      errno = EINVAL;
      fprintf(stderr, "\nValue must be > 0.\n");
      return 0;
    } else {
      convFail(fname, "value must be > 0", arg, name);
    }
  }
  return res;
}


x86 assembly (clang, -O0):
<convUnsigned>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1179 <convUnsigned+0x49>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c7 <convUnsigned+0x97>
mov    -0x1c(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     11aa <convUnsigned+0x7a>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1050 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1398 <convUnsigned+0x268>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe5b(%rip),%rsi
call   1030 <convFail@plt>
jmp    11c7 <convUnsigned+0x97>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11e3 <convUnsigned+0xb3>
mov    $0xa,%eax
mov    %eax,-0x44(%rbp)
jmp    121b <convUnsigned+0xeb>
mov    -0x1c(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11ff <convUnsigned+0xcf>
mov    $0x10,%eax
mov    %eax,-0x48(%rbp)
jmp    1215 <convUnsigned+0xe5>
mov    -0x1c(%rbp),%edx
and    $0x8,%edx
xor    %eax,%eax
mov    $0x8,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2db0(%rip),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    -0x40(%rbp),%rsi
call   1040 <strtoull@plt>
mov    %rax,-0x30(%rbp)
mov    0x2d8e(%rip),%rax
cmpq   $0x0,(%rax)
je     12a2 <convUnsigned+0x172>
mov    -0x1c(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1285 <convUnsigned+0x155>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
lea    0xdba(%rip),%rsi
call   1050 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1398 <convUnsigned+0x268>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xdae(%rip),%rsi
call   1030 <convFail@plt>
jmp    12a2 <convUnsigned+0x172>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1314 <convUnsigned+0x1e4>
mov    -0x1c(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     12f7 <convUnsigned+0x1c7>
mov    0x2d08(%rip),%rax
mov    (%rax),%rcx
mov    0x2d06(%rip),%rax
mov    %rcx,(%rax)
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
call   1050 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1398 <convUnsigned+0x268>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xd6a(%rip),%rsi
call   1030 <convFail@plt>
jmp    1314 <convUnsigned+0x1e4>
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1390 <convUnsigned+0x260>
cmpq   $0x0,-0x30(%rbp)
ja     1390 <convUnsigned+0x260>
mov    -0x1c(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1373 <convUnsigned+0x243>
mov    0x2c8c(%rip),%rax
mov    (%rax),%rcx
mov    0x2c8a(%rip),%rax
mov    %rcx,(%rax)
mov    0x2c88(%rip),%rax
mov    (%rax),%edi
lea    0xd29(%rip),%rsi
call   1050 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1398 <convUnsigned+0x268>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xd19(%rip),%rsi
call   1030 <convFail@plt>
jmp    1390 <convUnsigned+0x260>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convUnsigned>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r15
movq   $0x0,(%rsp)
test   %rsi,%rsi
je     1158 <convUnsigned+0x28>
cmpb   $0x0,(%rbx)
jne    1177 <convUnsigned+0x47>
test   $0x20,%bpl
jne    1227 <convUnsigned+0xf7>
lea    0xeaf(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <convFail@plt>
mov    %ebp,%eax
and    $0x8,%eax
test   $0x10,%bpl
mov    $0x10,%ecx
cmove  %eax,%ecx
test   $0x4,%bpl
mov    $0xa,%edx
cmove  %ecx,%edx
mov    0x2e3d(%rip),%r13
movq   $0x0,0x0(%r13)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <strtoull@plt>
mov    %rax,%r12
cmpq   $0x0,0x0(%r13)
je     11d3 <convUnsigned+0xa3>
test   $0x20,%bpl
jne    1239 <convUnsigned+0x109>
lea    0xe81(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <convFail@plt>
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     11f7 <convUnsigned+0xc7>
test   $0x20,%bpl
jne    124b <convUnsigned+0x11b>
lea    0xe8b(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <convFail@plt>
test   $0x2,%bpl
je     1291 <convUnsigned+0x161>
test   %r12,%r12
jne    1291 <convUnsigned+0x161>
test   $0x20,%bpl
jne    126b <convUnsigned+0x13b>
lea    0xe88(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <convFail@plt>
jmp    128e <convUnsigned+0x15e>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
jmp    1289 <convUnsigned+0x159>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
jmp    1289 <convUnsigned+0x159>
mov    0x2d7e(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x0(%r13)
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xdf2(%rip),%rsi
jmp    1289 <convUnsigned+0x159>
mov    0x2d5e(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x0(%r13)
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
lea    0xe01(%rip),%rsi
call   1050 <fprintf@plt>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"\0ANull or empty string.\0A\00"
@.str.1 = [21 x i8] c"null or empty string\00"
@errno = global i64 0
@.str.2 = [25 x i8] c"\0AConversion convFailed.\0A\00"
@.str.3 = [21 x i8] c"strtoll() convFailed\00"
@EINVAL = global i64 0
@.str.4 = [25 x i8] c"\0ANonnumeric characters.\0A\00"
@.str.5 = [22 x i8] c"nonnumeric characters\00"
@.str.6 = [21 x i8] c"\0AValue must be > 0.\0A\00"
@.str.7 = [18 x i8] c"value must be > 0\00"
define i64 @convUnsigned(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i64 0, i64* %10
store i32 0, i32* %11
store i8* null, i8** %12
%13 = load i8*, i8** %7
%14 = icmp eq i8* %13, null
br i1 %14, label %20, label %15
15: ; preds = %4
%16 = load i8*, i8** %7
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %15, %4
%21 = load i32, i32* %8
%22 = and i32 %21, 32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %5
br label %113
27: ; preds = %20
%28 = load i8*, i8** %6
%29 = load i8*, i8** %7
%30 = load i8*, i8** %9
%31 = call i32 @convFail(i8* %28, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30)
br label %32
32: ; preds = %27
br label %33
33: ; preds = %32, %15
%34 = load i32, i32* %8
%35 = and i32 %34, 4
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
br label %51
38: ; preds = %33
%39 = load i32, i32* %8
%40 = and i32 %39, 16
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
br label %49
43: ; preds = %38
%44 = load i32, i32* %8
%45 = and i32 %44, 8
%46 = icmp ne i32 %45, 0
%47 = zext i1 %46 to i64
%48 = select i1 %46, i32 8, i32 0
br label %49
49: ; preds = %43, %42
%50 = phi i32 [ 16, %42 ], [ %48, %43 ]
br label %51
51: ; preds = %49, %37
%52 = phi i32 [ 10, %37 ], [ %50, %49 ]
store i32 %52, i32* %11
store i64 0, i64* @errno
%53 = load i8*, i8** %7
%54 = load i32, i32* %11
%55 = call i64 @strtoull(i8* %53, i8** %12, i32 %54)
store i64 %55, i64* %10
%56 = load i64, i64* @errno
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %71
58: ; preds = %51
%59 = load i32, i32* %8
%60 = and i32 %59, 32
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i64 0, i64* %5
br label %113
65: ; preds = %58
%66 = load i8*, i8** %6
%67 = load i8*, i8** %7
%68 = load i8*, i8** %9
%69 = call i32 @convFail(i8* %66, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %67, i8* %68)
br label %70
70: ; preds = %65
br label %71
71: ; preds = %70, %51
%72 = load i8*, i8** %12
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %90
76: ; preds = %71
%77 = load i32, i32* %8
%78 = and i32 %77, 32
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %76
%81 = load i64, i64* @EINVAL
store i64 %81, i64* @errno
%82 = load i32, i32* @stderr
%83 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
store i64 0, i64* %5
br label %113
84: ; preds = %76
%85 = load i8*, i8** %6
%86 = load i8*, i8** %7
%87 = load i8*, i8** %9
%88 = call i32 @convFail(i8* %85, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %86, i8* %87)
br label %89
89: ; preds = %84
br label %90
90: ; preds = %89, %71
%91 = load i32, i32* %8
%92 = and i32 %91, 2
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %111
94: ; preds = %90
%95 = load i64, i64* %10
%96 = icmp ule i64 %95, 0
br i1 %96, label %97, label %111
97: ; preds = %94
%98 = load i32, i32* %8
%99 = and i32 %98, 32
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %97
%102 = load i64, i64* @EINVAL
store i64 %102, i64* @errno
%103 = load i32, i32* @stderr
%104 = call i32 @fprintf(i32 %103, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
store i64 0, i64* %5
br label %113
105: ; preds = %97
%106 = load i8*, i8** %6
%107 = load i8*, i8** %7
%108 = load i8*, i8** %9
%109 = call i32 @convFail(i8* %106, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %107, i8* %108)
br label %110
110: ; preds = %105
br label %111
111: ; preds = %110, %94, %90
%112 = load i64, i64* %10
store i64 %112, i64* %5
br label %113
113: ; preds = %111, %101, %80, %62, %24
%114 = load i64, i64* %5
ret i64 %114
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"\0ANull or empty string.\0A\00"
@.str.1 = [21 x i8] c"null or empty string\00"
@errno = global i64 0
@.str.2 = [25 x i8] c"\0AConversion convFailed.\0A\00"
@.str.3 = [21 x i8] c"strtoll() convFailed\00"
@EINVAL = global i64 0
@.str.4 = [25 x i8] c"\0ANonnumeric characters.\0A\00"
@.str.5 = [22 x i8] c"nonnumeric characters\00"
@.str.6 = [21 x i8] c"\0AValue must be > 0.\0A\00"
@.str.7 = [18 x i8] c"value must be > 0\00"
define i64 @convUnsigned(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%7 = icmp eq i8* %1, null
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = load i8, i8* %1
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %8, %4
%12 = and i32 %2, 32
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %65
17: ; preds = %11
%18 = tail call i32 @convFail(i8* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %3)
br label %19
19: ; preds = %17, %8
%20 = and i32 %2, 4
%21 = icmp eq i32 %20, 0
%22 = and i32 %2, 16
%23 = icmp eq i32 %22, 0
%24 = and i32 %2, 8
%25 = select i1 %23, i32 %24, i32 16
%26 = select i1 %21, i32 %25, i32 10
store i64 0, i64* @errno
%27 = call i64 @strtoull(i8* %1, i8** %5, i32 %26)
%28 = load i64, i64* @errno
%29 = icmp eq i64 %28, 0
br i1 %29, label %38, label %30
30: ; preds = %19
%31 = and i32 %2, 32
%32 = icmp eq i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %65
36: ; preds = %30
%37 = tail call i32 @convFail(i8* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %3)
br label %38
38: ; preds = %36, %19
%39 = load i8*, i8** %5
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 0
br i1 %41, label %51, label %42
42: ; preds = %38
%43 = and i32 %2, 32
%44 = icmp eq i32 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %42
%46 = load i64, i64* @EINVAL
store i64 %46, i64* @errno
%47 = load i32, i32* @stderr
%48 = tail call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %65
49: ; preds = %42
%50 = tail call i32 @convFail(i8* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* %3)
br label %51
51: ; preds = %49, %38
%52 = and i32 %2, 2
%53 = icmp ne i32 %52, 0
%54 = icmp eq i64 %27, 0
%55 = select i1 %53, i1 %54, i1 false
br i1 %55, label %56, label %65
56: ; preds = %51
%57 = and i32 %2, 32
%58 = icmp eq i32 %57, 0
br i1 %58, label %63, label %59
59: ; preds = %56
%60 = load i64, i64* @EINVAL
store i64 %60, i64* @errno
%61 = load i32, i32* @stderr
%62 = tail call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %65
63: ; preds = %56
%64 = tail call i32 @convFail(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %1, i8* %3)
br label %65
65: ; preds = %51, %63, %59, %45, %33, %14
%66 = phi i64 [ 0, %14 ], [ 0, %33 ], [ 0, %45 ], [ 0, %59 ], [ 0, %63 ], [ %27, %51 ]
ret i64 %66
}