// File: /workspace/github_c_makefile_star2_O0/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
subq $0x170, %rsp            # imm = 0x170
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, %al
callq 0x2750
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq 0x403d(%rip), %rax      # 0xafc8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq 0x4027(%rip), %rax      # 0xafc0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movl $0x0, -0x70(%rbp)
movl $0xffffffff, -0x74(%rbp) # imm = 0xFFFFFFFF
leaq 0x17ff(%rip), %rax      # 0x87e4
movq %rax, -0x80(%rbp)
leaq -0x160(%rbp), %rdi
leaq 0x3cf9(%rip), %rsi      # 0xacf0
movl $0xe0, %edx
callq 0x1120
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x80(%rbp), %rdx
leaq -0x160(%rbp), %rcx
leaq -0x74(%rbp), %r8
callq 0x10a0
movl %eax, -0x6c(%rbp)
cmpl $-0x1, %eax
je 0x7118
movl -0x6c(%rbp), %eax
addl $-0x49, %eax
movl %eax, %ecx
movq %rcx, -0x168(%rbp)
subl $0x18, %eax
ja 0x70ed
movq -0x168(%rbp), %rax
leaq 0x1732(%rip), %rcx      # 0x8780
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, -0x70(%rbp)
jmp 0x7113
movq 0x3f6e(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x6ef0
movq %rax, -0x40(%rbp)
movb $0x0, %al
callq 0x35e0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3200
jmp 0x7113
movq 0x3f3e(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x6ef0
movq %rax, -0x48(%rbp)
movb $0x0, %al
callq 0x35e0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3200
jmp 0x7113
movq 0x3f11(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x6ef0
movq %rax, -0x50(%rbp)
movb $0x0, %al
callq 0x35e0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x3200
jmp 0x7113
movq 0x3f04(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x1701(%rip), %rsi      # 0x8806
movb $0x0, %al
callq 0x1100
xorl %edi, %edi
callq 0x1190
jmp 0x7001
movq 0x3eb1(%rip), %rax      # 0xafd0
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jge 0x713c
movq -0x10(%rbp), %rax
movq 0x3e9f(%rip), %rcx      # 0xafd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq 0x3e8d(%rip), %rax      # 0xafd0
movl (%rax), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jge 0x7168
movq -0x10(%rbp), %rax
movq 0x3e78(%rip), %rcx      # 0xafd0
movl (%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x71b1
movq -0x20(%rbp), %rdi
leaq 0xf6f(%rip), %rsi       # 0x80e9
callq 0x1160
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x71af
movq 0x3e68(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0xf34(%rip), %rsi       # 0x80d2
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1190
jmp 0x71b1
cmpq $0x0, -0x28(%rbp)
je 0x71fa
movq -0x28(%rbp), %rdi
leaq 0x16a6(%rip), %rsi      # 0x8869
callq 0x1160
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x71f8
movq 0x3e1f(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0xeeb(%rip), %rsi       # 0x80d2
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1190
jmp 0x71fa
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x68(%rbp), %r8
movl -0x70(%rbp), %r9d
callq 0x12b0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2a90
movq -0x18(%rbp), %rdi
callq 0x2960
movq -0x30(%rbp), %rax
movq 0x3d84(%rip), %rcx      # 0xafc0
cmpq (%rcx), %rax
je 0x724a
movq -0x30(%rbp), %rdi
callq 0x1080
movq -0x38(%rbp), %rax
movq 0x3d6b(%rip), %rcx      # 0xafc0
cmpq (%rcx), %rax
je 0x7263
movq -0x38(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x40(%rbp)
je 0x7273
movq -0x40(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x48(%rbp)
je 0x7283
movq -0x48(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x50(%rbp)
je 0x7293
movq -0x50(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x58(%rbp)
je 0x72a3
movq -0x58(%rbp), %rdi
callq 0x3670
cmpq $0x0, -0x60(%rbp)
je 0x72b3
movq -0x60(%rbp), %rdi
callq 0x3670
cmpq $0x0, -0x68(%rbp)
je 0x72c3
movq -0x68(%rbp), %rdi
callq 0x3670
xorl %eax, %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq