// File: /workspace/github_cpp_makefile_star2_O3/night-shift[P]Srl/src/lib/ToolsStrConv.cpp
// Function: Srl::Tools::str_to_type(unsigned char const*, unsigned long, Srl::Type)
pair<bool, Value> Tools::str_to_type(const uint8_t* str, size_t str_len, Type hint)
{
    Tools::trim_space(str, str_len);

    if(str_len < 1) {
        return { false, Value(Type::Null) };
    }

    if(str_len >= 4 && str[0] >= 'f') {

        if((str[0] == 't' || str[0] == 'T') && cmp_str(str, str_len, str_true, 1)) {
            return { true, true };
        }

        if((str[0] == 'f' || str[0] == 'F') && cmp_str(str, str_len, str_false, 1)) {
            return { true, false };
        }

        if((str[0] == 'n' || str[0] == 'N') && cmp_str(str, str_len, str_null, 1)) {
            return { true, Value(Type::Null) };
        }
    }

    bool success = false;

    if(!TpTools::is_fp(hint)) {
        bool is_signed;
        uint64_t i;

        tie(i, is_signed, success) = str_to_int(str, str_len);

        if(success) {
            return is_signed ? make_pair(true, Value(-(int64_t)i)) : make_pair(true, Value(i));
        }
    }

    double fp;
    tie(fp, success) = str_to_double(str, str_len);

    return success ? make_pair(true, Value(fp)) : make_pair(false, Value(Type::Null));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, %ebp
movq %rdi, %rbx
leaq 0x10(%rsp), %rdi
movq %rsi, (%rdi)
leaq 0x20(%rsp), %r14
movq %rdx, (%r14)
movq %r14, %rsi
callq 0xb9c0
movq (%r14), %r14
testq %r14, %r14
je 0x1bdde
movq 0x10(%rsp), %r15
cmpq $0x4, %r14
jb 0x1be74
movb (%r15), %al
cmpb $0x66, %al
jb 0x1be74
cmpb $0x74, %al
jne 0x1be01
leaq 0x325f(%rip), %rdx      # 0x1f008
movq %r15, %rdi
movq %r14, %rsi
callq 0x1c097
testb %al, %al
je 0x1bdfe
movb $0x1, %al
movb %al, (%rbx)
movq $0x0, 0x8(%rbx)
movl $0x1, 0x18(%rbx)
movw $0x0, 0x1c(%rbx)
movq $0x1, 0x10(%rbx)
jmp 0x1c065
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movl $0x0, 0x18(%rbx)
xorl %eax, %eax
movb %al, (%rbx)
movw $0xb, 0x1c(%rbx)
movb %al, 0x1e(%rbx)
jmp 0x1c068
movb (%r15), %al
leal -0x46(%rax), %ecx
rolb $0x5, %cl
cmpb $0x5, %cl
ja 0x1be74
movzbl %cl, %ecx
leaq 0x31aa(%rip), %rdx      # 0x1efc0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpq $0x5, %r14
jne 0x1be33
cmpl $0x65736c61, 0x1(%r15)  # imm = 0x65736C61
je 0x1c07d
movzbl %al, %eax
orl $0x20, %eax
cmpl $0x6e, %eax
jne 0x1be74
leaq 0x31ce(%rip), %rdx      # 0x1f013
movq %r15, %rdi
movq %r14, %rsi
callq 0x1c097
testb %al, %al
je 0x1be74
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movl $0x0, 0x18(%rbx)
movb $0x1, (%rbx)
movw $0xb, 0x1c(%rbx)
movb $0x0, 0x1e(%rbx)
jmp 0x1c068
addb $-0x9, %bpl
cmpb $0x2, %bpl
jae 0x1bf40
leaq 0x1(%r14), %rsi
cmpq $0x3f, %rsi
jbe 0x1bf56
leaq 0x28(%rsp), %r12
leaq 0x18(%rsp), %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0xb600
movq (%r12), %rbp
movq $0x0, (%r13)
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xb790
leaq (%r14,%rbp), %r15
movb $0x0, (%rbp,%r14)
leaq 0x18(%rsp), %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0xb6d0
movq (%r14), %r14
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1befe
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
movsd %xmm0, 0x8(%rsp)
callq 0xb940
movsd 0x8(%rsp), %xmm0
cmpq %r15, %r14
jne 0x1bf96
cvtsd2ss %xmm0, %xmm2
movq $0x0, 0x40(%rsp)
cvtss2sd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1c01d
jp 0x1c01d
movss %xmm2, 0x40(%rsp)
movb $0x9, %al
movl $0x4, %ecx
movsd 0x40(%rsp), %xmm0
jmp 0x1c024
movb (%r15), %al
cmpb $0x2d, %al
je 0x1bf4b
xorl %ecx, %ecx
jmp 0x1bfb0
movl $0x1, %ecx
cmpq $0x1, %r14
jne 0x1bfb0
leaq 0x28(%rsp), %r12
movq $0x0, (%r12)
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xb790
addq %rsp, %r14
addq $0x40, %r14
movb $0x0, (%r14)
movq %r13, %rdi
movq %r12, %rsi
callq 0xb6d0
cmpq %r14, (%r12)
je 0x1bf07
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movl $0x0, 0x18(%rbx)
movb $0x0, (%rbx)
movb $0xb, %al
xorl %ecx, %ecx
jmp 0x1c039
cmpq %r14, %rcx
jae 0x1bff8
xorl %esi, %esi
movzbl (%r15,%rcx), %edx
leal -0x3a(%rdx), %edi
cmpb $-0xa, %dil
jb 0x1be82
leaq (%rsi,%rsi,4), %rdi
leaq (%rdx,%rdi,2), %rdx
addq $-0x30, %rdx
cmpq %rsi, %rdx
jb 0x1be82
incq %rcx
movq %rdx, %rsi
cmpq %rcx, %r14
jne 0x1bfb7
cmpb $0x2d, %al
jne 0x1bffa
testq %rdx, %rdx
js 0x1be82
jmp 0x1bffa
xorl %edx, %edx
cmpb $0x2d, %al
je 0x1c045
movb $0x1, %al
movb %al, (%rbx)
movq $0x0, 0x8(%rbx)
movq %rdx, 0x10(%rbx)
movl $0x8, 0x18(%rbx)
movw $0x8, 0x1c(%rbx)
jmp 0x1c065
movb $0xa, %al
movl $0x8, %ecx
movb $0x1, (%rbx)
movq $0x0, 0x8(%rbx)
movsd %xmm0, 0x10(%rbx)
movl %ecx, 0x18(%rbx)
movb $0x1, %cl
movb %al, 0x1c(%rbx)
movb $0x0, 0x1d(%rbx)
movb %cl, 0x1e(%rbx)
jmp 0x1c068
negq %rdx
movb $0x1, %al
movb %al, (%rbx)
movq $0x0, 0x8(%rbx)
movq %rdx, 0x10(%rbx)
movl $0x8, 0x18(%rbx)
movw $0x7, 0x1c(%rbx)
movb %al, 0x1e(%rbx)
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
movb %al, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movl $0x1, 0x18(%rbx)
movw $0x0, 0x1c(%rbx)
jmp 0x1c065