// File: /workspace/github_c_makefile_star2_O2/c0stya[P]fslib/src/fscompile.c
// Function: main
int main(int argc, char * argv[]) {
    struct _fst * fst = fst_create(); 

    const char * ifilename = NULL; 
    const char * ofilename = NULL;

    FILE * fin = stdin;
    FILE * fout = stdout;
    FILE * isym = NULL;
    FILE * osym = NULL;
    FILE * ssym = NULL;

    struct _symt * ist = NULL;
    struct _symt * ost = NULL;
    struct _symt * sst = NULL;

    int c;
    int acc=0;
    int opt_index = -1;

    const char * short_options = "I:O:S:";

    const struct option long_options [] = {
        { "isym", required_argument, NULL, 'I' },
        { "osym", required_argument, NULL, 'O' },
        { "ssym", required_argument, NULL, 'S' },
        { "acc", 0, NULL, 'a' },
        { "help", 0, NULL, 'h' },
        { "sr", 0, NULL, 's' },
        { 0, 0, NULL, 0}
    };

    while ( (c = getopt_long(argc, argv,  
                short_options, long_options, &opt_index )) != -1 ) {
        switch(c) {
            case 'a':
                acc = 1;
                break;
            case 'I': 
                isym = file_open(optarg);
                ist = symt_create();
                symt_read(ist, isym);
                break;
            case 'O': 
                osym = file_open(optarg);
                ost = symt_create();
                symt_read(ost, osym);
                break;
            case 'S': 
                ssym = file_open(optarg);
                sst = symt_create();
                symt_read(sst, ssym);
                break;
            default:
                fprintf(stderr, "Usage: %s [--acc] [--isym filename] [--osym filename]"
                    "[--ssym filename] [input_file] [output_file]\n", argv[0]);
                exit(EXIT_SUCCESS);
        } 
    }

    if (optind < argc)
        ifilename = argv[optind];
    if (optind+1 < argc)
        ofilename = argv[optind+1];

    if (ifilename) {
        if (( fin = fopen(ifilename, "rb")) == NULL ) {
            fprintf(stderr, "Error opening file: %s", ifilename);
            exit(EXIT_FAILURE);
        }
    }

    if (ofilename) {
        if (( fout = fopen(ofilename, "w")) == NULL ) {
            fprintf(stderr, "Error opening file: %s", ofilename);
            exit(EXIT_FAILURE);
        }
    }

    fst = fst_compile(fst, fin, ist, ost, sst, acc);
    fst_write(fst, fout);

    fst_remove(fst);
    
    if (fin != stdout)
        fclose(fin);
    if (fout != stdout)
        fclose(fout);

    if (isym != NULL)
        fclose(isym);
    if (osym != NULL)
        fclose(osym);
    if (ssym != NULL)
        fclose(ssym);

    if (ist != NULL)
        symt_remove(ist); 
    if (ost != NULL)
        symt_remove(ost); 
    if (sst != NULL)
        symt_remove(sst); 

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, -0x58(%rbp)
movl %edi, %ebx
xorl %eax, %eax
callq 0x1fb0
movq %rax, -0x88(%rbp)
movq 0x4161(%rip), %rax      # 0x8fc8
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq 0x414b(%rip), %rax      # 0x8fc0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
leaq -0x5c(%rbp), %rax
orl $-0x1, (%rax)
leaq 0x3e66(%rip), %rsi      # 0x8cf0
leaq -0x170(%rbp), %rdi
movl $0xe0, %edx
callq 0x1150
movq $0x0, -0x70(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
xorl %ecx, %ecx
movl %ebx, -0x2c(%rbp)
movl -0x2c(%rbp), %r12d
pushq $0x1
popq %r13
leaq 0x1895(%rip), %rbx      # 0x6774
movq -0x58(%rbp), %r14
movl %ecx, %r15d
movl %r12d, %edi
movq %r14, %rsi
movq %rbx, %rdx
leaq -0x170(%rbp), %rcx
leaq -0x5c(%rbp), %r8
callq 0x10b0
movl %r13d, %ecx
cmpl $0x61, %eax
je 0x4ee3
cmpl $-0x1, %eax
je 0x4fa6
cmpl $0x53, %eax
je 0x4f49
cmpl $0x4f, %eax
je 0x4f72
cmpl $0x49, %eax
jne 0x50f0
movq 0x40ae(%rip), %rax      # 0x8fd8
movq (%rax), %rdi
callq 0x4df4
movq %rax, %r14
xorl %eax, %eax
callq 0x294a
movq %rax, -0x48(%rbp)
movq %rax, %rdi
movq %r14, -0x70(%rbp)
jmp 0x4f96
movq 0x4088(%rip), %rax      # 0x8fd8
movq (%rax), %rdi
callq 0x4df4
movq %rax, %rbx
xorl %eax, %eax
callq 0x294a
movq %rax, -0x80(%rbp)
movq %rax, %rdi
movq %rbx, -0x40(%rbp)
movq %rbx, %rsi
jmp 0x4f99
movq 0x405f(%rip), %rax      # 0x8fd8
movq (%rax), %rdi
callq 0x4df4
movq %rax, %r14
xorl %eax, %eax
callq 0x294a
movq %rax, -0x78(%rbp)
movq %rax, %rdi
movq %r14, -0x38(%rbp)
movq %r14, %rsi
callq 0x26a8
movl %r15d, %ecx
jmp 0x4ed8
movq 0x4023(%rip), %rax      # 0x8fd0
movslq (%rax), %rax
movl -0x2c(%rbp), %edx
cmpl %edx, %eax
movq -0x58(%rbp), %rcx
jge 0x4fc1
movq (%rcx,%rax,8), %r12
jmp 0x4fc4
xorl %r12d, %r12d
movq -0x48(%rbp), %r13
incl %eax
cmpl %edx, %eax
jge 0x4fd6
cltq
movq (%rcx,%rax,8), %rbx
jmp 0x4fd8
xorl %ebx, %ebx
movq -0x68(%rbp), %rax
testq %r12, %r12
je 0x4ff9
leaq 0x10e6(%rip), %rsi      # 0x60ce
movq %r12, %rdi
callq 0x1190
testq %rax, %rax
je 0x5116
testq %rbx, %rbx
je 0x5020
leaq 0x17f4(%rip), %rsi      # 0x67f9
movq %rbx, %rdi
movq %rax, %r14
callq 0x1190
movq %rax, -0x50(%rbp)
testq %rax, %rax
movq %r14, %rax
je 0x512c
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movq %r13, %rdx
movq -0x78(%rbp), %r12
movq %r12, %rcx
movq -0x80(%rbp), %r14
movq %r14, %r8
movl %r15d, %r9d
movq %rax, %r15
callq 0x12dc
movq %rax, %rbx
movq %rax, %rdi
movq -0x50(%rbp), %rsi
callq 0x2139
movq %rbx, %rdi
callq 0x20b0
movq %r15, %rax
movq 0x3f59(%rip), %rbx      # 0x8fc0
cmpq (%rbx), %r15
je 0x5077
movq %rax, %rdi
callq 0x1090
movq (%rbx), %rax
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r15
movq -0x50(%rbp), %rdi
cmpq %rax, %rdi
je 0x508d
callq 0x1090
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x509b
callq 0x1090
testq %r15, %r15
je 0x50a8
movq %r15, %rdi
callq 0x1090
testq %rbx, %rbx
je 0x50b5
movq %rbx, %rdi
callq 0x1090
testq %r13, %r13
je 0x50c2
movq %r13, %rdi
callq 0x2999
testq %r12, %r12
je 0x50cf
movq %r12, %rdi
callq 0x2999
testq %r14, %r14
je 0x50dc
movq %r14, %rdi
callq 0x2999
xorl %eax, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3f01(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rdx
leaq 0x168e(%rip), %rsi      # 0x6796
xorl %eax, %eax
callq 0x1130
xorl %edi, %edi
callq 0x11c0
movq 0x3edb(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0xf90(%rip), %rsi       # 0x60b7
movq %r12, %rdx
jmp 0x5140
movq 0x3ec5(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0xf7a(%rip), %rsi       # 0x60b7
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1130
pushq $0x1
popq %rdi
callq 0x11c0