#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 */
int /*<<< orphan*/ luaL_verror(char *, char *, char *);
double luaO_str2d(char *);
double luaU_str2d(char *b, char *where) {
  int negative = (b[0] == '-');
  double x = luaO_str2d(b + negative);
  if (x < 0)
    luaL_verror("cannot convert number '%s' in %s", b, where);
  return negative ? -x : x;
}


x86 assembly (clang, -O0):
<luaU_str2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
call   1030 <luaO_str2d@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    117c <luaU_str2d+0x5c>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe89(%rip),%rdi
call   1040 <luaL_verror@plt>
cmpl   $0x0,-0x14(%rbp)
je     11ac <luaU_str2d+0x8c>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11b6 <luaU_str2d+0x96>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luaU_str2d>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%bpl
xor    %edi,%edi
cmp    $0x2d,%bpl
sete   %dil
add    %rbx,%rdi
call   1030 <luaO_str2d@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1169 <luaU_str2d+0x49>
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
movapd %xmm0,(%rsp)
call   1040 <luaL_verror@plt>
movapd (%rsp),%xmm0
cmp    $0x2d,%bpl
jne    1177 <luaU_str2d+0x57>
xorpd  0xe89(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"cannot convert number '%s' in %s\00"
define double @luaU_str2d(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca double
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
%12 = zext i1 %11 to i32
store i32 %12, i32* %5
%13 = load i8*, i8** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = call double @luaO_str2d(i8* %16)
store double %17, double* %6
%18 = load double, double* %6
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i8*, i8** %3
%22 = load i8*, i8** %4
%23 = call i32 @luaL_verror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
br label %24
24: ; preds = %20, %2
%25 = load i32, i32* %5
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load double, double* %6
%29 = fneg double %28
br label %32
30: ; preds = %24
%31 = load double, double* %6
br label %32
32: ; preds = %30, %27
%33 = phi double [ %29, %27 ], [ %31, %30 ]
ret double %33
}

LLVM IR (-O2):
@.str = [33 x i8] c"cannot convert number '%s' in %s\00"
define double @luaU_str2d(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 45
%5 = zext i1 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call double @luaO_str2d(i8* %6)
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @luaL_verror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %11
11: ; preds = %9, %2
%12 = fneg double %7
%13 = select i1 %4, double %12, double %7
ret double %13
}