// File: /workspace/github_cpp_makefile_star2_O2/besm6[P]pascal-re/pascompl.cc
// Function: main
int main(int argc, char **argv)
{
    // Data Initializations moved here
    blockBegSys = Bits(LABELSY, CONSTSY, TYPESY, VARSY) + Bits(FUNCSY, PROCSY, BEGINSY);
    statBegSys = Bits(BEGINSY, IFSY, CASESY, REPEATSY) + Bits(WHILESY, FORSY, WITHSY) +
        Bits(GOTOSY, SELECTSY);
    statEndSys = Bits(SEMICOLON, ENDSY, ELSESY, UNTILSY);
    lvalOpSet = Bits(GETELT, GETVAR, op36, op37) + Bits(GETFIELD, DEREF, FILEPTR);

    funcInsn[fnABS] = KAMX;
    funcInsn[fnTRUNC] = KADD+ZERO;
    funcInsn[fnODD] = KAAX+E1;
    funcInsn[fnORD] = KAOX+ZERO;
    funcInsn[fnCHR] = KAAX+MANTISSA;
    funcInsn[fnSUCC] = KARX+E1;
    funcInsn[fnPRED] = KSUB+E1;
    funcInsn[fnSQR] = macro + mcSQRR;
    funcInsn[fnROUND] = macro + mcROUND;
    funcInsn[fnCARD] = macro + mcCARD;
    funcInsn[fnMINEL] = macro + mcMINEL;
    funcInsn[fnPTR] = KAAX+MANTISSA;
    funcInsn[fnABSI] = KAMX;
    funcInsn[fnSQRI] = macro + mcSQRI;

    for (int i = 0; i < 128; ++i) {
        charSymTabBase[i] = NOSY;
        chrClassTabBase[i] = NOOP;
    }
    for (int i = 0; i < 10; ++i) {
        charSymTabBase[i+'0'] = INTCONST;
        chrClassTabBase[i+'0'] = ALNUM;
    }
    for (int i = 0; i < 26; ++i) {
        charSymTabBase[i+'A'] = IDENT;
        chrClassTabBase[i+'A'] = ALNUM;
        charSymTabBase[i+'a'] = IDENT;
        chrClassTabBase[i+'a'] = ALNUM;
    }

    // Allow Cyrillics except Ъ which does not have a TEXT code
    for (int i = 0; i < 31; ++i) {
        charSymTabBase[i+0300] = IDENT;
        chrClassTabBase[i+0300] = ALNUM;
        charSymTabBase[i+0340] = IDENT;
        chrClassTabBase[i+0340] = ALNUM;
    }
    charSymTabBase['\''] = CHARCONST;
    charSymTabBase['_'] = REALCONST;
    charSymTabBase['<'] = LTSY;
    charSymTabBase['>'] = GTSY;
    chrClassTabBase['+'] = PLUSOP;
    chrClassTabBase['-'] = MINUSOP;
    chrClassTabBase['*'] = MUL;
    chrClassTabBase['/'] = RDIVOP;
    chrClassTabBase['='] = EQOP;
    chrClassTabBase['&'] = AMPERS;
    chrClassTabBase['>'] = GTOP;
    chrClassTabBase['<'] = LTOP;
    chrClassTabBase['#'] = NEOP;
    chrClassTabBase['='] = EQOP;
    charSymTabBase['+'] = ADDOP;
    charSymTabBase['-'] = ADDOP;
    charSymTabBase['*'] = MULOP;
    charSymTabBase['/'] = MULOP;
    charSymTabBase['&'] = MULOP;
    charSymTabBase[','] = COMMA;
    charSymTabBase['.'] = PERIOD;
    charSymTabBase['@'] = ARROW;
    charSymTabBase['^'] = ARROW;
    charSymTabBase['('] = LPAREN;
    charSymTabBase[')'] = RPAREN;
    charSymTabBase[';'] = SEMICOLON;
    charSymTabBase['['] = LBRACK;
    charSymTabBase[']'] = RBRACK;
    charSymTabBase['#'] = RELOP;
    charSymTabBase['='] = RELOP;
    charSymTabBase[':'] = COLON;
    charSymTabBase['~'] = NOTSY;
    charSymTabBase['{'] = LBRACE;
    charSymTabBase['}'] = RBRACE;

    iAddOpMap[PLUSOP] = INTPLUS;
    iAddOpMap[MINUSOP] = INTMINUS;
    setOpMap[PLUSOP] = SETOR;
    setOpMap[MINUSOP] = SETSUB;
    iMulOpMap[MUL] = IMULOP;
    iMulOpMap[RDIVOP] = IDIVROP;
    setOpMap[MUL] = SETAND;
    setOpMap[RDIVOP] = SETXOR;

    // Main program starts here

    // L0 by default: no listing, only errors
    PASINFOR.listMode = 0;
    initOptions(argc, argv);
    if (PASINFOR.listMode != 0)
        printf("%s\n", boilerplate);
    curInsnTemplate = 0;
    initTables();
    litExternal = toText("EXTERNAL");
    litForward = toText("FORWARD");
    litFortran = toText("FORTRAN");
    litOct = toText("OCT");
    PASINPUT = ugetc(pasinput);
    try {
        programme(curInsnTemplate, hashTravPtr);
    } catch (int foo) {
        if (foo == 9999) goto L9999;
    }
    if (errors) {
L9999:  printf(" IN %ld LINES %ld ERRORS\n", lineCnt-1, totalErrors);
        exit(1);
    } else {
        finalize();
        // Dump CHILD here
        FILE *f = fopen(outFileName, "w");
        if (f == NULL) {
            fprintf(stderr, "%s: Cannot open output file\n", progname);
            perror(outFileName);
            exit(-1);
        }
        if (stdArrayFmt) {
            int words = 0;
            for (int i = 1; i < entryPtCnt; ++i) {
                write_stdarray_word(f, words, entryPtTable[i]);
            }
            for (size_t i = 0; i < CHILD.size(); ++i) {
                write_stdarray_word(f, words, CHILD[i]);
            }
            while (words++ % 16 != 0)
                fprintf(f, "`%016lo\n", 0l);
        } else {
            fwrite("BESM6\0", 6, 1, f);
            for (size_t i = 7; i < CHILD.size(); ++i) {
                for (int j = 40; j >= 0; j -= 8)
                    fputc((CHILD[i] >> j) & 0xFF, f);
            }
        }
        fclose(f);
        exit(0);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xc0, %rsp
movq $0xfc10000, 0x513d8(%rip) # imm = 0xFC10000
movq $0x1fe01, 0x513d5(%rip) # imm = 0x1FE01
movabsq $0x1000001c0, %rax      # imm = 0x1000001C0
movq %rax, 0x513b4(%rip)     # 0x637d0
movq $0xf7000, 0x513c9(%rip) # imm = 0xF7000
movl $0x7000, %eax           # imm = 0x7000
movq %rax, 0x55eb5(%rip)     # 0x682e8
movq $0x104009, 0x55eb2(%rip) # imm = 0x104009
movq $0x109008, 0x55eaf(%rip) # imm = 0x109008
movq $0x10d009, 0x55eac(%rip) # imm = 0x10D009
movl $0x10900c, %ecx         # imm = 0x10900C
movq %rcx, 0x55ea8(%rip)     # 0x68308
movq $0x10b008, 0x55ea5(%rip) # imm = 0x10B008
movq $0x105008, 0x55ea2(%rip) # imm = 0x105008
movq $0x100000c, 0x55eb7(%rip) # imm = 0x100000C
movq $0x100000b, 0x55eb4(%rip) # imm = 0x100000B
movq $0x1000017, 0x55eb1(%rip) # imm = 0x1000017
movq $0x100000f, 0x55eae(%rip) # imm = 0x100000F
movq %rcx, 0x55eaf(%rip)     # 0x68358
movq %rax, 0x55eb0(%rip)     # 0x68360
movq $0x100000d, 0x55ead(%rip) # imm = 0x100000D
xorl %edx, %edx
leaq 0x5690c(%rip), %rax     # 0x68dd0
leaq 0x56105(%rip), %rcx     # 0x685d0
cmpq $0x200, %rdx            # imm = 0x200
je 0x124e8
movl $0x34, (%rdx,%rax)
movl $0x2e, (%rdx,%rcx)
addq $0x4, %rdx
jmp 0x124cb
xorl %edx, %edx
cmpq $0xa, %rdx
je 0x1250b
movl $0x1, 0xc0(%rax,%rdx,4)
movl $0x25, 0xc0(%rcx,%rdx,4)
incq %rdx
jmp 0x124ea
xorl %r8d, %r8d
pushq $0x25
popq %rdx
cmpq $0x1a, %r8
je 0x1253e
andl $0x0, 0x104(%rax,%r8,4)
andl $0x0, 0x184(%rax,%r8,4)
movl %edx, 0x104(%rcx,%r8,4)
movl %edx, 0x184(%rcx,%r8,4)
incq %r8
jmp 0x12511
pushq $-0x7c
popq %r8
testq %r8, %r8
je 0x1256f
andl $0x0, 0x37c(%r8,%rax)
andl $0x0, 0x3fc(%r8,%rax)
movl %edx, 0x37c(%r8,%rcx)
movl %edx, 0x3fc(%r8,%rcx)
addq $0x4, %r8
jmp 0x12542
pushq $0x2
popq %rax
movl %eax, 0x569d4(%rip)     # 0x68f4c
movl $0x5, 0x56946(%rip)     # 0x68ec8
pushq $0x6
popq %rcx
movl %ecx, 0x560f9(%rip)     # 0x68684
movabsq $0x500000000, %rdx      # imm = 0x500000000
movq %rdx, 0x560dc(%rip)     # 0x68678
movl $0x1, 0x560e6(%rip)     # 0x6868c
movl %eax, 0x560bc(%rip)     # 0x68668
movl $0xc, 0x56112(%rip)     # 0x686c8
movabsq $0x90000000a, %rax      # imm = 0x90000000A
movq %rax, 0x560f9(%rip)     # 0x686c0
pushq $0x8
popq %rax
movl %eax, 0x5608c(%rip)     # 0x6865c
movaps 0x7319(%rip), %xmm0     # 0x198f0
movups %xmm0, 0x5689a(%rip)    # 0x68e78
movabsq $0x900000010, %rdx      # imm = 0x900000010
movq %rdx, 0x56899(%rip)     # 0x68e88
movl $0x11, 0x568d7(%rip)    # 0x68ed0
movaps 0x7300(%rip), %xmm0     # 0x19900
movups %xmm0, 0x56861(%rip)    # 0x68e68
movl %eax, 0x5692f(%rip)     # 0x68f3c
movabsq $0x110000000d, %rax     # imm = 0x110000000D
movq %rax, 0x56926(%rip)     # 0x68f44
movl $0xb, 0x56834(%rip)     # 0x68e5c
movaps 0x72e1(%rip), %xmm0     # 0x19910
movups %xmm0, 0x56882(%rip)    # 0x68eb8
movl %ecx, 0x5698c(%rip)     # 0x68fc8
movl $0x32, 0x56976(%rip)    # 0x68fbc
movl $0x33, 0x56974(%rip)    # 0x68fc4
movabsq $0x1600000015, %rax     # imm = 0x1600000015
movq %rax, 0x554e3(%rip)     # 0x67b44
movabsq $0x1400000013, %rax     # imm = 0x1400000013
movq %rax, 0x55412(%rip)     # 0x67a84
movabsq $0x100000000f, %rax     # imm = 0x100000000F
movq %rax, 0x5532d(%rip)     # 0x679b0
movabsq $0x1200000011, %rax     # imm = 0x1200000011
movq %rax, 0x553dc(%rip)     # 0x67a70
andq $0x0, 0xa9cc4(%rip)     # 0xbc360
callq 0x11e77
cmpq $0x0, 0xa9cb7(%rip)     # 0xbc360
je 0x126b7
movq 0x10bb6(%rip), %rdi     # 0x23268
callq 0x3360
andq $0x0, 0x511a1(%rip)     # 0x63860
leaq 0x5119a(%rip), %rbx     # 0x63860
leaq 0x8(%rsp), %rdi
callq 0x15c18
leaq 0x7e41(%rip), %rdi      # 0x1a518
callq 0x4dbc
movq %rax, 0x5139d(%rip)     # 0x63a80
leaq 0x7aa2(%rip), %rdi      # 0x1a18c
callq 0x4dbc
movq %rax, 0x51392(%rip)     # 0x63a88
leaq 0x7e24(%rip), %rdi      # 0x1a521
callq 0x4dbc
movq %rax, 0x51387(%rip)     # 0x63a90
leaq 0x7e19(%rip), %rdi      # 0x1a529
callq 0x4dbc
movq %rax, 0x5135c(%rip)     # 0x63a78
movq 0x1108d(%rip), %rdi     # 0x237b0
callq 0x5ced
movb %al, 0x1108a(%rip)      # 0x237b8
movq 0x5126b(%rip), %rdx     # 0x639a0
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x10864
addq $-0x8, 0xa9c2e(%rip)    # 0xbc378
jmp 0x12763
movq %rax, %rdi
callq 0x30d0
movl (%rax), %ebx
callq 0x33b0
cmpl $0x270f, %ebx           # imm = 0x270F
je 0x1276c
cmpb $0x1, 0x5120c(%rip)     # 0x63976
jne 0x1278f
movq 0x5113d(%rip), %rsi     # 0x638b0
decq %rsi
movq 0x5112b(%rip), %rdx     # 0x638a8
leaq 0x7da9(%rip), %rdi      # 0x1a52d
xorl %eax, %eax
callq 0x3030
pushq $0x1
jmp 0x127d9
callq 0x119a6
movq 0x10ac5(%rip), %rdi     # 0x23260
leaq 0x78af(%rip), %rsi      # 0x1a051
callq 0x32c0
testq %rax, %rax
jne 0x127df
movq 0x1081d(%rip), %rax     # 0x22fd0
movq (%rax), %rdi
movq 0xa9bcb(%rip), %rdx     # 0xbc388
leaq 0x7d83(%rip), %rsi      # 0x1a547
xorl %eax, %eax
callq 0x3330
movq 0x10a8e(%rip), %rdi     # 0x23260
callq 0x31d0
pushq $-0x1
popq %rdi
callq 0x32e0
movq %rax, %rbx
cmpb $0x1, 0x51187(%rip)     # 0x63970
jne 0x1281c
leaq 0x4(%rsp), %r14
andl $0x0, (%r14)
pushq $0x1
popq %r15
leaq 0x553f1(%rip), %r12     # 0x67bf0
cmpq %r15, 0x5103a(%rip)     # 0x63840
jle 0x12880
movq (%r12,%r15,8), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11c23
incq %r15
jmp 0x127ff
leaq 0x6f9d(%rip), %rdi      # 0x197c0
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x3470
pushq $0x7
popq %r14
pushq $0x28
popq %r15
movq 0xa9b10(%rip), %rax     # 0xbc350
subq 0xa9b01(%rip), %rax     # 0xbc348
sarq $0x3, %rax
cmpq %rax, %r14
jae 0x128da
movl %r15d, %ebp
testl %ebp, %ebp
js 0x1287b
movq 0xa9ae6(%rip), %rax     # 0xbc348
movq (%rax,%r14,8), %rax
movl %ebp, %ecx
sarq %cl, %rax
movzbl %al, %edi
movq %rbx, %rsi
callq 0x3300
addl $-0x8, %ebp
jmp 0x12857
incq %r14
jmp 0x12839
xorl %r15d, %r15d
leaq 0x4(%rsp), %r14
movq 0xa9ac1(%rip), %rcx     # 0xbc350
movq 0xa9ab2(%rip), %rax     # 0xbc348
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r15
jae 0x128b6
movq (%rax,%r15,8), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11c23
incq %r15
jmp 0x12888
movl 0x4(%rsp), %ebp
leaq 0x7b78(%rip), %r14      # 0x1a439
testb $0xf, %bpl
je 0x128da
incl %ebp
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3330
jmp 0x128c1
movq %rbx, %rdi
callq 0x3230
xorl %edi, %edi
callq 0x32e0
nop