#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 */
double my_str2double(char const *, char const **);
const char *json_parse_double(const char *s, double *dp) {
  const char *ep;
  while (*s > 0 && *s < 33)
    s++;
  double d = my_str2double(s, &ep);
  if (ep == s)
    return NULL;
  *dp = d;
  return ep;
}


x86 assembly (clang, -O0):
<json_parse_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
jle    1145 <json_parse_double+0x35>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1155 <json_parse_double+0x45>
jmp    1166 <json_parse_double+0x56>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <json_parse_double+0x10>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <my_str2double@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1193 <json_parse_double+0x83>
movq   $0x0,-0x8(%rbp)
jmp    11a8 <json_parse_double+0x98>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<json_parse_double>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
xchg   %ax,%ax
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
add    $0xff,%al
cmp    $0x20,%al
jb     1120 <json_parse_double+0x10>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <my_str2double@plt>
mov    (%rsp),%rax
cmp    %rax,%rbx
je     1149 <json_parse_double+0x39>
movsd  %xmm0,(%r14)
jmp    114b <json_parse_double+0x3b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @json_parse_double(i8* %0, double* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i8*
%7 = alloca double
store i8* %0, i8** %4
store double* %1, double** %5
br label %8
8: ; preds = %20, %2
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp slt i32 %16, 33
br label %18
18: ; preds = %13, %8
%19 = phi i1 [ false, %8 ], [ %17, %13 ]
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
br label %8
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = call double @my_str2double(i8* %24, i8** %6)
store double %25, double* %7
%26 = load i8*, i8** %6
%27 = load i8*, i8** %4
%28 = icmp eq i8* %26, %27
br i1 %28, label %29, label %30
29: ; preds = %23
store i8* null, i8** %3
br label %34
30: ; preds = %23
%31 = load double, double* %7
%32 = load double*, double** %5
store double %31, double* %32
%33 = load i8*, i8** %6
store i8* %33, i8** %3
br label %34
34: ; preds = %30, %29
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
define i8* @json_parse_double(i8* %0, double* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
br label %5
5: ; preds = %5, %2
%6 = phi i8* [ %0, %2 ], [ %10, %5 ]
%7 = load i8, i8* %6
%8 = add i8 %7, -1
%9 = icmp ult i8 %8, 32
%10 = getelementptr inbounds i8, i8* %6, i64 1
br i1 %9, label %5, label %11
11: ; preds = %5
%12 = call double @my_str2double(i8* %6, i8** %3)
%13 = load i8*, i8** %3
%14 = icmp eq i8* %13, %6
br i1 %14, label %16, label %15
15: ; preds = %11
store double %12, double* %1
br label %16
16: ; preds = %11, %15
%17 = phi i8* [ %13, %15 ], [ null, %11 ]
ret i8* %17
}