// File: /workspace/github_cpp_makefile_star2_O3/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 0xb4eb9(%rip), %rdi     # 0xbd3a0
callq 0x1b2b6
movb $0x0, 0x5c485(%rip)     # 0x64978
movl 0x10(%r15), %eax
movq %r15, %rcx
cmpl $0x2, %eax
jne 0x8503
movq 0x18(%r15), %rcx
movq %rcx, 0x5c4ae(%rip)     # 0x649b8
cmpq %r14, %r15
je 0x876d
cmpb $0x0, 0x5c458(%rip)     # 0x64972
je 0x876d
movl %eax, 0x4(%rbx)
movl 0x10(%r14), %ecx
movl %ecx, 0x8(%rbx)
cmpl %ecx, %eax
jne 0x85a7
decl %eax
cmpl $0x6, %eax
ja 0x875d
leaq 0x14060(%rip), %rcx     # 0x1c5a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x20(%r15), %rax
cmpq 0x20(%r14), %rax
jne 0x875d
movq 0x18(%r15), %rcx
movq %rcx, 0x28(%rbx)
movq 0x18(%r14), %rax
movq %rax, 0x30(%rbx)
testq %rcx, %rcx
je 0x8762
testq %rax, %rax
je 0x875d
movq (%rcx), %rdx
cmpq (%rax), %rdx
jne 0x875d
cmpl $0x0, 0x20(%rcx)
je 0x87ab
movq 0x28(%rcx), %rcx
movq %rcx, 0x28(%rbx)
cmpl $0x0, 0x20(%rax)
je 0x87ab
movq 0x28(%rax), %rax
jmp 0x8563
cmpl $0x2, %eax
jne 0x85c9
movb $0x1, 0x5c3c5(%rip)     # 0x64978
movq %r14, 0x5c3fe(%rip)     # 0x649b8
cmpq %r14, 0x18(%r15)
jne 0x875d
jmp 0x876d
cmpl $0x2, %ecx
jne 0x875d
cmpq %r15, 0x18(%r14)
jne 0x875d
jmp 0x876d
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 0x84c6
cmpb $0x1, (%r12)
jne 0x8755
movq 0x38(%rbx), %rax
cmpq 0x40(%rbx), %rax
jne 0x8755
movb 0x28(%r15), %al
cmpb 0x28(%r14), %al
jne 0x8755
addq $-0x8, 0xb4d65(%rip)    # 0xbd3a8
cmpb $0x0, 0x5c32e(%rip)     # 0x64978
jne 0x875d
testb %al, %al
je 0x876d
movq 0x38(%r15), %rax
cmpq 0x38(%r14), %rax
jne 0x875d
jmp 0x876d
movq 0x18(%r15), %rax
movq 0x18(%r14), %rcx
cmpq %rcx, %rax
sete 0x1(%rbx)
movq %rax, 0x5c337(%rip)     # 0x649b8
movq 0x28(%r15), %rdx
xorq 0x28(%r14), %rdx
movq 0x30(%r14), %rsi
xorq 0x30(%r15), %rsi
orq %rdx, %rsi
setne 0x5c2dd(%rip)           # 0x64978
cmpq %rcx, %rax
sete (%rbx)
jmp 0x8770
movq 0x5c31b(%rip), %rax     # 0x649c8
cmpq %r15, %rax
sete %cl
cmpq %r14, %rax
sete %al
orb %cl, %al
jne 0x876d
movq 0x18(%r15), %rax
movq %rax, 0x18(%rbx)
movq 0x18(%r14), %rcx
movq %rcx, 0x20(%rbx)
movq 0x5c348(%rip), %rdx     # 0x64a20
testq %rdx, %rdx
je 0x877c
movq 0x8(%rdx), %rsi
movq 0x10(%rdx), %rdi
movq %rsi, %r8
xorq %rax, %r8
movq %rdi, %r9
xorq %rcx, %r9
orq %r8, %r9
je 0x8769
xorq %rax, %rdi
xorq %rcx, %rsi
orq %rdi, %rsi
je 0x8769
movq (%rdx), %rdx
testq %rdx, %rdx
jne 0x86e1
movq $0x0, 0x10(%rbx)
movq %rbx, %rdi
callq 0x15cf2
jmp 0x875d
movq 0x20(%r15), %rdi
movq 0x20(%r14), %rsi
callq 0x8424
testb %al, %al
je 0x875d
jmp 0x876d
movq 0x18(%r15), %rsi
movq 0x18(%r14), %rdx
movq %rsp, %r14
movq %r14, %rdi
callq 0x84c6
addq $-0x8, 0xb4c5b(%rip)    # 0xbd3a8
cmpb $0x0, (%r14)
je 0x875d
jmp 0x876d
addq $-0x8, 0xb4c4b(%rip)    # 0xbd3a8
movb $0x0, (%rbx)
jmp 0x8770
testq %rax, %rax
jne 0x875d
jmp 0x876d
movq %rdx, 0x10(%rbx)
movb $0x1, (%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x1baed(%rip), %rax     # 0x24270
leaq 0x1c036(%rip), %rcx     # 0x247c0
leaq (%rcx,%rax,8), %r14
movq %rbx, %rdi
callq 0x15cf2
movq $0x0, 0x5c27f(%rip) # 0x64a20
movq %r14, %rdi
callq 0x3dae
jmp 0x8770
leaq 0x14ee8(%rip), %rdi     # 0x1d69a
leaq 0x14ebb(%rip), %rsi     # 0x1d674
leaq 0x14fed(%rip), %rcx     # 0x1d7ad
movl $0x2d5, %edx            # imm = 0x2D5
callq 0x3170