// File: /workspace/github_c_makefile_star2_O0/c0stya[P]fslib/src/fsprint.c
// Function: main
int main(int argc, char * argv[]) {
    struct _fst * fst; 
    const char * ifilename = NULL; 

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

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

    int c;
    int opt_index = -1;

    const char * short_options = "h";

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

    while ( (c = getopt_long(argc, argv,  
                short_options, long_options, &opt_index )) != -1 ) {
        switch(c) {
            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 [input_file]\n", argv[0]);
                exit(EXIT_SUCCESS);
        } 
    }

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

    fst = fst_create();
    fst_read(fst, fin);
    fst_print_sym(fst, ist, ost, sst);
    fst_remove(fst);
    
    if (fin != stdout) {
        fclose(fin);
    }

    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 $0x120, %rsp            # imm = 0x120
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq 0x4050(%rip), %rax      # 0xafc8
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movl $0xffffffff, -0x60(%rbp) # imm = 0xFFFFFFFF
leaq 0x17c2(%rip), %rax      # 0x877f
movq %rax, -0x68(%rbp)
leaq -0x110(%rbp), %rdi
leaq 0x3d61(%rip), %rsi      # 0xad30
movl $0xa0, %edx
callq 0x1120
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x68(%rbp), %rdx
leaq -0x110(%rbp), %rcx
leaq -0x60(%rbp), %r8
callq 0x10a0
movl %eax, -0x5c(%rbp)
cmpl $-0x1, %eax
je 0x70e2
movl -0x5c(%rbp), %eax
movl %eax, -0x114(%rbp)
subl $0x49, %eax
je 0x702d
jmp 0x7010
movl -0x114(%rbp), %eax
subl $0x4f, %eax
je 0x705d
jmp 0x701d
movl -0x114(%rbp), %eax
subl $0x53, %eax
je 0x708a
jmp 0x70b7
movq 0x3fa4(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x6ef0
movq %rax, -0x30(%rbp)
movb $0x0, %al
callq 0x35e0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3200
jmp 0x70dd
movq 0x3f74(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x6ef0
movq %rax, -0x38(%rbp)
movb $0x0, %al
callq 0x35e0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3200
jmp 0x70dd
movq 0x3f47(%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 0x70dd
movq 0x3f3a(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x16c6(%rip), %rsi      # 0x8795
movb $0x0, %al
callq 0x1100
xorl %edi, %edi
callq 0x1190
jmp 0x6fd9
movq 0x3ee7(%rip), %rax      # 0xafd0
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jge 0x7106
movq -0x10(%rbp), %rax
movq 0x3ed5(%rip), %rcx      # 0xafd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x714f
movq -0x20(%rbp), %rdi
leaq 0xfd1(%rip), %rsi       # 0x80e9
callq 0x1160
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x714d
movq 0x3eca(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0xf96(%rip), %rsi       # 0x80d2
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1190
jmp 0x714f
movb $0x0, %al
callq 0x2750
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x2bd0
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
callq 0x4220
movq -0x18(%rbp), %rdi
callq 0x2960
movq -0x28(%rbp), %rax
movq 0x3e30(%rip), %rcx      # 0xafc0
cmpq (%rcx), %rax
je 0x719e
movq -0x28(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x30(%rbp)
je 0x71ae
movq -0x30(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x38(%rbp)
je 0x71be
movq -0x38(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x40(%rbp)
je 0x71ce
movq -0x40(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x48(%rbp)
je 0x71de
movq -0x48(%rbp), %rdi
callq 0x3670
cmpq $0x0, -0x50(%rbp)
je 0x71ee
movq -0x50(%rbp), %rdi
callq 0x3670
cmpq $0x0, -0x58(%rbp)
je 0x71fe
movq -0x58(%rbp), %rdi
callq 0x3670
xorl %eax, %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq