// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
decl %esi
cmpl $0x3, %esi
ja 0x804c
movq %rdi, %r14
leaq 0x270ab(%rip), %rax     # 0x2f070
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq (%r14), %rax
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq *0x18(%rax)
leaq 0x20(%rsp), %rdx
andq $0x0, (%rdx)
movq (%r15), %rdi
leaq 0x2c827(%rip), %rsi     # 0x34817
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x6230
movl %eax, %ebp
movq %r15, %rdi
callq 0x6130
testl %ebp, %ebp
je 0x811d
pushq $0x18
popq %rdi
callq 0x6260
movq %rax, %rbx
movq (%r14), %rax
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq *0x18(%rax)
leaq 0x68(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6fa6
movq %r14, %rdi
jmp 0x8118
cmpl $0x3, 0x8(%r14)
jne 0x80b0
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
xorl %ebx, %ebx
jmp 0x811d
pushq $0x30
popq %rdi
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 0x6e18
leaq 0x48(%rsp), %rdi
jmp 0x8118
pushq $0x28
popq %rdi
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 0x7098
leaq 0x28(%rsp), %rdi
jmp 0x8118
movq (%r14), %rax
movq %rsp, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
leaq 0x2be9d(%rip), %rsi     # 0x33f63
movq %rbx, %rdi
callq 0x819d
testb %al, %al
jne 0x80e5
leaq 0x26f45(%rip), %rsi     # 0x2f01e
movq %rsp, %rdi
callq 0x819d
testb %al, %al
je 0x80f4
pushq $0x10
popq %rdi
callq 0x6260
movq %rax, %rbx
xorl %eax, %eax
jmp 0x8101
pushq $0x10
popq %rdi
callq 0x6260
movq %rax, %rbx
movb $0x1, %al
movl $0x3, 0x8(%rbx)
leaq 0x39c49(%rip), %rcx     # 0x41d58
movq %rcx, (%rbx)
movb %al, 0xc(%rbx)
movq %rsp, %rdi
callq 0x6130
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rsp, %rdi
callq 0x6130
jmp 0x8175
movq %rax, %r14
pushq $0x18
jmp 0x816c
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x6130
jmp 0x8163
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x6130
jmp 0x816a
movq %rax, %r14
pushq $0x28
jmp 0x816c
movq %rax, %r14
pushq $0x30
popq %rsi
movq %rbx, %rdi
callq 0x6270
movq %r14, %rdi
callq 0x6460
nop