#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 */
unsigned int parseBinary(char *);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
unsigned int parseNumber(char *str) {
  unsigned int addr = 0;
  if (!sscanf(str, "0x%x", &addr)) {
    if (!sscanf(str, "%u", &addr)) {
      addr = parseBinary(str);
    }
  }
  return addr;
}


x86 assembly (clang, -O0):
<parseNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec2(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x0,%eax
jne    117e <parseNumber+0x5e>
mov    -0x8(%rbp),%rdi
lea    0xeaa(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x0,%eax
jne    1179 <parseNumber+0x59>
mov    -0x8(%rbp),%rdi
call   1030 <parseBinary@plt>
mov    %eax,-0xc(%rbp)
jmp    117e <parseNumber+0x5e>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseNumber>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0xec9(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
jne    1169 <parseNumber+0x49>
lea    0xeb9(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <sscanf@plt>
test   %eax,%eax
jne    1169 <parseNumber+0x49>
mov    %rbx,%rdi
call   1030 <parseBinary@plt>
mov    %eax,0xc(%rsp)
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0x%x\00"
@.str.1 = [3 x i8] c"%u\00"
define i32 @parseNumber(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = icmp ne i32 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = call i32 @parseBinary(i8* %12)
store i32 %13, i32* %3
br label %14
14: ; preds = %11, %7
br label %15
15: ; preds = %14, %1
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@.str = [5 x i8] c"0x%x\00"
@.str.1 = [3 x i8] c"%u\00"
define i32 @parseNumber(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @parseBinary(i8* %0)
store i32 %10, i32* %2
br label %11
11: ; preds = %6, %9, %1
%12 = load i32, i32* %2
ret i32 %12
}