// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
addl $-0x2, %edi
cmpl $0xa, %edi
ja 0x1540a
movq %rsi, %r15
leaq 0xdb63(%rip), %rax      # 0x22c58
movslq (%rax,%rdi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leal -0x2(%rbx), %eax
cmpl $0x9, %eax
ja 0x1540a
leaq 0xdc13(%rip), %rcx      # 0x22d24
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cvtsi2sd %r15d, %xmm0
jmp 0x1529e
leal -0x2(%rbx), %eax
cmpl $0x9, %eax
ja 0x151e6
leaq 0xdbc5(%rip), %rcx      # 0x22cfc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cvtsi2sd %r15, %xmm0
jmp 0x1529e
leal -0x2(%rbx), %eax
movq %r15, %r14
cmpl $0x9, %eax
ja 0x1525f
leaq 0xdbec(%rip), %rcx      # 0x22d4c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %r15, %r14
jmpq *%rax
movslq %r15d, %r14
jmp 0x1525f
leal -0x2(%rbx), %eax
cmpl $0x9, %eax
ja 0x151e6
leaq 0xdb01(%rip), %rcx      # 0x22c84
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %xmm0
cvttsd2si %xmm0, %eax
movslq %eax, %r14
jmp 0x1540a
leal -0x2(%rbx), %eax
cmpl $0x9, %eax
ja 0x1540a
leaq 0xdb24(%rip), %rcx      # 0x22cd4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %r15d, %eax
cvtsi2sd %rax, %xmm0
jmp 0x1529e
leal -0x2(%rbx), %eax
cmpl $0x9, %eax
ja 0x151e6
leaq 0xdad7(%rip), %rcx      # 0x22cac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq %r15d, %r14
jmp 0x1540a
movq %r15, %r14
jmp 0x1540a
cmpl $0xb, %ebx
jne 0x1540a
movq %r15, %rdi
callq 0x176b0
movq %rax, %r14
jmp 0x1540a
movl %r15d, %r14d
jmp 0x1540a
movzbl %r15b, %r14d
jmp 0x1525f
movl %r15d, %r14d
jmp 0x1525f
movq %r15, %xmm0
punpckldq 0xa0a9(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xa0b1(%rip), %xmm0     # 0x1f2e0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movq %xmm1, %r14
jmp 0x1525f
testq %r15, %r15
leaq 0x94d3(%rip), %rax      # 0x1e71f
leaq 0x94c7(%rip), %rdi      # 0x1e71a
cmoveq %rax, %rdi
callq 0x176b0
movq %rax, %r14
leal -0x2(%rbx), %eax
cmpl $0x9, %eax
ja 0x1540a
leaq 0xdb02(%rip), %rcx      # 0x22d74
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %r15b, %r14d
jmp 0x1540a
xorl %r14d, %r14d
testq %r15, %r15
setne %r14b
jmp 0x1540a
movzbl %r15b, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %xmm0, %r14
jmp 0x1540a
movl $0x2, %edi
callq 0x4030
movq %rax, %r14
movb %r15b, (%rax)
movb $0x0, 0x1(%rax)
jmp 0x1540a
leaq -0x38(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x15510
movq (%r14), %rdi
callq 0x176b0
jmp 0x153f5
leaq -0x38(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x15649
movq (%r14), %rdi
callq 0x176b0
jmp 0x153f5
movq %r15, %xmm0
punpckldq 0x9fca(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x9fd2(%rip), %xmm0     # 0x1f2e0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movq %xmm1, %r14
jmp 0x1540a
btrq $0x3f, %r15
movq %r15, %xmm0
xorl %r14d, %r14d
ucomisd 0xd917(%rip), %xmm0     # 0x22c50
seta %r14b
jmp 0x1540a
movq %r15, %xmm0
cvttsd2si %xmm0, %r14
jmp 0x1540a
movq %r15, %xmm0
movq 0x16c5b(%rip), %rsi     # 0x2bfb8
leaq 0x9d0f(%rip), %rcx      # 0x1f073
leaq -0x38(%rbp), %r14
movl $0x148, %edx            # imm = 0x148
movq %r14, %rdi
movb $0x1, %al
callq 0x8a11
movq (%r14), %rdi
callq 0x176b0
jmp 0x153f5
movq %r15, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %r14d
jmp 0x1540a
movq %r15, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xa68f(%rip), %xmm0     # 0x1fa38
cvttsd2si %xmm0, %r14
andq %rcx, %r14
orq %rax, %r14
jmp 0x1540a
movq %r15, %xmm0
cvttsd2si %xmm0, %eax
movzbl %al, %r14d
jmp 0x1540a
leaq -0x38(%rbp), %r14
movq %r14, %rdi
movl %r15d, %esi
callq 0x15466
movq (%r14), %rdi
callq 0x176b0
jmp 0x153f5
leaq -0x38(%rbp), %r14
movq %r14, %rdi
movl %r15d, %esi
callq 0x155c4
movq (%r14), %rdi
callq 0x176b0
movq %rax, %r14
leaq -0x28(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1540a
callq 0x41e0
movl %ebx, %eax
movq %r14, %rdx
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x15422
jmp 0x15422
jmp 0x15422
jmp 0x15422
movq %rax, %rbx
leaq -0x28(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15437
callq 0x41e0
movq %rbx, %rdi
callq 0x4380