// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movl %ecx, %ebp
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
movq %rsi, (%rdi)
leaq 0x60(%rsp), %r14
movq %rdx, (%r14)
movq %r14, %rsi
callq 0xb9c0
movq (%r14), %r14
testq %r14, %r14
je 0x1c1d7
cmpq $0x4, %r14
jb 0x1c293
movq 0x8(%rsp), %r15
movb (%r15), %al
cmpb $0x66, %al
jb 0x1c293
cmpb $0x74, %al
jne 0x1c1f7
leaq 0x3e65(%rip), %rdx      # 0x20008
movq %r15, %rdi
movq %r14, %rsi
callq 0x1c4fa
testb %al, %al
je 0x1c1f7
movb $0x1, %al
movb %al, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movl $0x1, 0x18(%rbx)
movw $0x0, 0x1c(%rbx)
movq $0x1, 0x10(%rbx)
jmp 0x1c4c3
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 0x1c4c6
movzbl (%r15), %eax
leal -0x46(%rax), %ecx
rolb $0x5, %cl
cmpb $0x5, %cl
ja 0x1c293
movzbl %cl, %ecx
leaq 0x3dac(%rip), %rdx      # 0x1ffc0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpq $0x5, %r14
je 0x1c247
testq %r14, %r14
jne 0x1c255
leaq 0x3ee1(%rip), %rdi      # 0x20110
leaq 0x3eec(%rip), %rsi      # 0x20122
leaq 0x3f68(%rip), %rcx      # 0x201a5
movl $0x55, %edx
callq 0xb540
cmpl $0x65736c61, 0x1(%r15)  # imm = 0x65736C61
je 0x1c4d8
orl $0x20, %eax
cmpl $0x6e, %eax
jne 0x1c293
leaq 0x3daf(%rip), %rdx      # 0x20013
movq %r15, %rdi
movq %r14, %rsi
callq 0x1c4fa
testb %al, %al
je 0x1c293
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movl $0x0, 0x18(%rbx)
movb $0x1, (%rbx)
movw $0xb, 0x1c(%rbx)
movb $0x0, 0x1e(%rbx)
jmp 0x1c4c6
addb $-0x9, %bpl
cmpb $0x2, %bpl
jb 0x1c36d
movq 0x8(%rsp), %rdx
cmpb $0x2d, (%rdx)
jne 0x1c2bc
cmpq $0x1, %r14
jne 0x1c2c2
xorl %edx, %edx
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x1c33c
xorl %eax, %eax
xorl %esi, %esi
jmp 0x1c2c9
movl $0x1, %esi
movb $0x1, %al
cmpq %r14, %rsi
setb %dil
jae 0x1c2e4
movzbl (%rdx,%rsi), %r8d
leal -0x3a(%r8), %ecx
cmpb $-0xa, %cl
jae 0x1c2e8
xorl %ecx, %ecx
jmp 0x1c324
xorl %ecx, %ecx
jmp 0x1c32d
addq $-0x30, %r8
incq %rsi
movq %r8, %rcx
cmpq %rsi, %r14
je 0x1c32d
movq %rsi, %rdi
movzbl (%rdx,%rsi), %esi
leal -0x3a(%rsi), %r8d
cmpb $-0xa, %r8b
jb 0x1c31d
leaq (%rcx,%rcx,4), %r8
leaq (%rsi,%r8,2), %r8
addq $-0x30, %r8
leaq 0x1(%rdi), %rsi
cmpq %rcx, %r8
jae 0x1c2ef
cmpq %r14, %rdi
setb %dil
testb %dil, %dil
je 0x1c32d
xorl %edx, %edx
jmp 0x1c33c
testq %rcx, %rcx
setns %sil
movl %eax, %edx
xorb $0x1, %dl
orb %sil, %dl
testb %dl, %dl
je 0x1c36d
testb %al, %al
je 0x1c4a6
negq %rcx
movb $0x1, %al
movb %al, (%rbx)
movq $0x0, 0x8(%rbx)
movq %rcx, 0x10(%rbx)
movl $0x8, 0x18(%rbx)
movw $0x7, 0x1c(%rbx)
jmp 0x1c4c3
movq 0x8(%rsp), %r15
leaq 0x1(%r14), %rsi
cmpq $0x3f, %rsi
ja 0x1c3bc
leaq 0x10(%rsp), %r12
movq $0x0, (%r12)
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xb790
addq %rsp, %r14
addq $0x20, %r14
movb $0x0, (%r14)
movq %r13, %rdi
movq %r12, %rsi
callq 0xb6d0
cmpq %r14, (%r12)
sete %bpl
jmp 0x1c42e
leaq 0x20(%rsp), %r12
leaq 0x10(%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 0x10(%rsp), %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0xb6d0
cmpq %r15, (%r14)
sete %bpl
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1c42e
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
movsd %xmm0, 0x18(%rsp)
callq 0xb940
movsd 0x18(%rsp), %xmm0
testb %bpl, %bpl
je 0x1c45b
cvtsd2ss %xmm0, %xmm2
movq $0x0, 0x20(%rsp)
cvtss2sd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1c472
jp 0x1c472
movss %xmm2, 0x20(%rsp)
movl $0x4, %ecx
movb $0x9, %al
jmp 0x1c47f
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movl $0x0, 0x18(%rbx)
movb $0x0, (%rbx)
movb $0xb, %al
xorl %ecx, %ecx
jmp 0x1c49a
movsd %xmm0, 0x20(%rsp)
movl $0x8, %ecx
movb $0xa, %al
movb $0x1, (%rbx)
movq $0x0, 0x8(%rbx)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x10(%rbx)
movl %ecx, 0x18(%rbx)
movb $0x1, %cl
movb %al, 0x1c(%rbx)
movb $0x0, 0x1d(%rbx)
movb %cl, 0x1e(%rbx)
jmp 0x1c4c6
movb $0x1, %al
movb %al, (%rbx)
movq $0x0, 0x8(%rbx)
movq %rcx, 0x10(%rbx)
movl $0x8, 0x18(%rbx)
movw $0x8, 0x1c(%rbx)
movb %al, 0x1e(%rbx)
movq %rbx, %rax
addq $0x68, %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)
movq $0x0, 0x10(%rbx)
jmp 0x1c4c3