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

/* Variables and functions */
int asuint(int /*<<< orphan*/);
int asuint64(int /*<<< orphan*/);
scalar_t__ strchr(char const *, char);
int /*<<< orphan*/ strtod(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ strtof(char const *, int /*<<< orphan*/);
int strtoull(char const *, int /*<<< orphan*/, int /*<<< orphan*/);
char tolower(char const);
uint64_t getnum(const char *s, int singleprec) {
  uint64_t sign = 0;
  if (s[0] == '+')
    s++;
  else if (s[0] == '-') {
    sign = singleprec ? 1ULL << 31 : 1ULL << 63;
    s++;
  }
  if (s[0] == '0' && tolower(s[1]) == 'x' && strchr(s, 'p') == 0)
    return sign ^ strtoull(s, 0, 0);
  return sign | (singleprec ? asuint(strtof(s, 0)) : asuint64(strtod(s, 0)));
}


x86 assembly (clang, -O0):
<getnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    11a7 <getnum+0x37>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11e4 <getnum+0x74>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11df <getnum+0x6f>
mov    -0x14(%rbp),%edx
movabs $0x8000000000000000,%rax
mov    $0x80000000,%ecx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11e4 <getnum+0x74>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1247 <getnum+0xd7>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1090 <tolower@plt>
movsbl %al,%eax
cmp    $0x78,%eax
jne    1247 <getnum+0xd7>
mov    -0x10(%rbp),%rdi
mov    $0x70,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    1247 <getnum+0xd7>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <strtoull@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
xor    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1291 <getnum+0x121>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1271 <getnum+0x101>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <strtof@plt>
mov    %eax,%edi
call   1080 <asuint@plt>
mov    %eax,-0x24(%rbp)
jmp    1286 <getnum+0x116>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
mov    %eax,%edi
call   1070 <asuint64@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x24(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnum>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
mov    (%rdi),%al
xor    %ebp,%ebp
cmp    $0x2b,%al
je     1192 <getnum+0x22>
cmp    $0x2d,%al
jne    1199 <getnum+0x29>
xor    %ebp,%ebp
test   %r14d,%r14d
setne  %bpl
shl    $0x1f,%ebp
mov    0x1(%rbx),%al
add    $0x1,%rbx
cmp    $0x30,%al
jne    11bc <getnum+0x4c>
movsbl 0x1(%rbx),%edi
call   1090 <tolower@plt>
cmp    $0x78,%al
jne    11bc <getnum+0x4c>
mov    %rbx,%rdi
mov    $0x70,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11e7 <getnum+0x77>
mov    %rbx,%rdi
xor    %esi,%esi
test   %r14d,%r14d
je     11d4 <getnum+0x64>
call   1050 <strtof@plt>
mov    %eax,%edi
call   1080 <asuint@plt>
jmp    11e0 <getnum+0x70>
call   1030 <strtod@plt>
mov    %eax,%edi
call   1070 <asuint64@plt>
or     %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoull@plt>
xor    %ebp,%eax
jmp    11e2 <getnum+0x72>

LLVM IR (-O0):
define i32 @getnum(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 43
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
br label %30
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 45
br i1 %20, label %21, label %29
21: ; preds = %15
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i64 2147483648, i64 -9223372036854775808
%26 = trunc i64 %25 to i32
store i32 %26, i32* %6
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %4
br label %29
29: ; preds = %21, %15
br label %30
30: ; preds = %29, %12
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 48
br i1 %35, label %36, label %52
36: ; preds = %30
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = call signext i8 @tolower(i8 signext %39)
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 120
br i1 %42, label %43, label %52
43: ; preds = %36
%44 = load i8*, i8** %4
%45 = call i64 @strchr(i8* %44, i8 signext 112)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i32, i32* %6
%49 = load i8*, i8** %4
%50 = call i32 @strtoull(i8* %49, i32 0, i32 0)
%51 = xor i32 %48, %50
store i32 %51, i32* %3
br label %67
52: ; preds = %43, %36, %30
%53 = load i32, i32* %6
%54 = load i32, i32* %5
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %52
%57 = load i8*, i8** %4
%58 = call i32 @strtof(i8* %57, i32 0)
%59 = call i32 @asuint(i32 %58)
br label %64
60: ; preds = %52
%61 = load i8*, i8** %4
%62 = call i32 @strtod(i8* %61, i32 0)
%63 = call i32 @asuint64(i32 %62)
br label %64
64: ; preds = %60, %56
%65 = phi i32 [ %59, %56 ], [ %63, %60 ]
%66 = or i32 %53, %65
store i32 %66, i32* %3
br label %67
67: ; preds = %64, %47
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
define i32 @getnum(i8* %0, i32 %1) {
%3 = load i8, i8* %0
switch i8 %3, label %11 [
i8 43, label %7
i8 45, label %4
]
4: ; preds = %2
%5 = icmp eq i32 %1, 0
%6 = select i1 %5, i32 0, i32 -2147483648
br label %7
7: ; preds = %2, %4
%8 = phi i32 [ %6, %4 ], [ 0, %2 ]
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = load i8, i8* %9
br label %11
11: ; preds = %7, %2
%12 = phi i8 [ %10, %7 ], [ %3, %2 ]
%13 = phi i8* [ %9, %7 ], [ %0, %2 ]
%14 = phi i32 [ %8, %7 ], [ 0, %2 ]
%15 = icmp eq i8 %12, 48
br i1 %15, label %16, label %27
16: ; preds = %11
%17 = getelementptr inbounds i8, i8* %13, i64 1
%18 = load i8, i8* %17
%19 = tail call signext i8 @tolower(i8 signext %18)
%20 = icmp eq i8 %19, 120
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = tail call i64 @strchr(i8* %13, i8 signext 112)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = tail call i32 @strtoull(i8* %13, i32 0, i32 0)
%26 = xor i32 %25, %14
br label %38
27: ; preds = %21, %16, %11
%28 = icmp eq i32 %1, 0
br i1 %28, label %32, label %29
29: ; preds = %27
%30 = tail call i32 @strtof(i8* %13, i32 0)
%31 = tail call i32 @asuint(i32 %30)
br label %35
32: ; preds = %27
%33 = tail call i32 @strtod(i8* %13, i32 0)
%34 = tail call i32 @asuint64(i32 %33)
br label %35
35: ; preds = %32, %29
%36 = phi i32 [ %31, %29 ], [ %34, %32 ]
%37 = or i32 %36, %14
br label %38
38: ; preds = %35, %24
%39 = phi i32 [ %26, %24 ], [ %37, %35 ]
ret i32 %39
}