#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 */
scalar_t__ json_number_toDouble(char *, int /*<<< orphan*/, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
void test_json_number_toDouble() {
  puts("Test json_number_toDouble");
  puts("======================================================================="
       "=========");
  char *str[100] = {"--123",    "abc",    "123\n", "456",     "-",
                    "-abc",     "-123",   "0",     "-0",      "0.",
                    ".",        "0.0",    "1.2.3", "-10.123", "10.e",
                    "10..",     "e",      "-E",    "-0e12",   "10.5e00abc",
                    "10.5E+13", "8.5E-2", "8e",    "123E-",   "456E+",
                    "9.e",      "9.e99",  "0ee",   "",        "0.0eabc",
                    "0.0e-abc"};
  int i;
  for (i = 0; str[i] != NULL; i++) {
    double number;
    printf("%d. ", i + 1);
    if (json_number_toDouble(str[i], 0, &number) != 0) {
      printf("%s is not number\n", str[i]);
    } else {
      printf("%s = %f\n", str[i], number);
    }
  }
  puts("======================================================================="
       "=========\n");
}


x86 assembly (clang, -O0):
<test_json_number_toDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x330,%rsp
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    -0x320(%rbp),%rdi
lea    0x298f(%rip),%rsi
mov    $0x320,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x324(%rbp)
movslq -0x324(%rbp),%rax
cmpq   $0x0,-0x320(%rbp,%rax,8)
je     1239 <test_json_number_toDouble+0xf9>
mov    -0x324(%rbp),%esi
add    $0x1,%esi
lea    0xf43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x324(%rbp),%rax
mov    -0x320(%rbp,%rax,8),%rdi
ff
xor    %esi,%esi
lea    -0x330(%rbp),%rdx
call   1060 <json_number_toDouble@plt>
cmp    $0x0,%rax
je     11fb <test_json_number_toDouble+0xbb>
movslq -0x324(%rbp),%rax
mov    -0x320(%rbp,%rax,8),%rsi
ff
lea    0xf04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1220 <test_json_number_toDouble+0xe0>
movslq -0x324(%rbp),%rax
mov    -0x320(%rbp,%rax,8),%rsi
ff
movsd  -0x330(%rbp),%xmm0
ff
lea    0xeec(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1225 <test_json_number_toDouble+0xe5>
mov    -0x324(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x324(%rbp)
jmp    1185 <test_json_number_toDouble+0x45>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
add    $0x330,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_json_number_toDouble>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xf11(%rip),%rbp
mov    $0x1,%ebx
lea    0xf88(%rip),%r14
mov    %rsp,%r15
lea    0x2990(%rip),%r12
lea    0xf7c(%rip),%r13
jmp    11a4 <test_json_number_toDouble+0x74>
nopl   0x0(%rax)
movsd  (%rsp),%xmm0
lea    0xf79(%rip),%rdi
mov    %rbp,%rsi
mov    $0x1,%al
call   1040 <printf@plt>
mov    (%r12,%rbx,8),%rbp
add    $0x1,%rbx
cmp    $0x20,%rbx
je     11d1 <test_json_number_toDouble+0xa1>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1050 <json_number_toDouble@plt>
test   %rax,%rax
je     1180 <test_json_number_toDouble+0x50>
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1196 <test_json_number_toDouble+0x66>
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Test json_number_toDouble\00"
@.str.1 = [81 x i8] c"================================================================================\00"
@.str.2 = [6 x i8] c"--123\00"
@.str.3 = [4 x i8] c"abc\00"
@.str.4 = [5 x i8] c"123\0A\00"
@.str.5 = [4 x i8] c"456\00"
@.str.6 = [2 x i8] c"-\00"
@.str.7 = [5 x i8] c"-abc\00"
@.str.8 = [5 x i8] c"-123\00"
@.str.9 = [2 x i8] c"0\00"
@.str.10 = [3 x i8] c"-0\00"
@.str.11 = [3 x i8] c"0.\00"
@.str.12 = [2 x i8] c".\00"
@.str.13 = [4 x i8] c"0.0\00"
@.str.14 = [6 x i8] c"1.2.3\00"
@.str.15 = [8 x i8] c"-10.123\00"
@.str.16 = [5 x i8] c"10.e\00"
@.str.17 = [5 x i8] c"10..\00"
@.str.18 = [2 x i8] c"e\00"
@.str.19 = [3 x i8] c"-E\00"
@.str.20 = [6 x i8] c"-0e12\00"
@.str.21 = [11 x i8] c"10.5e00abc\00"
@.str.22 = [9 x i8] c"10.5E+13\00"
@.str.23 = [7 x i8] c"8.5E-2\00"
@.str.24 = [3 x i8] c"8e\00"
@.str.25 = [6 x i8] c"123E-\00"
@.str.26 = [6 x i8] c"456E+\00"
@.str.27 = [4 x i8] c"9.e\00"
@.str.28 = [6 x i8] c"9.e99\00"
@.str.29 = [4 x i8] c"0ee\00"
@.str.30 = [1 x i8] zeroinitializer
@.str.31 = [8 x i8] c"0.0eabc\00"
@.str.32 = [9 x i8] c"0.0e-abc\00"
@__const.test_json_number_toDouble.str = <{ [31 x i8*], [69 x i8*] }> <{ [31 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.31, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.32, i32 0, i32 0)], [69 x i8*] zeroinitializer }>
@.str.33 = [5 x i8] c"%d. \00"
@.str.34 = [18 x i8] c"%s is not number\0A\00"
@.str.35 = [9 x i8] c"%s = %f\0A\00"
@.str.36 = [82 x i8] c"================================================================================\0A\00"
define void @test_json_number_toDouble() {
%1 = alloca [100 x i8*]
%2 = alloca i32
%3 = alloca double
%4 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%6 = bitcast [100 x i8*]* %1 to i8*
store i32 0, i32* %2
br label %7
7: ; preds = %37, %0
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 %9
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %40
13: ; preds = %7
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.33, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = call i64 @json_number_toDouble(i8* %20, i32 0, double* %3)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %13
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.34, i64 0, i64 0), i8* %27)
br label %36
29: ; preds = %13
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i8*], [100 x i8*]* %1, i64 0, i64 %31
%33 = load i8*, i8** %32
%34 = load double, double* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.35, i64 0, i64 0), i8* %33, double %34)
br label %36
36: ; preds = %29, %23
br label %37
37: ; preds = %36
%38 = load i32, i32* %2
%39 = add nsw i32 %38, 1
store i32 %39, i32* %2
br label %7
40: ; preds = %7
%41 = call i32 @puts(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.36, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Test json_number_toDouble\00"
@.str.1 = [81 x i8] c"================================================================================\00"
@.str.2 = [6 x i8] c"--123\00"
@.str.3 = [4 x i8] c"abc\00"
@.str.4 = [5 x i8] c"123\0A\00"
@.str.5 = [4 x i8] c"456\00"
@.str.6 = [2 x i8] c"-\00"
@.str.7 = [5 x i8] c"-abc\00"
@.str.8 = [5 x i8] c"-123\00"
@.str.9 = [2 x i8] c"0\00"
@.str.10 = [3 x i8] c"-0\00"
@.str.11 = [3 x i8] c"0.\00"
@.str.12 = [2 x i8] c".\00"
@.str.13 = [4 x i8] c"0.0\00"
@.str.14 = [6 x i8] c"1.2.3\00"
@.str.15 = [8 x i8] c"-10.123\00"
@.str.16 = [5 x i8] c"10.e\00"
@.str.17 = [5 x i8] c"10..\00"
@.str.18 = [2 x i8] c"e\00"
@.str.19 = [3 x i8] c"-E\00"
@.str.20 = [6 x i8] c"-0e12\00"
@.str.21 = [11 x i8] c"10.5e00abc\00"
@.str.22 = [9 x i8] c"10.5E+13\00"
@.str.23 = [7 x i8] c"8.5E-2\00"
@.str.24 = [3 x i8] c"8e\00"
@.str.25 = [6 x i8] c"123E-\00"
@.str.26 = [6 x i8] c"456E+\00"
@.str.27 = [4 x i8] c"9.e\00"
@.str.28 = [6 x i8] c"9.e99\00"
@.str.29 = [4 x i8] c"0ee\00"
@.str.30 = [1 x i8] zeroinitializer
@.str.31 = [8 x i8] c"0.0eabc\00"
@.str.32 = [9 x i8] c"0.0e-abc\00"
@__const.test_json_number_toDouble.str = <{ [31 x i8*], [69 x i8*] }> <{ [31 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.31, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.32, i32 0, i32 0)], [69 x i8*] zeroinitializer }>
@.str.33 = [5 x i8] c"%d. \00"
@.str.34 = [18 x i8] c"%s is not number\0A\00"
@.str.35 = [9 x i8] c"%s = %f\0A\00"
@.str.36 = [82 x i8] c"================================================================================\0A\00"
define void @test_json_number_toDouble() {
%1 = alloca double
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast double* %1 to i8*
br label %5
5: ; preds = %0, %18
%6 = phi i64 [ 0, %0 ], [ %8, %18 ]
%7 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %0 ], [ %20, %18 ]
%8 = add nuw nsw i64 %6, 1
%9 = trunc i64 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.33, i64 0, i64 0), i32 %9)
%11 = call i64 @json_number_toDouble(i8* %7, i32 0, double* %1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %5
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.34, i64 0, i64 0), i8* %7)
br label %18
15: ; preds = %5
%16 = load double, double* %1
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.35, i64 0, i64 0), i8* %7, double %16)
br label %18
18: ; preds = %15, %13
%19 = getelementptr inbounds [100 x i8*], [100 x i8*]* bitcast (<{ [31 x i8*], [69 x i8*] }>* @__const.test_json_number_toDouble.str to [100 x i8*]*), i64 0, i64 %8
%20 = load i8*, i8** %19
%21 = icmp eq i64 %8, 31
br i1 %21, label %22, label %5
22: ; preds = %18
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str.36, i64 0, i64 0))
ret void
}