// File: /workspace/github_cpp_makefile_star2_O2/besm6[P]pascal-re/pascompl.cc
// Function: typeCheck::typeCheck(Types*, Types*)
typeCheck::typeCheck(TypesPtr type1, TypesPtr type2)
{
    super.push_back(this);
    rangeMismatch = false;
    if (type1->k == kindRange) {
        typ120z = type1->cast<RangeT>().base;
    } else {
        typ120z = type1;
    }
    if (not checkTypes or (type1 == type2)) {
L1:     ret = true;
    } else {
        kind1 = type1->k;
        kind2 = type2->k;
        if (kind1 == kind2) {
            switch (kind1) {
            case kindReal:
                /* empty */ break;
            case kindScalar: {
                /*(chain)*/
                if (type1->cast<ScalarT>().numen == type2->cast<ScalarT>().numen) {
                    enums1 = type1->cast<ScalarT>().enums;
                    enums2 = type2->cast<ScalarT>().enums;
                    while ((enums1 != NULL) and (enums2 != NULL)) {
                        if (enums1->id != enums2->id)
                            break; // exit chain;
                        enums1 = enums1->list();
                        enums2 = enums2->list();
                    };
                    if ((enums1 == NULL) and (enums2 == NULL))
                        goto L1;
                }
            } break;
            case kindRange: {
                RangeT & r1 = type1->cast<RangeT>();
                RangeT & r2 = type2->cast<RangeT>();
                baseMatch = (r1.base == r2.base);
                typ120z = r1.base;
                rangeMismatch = (r1.left != r2.left) or (r1.right != r2.right);
                ret = baseMatch;
                return;
            } break;
            case kindPtr: {
                if ((type1 == pointerType) or (type2 == pointerType))
                    goto L1;
                basetyp1 = type1->cast<PtrT>().pbase;
                basetyp2 = type2->cast<PtrT>().pbase;
                if (chain != NULL) {
                    link = chain;
                    while (link != NULL) {
                        if (((link->type1 == basetyp1) and
                             (link->type2 == basetyp2)) or
                            ((link->type2 == basetyp1) and
                             (link->type1 == basetyp2)))
                            goto L1;
                        link = link->next;
                    }
                    allocWithTypeCheck();
                } else {
                    setup(type1);
                    allocWithTypeCheck();
                    chain = NULL;
                    rollup(type1);
                    return;
                }
            }; break;
            case kindSet:
                goto L1;
            case kindArray: {
                ArrayT & a1 = type1->cast<ArrayT>();
                ArrayT & a2 = type2->cast<ArrayT>();
                span1 = a1.range->right - a1.range->left;
                span2 = a2.range->right - a2.range->left;
                if (typeCheck(a1.base, a2.base) and
                    (span1 == span2) and
                    (a1.pck == a2.pck) and
                    not rangeMismatch) {
                    if (a1.pck) {
                        if (a1.pcksize == a2.pcksize)
                            goto L1;
                    } else
                        goto L1;
                }
            } break;
            case kindFile: {
                if (typeCheck(type1->cast<FileT>().fbase, type2->cast<FileT>().fbase))
                    goto L1;
            } break;
            case kindRecord: {
                if (checkRecord(type1->cast<RecordT>().fields, type2->cast<RecordT>().fields))
                    goto L1;
            } break;
            case kindCases:
                break; // not checked
            } /* case */
        } else {
            if (kind1 == kindRange) {
                    rangeMismatch = true;
                    typ120z = type2;
                    if (type1->cast<RangeT>().base == type2)
                        goto L1;
                } else if ((kind2 == kindRange) and
                           (type1 == type2->cast<RangeT>().base))
                goto L1;
        }
        ret = false;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %rsp, %rsi
movq %rdi, (%rsi)
leaq 0xb4eab(%rip), %rdi     # 0xbc3a0
callq 0x17d74
movb $0x0, 0x5c477(%rip)     # 0x63978
cmpl $0x2, 0x10(%r15)
movq %r15, %rax
jne 0x7517
movq %r15, %rdi
callq 0x12d9c
movq 0x18(%rax), %rax
movq %rax, 0x5c49a(%rip)     # 0x639b8
cmpq %r14, %r15
je 0x7838
cmpb $0x0, 0x5c444(%rip)     # 0x63972
je 0x7838
movl 0x10(%r15), %eax
movl %eax, 0x4(%rbx)
movl 0x10(%r14), %ecx
movl %ecx, 0x8(%rbx)
cmpl %ecx, %eax
jne 0x75df
decl %eax
cmpl $0x6, %eax
ja 0x77fc
leaq 0x11f1c(%rip), %rcx     # 0x19478
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
callq 0x12dc6
movq 0x20(%rax), %r12
movq %r14, %rdi
callq 0x12dc6
cmpq 0x20(%rax), %r12
jne 0x77fc
movq %r15, %rdi
callq 0x12dc6
movq 0x18(%rax), %rax
movq %rax, 0x28(%rbx)
movq %r14, %rdi
callq 0x12dc6
addq $0x18, %rax
movq (%rax), %rax
movq %rax, 0x30(%rbx)
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x7833
testq %rax, %rax
je 0x77fc
movq (%rdi), %rcx
cmpq (%rax), %rcx
jne 0x77fc
callq 0x12d6e
movq (%rax), %rax
movq %rax, 0x28(%rbx)
movq 0x30(%rbx), %rdi
callq 0x12d6e
jmp 0x759f
cmpl $0x2, %eax
jne 0x7609
movb $0x1, 0x5c38d(%rip)     # 0x63978
movq %r14, 0x5c3c6(%rip)     # 0x639b8
movq %r15, %rdi
callq 0x12d9c
cmpq %r14, 0x18(%rax)
jne 0x77fc
jmp 0x7838
cmpl $0x2, %ecx
jne 0x77fc
movq %r14, %rdi
callq 0x12d9c
cmpq %r15, 0x18(%rax)
jne 0x77fc
jmp 0x7838
movq %r15, %rdi
callq 0x12c02
movq %rax, %r15
movq %r14, %rdi
callq 0x12c02
movq %rax, %r14
movq 0x20(%r15), %rax
movq 0x30(%rax), %rcx
subq 0x28(%rax), %rcx
movq %rcx, 0x38(%rbx)
movq 0x20(%r14), %rax
movq 0x30(%rax), %rcx
subq 0x28(%rax), %rcx
movq %rcx, 0x40(%rbx)
movq 0x18(%r15), %rsi
movq 0x18(%r14), %rdx
movq %rsp, %r12
movq %r12, %rdi
callq 0x74d4
cmpb $0x1, (%r12)
jne 0x77f4
movq 0x38(%rbx), %rax
cmpq 0x40(%rbx), %rax
jne 0x77f4
movb 0x28(%r15), %al
cmpb 0x28(%r14), %al
jne 0x77f4
addq $-0x8, 0xb4d07(%rip)    # 0xbc3a8
cmpb $0x0, 0x5c2d0(%rip)     # 0x63978
jne 0x77fc
testb %al, %al
je 0x7838
movq 0x38(%r15), %rax
cmpq 0x38(%r14), %rax
jne 0x77fc
jmp 0x7838
movq %r15, %rdi
callq 0x12d9c
movq %rax, %r15
movq %r14, %rdi
callq 0x12d9c
movq 0x18(%r15), %rcx
movq 0x18(%rax), %rdx
cmpq %rdx, %rcx
sete 0x1(%rbx)
movq %rcx, 0x5c2c6(%rip)     # 0x639b8
movq 0x28(%r15), %rsi
xorq 0x28(%rax), %rsi
movq 0x30(%rax), %rax
xorq 0x30(%r15), %rax
orq %rsi, %rax
setne 0x5c26c(%rip)           # 0x63978
cmpq %rdx, %rcx
sete (%rbx)
jmp 0x783b
movq 0x5c2aa(%rip), %rax     # 0x639c8
cmpq %r15, %rax
sete %cl
cmpq %r14, %rax
sete %al
orb %cl, %al
jne 0x7838
movq %r15, %rdi
callq 0x12df0
movq 0x18(%rax), %rax
movq %rax, 0x18(%rbx)
movq %r14, %rdi
callq 0x12df0
movq 0x18(%rax), %rax
movq %rax, 0x20(%rbx)
movq 0x5c2c7(%rip), %rcx     # 0x63a20
testq %rcx, %rcx
je 0x7807
movq 0x18(%rbx), %rdx
testq %rcx, %rcx
je 0x7847
movq 0x8(%rcx), %rsi
movq 0x10(%rcx), %rdi
movq %rsi, %r8
xorq %rdx, %r8
movq %rdi, %r9
xorq %rax, %r9
orq %r8, %r9
je 0x7801
xorq %rdx, %rdi
xorq %rax, %rsi
orq %rdi, %rsi
je 0x7801
movq (%rcx), %rcx
jmp 0x7766
movq %r15, %rdi
callq 0x12d3e
movq 0x20(%rax), %r15
movq %r14, %rdi
callq 0x12d3e
movq 0x20(%rax), %rsi
movq %r15, %rdi
callq 0x744e
testb %al, %al
je 0x77fc
jmp 0x7838
movq %r15, %rdi
callq 0x12e72
movq 0x18(%rax), %r15
movq %r14, %rdi
callq 0x12e72
movq 0x18(%rax), %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x74d4
addq $-0x8, 0xb4bbc(%rip)    # 0xbc3a8
cmpb $0x0, (%r14)
je 0x77fc
jmp 0x7838
addq $-0x8, 0xb4bac(%rip)    # 0xbc3a8
movb $0x0, (%rbx)
jmp 0x783b
movq %rcx, 0x10(%rbx)
jmp 0x7838
movq 0x1ba62(%rip), %rax     # 0x23270
leaq 0x1bfab(%rip), %rcx     # 0x237c0
leaq (%rcx,%rax,8), %r14
movq %rbx, %rdi
callq 0x12e1a
andq $0x0, 0x5c1f7(%rip)     # 0x63a20
movq %r14, %rdi
callq 0x3981
jmp 0x783b
testq %rax, %rax
jne 0x77fc
movb $0x1, (%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
andq $0x0, 0x10(%rbx)
movq %rbx, %rdi
callq 0x12e1a
jmp 0x77fc