// File: AshOlogn[P]ash-language-interpreter/src/casteval.cpp
// Function: castHelper(ParseData, ParseDataType)
ParseData castHelper(ParseData orig, ParseDataType finalType) {
  
  ParseDataType origType = orig.type;
  ParseData d;
  d.type = finalType;
  
  switch(origType) {
        
		case ARRAY_T: {
			if(finalType == ARRAY_T)
				d.value.allocated = orig.value.allocated;
			break;
		}
    
    case BOOL_T: {
      
      switch(finalType) {
        case BOOL_T: d.value.integer = orig.value.integer; break;
        case CHAR_T: d.value.integer = (unsigned char) orig.value.integer; break;
        case INT32_T: d.value.integer = (int32_t) orig.value.integer; break;
        case INT64_T: d.value.integer = (int64_t) orig.value.integer; break;
        case UINT32_T: d.value.integer = (uint32_t) orig.value.integer; break;
        case UINT64_T: d.value.integer = (uint64_t) orig.value.integer; break;
        case DOUBLE_T: d.value.floatingPoint = (double) orig.value.integer; break;
        case STRING_T: {
          d.value.allocated = (void*) copyString((orig.value.integer) ? "true" : "false");
          break;
        }
      } 
    }
    
    case CHAR_T: {
      switch(finalType) {
        case BOOL_T: d.value.integer = (orig.value.integer) ? 1 : 0; break;
        case CHAR_T: d.value.integer = (unsigned char) ((unsigned char) orig.value.integer); break;
        case INT32_T: d.value.integer = (int32_t) ((unsigned char) orig.value.integer); break;
        case INT64_T: d.value.integer = (int64_t) ((unsigned char) orig.value.integer); break;
        case UINT32_T: d.value.integer = (uint32_t) ((unsigned char) orig.value.integer); break;
        case UINT64_T: d.value.integer = (uint64_t) ((unsigned char) orig.value.integer); break;
        case DOUBLE_T: d.value.floatingPoint = (double) ((unsigned char) orig.value.integer); break;
        case STRING_T: {
          char* res = new char[2];
          res[0] = (unsigned char) orig.value.integer;
          res[1] = '\0';
          d.value.allocated = (void*) res;
          break;
        }
      }
      break;
    }
    
    case INT32_T: {
      switch(finalType) {
        case BOOL_T: d.value.integer = (orig.value.integer) ? 1 : 0; break;
        case CHAR_T: d.value.integer = (unsigned char) ((int32_t) orig.value.integer); break;
        case INT32_T: d.value.integer = (int32_t) orig.value.integer; break;
        case INT64_T: d.value.integer = (int64_t) ((int32_t) orig.value.integer); break;
        case UINT32_T: d.value.integer = (uint32_t) ((int32_t) orig.value.integer); break;
        case UINT64_T: d.value.integer = (uint64_t) ((int32_t) orig.value.integer); break;
        case DOUBLE_T: d.value.floatingPoint = (double) ((int32_t) orig.value.integer); break;
        case STRING_T: {
          d.value.allocated = (void*) copyString(std::to_string((int32_t) orig.value.integer).c_str());
          break;
        }
      }
      break;
    }
    
    case INT64_T: {
      switch(finalType) {
        case BOOL_T: d.value.integer = (orig.value.integer) ? 1 : 0; break;
        case CHAR_T: d.value.integer = (unsigned char) ((int64_t) orig.value.integer); break;
        case INT32_T: d.value.integer = (int32_t) ((int64_t) orig.value.integer); break;
        case INT64_T: d.value.integer = (int64_t) ((int64_t) orig.value.integer); break;
        case UINT32_T: d.value.integer = (uint32_t) ((int64_t) orig.value.integer); break;
        case UINT64_T: d.value.integer = (uint64_t) ((int64_t) orig.value.integer); break;
        case DOUBLE_T: d.value.floatingPoint = (double) ((int64_t) orig.value.integer); break;
        case STRING_T: {
          d.value.allocated = (void*) copyString(std::to_string((int64_t) orig.value.integer).c_str());
          break;
        }
      }
      break;
    }
    
    case UINT32_T: {
      switch(finalType) {
        case BOOL_T: d.value.integer = (orig.value.integer) ? 1 : 0; break;
        case CHAR_T: d.value.integer = (unsigned char) ((uint32_t) orig.value.integer); break;
        case INT32_T: d.value.integer = (int32_t) orig.value.integer; break;
        case INT64_T: d.value.integer = (int64_t) ((uint32_t) orig.value.integer); break;
        case UINT32_T: d.value.integer = (uint32_t) ((uint32_t) orig.value.integer); break;
        case UINT64_T: d.value.integer = (uint64_t) ((uint32_t) orig.value.integer); break;
        case DOUBLE_T: d.value.floatingPoint = (double) ((uint32_t) orig.value.integer); break;
        case STRING_T: {
          d.value.allocated = (void*) copyString(std::to_string((uint32_t) orig.value.integer).c_str());
          break;
        }
      }
      break;
    }
    
    case UINT64_T: {
      switch(finalType) {
        case BOOL_T: d.value.integer = (orig.value.integer) ? 1 : 0; break;
        case CHAR_T: d.value.integer = (unsigned char) ((uint64_t) orig.value.integer); break;
        case INT32_T: d.value.integer = (int32_t) ((uint64_t) orig.value.integer); break;
        case INT64_T: d.value.integer = (int64_t) ((uint64_t) orig.value.integer); break;
        case UINT32_T: d.value.integer = (uint32_t) ((uint64_t) orig.value.integer); break;
        case UINT64_T: d.value.integer = (uint64_t) ((uint64_t) orig.value.integer); break;
        case DOUBLE_T: d.value.floatingPoint = (double) ((uint64_t) orig.value.integer); break;
        case STRING_T: {
          d.value.allocated = (void*) copyString(std::to_string((uint64_t) orig.value.integer).c_str());
          break;
        }
      }
      break;
    }
    
    case DOUBLE_T: {
      
      switch(finalType) {
        case BOOL_T: d.value.integer = (std::abs((double) orig.value.floatingPoint) > 1.0e-16) ? 1 : 0; break;
        case CHAR_T: d.value.integer = (unsigned char) ((double) orig.value.floatingPoint); break;  
        case INT32_T: d.value.integer = (int32_t) ((double) orig.value.floatingPoint); break; 
        case INT64_T: d.value.integer = (int64_t) ((double) orig.value.floatingPoint); break; 
        case UINT32_T: d.value.integer = (uint32_t) ((double) orig.value.floatingPoint); break; 
        case UINT64_T: d.value.integer = (uint64_t) ((double) orig.value.floatingPoint); break; 
        case DOUBLE_T: d.value.floatingPoint = orig.value.floatingPoint; break;
        case STRING_T: {
          d.value.allocated = (void*) copyString(std::to_string((double) orig.value.floatingPoint).c_str());
          break;
        }
      }
      break;
    }
    
    case STRING_T: {
      if(finalType == STRING_T) {
        d.value.allocated = (void*) copyString((char*) orig.value.allocated);
      }
      
      break;
    }
    
  }
  
  return d;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl %edi, -0x20(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x24(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x28(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0xe8(%rbp)
subl $0xa, %eax
ja 0x2a3a8
movq -0xe8(%rbp), %rax
leaq 0x1a579(%rip), %rcx     # 0x441d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0xc, -0x24(%rbp)
jne 0x29c6e
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2a3a8
movl -0x24(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0xf0(%rbp)
subl $0x9, %eax
ja 0x29d39
movq -0xf0(%rbp), %rax
leaq 0x1a62b(%rip), %rcx     # 0x442c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x29d39
movq -0x18(%rbp), %rax
movzbl %al, %eax
movq %rax, -0x8(%rbp)
jmp 0x29d39
movq -0x18(%rbp), %rax
cltq
movq %rax, -0x8(%rbp)
jmp 0x29d39
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x29d39
movq -0x18(%rbp), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x29d39
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x29d39
movaps 0x16801(%rip), %xmm1    # 0x404f0
movq -0x18(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x16800(%rip), %xmm1    # 0x40500
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x29d39
movq -0x18(%rbp), %rcx
leaq 0x15b8a(%rip), %rdi     # 0x3f8ab
leaq 0x15b7e(%rip), %rax     # 0x3f8a6
cmpq $0x0, %rcx
cmovneq %rax, %rdi
callq 0x2fb10
movq %rax, -0x8(%rbp)
jmp 0x29d3b
movl -0x24(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0xf8(%rbp)
subl $0x9, %eax
ja 0x29e02
movq -0xf8(%rbp), %rax
leaq 0x1a58b(%rip), %rcx     # 0x442ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
cltq
movq %rax, -0x8(%rbp)
jmp 0x29e02
movq -0x18(%rbp), %rax
movzbl %al, %eax
movq %rax, -0x8(%rbp)
jmp 0x29e02
movq -0x18(%rbp), %rax
movzbl %al, %eax
cltq
movq %rax, -0x8(%rbp)
jmp 0x29e02
movq -0x18(%rbp), %rax
movzbl %al, %eax
movq %rax, -0x8(%rbp)
jmp 0x29e02
movq -0x18(%rbp), %rax
movzbl %al, %eax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x29e02
movq -0x18(%rbp), %rax
movzbl %al, %eax
movq %rax, -0x8(%rbp)
jmp 0x29e02
movzbl -0x18(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x29e02
movl $0x2, %edi
callq 0x4030
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x1(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2a3a8
movl -0x24(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x100(%rbp)
subl $0x9, %eax
ja 0x29f08
movq -0x100(%rbp), %rax
leaq 0x1a46f(%rip), %rcx     # 0x4429c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
cltq
movq %rax, -0x8(%rbp)
jmp 0x29f08
movq -0x18(%rbp), %rax
movzbl %al, %eax
movq %rax, -0x8(%rbp)
jmp 0x29f08
movq -0x18(%rbp), %rax
cltq
movq %rax, -0x8(%rbp)
jmp 0x29f08
movq -0x18(%rbp), %rax
cltq
movq %rax, -0x8(%rbp)
jmp 0x29f08
movq -0x18(%rbp), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x29f08
movq -0x18(%rbp), %rax
cltq
movq %rax, -0x8(%rbp)
jmp 0x29f08
movq -0x18(%rbp), %rax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x29f08
movl -0x18(%rbp), %esi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x7570
movq -0x110(%rbp), %rdi
callq 0x40e0
movq %rax, %rdi
callq 0x2fb10
movq %rax, -0x108(%rbp)
jmp 0x29ed8
movq -0x108(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4170
jmp 0x29f08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4170
jmp 0x2a3b8
jmp 0x2a3a8
movl -0x24(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x118(%rbp)
subl $0x9, %eax
ja 0x2a009
movq -0x118(%rbp), %rax
leaq 0x1a341(%rip), %rcx     # 0x44274
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
cltq
movq %rax, -0x8(%rbp)
jmp 0x2a009
movq -0x18(%rbp), %rax
movzbl %al, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a009
movq -0x18(%rbp), %rax
cltq
movq %rax, -0x8(%rbp)
jmp 0x2a009
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2a009
movq -0x18(%rbp), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a009
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2a009
cvtsi2sdq -0x18(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x2a009
movq -0x18(%rbp), %rsi
leaq -0x80(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0xc600
movq -0x128(%rbp), %rdi
callq 0x40e0
movq %rax, %rdi
callq 0x2fb10
movq %rax, -0x120(%rbp)
jmp 0x29fd9
movq -0x120(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4170
jmp 0x2a009
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4170
jmp 0x2a3b8
jmp 0x2a3a8
movl -0x24(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x130(%rbp)
subl $0x9, %eax
ja 0x2a11b
movq -0x130(%rbp), %rax
leaq 0x1a218(%rip), %rcx     # 0x4424c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
cltq
movq %rax, -0x8(%rbp)
jmp 0x2a11b
movq -0x18(%rbp), %rax
movzbl %al, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a11b
movq -0x18(%rbp), %rax
cltq
movq %rax, -0x8(%rbp)
jmp 0x2a11b
movq -0x18(%rbp), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a11b
movq -0x18(%rbp), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a11b
movq -0x18(%rbp), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a11b
movl -0x18(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x2a11b
movl -0x18(%rbp), %esi
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x6e40
movq -0x140(%rbp), %rdi
callq 0x40e0
movq %rax, %rdi
callq 0x2fb10
movq %rax, -0x138(%rbp)
jmp 0x2a0e5
movq -0x138(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x4170
jmp 0x2a11b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x4170
jmp 0x2a3b8
jmp 0x2a3a8
movl -0x24(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x148(%rbp)
subl $0x9, %eax
ja 0x2a24c
movq -0x148(%rbp), %rax
leaq 0x1a0de(%rip), %rcx     # 0x44224
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
cltq
movq %rax, -0x8(%rbp)
jmp 0x2a24c
movq -0x18(%rbp), %rax
movzbl %al, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a24c
movq -0x18(%rbp), %rax
cltq
movq %rax, -0x8(%rbp)
jmp 0x2a24c
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2a24c
movq -0x18(%rbp), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a24c
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2a24c
movaps 0x16335(%rip), %xmm1    # 0x404f0
movq -0x18(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x16334(%rip), %xmm1    # 0x40500
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x2a24c
movq -0x18(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0xc730
movq -0x158(%rbp), %rdi
callq 0x40e0
movq %rax, %rdi
callq 0x2fb10
movq %rax, -0x150(%rbp)
jmp 0x2a216
movq -0x150(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x4170
jmp 0x2a24c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x4170
jmp 0x2a3b8
jmp 0x2a3a8
movl -0x24(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x160(%rbp)
subl $0x9, %eax
ja 0x2a391
movq -0x160(%rbp), %rax
leaq 0x19f85(%rip), %rcx     # 0x441fc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd -0x18(%rbp), %xmm0
callq 0x2a430
movsd 0x19f1e(%rip), %xmm1    # 0x441b0
xorl %eax, %eax
movl $0x1, %ecx
ucomisd %xmm1, %xmm0
cmoval %ecx, %eax
cltq
movq %rax, -0x8(%rbp)
jmp 0x2a391
cvttsd2si -0x18(%rbp), %eax
movzbl %al, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a391
cvttsd2si -0x18(%rbp), %eax
cltq
movq %rax, -0x8(%rbp)
jmp 0x2a391
cvttsd2si -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2a391
cvttsd2si -0x18(%rbp), %rax
movl %eax, %eax
movq %rax, -0x8(%rbp)
jmp 0x2a391
movsd -0x18(%rbp), %xmm0
movsd 0x1695f(%rip), %xmm2    # 0x40c58
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rcx
cvttsd2si %xmm0, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x2a391
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x2a391
movsd -0x18(%rbp), %xmm0
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0xc810
movq -0x170(%rbp), %rdi
callq 0x40e0
movq %rax, %rdi
callq 0x2fb10
movq %rax, -0x168(%rbp)
jmp 0x2a35e
movq -0x168(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4170
jmp 0x2a391
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x4170
jmp 0x2a3b8
jmp 0x2a3a8
cmpl $0xb, -0x24(%rbp)
jne 0x2a3a6
movq -0x18(%rbp), %rdi
callq 0x2fb10
movq %rax, -0x8(%rbp)
jmp 0x2a3a8
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rdx
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x4420
nopw %cs:(%rax,%rax)