// File: Eba-M[P]E3DC-Control/cJSON.c
// Function: parse_number(cJSON*, parse_buffer*)
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
    double number = 0;
    unsigned char *after_end = NULL;
    unsigned char number_c_string[64];
    unsigned char decimal_point = get_decimal_point();
    size_t i = 0;

    if ((input_buffer == NULL) || (input_buffer->content == NULL))
    {
        return false;
    }

    /* copy the number into a temporary buffer and replace '.' with the decimal point
     * of the current locale (for strtod)
     * This also takes care of '\0' not necessarily being available for marking the end of the input */
    for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++)
    {
        switch (buffer_at_offset(input_buffer)[i])
        {
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
            case '+':
            case '-':
            case 'e':
            case 'E':
                number_c_string[i] = buffer_at_offset(input_buffer)[i];
                break;

            case '.':
                number_c_string[i] = decimal_point;
                break;

            default:
                goto loop_end;
        }
    }
loop_end:
    number_c_string[i] = '\0';

    number = strtod((const char*)number_c_string, (char**)&after_end);
    if (number_c_string == after_end)
    {
        return false; /* parse_error */
    }

    item->valuedouble = number;

    /* use saturation in case of overflow */
    if (number >= INT_MAX)
    {
        item->valueint = INT_MAX;
    }
    else if (number <= (double)INT_MIN)
    {
        item->valueint = INT_MIN;
    }
    else
    {
        item->valueint = (int)number;
    }

    item->type = cJSON_Number;

    input_buffer->offset += (size_t)(after_end - number_c_string);
    return true;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
callq 0x5d740
movb %al, 0x1f(%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x70(%rsp)
je 0x5cb48
movq 0x70(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x5cb58
movl $0x0, 0x84(%rsp)
jmp 0x5cd25
movq $0x0, 0x10(%rsp)
xorl %eax, %eax
cmpq $0x3f, 0x10(%rsp)
movb %al, 0xf(%rsp)
jae 0x5cba3
xorl %eax, %eax
cmpq $0x0, 0x70(%rsp)
movb %al, 0xe(%rsp)
je 0x5cb9b
movq 0x70(%rsp), %rax
movq 0x10(%rax), %rax
addq 0x10(%rsp), %rax
movq 0x70(%rsp), %rcx
cmpq 0x8(%rcx), %rax
setb %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x5cbb0
jmp 0x5cc57
movq 0x70(%rsp), %rax
movq (%rax), %rcx
movq 0x10(%rax), %rax
addq %rax, %rcx
movq 0x10(%rsp), %rax
movzbl (%rax,%rcx), %eax
movl %eax, 0x8(%rsp)
subl $0x2b, %eax
je 0x5cc0d
jmp 0x5cbd3
movl 0x8(%rsp), %eax
subl $0x2d, %eax
je 0x5cc0d
jmp 0x5cbde
movl 0x8(%rsp), %eax
subl $0x2e, %eax
je 0x5cc31
jmp 0x5cbe9
movl 0x8(%rsp), %eax
addl $-0x30, %eax
subl $0xa, %eax
jb 0x5cc0d
jmp 0x5cbf7
movl 0x8(%rsp), %eax
subl $0x45, %eax
je 0x5cc0d
jmp 0x5cc02
movl 0x8(%rsp), %eax
subl $0x65, %eax
jne 0x5cc40
jmp 0x5cc0d
movq 0x70(%rsp), %rax
movq (%rax), %rax
movq 0x70(%rsp), %rcx
addq 0x10(%rcx), %rax
movq 0x10(%rsp), %rcx
movb (%rax,%rcx), %cl
movq 0x10(%rsp), %rax
movb %cl, 0x20(%rsp,%rax)
jmp 0x5cc42
movb 0x1f(%rsp), %cl
movq 0x10(%rsp), %rax
movb %cl, 0x20(%rsp,%rax)
jmp 0x5cc42
jmp 0x5cc59
jmp 0x5cc44
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0x5cb61
jmp 0x5cc59
movq 0x10(%rsp), %rax
movb $0x0, 0x20(%rsp,%rax)
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x21f0
movsd %xmm0, 0x68(%rsp)
leaq 0x20(%rsp), %rax
cmpq 0x60(%rsp), %rax
jne 0x5cc94
movl $0x0, 0x84(%rsp)
jmp 0x5cd25
movsd 0x68(%rsp), %xmm0
movq 0x78(%rsp), %rax
movsd %xmm0, 0x30(%rax)
movsd 0x68(%rsp), %xmm0
movsd 0x5b16(%rip), %xmm1     # 0x627c8
ucomisd %xmm1, %xmm0
jb 0x5ccc6
movq 0x78(%rsp), %rax
movl $0x7fffffff, 0x28(%rax) # imm = 0x7FFFFFFF
jmp 0x5ccf4
movsd 0x5b02(%rip), %xmm0     # 0x627d0
ucomisd 0x68(%rsp), %xmm0
jb 0x5cce4
movq 0x78(%rsp), %rax
movl $0x80000000, 0x28(%rax) # imm = 0x80000000
jmp 0x5ccf2
cvttsd2si 0x68(%rsp), %ecx
movq 0x78(%rsp), %rax
movl %ecx, 0x28(%rax)
jmp 0x5ccf4
movq 0x78(%rsp), %rax
movl $0x8, 0x18(%rax)
movq 0x60(%rsp), %rcx
leaq 0x20(%rsp), %rax
subq %rax, %rcx
movq 0x70(%rsp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movl $0x1, 0x84(%rsp)
movl 0x84(%rsp), %eax
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)