// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0xa0, %rsp
movl %ecx, %ebp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rsi, (%rdi)
leaq 0x40(%rsp), %r14
movq %rdx, (%r14)
movq %r14, %rsi
callq 0x12000
movq (%r14), %r14
testq %r14, %r14
je 0x1f2cc
movq 0x20(%rsp), %r15
cmpq $0x4, %r14
jb 0x1f35c
movb (%r15), %al
cmpb $0x66, %al
jb 0x1f35c
cmpb $0x74, %al
jne 0x1f2ec
leaq 0x2d90(%rip), %rdx      # 0x22028
movq %r15, %rdi
movq %r14, %rsi
callq 0x1f544
testb %al, %al
je 0x1f2e9
movb $0x1, %al
movb %al, (%rbx)
andq $0x0, 0x8(%rbx)
movl $0x1, 0x18(%rbx)
andw $0x0, 0x1c(%rbx)
movq $0x1, 0x10(%rbx)
movb %al, 0x1e(%rbx)
jmp 0x1f515
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
andl $0x0, 0x18(%rbx)
xorl %eax, %eax
movb %al, (%rbx)
movw $0xb, 0x1c(%rbx)
movb %al, 0x1e(%rbx)
jmp 0x1f515
movb (%r15), %al
leal -0x46(%rax), %ecx
rolb $0x5, %cl
cmpb $0x5, %cl
ja 0x1f35c
movzbl %cl, %ecx
leaq 0x2cdf(%rip), %rdx      # 0x21fe0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpq $0x5, %r14
jne 0x1f31e
cmpl $0x65736c61, 0x1(%r15)  # imm = 0x65736C61
je 0x1f528
movzbl %al, %eax
orl $0x20, %eax
cmpl $0x6e, %eax
jne 0x1f35c
leaq 0x2d03(%rip), %rdx      # 0x22033
movq %r15, %rdi
movq %r14, %rsi
callq 0x1f544
testb %al, %al
je 0x1f35c
xorps %xmm0, %xmm0
andl $0x0, 0x18(%rbx)
movups %xmm0, 0x8(%rbx)
movb $0x1, (%rbx)
movw $0xb, 0x1c(%rbx)
movb $0x0, 0x1e(%rbx)
jmp 0x1f515
movb $0x0, 0xe(%rsp)
addb $-0x9, %bpl
cmpb $0x2, %bpl
jb 0x1f43c
cmpb $0x2d, (%r15)
jne 0x1f383
cmpq $0x1, %r14
jne 0x1f389
xorl %edx, %edx
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x1f3c9
xorl %eax, %eax
xorl %edx, %edx
jmp 0x1f38e
pushq $0x1
popq %rdx
movb $0x1, %al
xorl %esi, %esi
movq %rsi, %rcx
cmpq %r14, %rdx
jae 0x1f3bd
movzbl (%r15,%rdx), %esi
leal -0x3a(%rsi), %edi
cmpb $-0xa, %dil
jb 0x1f3b9
imulq $0xa, %rcx, %rdi
addq %rdi, %rsi
addq $-0x30, %rsi
incq %rdx
cmpq %rcx, %rsi
jae 0x1f390
xorl %edx, %edx
jmp 0x1f3c9
movb $0x1, %dl
testb %al, %al
je 0x1f3c9
testq %rcx, %rcx
setns %dl
leaq 0x28(%rsp), %rsi
movb %dl, (%rsi)
movb %al, 0x1(%rsi)
movq %rcx, 0x8(%rsi)
leaq 0xe(%rsp), %r12
leaq 0x60(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x10(%rsp), %rax
movq %rax, 0x8(%rdi)
leaq 0x48(%rsp), %rax
movq %rax, 0x10(%rdi)
callq 0x12b20
cmpb $0x1, (%r12)
jne 0x1f43c
movb 0x10(%rsp), %al
movq 0x48(%rsp), %rcx
movq %rcx, %rdx
negq %rdx
testb %al, %al
cmoveq %rcx, %rdx
movb $0x8, %cl
subb %al, %cl
movb $0x1, (%rbx)
andq $0x0, 0x8(%rbx)
movq %rdx, 0x10(%rbx)
movl $0x8, 0x18(%rbx)
movb %cl, 0x1c(%rbx)
movw $0x100, 0x1d(%rbx)      # imm = 0x100
jmp 0x1f515
leaq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movq %r14, 0x38(%rsp)
incq %r14
cmpq $0x3f, %r14
ja 0x1f474
leaq 0x28(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1fee0
testb %al, %al
je 0x1f4e0
movsd 0x10(%rsp), %xmm2
jmp 0x1f4b7
leaq 0x48(%rsp), %r15
leaq 0xf(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x119a0
movq (%r15), %rsi
leaq 0x28(%rsp), %rdi
callq 0x1fee0
movl %eax, %ebp
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
callq 0x12b60
movsd 0x18(%rsp), %xmm2
testb %bpl, %bpl
je 0x1f4e0
andq $0x0, 0x60(%rsp)
cvtsd2ss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm1
ucomisd %xmm1, %xmm2
jne 0x1f4f4
jp 0x1f4f4
movss %xmm0, 0x60(%rsp)
movb $0x9, %al
pushq $0x4
popq %rcx
movsd 0x60(%rsp), %xmm2
jmp 0x1f4f9
xorps %xmm0, %xmm0
andl $0x0, 0x18(%rbx)
movups %xmm0, 0x8(%rbx)
movb $0x0, (%rbx)
movb $0xb, %al
xorl %ecx, %ecx
jmp 0x1f50b
movb $0xa, %al
pushq $0x8
popq %rcx
movb $0x1, (%rbx)
andq $0x0, 0x8(%rbx)
movsd %xmm2, 0x10(%rbx)
movl %ecx, 0x18(%rbx)
movb $0x1, %cl
movb %al, 0x1c(%rbx)
movb $0x0, 0x1d(%rbx)
movb %cl, 0x1e(%rbx)
movq %rbx, %rax
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
movb %al, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movl $0x1, 0x18(%rbx)
andw $0x0, 0x1c(%rbx)
jmp 0x1f2c4