// File: /workspace/github_cpp_makefile_star2_O3/rofl0r[P]ascc/cs_parser.cpp
// Function: check_operator_valid_for_type(int*, int, int)
int check_operator_valid_for_type(int *vcpuOpPtr, int type1, int type2) {
  int NULL_TYPE = STYPE_POINTER | sym.nullSym;
  int vcpuOp = *vcpuOpPtr;

  int isError = 0;
  // it's allowed to add or subtract from a pointer to an integral type.
  if (is_int(type1) && (type2 & STYPE_POINTER)
     && (vcpuOp == SCMD_ADDREG || vcpuOp == SCMD_SUBREG)
     && is_integral_type(type2 & ~STYPE_POINTER))
      return 0;
  if ((type1 == sym.normalFloatSym) || (type2 == sym.normalFloatSym)) {
    // some operators not valid on floats
    int changeOpTo = vcpuOp;
    switch (vcpuOp) {
    case SCMD_ISEQUAL: // == and != same as integer versions
    case SCMD_NOTEQUAL:
      break;
    case SCMD_ADD:
      changeOpTo = SCMD_FADD;
      break;
    case SCMD_SUB:
      changeOpTo = SCMD_FSUB;
      break;
    case SCMD_ADDREG:
      changeOpTo = SCMD_FADDREG;
      break;
    case SCMD_SUBREG:
      changeOpTo = SCMD_FSUBREG;
      break;
    case SCMD_MULREG:
      changeOpTo = SCMD_FMULREG;
      break;
    case SCMD_DIVREG:
      changeOpTo = SCMD_FDIVREG;
      break;
    case SCMD_GREATER:
      changeOpTo = SCMD_FGREATER;
      break;
    case SCMD_LESSTHAN:
      changeOpTo = SCMD_FLESSTHAN;
      break;
    case SCMD_GTE:
      changeOpTo = SCMD_FGTE;
      break;
    case SCMD_LTE:
      changeOpTo = SCMD_FLTE;
      break;
    default:
      isError = 1;
    }
    vcpuOp = changeOpTo;
    *vcpuOpPtr = changeOpTo;
  }

  if (is_any_type_of_string(type1) && is_any_type_of_string(type2)) {
    if (vcpuOp == SCMD_ISEQUAL) {
      *vcpuOpPtr = SCMD_STRINGSEQUAL;
      return 0;
    }
    else if (vcpuOp == SCMD_NOTEQUAL) {
      *vcpuOpPtr = SCMD_STRINGSNOTEQ;
      return 0;
    }
  }

  if ((type1 & STYPE_POINTER) || (is_string(type1))) {
    isError = 1;
  }
  if (type2) {
    if ((type2 & STYPE_POINTER) || (is_string(type2))) {
      isError = 1;
    }
    if ((vcpuOp == SCMD_ISEQUAL) || (vcpuOp == SCMD_NOTEQUAL)) {
      // pointers can be compared to each other
      // (except strings)
      if (!is_string(type1))
        isError = 0;
    }
  }

  if (isError) {
    cc_error("Operator cannot be applied to this type");
    return -1;
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %ebx
movl (%rdi), %r14d
leaq 0x1e276(%rip), %rcx     # 0x256e0
cmpl %esi, (%rcx)
sete %al
shrl $0x1e, %edx
leal -0xb(%r14), %esi
cmpl $0x2, %esi
setb %sil
andb %dl, %sil
andb %al, %sil
cmpb $0x1, %sil
jne 0x74b6
movl %ebp, %edx
andl $0xbfffffff, %edx       # imm = 0xBFFFFFFF
xorl %eax, %eax
cmpl %ebx, %edx
je 0x75a8
cmpl %edx, 0x8(%rcx)
je 0x75a8
cmpl %edx, 0x4(%rcx)
je 0x75a8
cmpl %edx, 0xc(%rcx)
je 0x75a8
movl 0x14(%rcx), %eax
cmpl %ebx, %eax
setne %dl
cmpl %ebp, %eax
setne %al
xorl %r15d, %r15d
testb %al, %dl
jne 0x74f7
movl %r14d, %eax
decl %eax
movl $0x1, %r15d
cmpl $0x13, %eax
ja 0x74f4
movl $0xfcf03, %edx          # imm = 0xFCF03
btl %eax, %edx
jae 0x74f4
movl %eax, %eax
leaq 0x13433(%rip), %rdx     # 0x1a920
movl (%rdx,%rax,4), %r14d
xorl %r15d, %r15d
movl %r14d, (%rdi)
movl %ebx, %esi
andl $0x9fffffff, %esi       # imm = 0x9FFFFFFF
movl 0x10(%rcx), %edx
movl 0x20(%rcx), %eax
cmpl %edx, %esi
setne %cl
cmpl %eax, %esi
setne %sil
testb %sil, %cl
jne 0x753f
movl %ebp, %ecx
andl $0x9fffffff, %ecx       # imm = 0x9FFFFFFF
cmpl %edx, %ecx
setne %dl
cmpl %eax, %ecx
setne %al
testb %al, %dl
jne 0x753f
cmpl $0x10, %r14d
je 0x75a0
cmpl $0xf, %r14d
jne 0x753f
movl $0x41, (%rdi)
jmp 0x75a6
btl $0x1e, %ebx
jb 0x7550
movl %ebx, %edi
callq 0x73db
testl %eax, %eax
je 0x7556
movl $0x1, %r15d
testl %ebp, %ebp
je 0x7586
btl $0x1e, %ebp
jb 0x756b
movl %ebp, %edi
callq 0x73db
testl %eax, %eax
je 0x7571
movl $0x1, %r15d
addl $-0xf, %r14d
cmpl $0x1, %r14d
ja 0x7586
movl %ebx, %edi
callq 0x73db
testl %eax, %eax
je 0x75a6
testl %r15d, %r15d
je 0x75a6
leaq 0x13a84(%rip), %rdi     # 0x1b016
xorl %eax, %eax
callq 0x102f4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x75a8
movl $0x42, (%rdi)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq