#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 unsigned long uint8_t;

/* Variables and functions */
scalar_t__ errno;
unsigned long *malloc(int);
unsigned long strtoul(char const *, char **, int /*<<< orphan*/);
uint8_t *parse_number8_pow2(const char *argv) {
  uint8_t *n;
  unsigned long int tmp, i;
  char *endptr;
  if (!argv)
    return NULL;
  errno = 0;
  tmp = strtoul(argv, &endptr, 0);
  if (tmp >= 256)
    return NULL;
  for (i = tmp; i; i >>= 1)
    if ((i & 1) && (i >> 1))
      return NULL;
  n = malloc(sizeof(*n));
  *n = tmp;
  return n;
}


x86 assembly (clang, -O0):
<parse_number8_pow2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1144 <parse_number8_pow2+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11fb <parse_number8_pow2+0xdb>
mov    0x2e95(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x100,-0x20(%rbp)
jb     1180 <parse_number8_pow2+0x60>
movq   $0x0,-0x8(%rbp)
jmp    11fb <parse_number8_pow2+0xdb>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11da <parse_number8_pow2+0xba>
mov    -0x28(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11c4 <parse_number8_pow2+0xa4>
mov    -0x28(%rbp),%rax
shr    $0x1,%rax
cmp    $0x0,%rax
je     11c4 <parse_number8_pow2+0xa4>
movq   $0x0,-0x8(%rbp)
jmp    11fb <parse_number8_pow2+0xdb>
jmp    11c9 <parse_number8_pow2+0xa9>
mov    -0x28(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1188 <parse_number8_pow2+0x68>
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_number8_pow2>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1181 <parse_number8_pow2+0x61>
mov    0x2eb0(%rip),%rax
movq   $0x0,(%rax)
mov    %rsp,%rsi
xor    %ebx,%ebx
xor    %edx,%edx
call   1040 <strtoul@plt>
cmp    $0xff,%rax
ja     1195 <parse_number8_pow2+0x75>
mov    %rax,%r14
test   %rax,%rax
je     1185 <parse_number8_pow2+0x65>
xor    %ebx,%ebx
mov    %r14,%rax
jmp    116f <parse_number8_pow2+0x4f>
nopw   0x0(%rax,%rax,1)
mov    %rax,%rcx
shr    %rcx
cmp    $0x2,%rax
mov    %rcx,%rax
jb     1185 <parse_number8_pow2+0x65>
cmp    $0x1,%rax
je     1160 <parse_number8_pow2+0x40>
mov    %eax,%ecx
and    $0x1,%ecx
test   %rcx,%rcx
je     1160 <parse_number8_pow2+0x40>
jmp    1195 <parse_number8_pow2+0x75>
xor    %ebx,%ebx
jmp    1195 <parse_number8_pow2+0x75>
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    %r14,(%rax)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@errno = global i64 0
define i64* @parse_number8_pow2(i8* %0) {
%2 = alloca i64*
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i64* null, i64** %2
br label %40
11: ; preds = %1
store i64 0, i64* @errno
%12 = load i8*, i8** %3
%13 = call i64 @strtoul(i8* %12, i8** %7, i32 0)
store i64 %13, i64* %5
%14 = load i64, i64* %5
%15 = icmp uge i64 %14, 256
br i1 %15, label %16, label %17
16: ; preds = %11
store i64* null, i64** %2
br label %40
17: ; preds = %11
%18 = load i64, i64* %5
store i64 %18, i64* %6
br label %19
19: ; preds = %32, %17
%20 = load i64, i64* %6
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i64, i64* %6
%24 = and i64 %23, 1
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i64, i64* %6
%28 = lshr i64 %27, 1
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i64* null, i64** %2
br label %40
31: ; preds = %26, %22
br label %32
32: ; preds = %31
%33 = load i64, i64* %6
%34 = lshr i64 %33, 1
store i64 %34, i64* %6
br label %19
35: ; preds = %19
%36 = call i64* @malloc(i32 8)
store i64* %36, i64** %4
%37 = load i64, i64* %5
%38 = load i64*, i64** %4
store i64 %37, i64* %38
%39 = load i64*, i64** %4
store i64* %39, i64** %2
br label %40
40: ; preds = %35, %30, %16, %10
%41 = load i64*, i64** %2
ret i64* %41
}

LLVM IR (-O2):
@errno = global i64 0
define noalias i64* @parse_number8_pow2(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %21, label %5
5: ; preds = %1
store i64 0, i64* @errno
%6 = call i64 @strtoul(i8* %0, i8** %2, i32 0)
%7 = icmp ugt i64 %6, 255
br i1 %7, label %21, label %8
8: ; preds = %5
%9 = icmp eq i64 %6, 0
br i1 %9, label %19, label %13
10: ; preds = %13
%11 = lshr i64 %14, 1
%12 = icmp ult i64 %14, 2
br i1 %12, label %19, label %13
13: ; preds = %8, %10
%14 = phi i64 [ %11, %10 ], [ %6, %8 ]
%15 = and i64 %14, 1
%16 = icmp eq i64 %15, 0
%17 = icmp eq i64 %14, 1
%18 = or i1 %17, %16
br i1 %18, label %10, label %21
19: ; preds = %10, %8
%20 = tail call i64* @malloc(i32 8)
store i64 %6, i64* %20
br label %21
21: ; preds = %13, %5, %1, %19
%22 = phi i64* [ %20, %19 ], [ null, %1 ], [ null, %5 ], [ null, %13 ]
ret i64* %22
}