// File: /workspace/github_cpp_makefile_star2_O1/marxn[P]pupp/src/parser/constval.cpp
// Function: ConstValueCast(ConstValue*, DataType)
ConstValue * ConstValueCast(ConstValue * value, DataType dst_type)
{
        switch(dst_type)
        {
                case String:
                        return new StringValue(value->toString());
                break;
                case Decimal:
                        return new DecimalValue(value->toString());
                break;
                case Integer:
                        {
                                string s = value->toString();
                                long value = 0;
                                if(sscanf(s.c_str(), "%ld", &value)==0)
                                {
                                        return NULL;
                                }
                        }

                        return new IntegerValue(value->toString());
                break;
                case Boolean:
                        if(value->GetType()!=Boolean)
                        {
                                string s = value->toString();
                                if(s=="0" || s=="")
                                {
                                        return new BooleanValue(false);
                                }

                                return new BooleanValue(true);
                        }

                        value->DupValue();
                break;
        }

        return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x90, %rsp
decl %esi
cmpl $0x3, %esi
ja 0x9667
movq %rdi, %r14
leaq 0x2cad4(%rip), %rax     # 0x36070
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq (%r14), %rax
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq *0x18(%rax)
leaq 0x68(%rsp), %rdx
movq $0x0, (%rdx)
movq (%r15), %rdi
leaq 0x3225b(%rip), %rsi     # 0x3b827
xorl %eax, %eax
callq 0x6240
movl %eax, %ebx
movq (%r15), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x95ef
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6270
testl %ebx, %ebx
je 0x9667
movl $0x18, %edi
callq 0x6260
movq %rax, %rbx
movq (%r14), %rax
leaq 0x70(%rsp), %rdi
movq %r14, %rsi
callq *0x18(%rax)
movl $0x1, 0x8(%rbx)
leaq 0x3d6dc(%rip), %rax     # 0x46cf8
movq %rax, (%rbx)
leaq 0x80(%rsp), %r15
movq -0x10(%r15), %r14
movq %r14, %rdi
callq 0x6350
movq %rax, 0x10(%rbx)
cmpq %r15, %r14
je 0x977e
movq 0x80(%rsp), %rsi
incq %rsi
movq %r14, %rdi
jmp 0x9779
cmpl $0x3, 0x8(%r14)
jne 0x96f6
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
xorl %ebx, %ebx
jmp 0x977e
movl $0x30, %edi
callq 0x6260
movq %rax, %rbx
movq (%r14), %rax
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
callq *0x18(%rax)
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x7f9a
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x977e
movq 0x58(%rsp), %rsi
jmp 0x9776
movl $0x28, %edi
callq 0x6260
movq %rax, %rbx
movq (%r14), %rax
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq *0x18(%rax)
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x8270
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x977e
movq 0x38(%rsp), %rsi
jmp 0x9776
movq (%r14), %rax
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
leaq 0x31865(%rip), %rsi     # 0x3af73
movq %rbx, %rdi
callq 0x60c0
testl %eax, %eax
je 0x9740
leaq 0x2c8fd(%rip), %rsi     # 0x3601e
leaq 0x8(%rsp), %rdi
callq 0x60c0
testl %eax, %eax
je 0x9740
movl $0x10, %edi
callq 0x6260
movq %rax, %rbx
movb $0x1, %al
jmp 0x974f
movl $0x10, %edi
callq 0x6260
movq %rax, %rbx
xorl %eax, %eax
movl $0x3, 0x8(%rbx)
leaq 0x3d5fb(%rip), %rcx     # 0x46d58
movq %rcx, (%rbx)
movb %al, 0xc(%rbx)
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x977e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6270
movq %rbx, %rax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x980d
movq 0x18(%rsp), %rsi
incq %rsi
jmp 0x9808
movq %rax, %r14
movl $0x18, %esi
jmp 0x9805
movq %rax, %r14
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x97f6
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6270
jmp 0x97f6
movq %rax, %r14
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9800
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6270
jmp 0x9800
movq %rax, %r14
movl $0x28, %esi
jmp 0x9805
movq %rax, %r14
movl $0x30, %esi
movq %rbx, %rdi
callq 0x6270
movq %r14, %rdi
callq 0x6470
nop