#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 /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ atof(int /*<<< orphan*/);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ strtoul(char const *, char **, int);
uint32_t getOpt(const char *str) {
  char *endp;
  if (str[0] == '0' && str[1] == 'x')
    return strtoul(str + 2, &endp, 16);
  if (str[0] == '0' && str[1] == 'b')
    return strtoul(str + 2, &endp, 2);
  else
    return (atof(optarg));
}


x86 assembly (clang, -O0):
<getOpt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    116b <getOpt+0x4b>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
jne    116b <getOpt+0x4b>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x4(%rbp)
jmp    11bb <getOpt+0x9b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    11aa <getOpt+0x8a>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x62,%eax
jne    11aa <getOpt+0x8a>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
lea    -0x18(%rbp),%rsi
mov    $0x2,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x4(%rbp)
jmp    11bb <getOpt+0x9b>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1030 <atof@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getOpt>:
push   %rax
cmpb   $0x30,(%rdi)
jne    113f <getOpt+0x1f>
mov    0x1(%rdi),%al
cmp    $0x62,%al
je     114e <getOpt+0x2e>
cmp    $0x78,%al
jne    113f <getOpt+0x1f>
add    $0x2,%rdi
mov    %rsp,%rsi
mov    $0x10,%edx
jmp    115a <getOpt+0x3a>
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1030 <atof@plt>
add    $0x2,%rdi
mov    %rsp,%rsi
mov    $0x2,%edx
call   1040 <strtoul@plt>
pop    %rcx
ret

LLVM IR (-O0):
@optarg = global i32 0
define i32 @getOpt(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 48
br i1 %9, label %10, label %20
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 120
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 2
%19 = call i32 @strtoul(i8* %18, i8** %4, i32 16)
store i32 %19, i32* %2
br label %39
20: ; preds = %10, %1
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 48
br i1 %25, label %26, label %36
26: ; preds = %20
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 98
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i64 2
%35 = call i32 @strtoul(i8* %34, i8** %4, i32 2)
store i32 %35, i32* %2
br label %39
36: ; preds = %26, %20
%37 = load i32, i32* @optarg
%38 = call i32 @atof(i32 %37)
store i32 %38, i32* %2
br label %39
39: ; preds = %36, %32, %16
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@optarg = global i32 0
define i32 @getOpt(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 48
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
switch i8 %8, label %15 [
i8 120, label %9
i8 98, label %12
]
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = call i32 @strtoul(i8* %10, i8** %2, i32 16)
br label %18
12: ; preds = %6
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = call i32 @strtoul(i8* %13, i8** %2, i32 2)
br label %18
15: ; preds = %6, %1
%16 = load i32, i32* @optarg
%17 = tail call i32 @atof(i32 %16)
br label %18
18: ; preds = %15, %12, %9
%19 = phi i32 [ %11, %9 ], [ %14, %12 ], [ %17, %15 ]
ret i32 %19
}