// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq $0xfc10000, 0x4f7ae(%rip) # imm = 0xFC10000
movq $0x1fe01, 0x4f7ab(%rip) # imm = 0x1FE01
movabsq $0x1000001c0, %rax      # imm = 0x1000001C0
movq %rax, 0x4f78a(%rip)     # 0x647e0
movq $0xf7000, 0x4f79f(%rip) # imm = 0xF7000
movl $0x7000, %eax           # imm = 0x7000
movq %rax, 0x5428b(%rip)     # 0x692f8
movq $0x104009, 0x54288(%rip) # imm = 0x104009
movq $0x109008, 0x54285(%rip) # imm = 0x109008
movq $0x10d009, 0x54282(%rip) # imm = 0x10D009
movl $0x10900c, %ecx         # imm = 0x10900C
movq %rcx, 0x5427e(%rip)     # 0x69318
movq $0x10b008, 0x5427b(%rip) # imm = 0x10B008
movq $0x105008, 0x54278(%rip) # imm = 0x105008
movq $0x100000c, 0x5428d(%rip) # imm = 0x100000C
movq $0x100000b, 0x5428a(%rip) # imm = 0x100000B
movq $0x1000017, 0x54287(%rip) # imm = 0x1000017
movq $0x100000f, 0x54284(%rip) # imm = 0x100000F
movq %rcx, 0x54285(%rip)     # 0x69368
movq %rax, 0x54286(%rip)     # 0x69370
movq $0x100000d, 0x54283(%rip) # imm = 0x100000D
xorl %edx, %edx
leaq 0x54ce2(%rip), %rcx     # 0x69de0
leaq 0x544db(%rip), %rax     # 0x695e0
movl $0x34, (%rdx,%rcx)
movl $0x2e, (%rdx,%rax)
addq $0x4, %rdx
cmpq $0x200, %rdx            # imm = 0x200
jne 0x15105
xorl %edx, %edx
movl $0x1, 0xc0(%rcx,%rdx,4)
movl $0x25, 0xc0(%rax,%rdx,4)
incq %rdx
cmpq $0xa, %rdx
jne 0x15122
xorps %xmm0, %xmm0
movups %xmm0, 0x54de9(%rip)    # 0x69f34
movups %xmm0, 0x54dd2(%rip)    # 0x69f24
movups %xmm0, 0x54dbb(%rip)    # 0x69f14
movups %xmm0, 0x54da4(%rip)    # 0x69f04
movups %xmm0, 0x54d8d(%rip)    # 0x69ef4
movups %xmm0, 0x54d76(%rip)    # 0x69ee4
xorl %ecx, %ecx
movq %rcx, 0x54dcd(%rip)     # 0x69f44
movups %xmm0, 0x54de6(%rip)    # 0x69f64
movups %xmm0, 0x54def(%rip)    # 0x69f74
movups %xmm0, 0x54df8(%rip)    # 0x69f84
movups %xmm0, 0x54e01(%rip)    # 0x69f94
movups %xmm0, 0x54e0a(%rip)    # 0x69fa4
movups %xmm0, 0x54e13(%rip)    # 0x69fb4
movq %rcx, 0x54e1c(%rip)     # 0x69fc4
movq $-0x1a, %rcx
movl $0x25, %edx
movl %edx, 0x16c(%rax,%rcx,4)
movl %edx, 0x1ec(%rax,%rcx,4)
incq %rcx
jne 0x151b4
xorps %xmm0, %xmm0
movups %xmm0, 0x54f7b(%rip)    # 0x6a14c
movaps %xmm0, 0x54f68(%rip)    # 0x6a140
movaps %xmm0, 0x54f51(%rip)    # 0x6a130
movaps %xmm0, 0x54f3a(%rip)    # 0x6a120
movaps %xmm0, 0x54f23(%rip)    # 0x6a110
movaps %xmm0, 0x54f0c(%rip)    # 0x6a100
movaps %xmm0, 0x54ef5(%rip)    # 0x6a0f0
movaps %xmm0, 0x54ede(%rip)    # 0x6a0e0
movaps %xmm0, 0x54f57(%rip)    # 0x6a160
movaps %xmm0, 0x54f60(%rip)    # 0x6a170
movaps %xmm0, 0x54f69(%rip)    # 0x6a180
movaps %xmm0, 0x54f72(%rip)    # 0x6a190
movaps %xmm0, 0x54f7b(%rip)    # 0x6a1a0
movaps %xmm0, 0x54f84(%rip)    # 0x6a1b0
movaps %xmm0, 0x54f8d(%rip)    # 0x6a1c0
movups %xmm0, 0x54f92(%rip)    # 0x6a1cc
movq $-0x1f, %rcx
movl $0x25, %edx
movl %edx, 0x37c(%rax,%rcx,4)
movl %edx, 0x3fc(%rax,%rcx,4)
incq %rcx
jne 0x15246
movl $0x2, %eax
movl %eax, 0x54cf8(%rip)     # 0x69f5c
movl $0x6, 0x54426(%rip)     # 0x69694
movabsq $0x500000000, %rcx      # imm = 0x500000000
movq %rcx, 0x54409(%rip)     # 0x69688
movl $0x1, 0x54413(%rip)     # 0x6969c
movl %eax, 0x543e9(%rip)     # 0x69678
movl $0xc, 0x5443f(%rip)     # 0x696d8
movabsq $0x90000000a, %rax      # imm = 0x90000000A
movq %rax, 0x54426(%rip)     # 0x696d0
movl $0x8, %eax
movl %eax, 0x543b7(%rip)     # 0x6966c
movaps 0x7614(%rip), %xmm0     # 0x1c8d0
movups %xmm0, 0x54bc5(%rip)    # 0x69e88
movabsq $0x300000009, %rcx      # imm = 0x300000009
movq %rcx, 0x54ba4(%rip)     # 0x69e78
movabsq $0x900000010, %rcx      # imm = 0x900000010
movq %rcx, 0x54bb3(%rip)     # 0x69e98
movl $0x11, 0x54bf1(%rip)    # 0x69ee0
movabsq $0xc00000007, %rcx      # imm = 0xC00000007
movq %rcx, 0x54b80(%rip)     # 0x69e80
movabsq $0x40000000f, %rcx      # imm = 0x40000000F
movq %rcx, 0x54bbb(%rip)     # 0x69ecc
movl %eax, 0x54c35(%rip)     # 0x69f4c
movabsq $0x110000000d, %rax     # imm = 0x110000000D
movq %rax, 0x54c2c(%rip)     # 0x69f54
movl $0xb, 0x54b3a(%rip)     # 0x69e6c
movabsq $0x50000000b, %rax      # imm = 0x50000000B
movq %rax, 0x54b91(%rip)     # 0x69ed4
movl $0x12, 0x54b7b(%rip)    # 0x69ec8
movl $0x32, 0x54c75(%rip)    # 0x69fcc
movabsq $0x600000033, %rax      # imm = 0x600000033
movq %rax, 0x54c6c(%rip)     # 0x69fd4
movabsq $0x1600000015, %rax     # imm = 0x1600000015
movq %rax, 0x537db(%rip)     # 0x68b54
movabsq $0x1400000013, %rax     # imm = 0x1400000013
movq %rax, 0x5370a(%rip)     # 0x68a94
movabsq $0x100000000f, %rax     # imm = 0x100000000F
movq %rax, 0x53625(%rip)     # 0x689c0
movabsq $0x1200000011, %rax     # imm = 0x1200000011
movq %rax, 0x536d4(%rip)     # 0x68a80
movq $0x0, 0xa7fb9(%rip) # 0xbd370
callq 0x14b9f
cmpq $0x0, 0xa7fac(%rip)     # 0xbd370
je 0x153d2
movq 0xeeab(%rip), %rdi      # 0x24278
callq 0x3380
movq $0x0, 0x4f493(%rip) # 0x64870
leaq 0x10(%rsp), %rdi
callq 0x18d14
movb $0x45, %sil
xorl %ecx, %ecx
leaq 0xa7e4d(%rip), %rax     # 0xbd240
leaq 0x80ee(%rip), %rdx      # 0x1d4e8
xorl %edi, %edi
movq %rcx, %r8
shlq $0x6, %r8
movzbl %sil, %ecx
movsbq (%rcx,%rax), %rcx
orq %r8, %rcx
movb 0x1(%rdi,%rdx), %sil
incq %rdi
cmpq $0x8, %rdi
jne 0x153fc
movq %rcx, 0x4f66c(%rip)     # 0x64a90
movb $0x46, %dil
movl $0x1, %ecx
xorl %esi, %esi
leaq 0x7d27(%rip), %rdx      # 0x1d15c
movq %rsi, %r8
shlq $0x6, %r8
movzbl %dil, %esi
movsbq (%rsi,%rax), %rsi
orq %r8, %rsi
movb (%rcx,%rdx), %dil
incq %rcx
cmpq $0x8, %rcx
jne 0x15435
movq %rsi, 0x4f63c(%rip)     # 0x64a98
movb $0x46, %dil
movl $0x1, %ecx
xorl %esi, %esi
leaq 0x8084(%rip), %rdx      # 0x1d4f1
movq %rsi, %r8
shlq $0x6, %r8
movzbl %dil, %esi
movsbq (%rsi,%rax), %rsi
orq %r8, %rsi
movb (%rcx,%rdx), %dil
incq %rcx
cmpq $0x8, %rcx
jne 0x1546d
movq %rsi, 0x4f60c(%rip)     # 0x64aa0
movb $0x4f, %dil
movl $0x1, %ecx
xorl %esi, %esi
leaq 0x8054(%rip), %rdx      # 0x1d4f9
movq %rsi, %r8
shlq $0x6, %r8
movzbl %dil, %esi
movsbq (%rsi,%rax), %rsi
orq %r8, %rsi
movb (%rcx,%rdx), %dil
incq %rcx
cmpq $0x4, %rcx
jne 0x154a5
movq %rsi, 0x4f5bc(%rip)     # 0x64a88
movq 0xf2ed(%rip), %rdi      # 0x247c0
callq 0x6834
movb %al, 0xf2ea(%rip)       # 0x247c8
movq 0x4f4cb(%rip), %rdx     # 0x649b0
leaq 0x4f384(%rip), %rsi     # 0x64870
leaq 0x20(%rsp), %rdi
callq 0x131b2
addq $-0x8, 0xa7e8a(%rip)    # 0xbd388
jmp 0x15517
movq %rax, %rdi
callq 0x30d0
movl (%rax), %ebx
callq 0x33e0
cmpl $0x270f, %ebx           # imm = 0x270F
je 0x15520
cmpb $0x1, 0x4f468(%rip)     # 0x64986
jne 0x15549
movq 0x4f399(%rip), %rsi     # 0x648c0
decq %rsi
movq 0x4f387(%rip), %rdx     # 0x648b8
leaq 0x7fc5(%rip), %rdi      # 0x1d4fd
xorl %eax, %eax
callq 0x3030
movl $0x1, %edi
callq 0x32f0
callq 0x1466c
movq 0xed1b(%rip), %rdi      # 0x24270
leaq 0x7ac5(%rip), %rsi      # 0x1d021
callq 0x32d0
testq %rax, %rax
jne 0x1559b
movq 0xea6b(%rip), %rax      # 0x23fd8
movq (%rax), %rdi
movq 0xa7e21(%rip), %rdx     # 0xbd398
leaq 0x7f99(%rip), %rsi      # 0x1d517
xorl %eax, %eax
callq 0x3350
movq 0xece4(%rip), %rdi      # 0x24270
callq 0x31f0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x32f0
movq %rax, %rbx
cmpb $0x1, 0x4f3db(%rip)     # 0x64980
jne 0x15665
movl $0x0, 0xc(%rsp)
cmpq $0x2, 0x4f295(%rip)     # 0x64850
jl 0x155ea
movl $0x1, %r15d
leaq 0x53636(%rip), %r12     # 0x68c00
leaq 0xc(%rsp), %r14
movq (%r12,%r15,8), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x14947
incq %r15
cmpq %r15, 0x4f268(%rip)     # 0x64850
jg 0x155cf
movq 0xa7d67(%rip), %rax     # 0xbd358
cmpq %rax, 0xa7d68(%rip)     # 0xbd360
je 0x1562e
xorl %r15d, %r15d
leaq 0xc(%rsp), %r14
movq (%rax,%r15,8), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x14947
incq %r15
movq 0xa7d45(%rip), %rcx     # 0xbd360
movq 0xa7d36(%rip), %rax     # 0xbd358
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r15
jb 0x15602
movl 0xc(%rsp), %r15d
testb $0xf, %r15b
je 0x156de
incl %r15d
leaq 0x7dc2(%rip), %r14      # 0x1d409
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3350
leal 0x1(%r15), %eax
testb $0xf, %r15b
movl %eax, %r15d
jne 0x15647
jmp 0x156de
leaq 0x7130(%rip), %rdi      # 0x1c79c
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3490
movq 0xa7cdb(%rip), %rax     # 0xbd360
subq 0xa7ccc(%rip), %rax     # 0xbd358
cmpq $0x39, %rax
jb 0x156de
movl $0x7, %r15d
movl $0x28, %r14d
movq 0xa7cb3(%rip), %rax     # 0xbd358
movq (%rax,%r15,8), %rax
movl %r14d, %ecx
sarq %cl, %rax
movzbl %al, %edi
movq %rbx, %rsi
callq 0x3310
addq $-0x8, %r14
cmpq $-0x8, %r14
jne 0x1569e
incq %r15
movq 0xa7c92(%rip), %rax     # 0xbd360
subq 0xa7c83(%rip), %rax     # 0xbd358
sarq $0x3, %rax
cmpq %rax, %r15
jb 0x15698
movq %rbx, %rdi
callq 0x3240
xorl %edi, %edi
callq 0x32f0
nop